1#include "MdcTrkRecon/MdcTrkRecon.h"
2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/AlgFactory.h"
4#include "GaudiKernel/ISvcLocator.h"
5#include "GaudiKernel/DataSvc.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/IDataManagerSvc.h"
9#include "GaudiKernel/PropertyMgr.h"
10#include "GaudiKernel/Bootstrap.h"
11#include "GaudiKernel/INTupleSvc.h"
12#include "EventModel/EventHeader.h"
13#include "ReconEvent/ReconEvent.h"
14#include "MdcRecEvent/RecMdcHit.h"
15#include "MdcRecEvent/RecMdcTrack.h"
16#include "RawEvent/RawDataUtil.h"
17#include "RawDataProviderSvc/IRawDataProviderSvc.h"
18#include "RawDataProviderSvc/MdcRawDataProvider.h"
19#include "Identifier/MdcID.h"
20#include "Identifier/Identifier.h"
21#include "MdcRawEvent/MdcDigi.h"
22#include "MdcData/MdcHit.h"
23#include "MdcData/MdcHitMap.h"
24#include "MdcData/MdcHitUse.h"
25#include "MdcData/MdcHitOnTrack.h"
26#include "MdcData/MdcRecoHitOnTrack.h"
27#include "MdcGeom/MdcDetector.h"
28#include "EvTimeEvent/RecEsTime.h"
30#include "MdcTrkRecon/MdcSegData.h"
31#include "MdcTrkRecon/MdcSegList.h"
32#include "MdcTrkRecon/MdcSegFinder.h"
33#include "MdcTrkRecon/MdcTrackList.h"
34#include "MdcTrkRecon/MdcTrackListCsmc.h"
35#include "TrkFitter/TrkContextEv.h"
36#include "BField/BField.h"
37#include "MdcTrkRecon/MdcHistItem.h"
38#include "MdcTrkRecon/MdcSeg.h"
39#include "MdcTrkRecon/GmsList.h"
40#include "MdcGeom/Constants.h"
41#include "MdcRecoUtil/Pdt.h"
42#include "MdcTrkRecon/MdcTrack.h"
43#include "TrkBase/TrkExchangePar.h"
44#include "TrkBase/TrkRep.h"
45#include "TrkBase/TrkDifTraj.h"
46#include "TrkFitter/TrkHelixFitter.h"
48#include "McTruth/McParticle.h"
49#include "McTruth/MdcMcHit.h"
50#include "MdcPrintSvc/IMdcPrintSvc.h"
51#include "MdcTrkRecon/MdcSegUsage.h"
54#ifdef MDCPATREC_TIMETEST
55#include "BesTimerSvc/IBesTimerSvc.h"
56#include "BesTimerSvc/BesTimerSvc.h"
57#include "BesTimerSvc/BesTimer.h"
72 Algorithm(name, pSvcLocator),
73 m_hitData(0), m_segs(0), m_tracks(0), m_segFinder(0)
76 declareProperty(
"FittingMethod", m_fittingMethod = 2);
77 declareProperty(
"ConfigFile", m_configFile =
"MDCConfig.xml");
78 declareProperty(
"OnlyUnusedHits", m_onlyUnusedHits = 0);
79 declareProperty(
"PoisonHits", m_poisonHits = 0);
80 declareProperty(
"doLineFit", m_doLineFit =
false);
81 declareProperty(
"paramFile", m_paramFile =
"params");
82 declareProperty(
"pdtFile", m_pdtFile =
"pdt.table");
83 declareProperty(
"allHit", m_allHit = 1);
84 declareProperty(
"hist", m_hist=
false);
85 declareProperty(
"recForEsTime", m_recForEsTime=
false);
86 declareProperty(
"tryBunch", m_tryBunch =
false);
87 declareProperty(
"d0Cut", m_d0Cut= -999.);
88 declareProperty(
"z0Cut", m_z0Cut= -999.);
89 declareProperty(
"dropTrkPt", m_dropTrkPt = -999.);
90 declareProperty(
"debug", m_debug= 0);
91 declareProperty(
"mcHist", m_mcHist=
false);
92 declareProperty(
"fieldCosmic", m_fieldCosmic=
false);
93 declareProperty(
"doSag", m_doSagFlag=
false);
94 declareProperty(
"arbitrateHits", m_arbitrateHits =
true);
96 declareProperty(
"helixHitsSigma", m_helixHitsSigma);
98 declareProperty(
"getDigiFlag", m_getDigiFlag = 0);
99 declareProperty(
"maxMdcDigi", m_maxMdcDigi = 0);
100 declareProperty(
"keepBadTdc", m_keepBadTdc = 0);
101 declareProperty(
"dropHot", m_dropHot= 0);
102 declareProperty(
"keepUnmatch", m_keepUnmatch = 0);
103 declareProperty(
"minMdcDigi", m_minMdcDigi = 0);
104 declareProperty(
"selEvtNo", m_selEvtNo);
105 declareProperty(
"combineTracking",m_combineTracking =
false);
106 declareProperty(
"noInner",m_noInner =
false);
108#ifdef MDCPATREC_RESLAYER
109 declareProperty(
"resLayer",m_resLayer= -1);
117 m_segFinder.reset(0);
124 MsgStream log(
msgSvc(), name());
125 log << MSG::INFO <<
"in beginRun()" << endreq;
130 if(NULL == _gm)
return StatusCode::FAILURE;
135 return StatusCode::SUCCESS;
141 MsgStream log(
msgSvc(), name());
142 log << MSG::INFO <<
"in initialize()" << endreq;
150 m_flags.
lHist = m_hist;
157 std::cout<<
"MdcTrkRecon d0Cut "<<m_d0Cut<<
" z0Cut "<<
158 m_z0Cut<<
" ptCut "<<m_dropTrkPt << std::endl;
162 sc = service (
"MagneticFieldSvc",m_pIMF);
163 if(sc!=StatusCode::SUCCESS) {
164 log << MSG::ERROR << name() <<
" Unable to open magnetic field service"<<endreq;
166 m_bfield =
new BField(m_pIMF);
167 log << MSG::INFO <<name() <<
" field z = "<<m_bfield->
bFieldNominal()<< endreq;
171 sc = service (
"RawDataProviderSvc", irawDataProviderSvc);
173 if ( sc.isFailure() ){
174 log << MSG::FATAL << name()<<
" Could not load RawDataProviderSvc!" << endreq;
175 return StatusCode::FAILURE;
180 sc = service (
"MdcPrintSvc", imdcPrintSvc);
181 m_mdcPrintSvc =
dynamic_cast<MdcPrintSvc*
> (imdcPrintSvc);
182 if ( sc.isFailure() ){
183 log << MSG::FATAL <<
"Could not load MdcPrintSvc!" << endreq;
184 return StatusCode::FAILURE;
201 m_tracks->setNoInner(m_noInner);
206 if (!sc.isSuccess()) { m_flags.
lHist = 0;}
213 return StatusCode::SUCCESS;
218 setFilterPassed(
false);
220 MsgStream log(
msgSvc(), name());
221 log << MSG::INFO <<
"in execute()" << endreq;
225 for (
int ii=0;ii<43;ii++){
226 for (
int jj=0;jj<288;jj++){
234 mcDrift[ii][jj] = -99.;
239 hitPoisoned[ii][jj]=-99;
246#ifdef MDCPATREC_TIMETEST
251 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
253 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
254 return( StatusCode::FAILURE);
256 t_eventNo = evtHead->eventNumber();
257 if(m_debug!=0)std::cout<<t_iExexute<<
" run "<<evtHead->runNumber()<<
" evt "<<t_eventNo<<std::endl;
260 if (m_selEvtNo.size() >0){
261 std::vector<int>::iterator it = m_selEvtNo.begin();
262 for (; it!=m_selEvtNo.end(); it++){
263 if((*it)== t_eventNo) setFilterPassed(
true);
270 bool iterateT0 =
false;
271 const int nBunch = 3;
273 double BeamDeltaTime = 24. / nBunch;
274 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
275 if (!evTimeCol || evTimeCol->size()==0) {
276 log << MSG::WARNING <<
" run "<<evtHead->runNumber() <<
" evt "<<t_eventNo<<
" Could not find RecEsTimeCol" << endreq;
278 return StatusCode::SUCCESS;
281 RecEsTimeCol::iterator iter_evt = evTimeCol->begin();
283 if (iter_evt != evTimeCol->end()){
284 t_t0Stat = (*iter_evt)->getStat();
285 t_t0 = (*iter_evt)->getTest();
289 if (
abs(t_t0)<0.00001 || (t_t0 < 0) || (t_t0 > 9999.0) ){
290 log << MSG::WARNING <<
"Skip with t0 = "<<t_t0 << endreq;
291 return StatusCode::SUCCESS;
295 if(m_debug>0) std::cout<<name()<<
" t0 "<<t0<<
" "<<std::endl;
300 if ( !m_recForEsTime && m_tryBunch) {
301 if ( t_t0Stat < 10 )
return StatusCode::SUCCESS;
304 if ( iBunch > (nBunch - 1) )
return StatusCode::SUCCESS;
305 if ( t_t0Stat < 0 ){ iterateT0 =
true; }
308 if ( (t_t0Stat > -1) && (fabs( iBunch * BeamDeltaTime - t_t0) < 2.) ){
311 }
else{ t0 = iBunch * BeamDeltaTime *1.e-9;}
316 SmartDataPtr<MdcHitMap> hitMap(eventSvc(),
"/Event/Hit/MdcHitMap");
318 log << MSG::FATAL <<
"Could not retrieve MDC hit map" << endreq;
319 return( StatusCode::FAILURE);
322 SmartDataPtr<MdcHitCol> hitCol(eventSvc(),
"/Event/Hit/MdcHitCol");
324 log << MSG::FATAL <<
"Could not retrieve MDC hit list" << endreq;
325 return( StatusCode::FAILURE);
330 DataObject *aReconEvent;
331 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
332 if(aReconEvent==NULL) {
334 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon",aReconEvent);
335 if(sc!=StatusCode::SUCCESS) {
336 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
337 return( StatusCode::FAILURE);
341 DataObject *aTrackCol;
342 DataObject *aRecHitCol;
344 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
345 if(!m_combineTracking){
346 eventSvc()->findObject(
"/Event/Recon/RecMdcTrackCol",aTrackCol);
347 if(aTrackCol != NULL) {
348 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcTrackCol");
349 eventSvc()->unregisterObject(
"/Event/Recon/RecMdcTrackCol");
351 eventSvc()->findObject(
"/Event/Recon/RecMdcHitCol",aRecHitCol);
352 if(aRecHitCol != NULL) {
353 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcHitCol");
354 eventSvc()->unregisterObject(
"/Event/Recon/RecMdcHitCol");
359 eventSvc()->findObject(
"/Event/Recon/RecMdcTrackCol",aTrackCol);
365 if(!sc.isSuccess()) {
366 log << MSG::FATAL <<
" Could not register RecMdcTrack collection" <<endreq;
367 return StatusCode::FAILURE;
371 eventSvc()->findObject(
"/Event/Recon/RecMdcHitCol",aRecHitCol);
377 if(!sc.isSuccess()) {
378 log << MSG::FATAL <<
" Could not register RecMdcHit collection" <<endreq;
379 return StatusCode::FAILURE;
383 if(m_debug>0) std::cout<<name()<<
" t0 "<<t0<<
" "<<std::endl;
384 m_hitData->loadevent(hitCol, hitMap, t0);
385 t_nDigi = hitCol->size();
388 m_hitData->poisonHits(_gm,m_debug);
392 for(
int i=0;i<m_hitData->nhits();i++){
393 const MdcHit* thisHit = m_hitData->hit(i);
396 if(m_hitData->segUsage().get(thisHit)->deadHit()){
397 hitPoisoned[l][w] = 1;
399 hitPoisoned[l][w] = 0;
404#ifdef MDCPATREC_TIMETEST
405 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
407 log << MSG::INFO <<
"Could not retrieve McParticelCol" << endreq;
409 m_mcTkNum = mcParticleCol->size();
420 nSegs = m_segFinder->createSegs(_gm, *m_segs, m_hitData->segUsage(),
421 m_hitData->hitMap(), t0);
423 log << MSG::INFO <<
" Found " << nSegs <<
" segments" << endreq;
425 std::cout<<
"------------------------------------------------"<<std::endl;
426 std::cout<<
"==event "<<t_eventNo<<
" Found " << nSegs <<
" segments" << std::endl;
441 nTracks = m_tracks->createFromSegs(m_segs.get(), m_hitData->hitMap(),
445 if(m_arbitrateHits) nDeleted = m_tracks->arbitrateHits();
446 int nKeep = nTracks - nDeleted;
448 if (m_debug>0 && (nTracks - nDeleted)>0){
449 std::cout<<
"MdcTrkRecon: evt "<< setw(5)<<t_eventNo
450 <<
" nDigi "<<setw(4)<<t_nDigi<<
" t0 "<<setw(5)<<t_t0
451 <<
" keep "<< nKeep <<
" track(s)";
452 if (nDeleted!=0){ std::cout <<
",deleted " <<nDeleted; }
453 std::cout<< std::endl;
456 std::cout<<
"MdcTrkRecon: evt "<< setw(5)<<t_eventNo
457 <<
" nDigi "<<setw(4)<<t_nDigi<<
" t0 "<<setw(5)<<t_t0
458 <<
" found 0 track "<< endl;
462 if (m_flags.
lHist) t_nRecTk = nKeep;
464#ifdef MDCPATREC_RESLAYER
465 m_tracks->setResLayer(m_resLayer);
469 m_tracks->store(trackList, hitList);
472 std::cout<<name()<<
" print track list "<<std::endl;
477#ifdef MDCPATREC_TIMETEST
478 RecMdcTrackCol::iterator
iter = trackList->begin();
479 for (;
iter != trackList->end();
iter++) {
481 ti_nHit += tk->getNhits();
487 m_segs->destroySegs();
493#ifdef MDCPATREC_TIMETEST
497 m_eventTime = m_timer[1]->elapsed();
498 m_t5recTkNum = m_tracks->length();
499 m_t5EvtNo = t_eventNo;
502 sc = m_tupleTime->write();
506 if ( nTracks <1 ){ iterateT0 =
true;
512 return StatusCode::SUCCESS;
517 MsgStream log(
msgSvc(), name());
518 log << MSG::INFO <<
"in finalize()" << endreq;
521#ifdef MDCPATREC_TIMETEST
524 return StatusCode::SUCCESS;
528 MsgStream log(
msgSvc(), name());
529 StatusCode sc = StatusCode::SUCCESS;
533 h_sfHit =
histoSvc()->book(
"sfHit",
"Hits after segment finding",46,-1.,44. );
540 g_cirTkChi2 =
histoSvc()->book(
"cirTkChi2",
"chi2 per dof in circle finding",21,-1. ,20. );
542 g_nSigAdd =
histoSvc()->book(
"nSigAdd",
"max allowed n sigma to add hit to existing segment",50,0,50 );
543 g_z0Cut =
histoSvc()->book(
"z0Cut",
"z0 for including stereo segs in cluster",100,0,600 );
544 g_ctCut =
histoSvc()->book(
"ctCut",
"ct for including stereo segs in cluster",100,-50,50 );
545 g_delCt =
histoSvc()->book(
"delCt",
"del ct cut forming seg group",100,-20,20 );
546 g_delZ0 =
histoSvc()->book(
"delZ0",
"del z0 cut forming seg group",100,-60,60 );
547 g_phiDiff =
histoSvc()->book(
"phiDiff",
"phidiff mult for drop dup seg",100,-0.5,6.5 );
562 NTuplePtr ntWireEff(
ntupleSvc(),
"MdcWire/mc");
581 log << MSG::ERROR <<
"Cannot book tuple MdcWire/mc" << endmsg;
586 NTuplePtr ntt(
ntupleSvc(),
"MdcRec/test");
589 m_tuplet =
ntupleSvc()->book (
"MdcRec/test", CLID_ColumnWiseTuple,
"MdcTrkRecon t particle");
597 log << MSG::ERROR <<
"Cannot book tuple MdcRec/test" << endmsg;
603 NTuplePtr ntMc(
ntupleSvc(),
"MdcMc/mcTk");
606 m_tupleMc =
ntupleSvc()->book (
"MdcMc/mcTk", CLID_ColumnWiseTuple,
"MdcTrkRecon Mc particle");
611 log << MSG::ERROR <<
"Cannot book tuple MdcMc/mcTk" << endmsg;
617 NTuplePtr ntMcHit(
ntupleSvc(),
"MdcMc/mcHit");
640 log << MSG::ERROR <<
"Cannot book tuple MdcMc/mcHit" << endmsg;
645 NTuplePtr nt1(
ntupleSvc(),
"MdcRec/rec");
648 m_tuple1 =
ntupleSvc()->book (
"MdcRec/rec", CLID_ColumnWiseTuple,
"MdcTrkRecon results");
702 log << MSG::ERROR <<
"Cannot book tuple MdcRec/rec" << endmsg;
707 NTuplePtr ntSeg(
ntupleSvc(),
"MdcSeg/seg");
710 m_tupleSeg =
ntupleSvc()->book (
"MdcSeg/seg", CLID_ColumnWiseTuple,
"MdcTrkRecon segment data");
720 log << MSG::ERROR <<
"Cannot book tuple MdcSeg/seg" << endmsg;
726 NTuplePtr nt4(
ntupleSvc(),
"MdcRec/evt");
729 m_tupleEvt =
ntupleSvc()->book (
"MdcRec/evt", CLID_ColumnWiseTuple,
"MdcTrkRecon event data");
748 log << MSG::ERROR <<
"Cannot book N-tuple: MdcRec/evt" << endmsg;
754 NTuplePtr ntCombAx(
ntupleSvc(),
"MdcCombAx/combAx");
757 g_tupleCombAx =
ntupleSvc()->book (
"MdcCombAx/combAx", CLID_RowWiseTuple,
"MdcTrkRecon cuts in combine ax seg");
778 log << MSG::ERROR <<
"Cannot book N-tuple: FILE101/combAx" << endmsg;
784 NTuplePtr ntFindSeg(
ntupleSvc(),
"MdcSeg/findSeg");
787 g_tupleFindSeg =
ntupleSvc()->book (
"MdcSeg/findSeg", CLID_RowWiseTuple,
"MdcTrkRecon cuts in segment finder");
801 log << MSG::ERROR <<
"Cannot book N-tuple: FILE101/findSeg" << endmsg;
807 NTuplePtr ntPick(
ntupleSvc(),
"MdcTrk/pick");
831 log << MSG::ERROR <<
"Cannot book N-tuple: MdcTrk/pick" << endmsg;
836#ifdef MDCPATREC_TIMETEST
838 NTuplePtr nt5(
ntupleSvc(),
"MdcTime/ti");
839 if ( nt5 ) { m_tupleTime = nt5;}
841 m_tupleTime =
ntupleSvc()->book (
"MdcTime/ti", CLID_RowWiseTuple,
"MdcTrkRecon time");
843 sc = m_tupleTime->addItem (
"eventtime", m_eventTime);
844 sc = m_tupleTime->addItem (
"recTkNum", m_t5recTkNum);
845 sc = m_tupleTime->addItem (
"mcTkNum", m_mcTkNum);
846 sc = m_tupleTime->addItem (
"evtNo", m_t5EvtNo);
847 sc = m_tupleTime->addItem (
"nHit", m_t5nHit);
848 sc = m_tupleTime->addItem (
"nDigi", m_t5nDigi);
850 log << MSG::ERROR <<
"Cannot book N-tuple: FILE101/time" << endmsg;
854 sc = service(
"BesTimerSvc", m_timersvc);
855 if( sc.isFailure() ) {
856 log << MSG::WARNING <<
" Unable to locate BesTimerSvc" << endreq;
859 m_timer[1] = m_timersvc->addItem(
"Execution");
860 m_timer[1]->propName(
"nExecution");
863#ifdef MDCPATREC_RESLAYER
865 NTuplePtr nt6(
ntupleSvc(),
"MdcRes/res");
866 if ( nt6 ) { g_tupleres = nt6;}
868 g_tupleres=
ntupleSvc()->book (
"MdcRes/res", CLID_RowWiseTuple,
"MdcTrkRecon res");
870 sc = g_tupleres->addItem (
"resid", g_resLayer);
871 sc = g_tupleres->addItem (
"layer", g_t6Layer);
873 log << MSG::ERROR <<
"Cannot book N-tuple: FILE101/res" << endmsg;
874 return StatusCode::FAILURE;
883 MsgStream log(
msgSvc(), name());
886 for(
int i=0;i<100;i++){
887 isPrimaryOfMcTk[i]=-9999;
890 double ptOfMcTk[100]={0.};
891 double thetaOfMcTk[100]={0.};
892 double phiOfMcTk[100]={0.};
893 double nDigiOfMcTk[100]={0.};
896 SmartDataPtr<Event::MdcMcHitCol> mcMdcMcHitCol(eventSvc(),
"/Event/MC/MdcMcHitCol");
897 if (!mcMdcMcHitCol) {
898 log << MSG::INFO <<
"Could not find MdcMcHit" << endreq;
900 Event::MdcMcHitCol::iterator iter_mchit = mcMdcMcHitCol->begin();
901 for (;iter_mchit != mcMdcMcHitCol->end(); iter_mchit++ ) {
902 const Identifier id= (*iter_mchit)->identify();
905 int iMcTk = (*iter_mchit)->getTrackIndex();
906 if(iMcTk<100&&iMcTk>0) nDigiOfMcTk[iMcTk]++;
907 mcDrift[layer][wire]= (*iter_mchit)->getDriftDistance()/10.;
909 mcX[layer][wire] = (*iter_mchit)->getPositionX()/10.;
910 mcY[layer][wire] = (*iter_mchit)->getPositionY()/10.;
911 mcZ[layer][wire] = (*iter_mchit)->getPositionZ()/10.;
912 mcLR[layer][wire] = (*iter_mchit)->getPositionFlag();
913 if (mcLR[layer][wire] == 0) mcLR[layer][wire] = -1;
922 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
924 log << MSG::INFO <<
"Could not retrieve McParticelCol" << endreq;
927 Event::McParticleCol::iterator it = mcParticleCol->begin();
928 for (;it != mcParticleCol->end(); it++){
934 it = mcParticleCol->begin();
935 for (;it != mcParticleCol->end(); it++){
936 int tkId = (*it)->trackIndex();
937 if ((*it)->primaryParticle()){
938 t_t0Truth = (*it)->initialPosition().t();
939 isPrimaryOfMcTk[tkId] = 1;
941 isPrimaryOfMcTk[tkId] = 0;
945 int pdg_code = (*it)->particleProperty();
946 pdgOfMcTk[tkId] = pdg_code;
950 const CLHEP::Hep3Vector& true_mom = (*it)->initialFourMomentum().vect();
951 const CLHEP::HepLorentzVector& posIni = (*it)->initialPosition();
952 const CLHEP::HepLorentzVector& posFin = (*it)->finalPosition();
953 if(tkId<100&&tkId>=0) {
954 ptOfMcTk[tkId] = true_mom.perp();
955 thetaOfMcTk[tkId] = (*it)->initialFourMomentum().theta();
956 phiOfMcTk[tkId] = (*it)->initialFourMomentum().phi();
965 m_tMcTheta = (*it)->initialFourMomentum().theta();
981 uint32_t getDigiFlag = 0;
982 getDigiFlag += m_maxMdcDigi;
987 if ((
int)mdcDigiVec.size()<m_minMdcDigi){
988 std::cout <<
" Skip this event for MdcDigiVec.size() < "<<m_minMdcDigi << endl;
991 if (mdcDigiVec.size()<=0)
return;
993 MdcDigiCol::iterator
iter = mdcDigiVec.begin();
994 for (;
iter!= mdcDigiVec.end();
iter++ ) {
997 int tkId = (*iter)->getTrackIndex();
1000 haveDigiPt[l][w] = ptOfMcTk[(*iter)->getTrackIndex()];
1001 haveDigiTheta[l][w] = thetaOfMcTk[(*iter)->getTrackIndex()];
1002 haveDigiPhi[l][w] = phiOfMcTk[(*iter)->getTrackIndex()];
1006 if(tkId>=1000) tkId-=1000;
1019 if(hitInSegList[l][w]>0)
m_we_seg = 1;
1023 if(l==35&&tkId>=0&&
abs(pdgOfMcTk[tkId])==11&&hitInSegList[l][w]<=0) {
1024 cout<<
"layer "<<l<<
" cell "<<w<<
" gwire "<<gwire<<
" inseg "<<hitInSegList[l][w]<<endl;
1036 std::cout <<
"print after Segment finding " << std::endl;
1038 if (!m_flags.
lHist)
return;
1040 for (
int ii=0;ii<43;ii++){
1041 for (
int jj=0;jj<288;jj++){ hitInSegList[ii][jj] = 0; }
1044 for (
int i = 0; i < _gm->
nSuper(); i++) {
1046 while (aSeg != NULL) {
1048 for (
int ihit=0 ; ihit< aSeg->
nHit() ; ihit++){
1052 hitInSegList[layer][wire]++;
1061 for (
int ii=0;ii<43;ii++){
1062 for (
int jj=0;jj<288;jj++){
1066 m_tsInSeg[iDigi] = hitInSegList[ii][jj];
1077 std::cout<<
"tksize = "<<trackList->size() << std::endl;
1078 RecMdcTrackCol::iterator it = trackList->begin();
1079 for (;it!= trackList->end();it++){
1081 std::cout<< endl<<
"//====RecMdcTrack "<<tk->
trackId()<<
"====:" << std::endl;
1082 cout <<
" d0 "<<tk->
helix(0)
1083 <<
" phi0 "<<tk->
helix(1)
1084 <<
" cpa "<<tk->
helix(2)
1085 <<
" z0 "<<tk->
helix(3)
1086 <<
" tanl "<<tk->
helix(4)
1088 std::cout<<
" q "<<tk->
charge()
1089 <<
" theta "<<tk->
theta()
1090 <<
" phi "<<tk->
phi()
1096 std::cout <<
" p "<<tk->
p()
1102 std::cout<<
" tkStat "<<tk->
stat()
1103 <<
" chi2 "<<tk->
chi2()
1104 <<
" ndof "<<tk->
ndof()
1106 <<
" nst "<<tk->
nster()
1108 std::cout<<
"errmat mat " << std::endl;
1109 std::cout<< tk->
err()<<std::endl;
1115 std::cout<<nhits <<
" Hits: " << std::endl;
1116 for(
int ii=0; ii <nhits ; ii++){
1120 cout<<
"("<< layer <<
","<<wire<<
","<<tk->
getVecHits()[ii]->getStat()
1121 <<
",lr:"<<tk->
getVecHits()[ii]->getFlagLR()<<
") ";
1123 std::cout <<
" "<< std::endl;
1125 std::cout <<
" "<< std::endl;
1130 std::cout <<
"=======Print after Track finding=======" << std::endl;
1134 if (!m_flags.
lHist)
return;
1136 int nTk = (*m_tracks).nTrack();
1137 for (
int itrack = 0; itrack < nTk; itrack++) {
1138 MdcTrack *atrack = (*m_tracks)[itrack];
1139 if (atrack==NULL)
continue;
1141 if (fitResult == 0)
continue;
1145 int seg[11] = {0};
int segme;
1149 int layerCount[43]={0};
1150 for(
int iii=0;iii<43;iii++){layerCount[iii]=0;}
1152 for (;hot!= hitlist->
end();hot++){
1157 layerCount[layer]++;
1161 if ( layer >0 ) {segme=(layer-1)/4;}
1163 if (recoHot->
layer()->
view()) { ++nSt; }
1170 double fltLen = recoHot->
fltLen();
1189 m_dx[i] =
m_x[i] - mcX[layer][wire];
1190 m_dy[i] =
m_y[i] - mcY[layer][wire];
1191 m_dz[i] =
m_z[i] - mcZ[layer][wire];
1198 double res=999.,rese=999.;
1199 if (recoHot->
resid(res,rese,
false)){
1205 for(
int i=0;i<11;i++){
1206 if (seg[i]>0) nSlay++;
1212 double fltLenPoca = 0.0;
1221 if (
m_pt > 0.00001){
1225 CLHEP::Hep3Vector p1 = fitResult->
momentum(fltLenPoca);
1226 double px,py,pz,pxy;
1227 pxy = fitResult->
pt();
1258 uint32_t getDigiFlag = 0;
1259 getDigiFlag += m_maxMdcDigi;
1264 if ((
int)mdcDigiVec.size()<m_minMdcDigi){
1265 std::cout <<
" Skip this event for MdcDigiVec.size() < "<<m_minMdcDigi << endl;
1270 MdcDigiCol::iterator
iter = mdcDigiVec.begin();
1289 SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc(),
"/Event/Digi/MdcDigiCol");
1299 uint32_t getDigiFlag = 0;
1300 getDigiFlag += m_maxMdcDigi;
1305 MdcDigiCol::iterator
iter = mdcDigiVec.begin();
1306 std::cout<<name()<<
" dump MdcDigiVec, nDigi="<<mdcDigiVec.size()<<std::endl;
1307 for (
int iDigi=0;
iter!= mdcDigiVec.end();
iter++,iDigi++ ) {
1310 int tkTruth = (*iter)->getTrackIndex();
1313 std::cout<<
"("<<l<<
","<<w<<
";"<<tkTruth<<
",t "<<tdc<<
",c "<<adc<<
")";
1314 if(iDigi%4==0) std::cout<<std::endl;
1316 std::cout<<std::endl;
std::vector< MdcDigi * > MdcDigiVec
double abs(const EvtComplex &c)
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
NTuple::Array< long > m_tsLayer
NTuple::Array< double > m_entra
NTuple::Array< long > m_tsMcTkId
NTuple::Item< double > g_findSegMc
NTuple::Tuple * m_tupleMcHit
NTuple::Tuple * m_tupleSeg
NTuple::Item< double > m_t4nMcTk
NTuple::Array< double > m_tMcLR
NTuple::Array< double > m_adc
NTuple::Item< long > m_tsNDigi
NTuple::Item< double > g_combAxMcPt
NTuple::Item< long > m_tMcNHit
NTuple::Item< double > g_combAxSlTest
NTuple::Array< double > m_dDriftD
NTuple::Array< double > m_dz
NTuple::Array< double > m_ambig
NTuple::Array< long > m_pickIs2D
NTuple::Item< double > m_tMcEvtNo
NTuple::Item< double > m_nSt
NTuple::Item< long > m_we_poisoned
NTuple::Item< double > m_we_pt
NTuple::Item< double > g_combAxQualitySeed
NTuple::Array< long > m_t4Layer
NTuple::Item< double > g_combAxPatSeed
NTuple::Item< double > m_nSlay
NTuple::Item< long > m_tMcTkId
NTuple::Item< long > m_t4nDigi
NTuple::Array< double > m_pickPt
NTuple::Tuple * g_tupleFindSeg
NTuple::Item< long > m_pickLayer
NTuple::Item< double > m_pocax
NTuple::Item< double > m_tMcPz
NTuple::Array< long > m_pickMcTk
NTuple::Array< double > m_dlr
NTuple::Item< double > g_combAxMcAmbigTest
NTuple::Item< int > g_findSegPat34
NTuple::Item< double > m_p
NTuple::Item< double > g_findSegAmbig
NTuple::Item< long > m_tMcNTk
NTuple::Item< int > g_findSegPat
NTuple::Array< long > m_tsWire
AIDA::IHistogram1D * g_pickHitWire
NTuple::Item< long > m_pickNCellWithDigi
NTuple::Array< double > m_tof
NTuple::Array< double > m_tMcWire
NTuple::Item< double > m_we_phi
AIDA::IHistogram1D * g_delCt
AIDA::IHistogram1D * g_phiDiff
NTuple::Array< double > m_pickPhiLowCut
NTuple::Array< double > m_doca
NTuple::Item< double > m_tMcPx
NTuple::Item< double > g_findSegChi2Refit
NTuple::Item< double > m_phi0
NTuple::Item< long > m_tw
NTuple::Item< double > m_nDof
NTuple::Array< double > m_tdc
NTuple::Item< long > m_t4EvtNo
NTuple::Item< double > m_tMcPy
double haveDigiDrift[43][288]
NTuple::Item< long > m_we_layer
NTuple::Tuple * m_tupleWireEff
NTuple::Item< double > m_tdncell
NTuple::Array< double > m_tMcZ
NTuple::Array< long > m_t4Wire
NTuple::Array< double > m_pickDriftCut
NTuple::Item< double > m_z0
int haveDigiAmbig[43][288]
NTuple::Item< long > m_nHit
NTuple::Item< double > m_tMcTheta
NTuple::Item< double > g_findSegIntercept
double haveDigiPhi[43][288]
AIDA::IHistogram1D * g_nSigAdd
NTuple::Item< double > m_tdphi
NTuple::Array< double > m_act
NTuple::Item< long > m_we_primary
NTuple::Item< double > m_pz
NTuple::Array< double > m_tMcX
NTuple::Array< double > m_wire
NTuple::Item< double > m_pocay
NTuple::Item< double > m_tMcZ0
NTuple::Item< long > m_we_seg
NTuple::Array< double > m_t4Charge
NTuple::Item< double > m_evtNo
NTuple::Item< long > m_we_tkId
NTuple::Item< double > m_d0
NTuple::Array< double > m_pickCurv
NTuple::Item< double > m_we_theta
NTuple::Item< long > m_we_track
NTuple::Array< double > m_resid
NTuple::Array< double > m_pickDrift
NTuple::Item< long > m_tMcPid
NTuple::Item< long > m_we_pdg
NTuple::Array< double > m_tMcY
NTuple::Item< double > m_tMcD0
NTuple::Item< double > m_t4t0
double haveDigiTheta[43][288]
NTuple::Array< double > m_z
AIDA::IHistogram1D * g_delZ0
AIDA::IHistogram1D * g_z0Cut
NTuple::Array< double > m_pickResid
NTuple::Array< int > m_pickPhizOk
NTuple::Item< long > m_we_wire
NTuple::Item< double > m_t4nRecTk
NTuple::Item< double > m_q
AIDA::IHistogram2D * g_residVsLayer
NTuple::Array< double > m_x
NTuple::Item< double > g_combAxMcTheta
AIDA::IHistogram1D * g_cirTkChi2
AIDA::IHistogram1D * g_maxSegChisqSt
NTuple::Item< long > m_tsNSeg
NTuple::Item< double > g_findSegChi2
NTuple::Item< double > g_combAxQualityTest
AIDA::IHistogram1D * h_sfHit
NTuple::Item< double > m_chi2
NTuple::Item< double > m_t0
NTuple::Array< double > m_pickSigma
AIDA::IHistogram1D * g_3dTkChi2
NTuple::Item< long > m_t4t0Stat
NTuple::Item< double > g_combAxNhitTest
AIDA::IHistogram2D * g_residVsDoca
NTuple::Item< double > g_combAxSigPhi0
NTuple::Item< double > m_nTdsTk
NTuple::Item< double > m_tphi
NTuple::Item< double > g_combAxdCurv
NTuple::Array< long > m_pickWire
NTuple::Item< double > m_pocaz
NTuple::Array< double > m_tMcDrift
NTuple::Tuple * m_tupleEvt
NTuple::Item< double > g_findSegChi2Add
NTuple::Array< double > m_cellWidth
NTuple::Tuple * m_tuplePick
NTuple::Item< double > m_nMcTk
NTuple::Array< double > m_pickDriftTruth
NTuple::Item< double > g_findSegSlope
NTuple::Item< double > g_combAxSigCurv
NTuple::Array< double > m_driftT
NTuple::Item< double > m_tMcFiTerm
NTuple::Item< long > m_tl
NTuple::Array< double > m_dx
NTuple::Array< long > m_tsInSeg
NTuple::Array< double > m_dy
NTuple::Item< double > m_t4t0Truth
double haveDigiPt[43][288]
NTuple::Item< double > m_t0Truth
NTuple::Item< double > g_combAxdPhi0
NTuple::Array< double > m_pickZ
AIDA::IHistogram1D * g_slopeDiff
NTuple::Array< double > m_pickPredDrift
NTuple::Array< double > m_tMcLayer
NTuple::Item< int > g_findSegSl
NTuple::Array< double > m_t4PhiMid
NTuple::Array< double > m_layer
NTuple::Item< double > m_pt
NTuple::Item< double > m_cpa
NTuple::Array< double > m_driftD
NTuple::Item< double > m_tanl
NTuple::Item< double > m_t0Stat
NTuple::Array< double > m_sigma
NTuple::Item< double > g_combAxPatTest
NTuple::Item< double > g_combAxNhitSeed
NTuple::Item< double > m_nAct
NTuple::Item< double > g_combAxMc
NTuple::Item< long > m_we_gwire
NTuple::Item< long > m_t4nDigiUnmatch
NTuple::Array< double > m_y
AIDA::IHistogram1D * g_maxSegChisqAx
AIDA::IHistogram1D * g_ctCut
NTuple::Array< double > m_t4Time
NTuple::Item< double > g_combAxSlSeed
NTuple::Tuple * g_tupleCombAx
NTuple::Tuple * m_tupleMc
NTuple::Item< long > m_pickNCell
NTuple::Item< double > g_combAxMcAmbigSeed
NTuple::Item< long > m_tsEvtNo
NTuple::Item< double > g_combAxMcPhi
NTuple::Array< double > m_fltLen
NTuple::Array< double > m_pickPhiHighCut
NTuple::Item< double > m_tkId
NTuple::Array< double > m_t4Hot
NTuple::Item< int > g_findSegNhit
IHistogramSvc * histoSvc()
double bFieldNominal() const
static const double twoPi
static const int nWireBeforeLayer[43]
const double theta() const
const HepSymMatrix err() const
const double chi2() const
const int trackId() const
const HepVector helix() const
......
GmsListLink * next() const
const MdcLayer * Layer(unsigned id) const
static MdcDetector * instance()
void setDebug(int debugFlag)
void readPar(std::string inname)
MdcTrackParams tkParTight
double entranceAngle() const
const MdcLayer * layer() const
const MdcHit * mdcHit() const
unsigned layernumber() const
unsigned wirenumber() const
double driftTime(double tof, double z) const
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
double phiWire(int cell) const
void printRecMdcTrackCol() const
const MdcHit * mdcHit() const
MdcHitUse * hit(int i) const
void dumpTdsTrack(RecMdcTrackCol *trackList)
bool ignoringUsedHits() const
MdcTrkRecon(const std::string &name, ISvcLocator *pSvcLocator)
bool poisoningHits() const
static void readMCppTable(std::string filenm)
MdcDigiVec & getMdcDigiVec(uint32_t control=0)
static double MdcTime(int timeChannel)
static double MdcCharge(int chargeChannel)
const HitRefVec getVecHits(void) const
const int getNhits() const
virtual void getInfo(double fltLen, HepPoint3D &pos, Hep3Vector &direction) const =0
virtual Hep3Vector momentum(double fltL=0.) const =0
virtual double pt(double fltL=0.) const =0
virtual double chisq() const =0
virtual int charge() const =0
virtual int nDof() const =0
virtual const TrkDifTraj & traj() const =0
virtual HepPoint3D position(double fltL) const =0
virtual int nActive() const =0
virtual TrkExchangePar helix(double fltL) const =0
static double nSigmaCut[43]
hot_iterator begin() const
double resid(bool exclude=false) const
const TrkRep * getParentRep() const
const TrkFit * fitResult() const
virtual double arrivalTime(double fltL) const
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string RecMdcHitCol