43#include "GaudiKernel/MsgStream.h"
44#include "GaudiKernel/AlgFactory.h"
58#include "CLHEP/Alist/AIterator.h"
85#include "GaudiKernel/INTupleSvc.h"
86#include "GaudiKernel/NTuple.h"
108 Algorithm(name, pSvcLocator), m_mdcCalibFunSvc(0)
111 declareProperty(
"pdtFile", m_pdtFile =
"pdt.table");
113 declareProperty(
"debug",
m_debug= 0);
114 declareProperty(
"hist", m_hist= 0);
115 declareProperty(
"mcHist", m_mcHist =
false);
117 declareProperty(
"cresol", m_cresol = 0.013);
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.);
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);
157 if(
NULL == m_gm)
return StatusCode::FAILURE;
160 return StatusCode::SUCCESS;
166 MsgStream log(
msgSvc(), name());
167 log << MSG::INFO <<
"in initialize()" << endreq;
170 for (
int i=0;i<20;i++) t_nTkNum[i]=0;
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;
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");
189 if (m_helixFitCut.size() == 43){
190 for(
int i=0; i<43; i++){
210 StatusCode sc = service (
"MdcCalibFunSvc", imdcCalibSvc);
212 if ( sc.isFailure() ){
213 log << MSG::FATAL <<
"Could not load MdcCalibFunSvc!" << endreq;
214 return StatusCode::FAILURE;
221 sc = service (
"RawDataProviderSvc", iRawDataProvider);
222 if ( sc.isFailure() ){
223 log << MSG::FATAL <<
"Could not load RawDataProviderSvc!" << endreq;
224 return StatusCode::FAILURE;
230 sc = service (
"MagneticFieldSvc",m_pIMF);
231 if(sc!=StatusCode::SUCCESS) {
232 log << MSG::ERROR <<
"Unable to open Magnetic field service"<<endreq;
234 m_bfield =
new BField(m_pIMF);
235 log << MSG::INFO <<
"field z = "<<m_bfield->
bFieldNominal()<< endreq;
238 if (m_hist) {bookNTuple();}
239 if (m_dropHitsSigma.size()==43){
240 for (
int ii=0;ii<43;ii++) {
245 return StatusCode::SUCCESS;
252 setFilterPassed(b_saveEvent);
257 MsgStream log(
msgSvc(), name());
258 log << MSG::INFO <<
"in execute()" << endreq;
261 nTk = 0; t_nTdsTk = 0; t_nDigi=0; t_nSeg=0;
265 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
267 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
268 return StatusCode::FAILURE;
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;
275 IDataManagerSvc *dataManSvc;
276 DataObject *aTrackCol;
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");
285 eventSvc()->findObject(
"/Event/Recon/RecMdcHitCol",aHitCol);
286 if(aHitCol !=
NULL) {
287 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcHitCol");
288 eventSvc()->unregisterObject(
"/Event/Recon/RecMdcHitCol");
295 DataObject *aReconEvent;
296 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
297 if (aReconEvent==
NULL) {
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;
306 eventSvc()->findObject(
"/Event/Recon/RecMdcTrackCol",aTrackCol);
312 if(!sc.isSuccess()) {
313 log << MSG::FATAL <<
" Could not register RecMdcTrack collection" <<endreq;
314 return StatusCode::FAILURE;
318 eventSvc()->findObject(
"/Event/Recon/RecMdcHitCol",aHitCol);
324 if(!sc.isSuccess()) {
325 log << MSG::FATAL <<
" Could not register RecMdcHit collection" <<endreq;
326 return StatusCode::FAILURE;
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;
343 SmartDataPtr<MdcHitCol> m_hitCol(eventSvc(),
"/Event/Hit/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;
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;
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;
374 if(m_debug>1) std::cout<<name()<<
" evt "<<t_evtNo<<
" t0 "<<m_bunchT0<<
" t0Stat "<<m_t0Stat<<std::endl;
376 SmartDataPtr<TrigData> trigData(eventSvc(),
"/Event/Trig/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;
382 for(
int i = 0; i < 16; i++) log << MSG::INFO <<
"Trigger channel "<< i <<
": " << trigData->getTrigChannel(i) << endreq;
383 m_timing=trigData->getTimingType();
385 log << MSG::INFO <<
"Tigger Timing type: "<< trigtiming << endreq;
392 uint32_t getDigiFlag = 0;
393 getDigiFlag += m_maxMdcDigi;
397 mdcDigiVec = m_rawDataProviderSvc->
getMdcDigiVec(getDigiFlag);
398 t_nDigi = mdcDigiVec.size();
404 if (t_nDigi < m_minMdcDigi){
406 log << MSG::WARNING <<
" No hits in MdcDigiVec" << endreq;
408 log << MSG::WARNING <<
" Skip this event for MdcDigiVec.size() < "<<m_minMdcDigi << endreq;
409 return StatusCode::SUCCESS;
411 m_mdcxHits.
create(mdcDigiVec, m_bunchT0, m_cresol);
414 if(m_debug>2) m_mdcxHits.
print(std::cout,6796);
421 if(m_debug > 1 ){ dumpMdcxSegs(seglist);}
422 t_nSeg = seglist.length();
434 if(m_debug>1) dumpTrackList(firsttrkl);
466 sc = FitMdcxTrack(trkl, dchitlist, m_hitCol, trackList, hitList);
467 if (!sc.isSuccess()) {
return StatusCode::SUCCESS;}
468 t_nTdsTk = trackList->size();
470 t_nTkTot += trackList->size();
471 if(t_nTdsTk<20) t_nTkNum[t_nTdsTk]++;
478 if(m_hist) fillEvent();
481 eventSvc()->retrieveObject(
"/Event/Recon/RecMdcTrackCol",pNode);
483 eventSvc()->retrieveObject(
"/Event/Recon/RecMdcHitCol",pNode);
485 if(tmpTrackCol) nTdsTk = tmpTrackCol->size();
488 std::cout<<
"MdcxTrackFinder: evtNo "<< m_eventNo <<
" t0="<<m_bunchT0
489 <<
" Found " <<trkl.length()
490 <<
" keep "<< t_nTdsTk
491 <<
" finialy keep "<< nTdsTk;
493 int ndelete =0; trkl.length() - trackList->size();
494 if( ndelete>0 ) std::cout <<
" delete "<< ndelete;
495 std::cout <<
" track(s)" <<endl;
498 if(m_debug>1)dumpTdsTrack(tmpTrackCol);
499 if(m_debug>1)dumpTrack(tmpTrackCol);
503 if((trackList->size()!=4) ) b_saveEvent =
true;
504 setFilterPassed(b_saveEvent);
505 return StatusCode::SUCCESS;
509 MsgStream log(
msgSvc(), name());
510 log << MSG::INFO <<
"in finalize()" << endreq;
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;
518 return StatusCode::SUCCESS;
525 if ( 0 == mdcxHits.length() )
return;
528 while(mdcxHits[ihits]) {
530 const MdcHit* newhit = mdcxHits[ihits]->getMdcHit();
532 const MdcDigi* theDigi = mdcxHits[ihits]->getDigi();
533 int layer =
MdcID::layer(mdcxHits[ihits]->getDigi()->identify());
534 int wire =
MdcID::wire(mdcxHits[ihits]->getDigi()->identify());
535 m_digiMap[layer][wire] = mdcxHits[ihits]->getDigi();
541 mdcHitCol->push_back(thehit);
565 MsgStream log(
msgSvc(), name());
589 int tkLen = trkl.length();
590 for (
int kk=0; kk< tkLen; kk++){
593 std::cout<<__FILE__<<
" FitMdcxTrack "<<kk<< std::endl;
594 for(
int i=0; i<xhits.length(); i++){ xhits[i]->print(std::cout); }
595 std::cout<<std::endl;
598 if(m_debug>2) std::cout<<
" before add hits nhits="<<xhits.length()<< std::endl;
601 std::cout<<
" after,add "<<xass.length()<<
" hits"<<std::endl;
605 double thechisq = mdcxHelix.
Chisq();
612 aTrack = linefactory.
makeTrack(tt, thechisq, *m_context, m_bunchT0*1.e-9);
616 aTrack = helixfactory.
makeTrack(tt, thechisq, *m_context, m_bunchT0*1.e-9);
622 if (0 == m_trkHitList) {
629 MdcxHitsToHots(mdcxHelix, xhits, m_trkHitList, m_hitCol);
632 MdcxHitsToHots(mdcxHelix, xass, m_trkHitList, m_hitCol);
637 if(m_dropMultiHotInLayer) dropMultiHotInLayer(m_trkHitList);
640 if(m_debug>1){ std::cout<<
"== put to official fitter "<<std::endl;}
644 std::cout<<
"== after official fitter "<<std::endl;
652 int ndof = theFit->
nActive()-nparm;
653 if (ndof > 0) rcs = theFit->
chisq()/float(ndof);
655 if (4 == nparm) cout <<
" TrkLineMaker";
656 else cout <<
" TrkHelixMaker";
657 cout <<
" trkNo. " << kk <<
" success " << err.
success() <<
" rcs " << rcs
658 <<
" chi2 " << theFit->
chisq() <<
" nactive " << theFit->
nActive() << endl;
662 if ( (1 == err.
success()) && (rcs < 20.0) ) {
663 if(m_debug>1) std::cout<<
"== fit success "<<std::endl;
670 if (m_debug>1) { cout <<
"MdcxTrackFinder: accept a track " << endl; }
673 store(aTrack, trackList, hitList);
674 }
else if ( (2 == err.
success()) && (rcs < 150.0) ) {
675 if(m_debug > 1) std::cout<<
"== fit success = 2, refit now"<<std::endl;
677 while (nrefit++ < 5) {
678 if (m_debug>1) std::cout <<
"refit time " << nrefit << std::endl;
679 err = m_trkHitList->
fit();
692 store(aTrack, trackList, hitList);
696 std::cout<<
"== fit faild "<<std::endl;
705 if(m_debug>1) std::cout<<
"== Fit no good; try a better input helix"<<std::endl;
706 mdcxHelix.
Grow(*trkl[kk],xass);
709 int fail = mdcxHelix.
ReFit();
710 if(m_debug>1)std::cout<<__FILE__<<
" refit fail:"<<fail<< std::endl;
711 if (!mdcxHelix.
Fail()) {
713 thechisq = mdcxHelix.
Chisq();
717 bTrack = linefactory.
makeTrack(tb,thechisq,*m_context,m_bunchT0*1.e-9);
720 bTrack = helixfactory.
makeTrack(tb,thechisq,*m_context,m_bunchT0*1.e-9);
724 if (0 == bhits){
delete bTrack; bTrack =
NULL;
continue;}
726 MdcxHitsToHots(mdcxHelix, bxhits, bhits, m_hitCol);
731 int ndof = bFit->
nActive() - nparm;
732 if (ndof > 0) rcs = bFit->
chisq()/float(ndof);
734 if (4 == nparm) cout <<
" TrkLineMaker";
735 else cout <<
" TrkHelixMaker";
736 cout <<
" success trkNo. " << kk <<
" status " << berr.
success() <<
" rcs " << rcs
737 <<
" chi2 " << bFit->
chisq() <<
" nactive "<< bFit->
nActive() << endl;
740 if ( ( 1 == berr.
success() ) && ( rcs < 50.0 ) ) {
744 cout <<
"MdcxTrackFinder: accept b track and store to TDS" << endl;
747 store(bTrack, trackList, hitList);
750 cout<<
" fit failed "<<endl;
754 if (bTrack!=
NULL) {
delete bTrack; bTrack =
NULL; }
761 if(m_debug >1) dumpTdsTrack(trackList);
762 return StatusCode::SUCCESS;
768 assert (aTrack !=
NULL);
770 int trackId = trackList->size();
772 if(m_dropTrkPt>0. && (aTrack->
fitResult()->
pt()<m_dropTrkPt)) {
773 if(m_debug>1) std::cout<<
"MdcxTrackFinder delete track by pt "
774 <<aTrack->
fitResult()->
pt()<<
"<ptCut "<<m_dropTrkPt << std::endl;
778 if( ( (fabs(helix.
d0())>m_d0Cut) ||( fabs(helix.
z0())>m_z0Cut) ) ){
779 if(m_debug>1) std::cout<< name()<<
" delete track by d0 "<<helix.
d0()<<
">d0Cut "<<m_d0Cut
780 <<
" or z0 "<<helix.
z0()<<
" >z0Cut "<<m_z0Cut << std::endl;
784 if(m_hist) fillTrack(aTrack);
788 int nHitbefore = hitList->size();
790 mdcTrack.storeTrack(trackId, trackList, hitList, tkStat);
791 int nHitAfter = hitList->size();
792 if (nHitAfter - nHitbefore <10 ) setFilterPassed(
true);
796 RecMdcTrackCol::iterator i_tk = trackList->begin();
797 for (;i_tk != trackList->end(); i_tk++) {
804 std::cout<<
" MdcTrack Id:"<<tk->
trackId() <<
" q:"<< tk->
charge()<< std::endl;
805 std::cout<<
"dr Fi0 Cpa Dz Tanl Chi2 Ndf nSt FiTerm poca" << std::endl;
806 std::cout<<
"(" <<setw(5) << tk->
helix(0)<<
","<< setw(5) << tk->
helix(1)<<
"," << setw(5) << tk->
helix(2) <<
","
807 << setw(5) << tk->
helix(3) <<
","<< setw(5) << tk->
helix(4) <<
")"
808 << setw(5) << tk->
chi2() << setw(4) << tk->
ndof()
811 std::cout<<
" ErrMat "<<tk->
err() << std::endl;
813 std::cout<<
"hitId tkId (l,w) fltLen lr dt ddl tdc "
814 <<
"doca entr z tprop stat " << std::endl;
817 HitRefVec::iterator it = hl.begin();
818 for (;it!=hl.end();++it){
823 double _zlen = _layerPtr->
zLength();
827 tprop = (0.5*_zlen + z)/_vprop;
829 tprop = (0.5*_zlen - z)/_vprop;
846 std::cout<< setw(3) << h->
getId() << setw(2) << h->
getTrkId() <<
853 setw(10) << h->
getZhit() << setw(10) << tprop<<
854 setw(2)<< h->
getStat() << std::endl;
858void MdcxTrackFinder::bookNTuple(){
859 MsgStream log(
msgSvc(), name());
903 NTuplePtr nt1(
ntupleSvc(),
"MdcxReco/rec");
906 m_xtuple1 =
ntupleSvc()->book (
"MdcxReco/rec", CLID_ColumnWiseTuple,
"MdcxReco reconsturction results");
952 log << MSG::ERROR <<
" Cannot book N-tuple: MdcxReco/rec" << endmsg;
956 NTuplePtr nt4(
ntupleSvc(),
"MdcxReco/evt");
979 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/evt" << endmsg;
985 NTuplePtr ntSeg(
ntupleSvc(),
"MdcxReco/seg");
988 m_xtupleSeg =
ntupleSvc()->book (
"MdcxReco/seg", CLID_ColumnWiseTuple,
"MdcxTrackFinder segment data");
1007 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/evt" << endmsg;
1011 NTuplePtr nt5(
ntupleSvc(),
"MdcxReco/trkl");
1019 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/trkl" << endmsg;
1024 NTuplePtr ntCsmcSew(
ntupleSvc(),
"MdcxReco/csmc");
1036 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/csmc" << endmsg;
1040 NTuplePtr ntSegAdd1(
ntupleSvc(),
"MdcxReco/addSeg1");
1060 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/addSeg1" << endmsg;
1065 NTuplePtr ntSegComb(
ntupleSvc(),
"MdcxReco/segComb");
1084 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/segComb" << endmsg;
1089 NTuplePtr ntDropHits(
ntupleSvc(),
"MdcxReco/dropHits");
1103 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/dropHits" << endmsg;
1107 NTuplePtr ntAddSeg2(
ntupleSvc(),
"MdcxReco/addSeg2");
1117 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/addSeg2" << endmsg;
1125void MdcxTrackFinder::fillEvent(){
1143 MdcDigiCol::iterator
iter = mdcDigiVec.begin();
1144 for (;iDigi<t_nDigi;
iter++ ) {
1156void MdcxTrackFinder::fillTrack(
TrkRecoTrk* atrack){
1164 if (atrack==
NULL)
return;
1167 if (fitResult == 0)
return;
1171 int seg[11] = {0};
int segme;
1177 int layerCount[43]={0};
1179 for (;hot!= hitlist->
end();hot++){
1188 layerCount[layer]++;
1192 double fltLen = recoHot->
fltLen();
1212 double res=999.,rese=999.;
1213 if (recoHot->
resid(res,rese,
false)){
1218 if ( layer >0 ) {segme=(layer-1)/4;}
1220 if (recoHot->
layer()->
view()) { ++nSt; }
1225 for(
int i=0;i<11;i++){
1226 if (seg[i]>0) nSlay++;
1233 double fltLenPoca = 0.0;
1241 if(m_debug>1) std::cout<<
"evt:"<<m_eventNo<<
" BigVtx:"
1242 <<
" d0 "<<helix.
d0()<<
" z0 "<<helix.
z0()<<std::endl;
1245 if (
m_xpt > 0.00001){
1249 CLHEP::Hep3Vector p1 = fitResult->
momentum(fltLenPoca);
1250 double px,py,pz,pxy;
1251 pxy = fitResult->
pt();
1279 cout << name()<<
" found " <<segList.length() <<
" segs :" << endl;
1280 for (
int i =0; i< segList.length(); i++){
1282 segList[i]->printSeg();
1290 40,44,48,56, 64,72,80,80, 76,76,88,88,
1291 100,100,112,112, 128,128,140,140, 160,160,160,160,
1292 176,176,176,176, 208,208,208,208, 240,240,240,240,
1293 256,256,256,256, 288,288,288 };
1295 int hitInSegList[43][288];
1296 for (
int ii=0;ii<43;ii++){
1297 for (
int jj=0;jj<cellMax[ii];jj++){ hitInSegList[ii][jj] = 0; }
1299 for (
int i = 0; i < segList.length(); i++) {
1301 for (
int ihit=0 ; ihit< aSeg->
Nhits() ; ihit++){
1303 int layer = hit->
Layer();
1304 int wire = hit->
WireNo();
1305 hitInSegList[layer][wire]++;
1308 for (
int i = 0; i < segList.length(); i++) {
1310 if(aSeg==
NULL)
continue;
1322 for (
int ii = 0;ii<14;ii++){
1328 for (
int ii = 0;ii<20;ii++){
1337 for (
int ihit=0 ; ihit< aSeg->
Nhits() ; ihit++){
1339 int layer = hit->
Layer();
1340 int wire = hit->
WireNo();
1343 m_xtsInSeg[ihit] = hitInSegList[layer][wire];
1352 std::cout<<
"dump track list " <<std::endl;
1353 for (
int i=0;i<trackList.length();i++){
1354 std::cout<<
"track "<<i<<std::endl;
1355 for (
int ihit=0 ; ihit< trackList[i]->Nhits() ; ihit++){
1356 const MdcxHit* hit = trackList[i]->XHitList()[ihit];
1357 int layer = hit->
Layer();
1358 int wire = hit->
WireNo();
1359 std::cout<<
" ("<<layer <<
","<< wire<<
") ";
1361 std::cout<<std::endl;
1369 for (
int i =0; i< firsttrkl.length(); i++){
1370 nDigi+= firsttrkl[i]->Nhits();
1372 for (
int i=0;i<firsttrkl.length();i++){
1373 for (
int ihit=0 ; ihit< firsttrkl[i]->Nhits() ; ihit++){
1374 const MdcxHit* hit = firsttrkl[i]->XHitList()[ihit];
1375 int layer = hit->
Layer();
1376 int wire = hit->
WireNo();
1385void MdcxTrackFinder::fillMcTruth(){
1386 MsgStream log(
msgSvc(), name());
1389 for (
int ii=0;ii<43;ii++){
1390 for (
int jj=0;jj<288;jj++){
1391 haveDigi[ii][jj] = -2;
1394 int nDigi = mdcDigiVec.size();
1395 for (
int iDigi =0 ;iDigi<nDigi; iDigi++ ) {
1405 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
1407 log << MSG::INFO <<
"Could not retrieve McParticelCol" << endreq;
1409 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
1410 for (;iter_mc != mcParticleCol->end(); iter_mc++){
1411 if ((*iter_mc)->primaryParticle()){
1412 m_t0Truth = (*iter_mc)->initialPosition().t();
1442void MdcxTrackFinder::dropMultiHotInLayer(
TrkHitList* trkHitList){
1444 double tdr_wire[43];
1445 for(
int i=0; i<43; i++){tdr[i]=9999.;}
1449 while (hotIter!=trkHitList->
hotList().
end()) {
1458 if (
dt < tdr[layer]) {
1460 tdr_wire[layer] = wire;
1471 while (hotIter!=trkHitList->
hotList().
end()) {
1472 int layer = hotIter->mdcHitOnTrack()->mdcHit()->layernumber();
1473 int wire = hotIter->mdcHitOnTrack()->mdcHit()->wirenumber();
1476 if ((tdr[layer] <9998.) && (tdr_wire[layer]!=wire)){
1479 trkHitList->
removeHit( hotIter->mdcHitOnTrack()->mdcHit() );
1487 std::cout<<
"tksize = "<<trackList->size() << std::endl;
1488 RecMdcTrackCol::iterator it = trackList->begin();
1489 for (;it!= trackList->end();it++){
1491 std::cout<<
"//====RecMdcTrack "<<tk->
trackId()<<
"====:" << std::endl;
1492 cout <<
" d0 "<<tk->
helix(0)
1493 <<
" phi0 "<<tk->
helix(1)
1494 <<
" cpa "<<tk->
helix(2)
1495 <<
" z0 "<<tk->
helix(3)
1496 <<
" tanl "<<tk->
helix(4)
1498 std::cout<<
" q "<<tk->
charge()
1499 <<
" theta "<<tk->
theta()
1500 <<
" phi "<<tk->
phi()
1506 std::cout <<
" p "<<tk->
p()
1512 std::cout<<
" tkStat "<<tk->
stat()
1513 <<
" chi2 "<<tk->
chi2()
1514 <<
" ndof "<<tk->
ndof()
1516 <<
" nst "<<tk->
nster()
1520 std::cout<<
nhits <<
" Hits: " << std::endl;
1521 for(
int ii=0; ii <
nhits ; ii++){
1525 cout<<
"("<< layer <<
","<<wire<<
","<<tk->
getVecHits()[ii]->getStat()
1526 <<
",lr:"<<tk->
getVecHits()[ii]->getFlagLR()<<
") ";
1528 std::cout <<
" "<< std::endl;
1530 std::cout <<
" "<< std::endl;
1535void MdcxTrackFinder::dumpTdsHits(
RecMdcHitCol* hitList){
1536 std::cout<<__FILE__<<
" "<<__LINE__<<
" All hits in TDS, nhit="<<hitList->size()<< std::endl;
1537 RecMdcHitCol::iterator it = hitList->begin();
1538 for(;it!= hitList->end(); it++){
ObjectVector< MdcHit > MdcHitCol
NTuple::Array< double > m_xfltLen
AIDA::IHistogram1D * g_dPhiAV
NTuple::Item< double > m_addSegAddPhiLay
NTuple::Array< double > m_xwire
NTuple::Item< double > m_xtsXline_bbrrf
NTuple::Item< double > m_xt0Stat
NTuple::Array< double > m_xdriftT
AIDA::IHistogram1D * g_trkldrop1
NTuple::Array< double > m_xdriftD
NTuple::Item< double > m_xpocax
NTuple::Item< double > m_xtsChisq
NTuple::Item< long > m_xnHit
AIDA::IHistogram1D * g_dPhiAU_1
NTuple::Item< double > m_xtsYline_slope
NTuple::Item< long > m_xt5Layer
NTuple::Item< double > m_xtsYline_bbrrf
NTuple::Item< double > m_xq
AIDA::IHistogram1D * g_csmax3
AIDA::IHistogram1D * g_trklappend2
NTuple::Item< double > m_addSegSeedPhi0
NTuple::Array< double > m_xambig
NTuple::Item< double > m_xtiming
NTuple::Item< double > m_segCombDLenUV
AIDA::IHistogram1D * g_trklappend1
AIDA::IHistogram1D * g_dPhiAV_0
NTuple::Item< long > m_addSegSlayer
AIDA::IHistogram2D * g_poison
NTuple::Item< double > m_xchi2
NTuple::Array< double > m_xresid
NTuple::Item< long > m_addSegSame
NTuple::Item< double > m_xpocaz
AIDA::IHistogram1D * g_trklproca
NTuple::Item< long > m_segDropHitsWire
NTuple::Item< long > m_xtsNDigi
NTuple::Item< double > m_addSegSeedSl
NTuple::Tuple * m_xtupleTrkl
NTuple::Item< double > m_xnAct
NTuple::Array< double > m_xtof
NTuple::Tuple * m_xtupleAddSeg1
NTuple::Item< double > m_addSegAddLen
AIDA::IHistogram1D * g_addSegPhi
AIDA::IHistogram1D * g_dPhiAV_1
NTuple::Item< long > m_xtsSl
NTuple::Item< double > m_xt4nTdsTk
NTuple::Item< double > m_addSegLen
AIDA::IHistogram1D * g_trkle
NTuple::Item< long > m_xtsPat
AIDA::IHistogram1D * g_dPhiAU_5
NTuple::Item< double > m_xp
AIDA::IHistogram1D * g_trkld
NTuple::Array< long > m_xtsWire
NTuple::Item< double > m_xt0
AIDA::IHistogram1D * g_trkltemp
NTuple::Item< double > m_segDropHitsDoca
NTuple::Item< long > m_xt4nSeg
NTuple::Item< double > m_xtsPhi0_sl_approx
AIDA::IHistogram1D * g_csmax4
NTuple::Item< double > m_csmcTanl
NTuple::Item< double > m_segDropHitsSigma
AIDA::IHistogram2D * g_trklel
NTuple::Item< double > m_xtsD0
NTuple::Item< double > m_addSegSeedPhiLay
NTuple::Array< double > m_xact
NTuple::Item< double > m_csmcOmega
NTuple::Item< double > m_xpz
NTuple::Item< double > m_addSegSeedLen
NTuple::Item< double > m_xnSt
NTuple::Array< long > m_xtsInSeg
NTuple::Item< double > m_segCombSlV
NTuple::Item< long > m_segDropHitsLayer
NTuple::Item< double > m_addSegSeedD0
AIDA::IHistogram1D * g_dPhiAU_7
NTuple::Tuple * m_xtuple1
AIDA::IHistogram2D * g_dropHitsSigma
NTuple::Item< double > m_xtsPhi0
AIDA::IHistogram1D * g_trklappend3
NTuple::Item< double > m_xt4t0
AIDA::IHistogram1D * g_trklhelix
NTuple::Item< double > m_xt4timeFit
NTuple::Item< double > m_xt4t0Truth
NTuple::Item< double > m_segDropHitsMcTkId
NTuple::Array< double > m_xdoca
AIDA::IHistogram1D * g_trkllmk
NTuple::Item< double > m_xevtNo
AIDA::IHistogram1D * g_addHitCut
AIDA::IHistogram2D * g_trkldl
NTuple::Item< long > m_xt4t0Stat
NTuple::Item< double > m_xt4nRecTk
NTuple::Item< double > m_segCombPhiA
NTuple::Item< long > m_xt4EvtNo
AIDA::IHistogram1D * g_dPhiAU_0
NTuple::Item< double > m_segCombSlA
NTuple::Item< double > m_xt4timeTrack
NTuple::Array< double > m_xsigma
NTuple::Item< double > m_xt4time
NTuple::Item< double > m_segCombDLenAU
AIDA::IHistogram2D * g_addHitCut2d
NTuple::Item< long > m_xt5Wire
AIDA::IHistogram1D * g_trklgood
AIDA::IHistogram1D * g_trkllayer
NTuple::Item< double > m_xphi0
NTuple::Item< double > m_segCombSlU
NTuple::Item< long > m_segCombEvtNo
NTuple::Item< double > m_segCombPhiU
NTuple::Item< double > m_csmcPhi0
NTuple::Array< double > m_xadc
NTuple::Array< double > m_xt4Time
AIDA::IHistogram1D * g_dPhiAU
NTuple::Item< double > m_segCombSameUV
NTuple::Item< double > m_addSegAddPhi
NTuple::Item< double > m_xt4timeSeg
NTuple::Item< double > m_addSegSeedPhi
NTuple::Array< double > m_xx
NTuple::Item< double > m_xz0
NTuple::Item< double > m_csmcPt
NTuple::Item< long > m_xnSlay
AIDA::IHistogram1D * g_trkldrop2
NTuple::Array< double > m_xtdc
NTuple::Item< double > m_segCombPhiV
NTuple::Item< double > m_xtanl
NTuple::Item< double > m_addSegAddPhi0
NTuple::Item< double > m_xt0Truth
AIDA::IHistogram1D * g_dPhiAV_8
NTuple::Tuple * m_xtupleSegComb
NTuple::Item< double > m_addSegAddSl
NTuple::Item< double > m_segCombOmega
NTuple::Array< long > m_xt4Layer
NTuple::Item< double > m_xtsD0_sl_approx
NTuple::Item< double > m_xtkId
NTuple::Item< double > m_addSegAddD0
NTuple::Item< long > m_segDropHitsEvtNo
NTuple::Item< double > m_segCombSameAU
NTuple::Tuple * m_xtupleEvt
NTuple::Item< double > m_xpt
NTuple::Item< double > m_xpocay
NTuple::Item< double > m_segDropHitsPull
NTuple::Item< double > m_xcpa
NTuple::Item< double > m_csmcD0
AIDA::IHistogram1D * g_trklfirstProb
NTuple::Tuple * m_xtupleAddSeg2
AIDA::IHistogram1D * g_omegag
NTuple::Array< long > m_xtsLayer
AIDA::IHistogram1D * g_trkldoca
NTuple::Array< double > m_xentra
NTuple::Item< double > m_xnDof
NTuple::Array< double > m_xlayer
NTuple::Array< double > m_xy
NTuple::Array< double > m_xz
NTuple::Item< double > m_xtsOmega
NTuple::Item< double > m_xd0
NTuple::Item< long > m_addSegEvtNo
NTuple::Item< double > m_segDropHitsDrift
NTuple::Item< long > m_xt4nDigi
AIDA::IHistogram1D * g_dPhiAV_6
NTuple::Tuple * m_xtupleDropHits
NTuple::Item< double > m_csmcZ0
NTuple::Tuple * m_xtupleSeg
NTuple::Item< double > m_addSegPoca
NTuple::Tuple * m_xtupleCsmcSew
AIDA::IHistogram1D * g_trklcircle
NTuple::Item< double > m_xtsXline_slope
NTuple::Array< double > m_xt4Charge
double MdcTrkReconCut_helix_fit[43]
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
SmartRefVector< RecMdcHit > HitRefVec
IHistogramSvc * histoSvc()
double bFieldNominal() const
static const double vpropInner
static const double vpropOuter
const double theta() const
const HepSymMatrix err() const
const double chi2() const
const int trackId() const
const HepVector helix() const
......
const HepPoint3D poca() const
const MdcLayer * Layer(unsigned id) const
static MdcDetector * instance()
virtual const MdcHit * mdcHit() const
double entranceAngle() const
const MdcLayer * layer() const
void setCalibSvc(const MdcCalibFunSvc *calibSvc)
unsigned layernumber() const
unsigned wirenumber() const
double driftTime(double tof, double z) const
void setCountPropTime(const bool count)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
double zLength(void) const
const MdcHit * mdcHit() const
const HepAList< MdcxSeg > & GetMdcxSeglist()
const HepAList< MdcxFittedHel > & GetMdcxTrklist()
const HepAList< MdcxHit > & XHitList() const
int SuperLayer(int hitno=0) const
int Fail(float Probmin=0.0) const
void SetChiDofBail(float r)
MdcxFittedHel & Grow(const MdcxFittedHel &, const HepAList< MdcxHit > &)
static void setMdcDetector(const MdcDetector *gm)
static void setMdcCalibFunSvc(const MdcCalibFunSvc *calibSvc)
static void setCountPropTime(bool countPropTime)
void print(std::ostream &o, int pmax=10) const
const HepAList< MdcxHit > & GetMdcxHitList()
void create(MdcDigiVec digiVec, float c0=0.0, float cresol=0.0180)
const HepAList< MdcxFittedHel > & GetMergedTrklist()
static double maxRcsInAddSeg
static float dropHitsSigma[43]
static double helixFitSigma
static double nSigAddHitTrk
static const unsigned patt4[14]
static const unsigned patt3[20]
virtual ~MdcxTrackFinder()
static void readMCppTable(std::string filenm)
MdcDigiVec & getMdcDigiVec(uint32_t control=0)
static double MdcTime(int timeChannel)
static double MdcCharge(int chargeChannel)
const int getFlagLR(void) const
const double getZhit(void) const
const int getTrkId(void) const
const int getId(void) const
const int getStat(void) const
const Identifier getMdcId(void) const
const double getTdc(void) const
const double getDriftT(void) const
const double getEntra(void) const
const double getDriftDistLeft(void) const
const double getFltLen(void) const
const double getDoca(void) const
const HitRefVec getVecHits(void) const
const int getNhits() const
const double getFiTerm() 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
void print(std::ostream &ostr) const
virtual void addHistory(const TrkErrCode &status, const char *modulename)
virtual int nActive() const =0
virtual TrkExchangePar helix(double fltL) const =0
static double nSigmaCut[43]
hot_iterator begin() const
TrkHitOnTrk * appendHot(const TrkHitOnTrk *theHot)
const TrkHotList & hotList() const
bool removeHit(const TrkFundHit *theHit)
void setActivity(bool turnOn)
void setUsability(int usability)
double resid(bool exclude=false) const
const TrkRep * getParentRep() const
hot_iterator begin() const
virtual void printAll(std::ostream &) const
const TrkFit * fitResult() const
const TrkFitStatus * status() const
virtual double arrivalTime(double fltL) const
bool setFlipAndDrop(TrkRecoTrk &, bool allowFlips, bool allowDrops) const
TrkRecoTrk * makeTrack(const TrkExchangePar &helix, const double chi2, const TrkContext &, double trackT0) const
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string RecMdcHitCol
NTuple::Item< long > g_eventNo