BOSS 7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcxTrackFinder Class Reference

#include <MdcxTrackFinder.h>

+ Inheritance diagram for MdcxTrackFinder:

Public Member Functions

 MdcxTrackFinder (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~MdcxTrackFinder ()
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
StatusCode beginRun ()
 

Detailed Description

Definition at line 60 of file MdcxTrackFinder.h.

Constructor & Destructor Documentation

◆ MdcxTrackFinder()

MdcxTrackFinder::MdcxTrackFinder ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 107 of file MdcxTrackFinder.cxx.

107 :
108 Algorithm(name, pSvcLocator), m_mdcCalibFunSvc(0)
109{
110 //input
111 declareProperty("pdtFile", m_pdtFile = "pdt.table");
112 //debug control
113 declareProperty("debug", m_debug= 0);
114 declareProperty("hist", m_hist= 0);
115 declareProperty("mcHist", m_mcHist = false);
116 //cuts and control
117 declareProperty("cresol", m_cresol = 0.013);
118
119 declareProperty("getDigiFlag", m_getDigiFlag = 0);
120 declareProperty("maxMdcDigi", m_maxMdcDigi= 0);
121 declareProperty("keepBadTdc", m_keepBadTdc= 0);
122 declareProperty("dropHot", m_dropHot= 0);
123 declareProperty("keepUnmatch", m_keepUnmatch= 0);
124 declareProperty("salvageTrk", m_salvageTrk = false);
125 declareProperty("dropMultiHotInLayer",m_dropMultiHotInLayer = false);
126 declareProperty("dropTrkPt", m_dropTrkPt = -999.);
127 declareProperty("d0Cut", m_d0Cut = 999.);
128 declareProperty("z0Cut", m_z0Cut = 999.);
129
130 declareProperty("minMdcDigi", m_minMdcDigi = 0);
131 declareProperty("countPropTime",m_countPropTime = true);
132 declareProperty("addHitCut", m_addHitCut = 5.);
133 declareProperty("dropHitsSigma",m_dropHitsSigma);
134 declareProperty("helixFitCut", m_helixFitCut);
135 declareProperty("minTrkProb", m_minTrkProb = 0.01);
136 declareProperty("csmax4", m_csmax4 = 50.);
137 declareProperty("csmax3", m_csmax3 = 1.);
138 declareProperty("helixFitSigma",m_helixFitSigma= 5.);
139 declareProperty("maxRcsInAddSeg",m_maxRcsInAddSeg= 50.);
140 declareProperty("nSigAddHitTrk", m_nSigAddHitTrk= 5.);
141 declareProperty("maxProca", m_maxProca= 0.6);
142 declareProperty("doSag", m_doSag= false);
143 declareProperty("lineFit", m_lineFit = false);
144 //declareProperty("cosmicFit", m_cosmicFit= false);
145}

◆ ~MdcxTrackFinder()

MdcxTrackFinder::~MdcxTrackFinder ( )
virtual

Definition at line 150 of file MdcxTrackFinder.cxx.

150 {
151 delete m_bfield;
152}

Member Function Documentation

◆ beginRun()

StatusCode MdcxTrackFinder::beginRun ( )

Definition at line 154 of file MdcxTrackFinder.cxx.

154 {
155 // Get Mdc Detector Geometry
156 m_gm = MdcDetector::instance(m_doSag);
157 if(NULL == m_gm) return StatusCode::FAILURE;
159
160 return StatusCode::SUCCESS;
161}
#define NULL
static MdcDetector * instance()
static void setMdcDetector(const MdcDetector *gm)
Definition MdcxHit.cxx:68

◆ execute()

StatusCode MdcxTrackFinder::execute ( )

Definition at line 248 of file MdcxTrackFinder.cxx.

248 {
249
250
251 b_saveEvent=false;
252 setFilterPassed(b_saveEvent);
253#ifdef MDCXTIMEDEBUG
254 m_timer[0]->start();
255 m_timer[1]->start();
256#endif
257 MsgStream log(msgSvc(), name());
258 log << MSG::INFO << "in execute()" << endreq;
259 StatusCode sc;
260
261 nTk = 0; t_nTdsTk = 0; t_nDigi=0; t_nSeg=0; //yzhang for fill
262 //------------------------------------
263 // Get event No.
264 //------------------------------------
265 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),"/Event/EventHeader");
266 if (!evtHead) {
267 log << MSG::FATAL<< "Could not retrieve event header" << endreq;
268 return StatusCode::FAILURE;
269 }
270 m_eventNo = evtHead->eventNumber();
271 if(m_debug>0)std::cout << "x evt: "<<evtHead->runNumber()<<" " << m_eventNo<< std::endl;
272 long t_evtNo = m_eventNo;
273 g_eventNo = m_eventNo;
274 //if (t_evtNo % 1000 == 0) std::cout << "x evt: " << t_evtNo << std::endl;
275 IDataManagerSvc *dataManSvc;
276 DataObject *aTrackCol;
277 DataObject *aHitCol;
278 if (!m_salvageTrk) {
279 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
280 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
281 if(aTrackCol != NULL) {
282 dataManSvc->clearSubTree("/Event/Recon/RecMdcTrackCol");
283 eventSvc()->unregisterObject("/Event/Recon/RecMdcTrackCol");
284 }
285 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aHitCol);
286 if(aHitCol != NULL) {
287 dataManSvc->clearSubTree("/Event/Recon/RecMdcHitCol");
288 eventSvc()->unregisterObject("/Event/Recon/RecMdcHitCol");
289 }
290 }
291
292 //------------------------------------
293 // Initialize track collection in TDS
294 //------------------------------------
295 DataObject *aReconEvent;
296 eventSvc()->findObject("/Event/Recon",aReconEvent);
297 if (aReconEvent==NULL) {
298 aReconEvent = new ReconEvent();
299 sc = eventSvc()->registerObject("/Event/Recon",aReconEvent);
300 if(sc != StatusCode::SUCCESS) {
301 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
302 return StatusCode::FAILURE;
303 }
304 }
305 RecMdcTrackCol* trackList;
306 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
307 if (aTrackCol) {
308 trackList = dynamic_cast<RecMdcTrackCol*> (aTrackCol);
309 }else{
310 trackList = new RecMdcTrackCol;
311 sc = eventSvc()->registerObject(EventModel::Recon::RecMdcTrackCol, trackList);
312 if(!sc.isSuccess()) {
313 log << MSG::FATAL << " Could not register RecMdcTrack collection" <<endreq;
314 return StatusCode::FAILURE;
315 }
316 }
317 RecMdcHitCol* hitList;
318 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aHitCol);
319 if (aHitCol) {
320 hitList = dynamic_cast<RecMdcHitCol*> (aHitCol);
321 }else{
322 hitList = new RecMdcHitCol;
323 sc = eventSvc()->registerObject(EventModel::Recon::RecMdcHitCol, hitList);
324 if(!sc.isSuccess()) {
325 log << MSG::FATAL << " Could not register RecMdcHit collection" <<endreq;
326 return StatusCode::FAILURE;
327 }
328 }
329
330 //------------------------------------
331 // Initialize hit collection in TDS
332 //------------------------------------
333 DataObject *pnode = 0;
334 sc = eventSvc()->retrieveObject("/Event/Hit",pnode);
335 if(!sc.isSuccess()) {
336 pnode = new DataObject;
337 sc = eventSvc()->registerObject("/Event/Hit",pnode);
338 if(!sc.isSuccess()) {
339 log << MSG::FATAL << " Could not register /Event/Hit branch " <<endreq;
340 return StatusCode::FAILURE;
341 }
342 }
343 SmartDataPtr<MdcHitCol> m_hitCol(eventSvc(), "/Event/Hit/MdcHitCol");
344 if (!m_hitCol){
345 m_hitCol= new MdcHitCol;
346 sc = eventSvc()->registerObject("/Event/Hit/MdcHitCol",m_hitCol);
347 if(!sc.isSuccess()) {
348 log << MSG::FATAL << " Could not register hit collection" <<endreq;
349 return StatusCode::FAILURE;
350 }
351 }
352
353
354 //------------------------------------
355 // Get bunch time t0 (ns) and timing
356 //------------------------------------
357 m_bunchT0 = -999.;
358 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
359 if (!aevtimeCol || aevtimeCol->size()==0) {
360 log << MSG::WARNING<< "evt "<<m_eventNo<<" Could not find RecEsTimeCol"<< endreq;
361 return StatusCode::SUCCESS;
362 }
363
364 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
365 for(; iter_evt!=aevtimeCol->end(); iter_evt++){
366 m_bunchT0 = (*iter_evt)->getTest();
367 m_t0Stat = (*iter_evt)->getStat();
368 if(m_debug>1) std::cout<<name()<<" "<<t_evtNo<<" t0 "<<m_bunchT0<<" t0Stat "<<m_t0Stat<<std::endl;
369 if ((m_t0Stat==0) || (m_bunchT0 < 0.) || (m_bunchT0 > 9999.0) ){
370 log << MSG::WARNING << "Skip evt:"<<m_eventNo<< " by t0 = "<<m_bunchT0 << endreq;
371 //return StatusCode::SUCCESS;
372 }
373 }
374 if(m_debug>1) std::cout<<name()<<" evt "<<t_evtNo<<" t0 "<<m_bunchT0<<" t0Stat "<<m_t0Stat<<std::endl;
375 int trigtiming=-10;
376 SmartDataPtr<TrigData> trigData(eventSvc(),"/Event/Trig/TrigData");
377 if(trigData){
378 log << MSG::INFO <<"Trigger conditions 0--43:"<<endreq;
379 for(int i = 0; i < 48; i++) {
380 log << MSG::INFO << trigData->getTrigCondName(i)<<" ---- "<<trigData->getTrigCondition(i)<< endreq;
381 }
382 for(int i = 0; i < 16; i++) log << MSG::INFO << "Trigger channel "<< i << ": " << trigData->getTrigChannel(i) << endreq;
383 m_timing=trigData->getTimingType();
384 //cout<<"-----------------trigger timing type-----------------------: "<<trigtiming<<endl;
385 log << MSG::INFO <<"Tigger Timing type: "<< trigtiming << endreq;
386 }
387
388 //------------------------------------
389 // Initialize MdcxHits
390 //------------------------------------
391 m_mdcxHits.reset();
392 uint32_t getDigiFlag = 0;
393 getDigiFlag += m_maxMdcDigi;
394 if(m_dropHot||m_salvageTrk) getDigiFlag |= MdcRawDataProvider::b_dropHot;
395 if(m_keepBadTdc) getDigiFlag |= MdcRawDataProvider::b_keepBadTdc;
396 if(m_keepUnmatch) getDigiFlag |= MdcRawDataProvider::b_keepUnmatch;
397 mdcDigiVec = m_rawDataProviderSvc->getMdcDigiVec(getDigiFlag);
398 t_nDigi = mdcDigiVec.size();
399
400 // fill Mc truth
401 //if(m_hist) fillMcTruth();
402
403 //skip event by hit numbe
404 if (t_nDigi < m_minMdcDigi){
405 if (0 == t_nDigi ){
406 log << MSG::WARNING << " No hits in MdcDigiVec" << endreq;
407 }
408 log << MSG::WARNING << " Skip this event for MdcDigiVec.size() < "<<m_minMdcDigi << endreq;
409 return StatusCode::SUCCESS;
410 }
411 m_mdcxHits.create(mdcDigiVec, m_bunchT0, m_cresol);
412 const HepAList<MdcxHit>& dchitlist = m_mdcxHits.GetMdcxHitList();
413
414 if(m_debug>2) m_mdcxHits.print(std::cout,6796);
415
416 //--------------------------------------------
417 // Make segments (MdcxSeg's) out of MdcxHit's
418 //--------------------------------------------
419 MdcxFindSegs dcsegs(dchitlist,m_debug);
420 const HepAList<MdcxSeg>& seglist = dcsegs.GetMdcxSeglist();
421 if(m_debug > 1 ){ dumpMdcxSegs(seglist);}
422 t_nSeg = seglist.length();
423 //if(m_hist){ fillMdcxSegs(seglist);}
424
425#ifdef MDCXTIMEDEBUG
426 m_timer[1]->stop();
427 m_timer[2]->start();
428#endif
429 //--------------------------------------------
430 // Make tracks (MdcxFittedHel's) out of MdcxSeg's
431 //--------------------------------------------
432 MdcxFindTracks dctrks(seglist,m_debug);
433 HepAList<MdcxFittedHel>& firsttrkl = (HepAList<MdcxFittedHel>&)dctrks.GetMdcxTrklist();
434 if(m_debug>1) dumpTrackList(firsttrkl);
435
436#ifdef MDCXTIMEDEBUG
437 m_timer[2]->stop();
438 m_timer[3]->start();
439#endif
440 //if(m_hist){ fillTrkl(firsttrkl);}
441
442 //if(m_debug>1){
443 // std::cout << "dchitlist after find tracks before MergeDups, nhits=" << dchitlist.length() << std::endl;
444 // for (int ii = 0; ii < dchitlist.length(); ii++) {
445 // dchitlist[ii]->print(std::cout, ii);
446 // }
447 // std::cout<<std::endl;
448 //}
449 MdcxMergeDups dcmergeem(firsttrkl,m_debug);
450 HepAList<MdcxFittedHel>& trkl = (HepAList<MdcxFittedHel>&)dcmergeem.GetMergedTrklist();
451
452 //if (m_debug > 1 ){
453 // cout << "MdcxTrackFinder: after MergeDups, have "
454 // << trkl.length() << " track(s). nhits=" << dchitlist.length() << endl;
455 // for (int ii = 0; ii < dchitlist.length(); ii++) {
456 // dchitlist[ii]->print(std::cout, ii);
457 // }
458 // std::cout<<std::endl;
459 //}
460
461 //---------------------------------------------------------
462 // Put my tracks into official fitter and store to TDS
463 //----------------------------------------------------------
464
465
466 sc = FitMdcxTrack(trkl, dchitlist, m_hitCol, trackList, hitList);
467 if (!sc.isSuccess()) {return StatusCode::SUCCESS;}
468 t_nTdsTk = trackList->size();
469
470 t_nTkTot += trackList->size();
471 if(t_nTdsTk<20) t_nTkNum[t_nTdsTk]++;
472
473#ifdef MDCXTIMEDEBUG
474 m_timer[0]->stop();
475 m_timer[3]->stop();
476#endif
477
478 if(m_hist) fillEvent();
479 if (m_debug > 0) {
480 DataObject* pNode;
481 eventSvc()->retrieveObject("/Event/Recon/RecMdcTrackCol",pNode);
482 RecMdcTrackCol *tmpTrackCol = dynamic_cast<RecMdcTrackCol*> (pNode);
483 eventSvc()->retrieveObject("/Event/Recon/RecMdcHitCol",pNode);
484 int nTdsTk = 0;
485 if(tmpTrackCol) nTdsTk = tmpTrackCol->size();
486
487 //if (t_evtNo % 1000 == 0) {
488 std::cout<< "MdcxTrackFinder: evtNo "<< m_eventNo << " t0="<<m_bunchT0
489 <<" Found " <<trkl.length()
490 <<" keep "<< t_nTdsTk
491 <<" finialy keep "<< nTdsTk;
492
493 int ndelete =0; trkl.length() - trackList->size();
494 if( ndelete>0 ) std::cout <<" delete "<< ndelete;
495 std::cout <<" track(s)" <<endl;
496 //}
497
498 if(m_debug>1)dumpTdsTrack(tmpTrackCol);
499 if(m_debug>1)dumpTrack(tmpTrackCol);
500 //dumpTdsHits(tmpHitCol);
501
502 }
503 if((trackList->size()!=4) ) b_saveEvent = true;
504 setFilterPassed(b_saveEvent);
505 return StatusCode::SUCCESS;
506}
ObjectVector< MdcHit > MdcHitCol
Definition MdcHit.h:129
ObjectVector< RecMdcHit > RecMdcHitCol
Definition RecMdcHit.h:99
ObjectVector< RecMdcTrack > RecMdcTrackCol
Definition RecMdcTrack.h:79
IMessageSvc * msgSvc()
void print(std::ostream &o, int pmax=10) const
Definition MdcxHits.cxx:72
const HepAList< MdcxHit > & GetMdcxHitList()
Definition MdcxHits.h:40
void reset()
Definition MdcxHits.cxx:55
void create(MdcDigiVec digiVec, float c0=0.0, float cresol=0.0180)
Definition MdcxHits.cxx:59
MdcDigiVec & getMdcDigiVec(uint32_t control=0)
_EXTERN_ std::string RecMdcTrackCol
Definition EventModel.h:86
_EXTERN_ std::string RecMdcHitCol
Definition EventModel.h:85
NTuple::Item< long > g_eventNo
Definition ntupleItem.h:22

