BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcMakeHits.cxx
Go to the documentation of this file.
1#include <CLHEP/Units/PhysicalConstants.h>
2#include <CLHEP/Geometry/Point3D.h>
3#include "MdcTrkRecon/MdcMakeHits.h"
4#include "MdcData/MdcHitMap.h"
5#include "MdcData/MdcHit.h"
6#include "GaudiKernel/MsgStream.h"
7#include "GaudiKernel/AlgFactory.h"
8#include "GaudiKernel/ISvcLocator.h"
9#include "GaudiKernel/SmartDataPtr.h"
10#include "GaudiKernel/IDataProviderSvc.h"
11#include "GaudiKernel/IDataManagerSvc.h"
12#include "GaudiKernel/PropertyMgr.h"
13#include "MdcRawEvent/MdcDigi.h"
14#include "EventModel/Event.h"
15#include "MdcGeom/MdcSWire.h"
16#include "MdcGeom/MdcLayer.h"
17#include "MdcGeom/MdcDetector.h"
18#include "Identifier/MdcID.h"
19#include "MdcCalibFunSvc/IMdcCalibFunSvc.h"
20#include "MdcCalibFunSvc/MdcCalibFunSvc.h"
21#include "GaudiKernel/INTupleSvc.h"
22#include "RawDataProviderSvc/IRawDataProviderSvc.h"
23#include "RawDataProviderSvc/MdcRawDataProvider.h"
24
25#include <vector>
26#include <iostream>
27using namespace std;
28using namespace Event;
29
30
31extern const CLID & CLID_MdcHitCol;
32
33
34/////////////////////////////////////////////////////////////////////////////
35
36MdcMakeHits::MdcMakeHits(const std::string& name, ISvcLocator* pSvcLocator) :
37 Algorithm(name, pSvcLocator)
38{
39 // Declare the properties
40 declareProperty("cosmicFit", m_cosmicFit= false);
41 declareProperty("doSag", m_doSag= false);
42 declareProperty("countPropTime",m_countPropTime = true);
43
44 declareProperty("getDigiFlag", m_getDigiFlag = 0);
45 declareProperty("maxMdcDigi", m_maxMdcDigi= 0);
46 declareProperty("keepBadTdc", m_keepBadTdc= 0);
47 declareProperty("dropHot", m_dropHot= 0);
48 declareProperty("keepUnmatch", m_keepUnmatch= 0);
49 declareProperty("minMdcDigi", m_minMdcDigi = 0);
50 declareProperty("combineTracking",m_combineTracking = false);//yzhang 2010-05-28
51
52#ifdef MDCPATREC_RESLAYER
53 declareProperty("resLayer", m_resLayer= -1);
54#endif
55}
56
57// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
59 _gm = MdcDetector::instance(m_doSag);
60 if(NULL == _gm) return StatusCode::FAILURE;
61 return StatusCode::SUCCESS;
62}
63// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
65
66 MsgStream log(msgSvc(), name());
67 log << MSG::INFO << "in initialize()" << endreq;
68
69 StatusCode sc;
70
71 IMdcCalibFunSvc* imdcCalibSvc;
72 sc = service ("MdcCalibFunSvc",imdcCalibSvc);
73 m_mdcCalibFunSvc = dynamic_cast<MdcCalibFunSvc*> (imdcCalibSvc);
74 if ( sc.isFailure() ){
75 log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endreq;
76 }
77
78 IRawDataProviderSvc* irawDataProviderSvc;
79 sc = service ("RawDataProviderSvc", irawDataProviderSvc);
80 m_rawDataProviderSvc = dynamic_cast<RawDataProviderSvc*> (irawDataProviderSvc);
81 if ( sc.isFailure() ){
82 log << MSG::FATAL << "Could not load RawDataProviderSvc!" << endreq;
83 return StatusCode::FAILURE;
84 }
85
86 return StatusCode::SUCCESS;
87}
88
89// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
91 MsgStream log(msgSvc(), name());
92 log << MSG::INFO << "in execute()" << endreq;
93 StatusCode sc;
94
95 DataObject *pnode = 0;
96 sc = eventSvc()->retrieveObject("/Event/Hit",pnode);
97 if(!sc.isSuccess()) {
98 pnode = new DataObject;
99 sc = eventSvc()->registerObject("/Event/Hit",pnode);
100 if(!sc.isSuccess()) {
101 log << MSG::FATAL << " Could not register hit branch" <<endreq;
102 return StatusCode::FAILURE;
103 }
104 }
105
106 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
107 DataObject *hitCol;
108 eventSvc()->findObject("/Event/Hit/MdcHitCol",hitCol);
109 if(hitCol!= NULL) {
110 dataManSvc->clearSubTree("/Event/Hit/MdcHitCol");
111 eventSvc()->unregisterObject("/Event/Hit/MdcHitCol");
112 }
113 MdcHitCol *mdcHitCol = new MdcHitCol;
114 sc = eventSvc()->registerObject("/Event/Hit/MdcHitCol",mdcHitCol);
115 if(!sc.isSuccess()) {
116 log << MSG::FATAL << " Could not register hit collection" <<endreq;
117 return StatusCode::FAILURE;
118 }
119
120 DataObject *hitMap;
121 eventSvc()->findObject("/Event/Hit/MdcHitMap",hitMap);
122 if(hitMap!= NULL) {
123 dataManSvc->clearSubTree("/Event/Hit/MdcHitMap");
124 eventSvc()->unregisterObject("/Event/Hit/MdcHitMap");
125 }
126 MdcHitMap *mdcHitMap = new MdcHitMap(*_gm);
127 sc = eventSvc()->registerObject("/Event/Hit/MdcHitMap",mdcHitMap);
128 if(!sc.isSuccess()) {
129 log << MSG::FATAL << " Could not register hit map" <<endreq;
130 return StatusCode::FAILURE;
131 }
132
133 // retrieve Mdc digi vector form RawDataProviderSvc
134 uint32_t getDigiFlag = 0;
135 getDigiFlag += m_maxMdcDigi;
136 if(m_dropHot || m_combineTracking)getDigiFlag |= MdcRawDataProvider::b_dropHot;
137 if(m_keepBadTdc) getDigiFlag |= MdcRawDataProvider::b_keepBadTdc;
138 if(m_keepUnmatch) getDigiFlag |= MdcRawDataProvider::b_keepUnmatch;
139 MdcDigiVec mdcDigiVec = m_rawDataProviderSvc->getMdcDigiVec(getDigiFlag);
140
141 //std::cout<<__FILE__<<" nDigi = "<<mdcDigiVec.size()<< std::endl;
142 if ((int)mdcDigiVec.size()<m_minMdcDigi){
143 log << MSG::WARNING << " Skip this event for MdcDigiVec.size() < "<<m_minMdcDigi << endreq;
144 return StatusCode::SUCCESS;
145 }
146
147 MdcDigiVec::iterator iter = mdcDigiVec.begin();
148 for (;iter != mdcDigiVec.end(); iter++ ) {
149 const MdcDigi* aDigi = *iter;
150 MdcHit *hit = new MdcHit(aDigi, _gm);
151 hit->setCalibSvc(m_mdcCalibFunSvc);
152 hit->setCosmicFit(m_cosmicFit);
153 hit->setCountPropTime(m_countPropTime);
154#ifdef MDCPATREC_RESLAYER
155 hit->setResLayer(m_resLayer);
156#endif
157 mdcHitCol->push_back(hit);
158 mdcHitMap->addHit(*hit);
159 }
160 return StatusCode::SUCCESS;
161}
162
163// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
165
166 MsgStream log(msgSvc(), name());
167 log << MSG::INFO << "in finalize()" << endreq;
168
169 return StatusCode::SUCCESS;
170}
171
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
ObjectVector< MdcHit > MdcHitCol
const CLID & CLID_MdcHitCol
static MdcDetector * instance()
Definition: MdcDetector.cxx:21
void setCalibSvc(const MdcCalibFunSvc *calibSvc)
Definition: MdcHit.cxx:136
void setCosmicFit(const bool cosmicfit)
void setCountPropTime(const bool count)
StatusCode beginRun()
Definition: MdcMakeHits.cxx:58
StatusCode initialize()
Definition: MdcMakeHits.cxx:64
StatusCode execute()
Definition: MdcMakeHits.cxx:90
StatusCode finalize()
MdcMakeHits(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MdcMakeHits.cxx:36