◆ finalize()

StatusCode MdcxTrackFinder::finalize ( )

Definition at line 508 of file MdcxTrackFinder.cxx.

508 {
509 MsgStream log(msgSvc(), name());
510 log << MSG::INFO << "in finalize()" << endreq;
511
512 std::cout<< " --after " << name() << " keep " << t_nTkTot<< " tracks "<<std::endl;
513 for(int i=0; i<20; i++){
514 if(t_nTkNum[i]>0)std::cout<< " nTk="<< i << " "<< t_nTkNum[i]<< std::endl;
515 }
516
517 //tot evtNo, trkNum
518 return StatusCode::SUCCESS;
519}

◆ initialize()

StatusCode MdcxTrackFinder::initialize ( )

Definition at line 165 of file MdcxTrackFinder.cxx.

165 {
166 MsgStream log(msgSvc(), name());
167 log << MSG::INFO << "in initialize()" << endreq;
168
169 t_nTkTot = 0;
170 for (int i=0;i<20;i++) t_nTkNum[i]=0;
171
172 //m_flags.readPar(m_paramFile);
173#ifdef MDCXTIMEDEBUG
174 StatusCode tsc = service( "BesTimerSvc", m_timersvc);
175 if( tsc.isFailure() ) {
176 log << MSG::WARNING << name() << ": Unable to locate BesTimer Service" << endreq;
177 return StatusCode::FAILURE;
178 }
179 m_timer[0] = m_timersvc->addItem("Execution");
180 m_timer[0]->propName("Execution");
181 m_timer[1] = m_timersvc->addItem("findSeg");
182 m_timer[1]->propName("findSeg");
183 m_timer[2] = m_timersvc->addItem("findTrack");
184 m_timer[2]->propName("findTrack");
185 m_timer[3] = m_timersvc->addItem("fitting");
186 m_timer[3]->propName("fitting");
187#endif
188
189 if (m_helixFitCut.size() == 43){
190 for(int i=0; i<43; i++){
191 //MdcTrkReconCut_helix_fit[i] = m_helixFitCut[i];
192 TrkHelixFitter::nSigmaCut[i] = m_helixFitCut[i];
193 }
194 }
195 MdcxParameters::debug = m_debug;
196 MdcxParameters::minTrkProb = m_minTrkProb;
197 MdcxParameters::csmax4 = m_csmax4;
198 MdcxParameters::csmax3 = m_csmax3;
199 MdcxParameters::helixFitSigma = m_helixFitSigma;
200 MdcxParameters::maxRcsInAddSeg= m_maxRcsInAddSeg;
201 MdcxParameters::nSigAddHitTrk = m_nSigAddHitTrk;
202 MdcxParameters::maxProca = m_maxProca;
203 TrkHelixFitter::m_debug = (m_debug>7);
204 Pdt::readMCppTable(m_pdtFile);
205 MdcxFittedHel::debug = m_debug;
206
207
208 // Get MdcCalibFunSvc
209 IMdcCalibFunSvc* imdcCalibSvc;
210 StatusCode sc = service ("MdcCalibFunSvc", imdcCalibSvc);
211 m_mdcCalibFunSvc = dynamic_cast<MdcCalibFunSvc*>(imdcCalibSvc);
212 if ( sc.isFailure() ){
213 log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endreq;
214 return StatusCode::FAILURE;
215 }
216 MdcxHit::setMdcCalibFunSvc(m_mdcCalibFunSvc);
217 MdcxHit::setCountPropTime(m_countPropTime);
218
219 // Get RawDataProviderSvc
220 IRawDataProviderSvc* iRawDataProvider;
221 sc = service ("RawDataProviderSvc", iRawDataProvider);
222 if ( sc.isFailure() ){
223 log << MSG::FATAL << "Could not load RawDataProviderSvc!" << endreq;
224 return StatusCode::FAILURE;
225 }
226 m_rawDataProviderSvc = dynamic_cast<RawDataProviderSvc*>(iRawDataProvider);
227
228
229 //Initailize magnetic filed
230 sc = service ("MagneticFieldSvc",m_pIMF);
231 if(sc!=StatusCode::SUCCESS) {
232 log << MSG::ERROR << "Unable to open Magnetic field service"<<endreq;
233 }
234 m_bfield = new BField(m_pIMF);
235 log << MSG::INFO << "field z = "<<m_bfield->bFieldNominal()<< endreq;
236 m_context = new TrkContextEv(m_bfield);
237
238 if (m_hist) {bookNTuple();}
239 if (m_dropHitsSigma.size()==43){
240 for (int ii=0;ii<43;ii++) {
241 MdcxParameters::dropHitsSigma[ii]=m_dropHitsSigma[ii];
242 }
243 }
244
245 return StatusCode::SUCCESS;
246}
static int debug
static void setMdcCalibFunSvc(const MdcCalibFunSvc *calibSvc)
Definition MdcxHit.cxx:60
static void setCountPropTime(bool countPropTime)
Definition MdcxHit.cxx:64
static double maxProca
static int debug
static double maxRcsInAddSeg
static double minTrkProb
static float dropHitsSigma[43]
static double csmax4
static double helixFitSigma
static double csmax3
static double nSigAddHitTrk
static void readMCppTable(std::string filenm)
Definition Pdt.cxx:291
static bool m_debug
static double nSigmaCut[43]

The documentation for this class was generated from the following files: