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");
183 if (m_helixFitCut.size() == 43){
184 for(
int i=0; i<43; i++){
204 StatusCode sc = service (
"MdcCalibFunSvc", imdcCalibSvc);
206 if ( sc.isFailure() ){
207 log << MSG::FATAL <<
"Could not load MdcCalibFunSvc!" << endreq;
208 return StatusCode::FAILURE;
215 sc = service (
"RawDataProviderSvc", iRawDataProvider);
216 if ( sc.isFailure() ){
217 log << MSG::FATAL <<
"Could not load RawDataProviderSvc!" << endreq;
218 return StatusCode::FAILURE;
224 sc = service (
"MagneticFieldSvc",m_pIMF);
225 if(sc!=StatusCode::SUCCESS) {
226 log << MSG::ERROR <<
"Unable to open Magnetic field service"<<endreq;
228 m_bfield =
new BField(m_pIMF);
229 log << MSG::INFO <<
"field z = "<<m_bfield->
bFieldNominal()<< endreq;
232 if (m_hist) {bookNTuple();}
233 if (m_dropHitsSigma.size()==43){
234 for (
int ii=0;ii<43;ii++) {
239 return StatusCode::SUCCESS;
246 setFilterPassed(b_saveEvent);
250 MsgStream log(
msgSvc(), name());
251 log << MSG::INFO <<
"in execute()" << endreq;
254 nTk = 0; t_nTdsTk = 0;
258 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),
"/Event/EventHeader");
260 log << MSG::FATAL<<
"Could not retrieve event header" << endreq;
261 return StatusCode::FAILURE;
263 m_eventNo = evtHead->eventNumber();
265 long t_evtNo = m_eventNo;
268 IDataManagerSvc *dataManSvc;
269 DataObject *aTrackCol;
272 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
273 eventSvc()->findObject(
"/Event/Recon/RecMdcTrackCol",aTrackCol);
274 if(aTrackCol != NULL) {
275 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcTrackCol");
276 eventSvc()->unregisterObject(
"/Event/Recon/RecMdcTrackCol");
278 eventSvc()->findObject(
"/Event/Recon/RecMdcHitCol",aHitCol);
279 if(aHitCol != NULL) {
280 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcHitCol");
281 eventSvc()->unregisterObject(
"/Event/Recon/RecMdcHitCol");
288 DataObject *aReconEvent;
289 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
290 if (aReconEvent==NULL) {
292 sc = eventSvc()->registerObject(
"/Event/Recon",aReconEvent);
293 if(sc != StatusCode::SUCCESS) {
294 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
295 return StatusCode::FAILURE;
299 eventSvc()->findObject(
"/Event/Recon/RecMdcTrackCol",aTrackCol);
305 if(!sc.isSuccess()) {
306 log << MSG::FATAL <<
" Could not register RecMdcTrack collection" <<endreq;
307 return StatusCode::FAILURE;
311 eventSvc()->findObject(
"/Event/Recon/RecMdcHitCol",aHitCol);
317 if(!sc.isSuccess()) {
318 log << MSG::FATAL <<
" Could not register RecMdcHit collection" <<endreq;
319 return StatusCode::FAILURE;
326 DataObject *pnode = 0;
327 sc = eventSvc()->retrieveObject(
"/Event/Hit",pnode);
328 if(!sc.isSuccess()) {
329 pnode =
new DataObject;
330 sc = eventSvc()->registerObject(
"/Event/Hit",pnode);
331 if(!sc.isSuccess()) {
332 log << MSG::FATAL <<
" Could not register /Event/Hit branch " <<endreq;
333 return StatusCode::FAILURE;
336 SmartDataPtr<MdcHitCol> m_hitCol(eventSvc(),
"/Event/Hit/MdcHitCol");
339 sc = eventSvc()->registerObject(
"/Event/Hit/MdcHitCol",m_hitCol);
340 if(!sc.isSuccess()) {
341 log << MSG::FATAL <<
" Could not register hit collection" <<endreq;
342 return StatusCode::FAILURE;
351 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
352 if (!aevtimeCol || aevtimeCol->size()==0) {
353 log << MSG::WARNING<<
"evt "<<m_eventNo<<
" Could not find RecEsTimeCol"<< endreq;
354 return StatusCode::SUCCESS;
357 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
358 for(; iter_evt!=aevtimeCol->end(); iter_evt++){
359 m_bunchT0 = (*iter_evt)->getTest();
360 m_t0Stat = (*iter_evt)->getStat();
361 if ((m_t0Stat==0) || (m_bunchT0 < 0.) || (m_bunchT0 > 9999.0) ){
362 log << MSG::WARNING <<
"Skip evt:"<<m_eventNo<<
" by t0 = "<<m_bunchT0 << endreq;
366 if(m_debug>1) std::cout<<name()<<
" t0 "<<m_bunchT0<<
" t0Stat "<<m_t0Stat<<std::endl;
368 SmartDataPtr<TrigData> trigData(eventSvc(),
"/Event/Trig/TrigData");
370 log << MSG::INFO <<
"Trigger conditions 0--43:"<<endreq;
371 for(
int i = 0; i < 48; i++) {
372 log << MSG::INFO << trigData->getTrigCondName(i)<<
" ---- "<<trigData->getTrigCondition(i)<< endreq;
374 for(
int i = 0; i < 16; i++) log << MSG::INFO <<
"Trigger channel "<< i <<
": " << trigData->getTrigChannel(i) << endreq;
375 m_timing=trigData->getTimingType();
377 log << MSG::INFO <<
"Tigger Timing type: "<< trigtiming << endreq;
384 uint32_t getDigiFlag = 0;
385 getDigiFlag += m_maxMdcDigi;
389 mdcDigiVec = m_rawDataProviderSvc->
getMdcDigiVec(getDigiFlag);
390 t_nDigi = mdcDigiVec.size();
393 log << MSG::WARNING <<
" No hits in MdcDigiVec" << endreq;
394 return StatusCode::SUCCESS;
402 if (t_nDigi < m_minMdcDigi){
403 log << MSG::WARNING <<
" Skip this event for MdcDigiVec.size() < "<<m_minMdcDigi << endreq;
404 return StatusCode::SUCCESS;
406 m_mdcxHits.
create(mdcDigiVec, m_bunchT0, m_cresol);
414 if(m_debug > 1 ){ dumpMdcxSegs(seglist);}
422 if(m_debug>1) dumpTrackList(firsttrkl);
450 sc = FitMdcxTrack(trkl, dchitlist, m_hitCol, trackList, hitList);
451 if (!sc.isSuccess()) {
return StatusCode::SUCCESS;}
452 t_nTdsTk = trackList->size();
454 t_nTkTot += trackList->size();
455 if(t_nTdsTk<20) t_nTkNum[t_nTdsTk]++;
463 if(m_hist) fillEvent();
466 eventSvc()->retrieveObject(
"/Event/Recon/RecMdcTrackCol",pNode);
468 eventSvc()->retrieveObject(
"/Event/Recon/RecMdcHitCol",pNode);
470 if(tmpTrackCol) nTdsTk = tmpTrackCol->size();
473 std::cout<<
"MdcxTrackFinder: evtNo "<< m_eventNo <<
" t0="<<m_bunchT0
474 <<
" Found " <<trkl.length()
475 <<
" keep "<< t_nTdsTk
476 <<
" finialy keep "<< nTdsTk;
478 int ndelete =0; trkl.length() - trackList->size();
479 if( ndelete>0 ) std::cout <<
" delete "<< ndelete;
480 std::cout <<
" track(s)" <<endl;
483 if(m_debug>1)dumpTdsTrack(tmpTrackCol);
484 if(m_debug>1)dumpTrack(tmpTrackCol);
488 if((trackList->size()!=4) ) b_saveEvent =
true;
489 setFilterPassed(b_saveEvent);
490 return StatusCode::SUCCESS;
494 MsgStream log(
msgSvc(), name());
495 log << MSG::INFO <<
"in finalize()" << endreq;
497 std::cout<<
" --after " << name() <<
" keep " << t_nTkTot<<
" tracks "<<std::endl;
498 for(
int i=0; i<20; i++){
499 if(t_nTkNum[i]>0)std::cout<<
" nTk="<< i <<
" "<< t_nTkNum[i]<< std::endl;
503 return StatusCode::SUCCESS;
510 if ( 0 == mdcxHits.length() )
return;
513 while(mdcxHits[ihits]) {
515 const MdcHit* newhit = mdcxHits[ihits]->getMdcHit();
517 const MdcDigi* theDigi = mdcxHits[ihits]->getDigi();
518 int layer =
MdcID::layer(mdcxHits[ihits]->getDigi()->identify());
519 int wire =
MdcID::wire(mdcxHits[ihits]->getDigi()->identify());
520 m_digiMap[layer][wire] = mdcxHits[ihits]->getDigi();
526 mdcHitCol->push_back(thehit);
550 MsgStream log(
msgSvc(), name());
574 int tkLen = trkl.length();
575 for (
int kk=0; kk< tkLen; kk++){
578 std::cout<<__FILE__<<
" FitMdcxTrack "<<kk<< std::endl;
579 for(
int i=0; i<xhits.length(); i++){ xhits[i]->print(std::cout); }
580 std::cout<<std::endl;
583 if(m_debug>2) std::cout<<
" before add hits nhits="<<xhits.length()<< std::endl;
586 std::cout<<
" after,add "<<xass.length()<<
" hits"<<std::endl;
590 double thechisq = mdcxHelix.
Chisq();
597 aTrack = linefactory.
makeTrack(tt, thechisq, *m_context, m_bunchT0*1.e-9);
601 aTrack = helixfactory.
makeTrack(tt, thechisq, *m_context, m_bunchT0*1.e-9);
607 if (0 == m_trkHitList) {
614 MdcxHitsToHots(mdcxHelix, xhits, m_trkHitList, m_hitCol);
617 MdcxHitsToHots(mdcxHelix, xass, m_trkHitList, m_hitCol);
622 if(m_dropMultiHotInLayer) dropMultiHotInLayer(m_trkHitList);
625 if(m_debug>1){ std::cout<<
"== put to official fitter "<<std::endl;}
629 std::cout<<
"== after official fitter "<<std::endl;
637 int ndof = theFit->
nActive()-nparm;
638 if (ndof > 0) rcs = theFit->
chisq()/float(ndof);
640 if (4 == nparm) cout <<
" TrkLineMaker";
641 else cout <<
" TrkHelixMaker";
642 cout <<
" trkNo. " << kk <<
" success " << err.
success() <<
" rcs " << rcs
643 <<
" chi2 " << theFit->
chisq() <<
" nactive " << theFit->
nActive() << endl;
647 if ( (1 == err.
success()) && (rcs < 20.0) ) {
648 if(m_debug>1) std::cout<<
"== fit success "<<std::endl;
655 if (m_debug>1) { cout <<
"MdcxTrackFinder: accept a track " << endl; }
658 store(aTrack, trackList, hitList);
659 }
else if ( (2 == err.
success()) && (rcs < 150.0) ) {
660 if(m_debug > 1) std::cout<<
"== fit success = 2, refit now"<<std::endl;
662 while (nrefit++ < 5) {
663 if (m_debug>1) std::cout <<
"refit time " << nrefit << std::endl;
664 err = m_trkHitList->
fit();
677 store(aTrack, trackList, hitList);
681 std::cout<<
"== fit faild "<<std::endl;
690 if(m_debug>1) std::cout<<
"== Fit no good; try a better input helix"<<std::endl;
691 mdcxHelix.
Grow(*trkl[kk],xass);
694 int fail = mdcxHelix.
ReFit();
695 if(m_debug>1)std::cout<<__FILE__<<
" refit fail:"<<fail<< std::endl;
696 if (!mdcxHelix.
Fail()) {
698 thechisq = mdcxHelix.
Chisq();
702 bTrack = linefactory.
makeTrack(tb,thechisq,*m_context,m_bunchT0*1.e-9);
705 bTrack = helixfactory.
makeTrack(tb,thechisq,*m_context,m_bunchT0*1.e-9);
709 if (0 == bhits){
delete bTrack; bTrack = NULL;
continue;}
711 MdcxHitsToHots(mdcxHelix, bxhits, bhits, m_hitCol);
716 int ndof = bFit->
nActive() - nparm;
717 if (ndof > 0) rcs = bFit->
chisq()/float(ndof);
719 if (4 == nparm) cout <<
" TrkLineMaker";
720 else cout <<
" TrkHelixMaker";
721 cout <<
" success trkNo. " << kk <<
" status " << berr.
success() <<
" rcs " << rcs
722 <<
" chi2 " << bFit->
chisq() <<
" nactive "<< bFit->
nActive() << endl;
725 if ( ( 1 == berr.
success() ) && ( rcs < 50.0 ) ) {
729 cout <<
"MdcxTrackFinder: accept b track and store to TDS" << endl;
732 store(bTrack, trackList, hitList);
735 cout<<
" fit failed "<<endl;
739 if (bTrack!=NULL) {
delete bTrack; bTrack = NULL; }
746 if(m_debug >1) dumpTdsTrack(trackList);
747 return StatusCode::SUCCESS;
753 assert (aTrack != NULL);
755 int trackId = trackList->size();
757 if(m_dropTrkPt>0. && (aTrack->
fitResult()->
pt()<m_dropTrkPt)) {
758 if(m_debug>1) std::cout<<
"MdcxTrackFinder delete track by pt "
759 <<aTrack->
fitResult()->
pt()<<
"<ptCut "<<m_dropTrkPt << std::endl;
763 if( ( (fabs(helix.
d0())>m_d0Cut) ||( fabs(helix.
z0())>m_z0Cut) ) ){
764 if(m_debug>1) std::cout<< name()<<
" delete track by d0 "<<helix.
d0()<<
">d0Cut "<<m_d0Cut
765 <<
" or z0 "<<helix.
z0()<<
" >z0Cut "<<m_z0Cut << std::endl;
769 if(m_hist) fillTrack(aTrack);
773 int nHitbefore = hitList->size();
775 mdcTrack.storeTrack(trackId, trackList, hitList, tkStat);
776 int nHitAfter = hitList->size();
777 if (nHitAfter - nHitbefore <10 ) setFilterPassed(
true);
781 RecMdcTrackCol::iterator i_tk = trackList->begin();
782 for (;i_tk != trackList->end(); i_tk++) {
789 std::cout<<
" MdcTrack Id:"<<tk->
trackId() <<
" q:"<< tk->
charge()<< std::endl;
790 std::cout<<
"dr Fi0 Cpa Dz Tanl Chi2 Ndf nSt FiTerm poca" << std::endl;
791 std::cout<<
"(" <<setw(5) << tk->
helix(0)<<
","<< setw(5) << tk->
helix(1)<<
"," << setw(5) << tk->
helix(2) <<
","
792 << setw(5) << tk->
helix(3) <<
","<< setw(5) << tk->
helix(4) <<
")"
793 << setw(5) << tk->
chi2() << setw(4) << tk->
ndof()
796 std::cout<<
" ErrMat "<<tk->
err() << std::endl;
798 std::cout<<
"hitId tkId (l,w) fltLen lr dt ddl tdc "
799 <<
"doca entr z tprop stat " << std::endl;
802 HitRefVec::iterator it = hl.begin();
803 for (;it!=hl.end();++it){
808 double _zlen = _layerPtr->
zLength();
812 tprop = (0.5*_zlen + z)/_vprop;
814 tprop = (0.5*_zlen - z)/_vprop;
831 std::cout<< setw(3) << h->
getId() << setw(2) << h->
getTrkId() <<
838 setw(10) << h->
getZhit() << setw(10) << tprop<<
839 setw(2)<< h->
getStat() << std::endl;
843void MdcxTrackFinder::bookNTuple(){
844 MsgStream log(
msgSvc(), name());
888 NTuplePtr nt1(
ntupleSvc(),
"MdcxReco/rec");
891 m_xtuple1 =
ntupleSvc()->book (
"MdcxReco/rec", CLID_ColumnWiseTuple,
"MdcxReco reconsturction results");
937 log << MSG::ERROR <<
" Cannot book N-tuple: MdcxReco/rec" << endmsg;
941 NTuplePtr nt4(
ntupleSvc(),
"MdcxReco/evt");
960 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/evt" << endmsg;
966 NTuplePtr ntSeg(
ntupleSvc(),
"MdcxReco/seg");
969 m_xtupleSeg =
ntupleSvc()->book (
"MdcxReco/seg", CLID_ColumnWiseTuple,
"MdcxTrackFinder segment data");
988 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/evt" << endmsg;
992 NTuplePtr nt5(
ntupleSvc(),
"MdcxReco/trkl");
1000 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/trkl" << endmsg;
1005 NTuplePtr ntCsmcSew(
ntupleSvc(),
"MdcxReco/csmc");
1017 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/csmc" << endmsg;
1021 NTuplePtr ntSegAdd1(
ntupleSvc(),
"MdcxReco/addSeg1");
1041 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/addSeg1" << endmsg;
1046 NTuplePtr ntSegComb(
ntupleSvc(),
"MdcxReco/segComb");
1065 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/segComb" << endmsg;
1070 NTuplePtr ntDropHits(
ntupleSvc(),
"MdcxReco/dropHits");
1084 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/dropHits" << endmsg;
1088 NTuplePtr ntAddSeg2(
ntupleSvc(),
"MdcxReco/addSeg2");
1098 log << MSG::ERROR <<
"Cannot book N-tuple: MdcxReco/addSeg2" << endmsg;
1106void MdcxTrackFinder::fillEvent(){
1108 if (t_nDigi<=0)
return;
1118 MdcDigiCol::iterator
iter = mdcDigiVec.begin();
1119 for (;iDigi<t_nDigi;
iter++ ) {
1131void MdcxTrackFinder::fillTrack(
TrkRecoTrk* atrack){
1139 if (atrack==NULL)
return;
1142 if (fitResult == 0)
return;
1146 int seg[11] = {0};
int segme;
1152 int layerCount[43]={0};
1154 for (;hot!= hitlist->
end();hot++){
1163 layerCount[layer]++;
1167 double fltLen = recoHot->
fltLen();
1187 double res=999.,rese=999.;
1188 if (recoHot->
resid(res,rese,
false)){
1193 if ( layer >0 ) {segme=(layer-1)/4;}
1195 if (recoHot->
layer()->
view()) { ++nSt; }
1200 for(
int i=0;i<11;i++){
1201 if (seg[i]>0) nSlay++;
1208 double fltLenPoca = 0.0;
1216 if(m_debug>1) std::cout<<
"evt:"<<m_eventNo<<
" BigVtx:"
1217 <<
" d0 "<<helix.
d0()<<
" z0 "<<helix.
z0()<<std::endl;
1220 if (
m_xpt > 0.00001){
1224 CLHEP::Hep3Vector p1 = fitResult->
momentum(fltLenPoca);
1225 double px,py,pz,pxy;
1226 pxy = fitResult->
pt();
1254 cout << name()<<
" found " <<segList.length() <<
" segs :" << endl;
1255 for (
int i =0; i< segList.length(); i++){
1257 segList[i]->printSeg();
1265 40,44,48,56, 64,72,80,80, 76,76,88,88,
1266 100,100,112,112, 128,128,140,140, 160,160,160,160,
1267 176,176,176,176, 208,208,208,208, 240,240,240,240,
1268 256,256,256,256, 288,288,288 };
1270 int hitInSegList[43][288];
1271 for (
int ii=0;ii<43;ii++){
1272 for (
int jj=0;jj<cellMax[ii];jj++){ hitInSegList[ii][jj] = 0; }
1274 for (
int i = 0; i < segList.length(); i++) {
1276 for (
int ihit=0 ; ihit< aSeg->
Nhits() ; ihit++){
1278 int layer = hit->
Layer();
1279 int wire = hit->
WireNo();
1280 hitInSegList[layer][wire]++;
1283 for (
int i = 0; i < segList.length(); i++) {
1285 if(aSeg==NULL)
continue;
1297 for (
int ii = 0;ii<14;ii++){
1303 for (
int ii = 0;ii<20;ii++){
1312 for (
int ihit=0 ; ihit< aSeg->
Nhits() ; ihit++){
1314 int layer = hit->
Layer();
1315 int wire = hit->
WireNo();
1318 m_xtsInSeg[ihit] = hitInSegList[layer][wire];
1327 std::cout<<
"dump track list " <<std::endl;
1328 for (
int i=0;i<trackList.length();i++){
1329 std::cout<<
"track "<<i<<std::endl;
1330 for (
int ihit=0 ; ihit< trackList[i]->Nhits() ; ihit++){
1331 const MdcxHit* hit = trackList[i]->XHitList()[ihit];
1332 int layer = hit->
Layer();
1333 int wire = hit->
WireNo();
1334 std::cout<<
" ("<<layer <<
","<< wire<<
") ";
1336 std::cout<<std::endl;
1344 for (
int i =0; i< firsttrkl.length(); i++){
1345 nDigi+= firsttrkl[i]->Nhits();
1347 for (
int i=0;i<firsttrkl.length();i++){
1348 for (
int ihit=0 ; ihit< firsttrkl[i]->Nhits() ; ihit++){
1349 const MdcxHit* hit = firsttrkl[i]->XHitList()[ihit];
1350 int layer = hit->
Layer();
1351 int wire = hit->
WireNo();
1360void MdcxTrackFinder::fillMcTruth(){
1361 MsgStream log(
msgSvc(), name());
1364 for (
int ii=0;ii<43;ii++){
1365 for (
int jj=0;jj<288;jj++){
1366 haveDigi[ii][jj] = -2;
1369 int nDigi = mdcDigiVec.size();
1370 for (
int iDigi =0 ;iDigi<nDigi; iDigi++ ) {
1372 int w =
MdcID::wire((mdcDigiVec[iDigi])->identify());
1380 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
1382 log << MSG::INFO <<
"Could not retrieve McParticelCol" << endreq;
1384 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
1385 for (;iter_mc != mcParticleCol->end(); iter_mc++){
1386 if ((*iter_mc)->primaryParticle()){
1387 m_t0Truth = (*iter_mc)->initialPosition().t();
1417void MdcxTrackFinder::dropMultiHotInLayer(
TrkHitList* trkHitList){
1419 double tdr_wire[43];
1420 for(
int i=0; i<43; i++){tdr[i]=9999.;}
1424 while (hotIter!=trkHitList->
hotList().
end()) {
1433 if (
dt < tdr[layer]) {
1435 tdr_wire[layer] = wire;
1446 while (hotIter!=trkHitList->
hotList().
end()) {
1447 int layer = hotIter->mdcHitOnTrack()->mdcHit()->layernumber();
1448 int wire = hotIter->mdcHitOnTrack()->mdcHit()->wirenumber();
1451 if ((tdr[layer] <9998.) && (tdr_wire[layer]!=wire)){
1454 trkHitList->
removeHit( hotIter->mdcHitOnTrack()->mdcHit() );
1462 std::cout<<
"tksize = "<<trackList->size() << std::endl;
1463 RecMdcTrackCol::iterator it = trackList->begin();
1464 for (;it!= trackList->end();it++){
1466 std::cout<<
"//====RecMdcTrack "<<tk->
trackId()<<
"====:" << std::endl;
1467 cout <<
" d0 "<<tk->
helix(0)
1468 <<
" phi0 "<<tk->
helix(1)
1469 <<
" cpa "<<tk->
helix(2)
1470 <<
" z0 "<<tk->
helix(3)
1471 <<
" tanl "<<tk->
helix(4)
1473 std::cout<<
" q "<<tk->
charge()
1474 <<
" theta "<<tk->
theta()
1475 <<
" phi "<<tk->
phi()
1481 std::cout <<
" p "<<tk->
p()
1487 std::cout<<
" tkStat "<<tk->
stat()
1488 <<
" chi2 "<<tk->
chi2()
1489 <<
" ndof "<<tk->
ndof()
1491 <<
" nst "<<tk->
nster()
1495 std::cout<<nhits <<
" Hits: " << std::endl;
1496 for(
int ii=0; ii <nhits ; ii++){
1500 cout<<
"("<< layer <<
","<<wire<<
","<<tk->
getVecHits()[ii]->getStat()
1501 <<
",lr:"<<tk->
getVecHits()[ii]->getFlagLR()<<
") ";
1503 std::cout <<
" "<< std::endl;
1505 std::cout <<
" "<< std::endl;
1510void MdcxTrackFinder::dumpTdsHits(
RecMdcHitCol* hitList){
1511 std::cout<<__FILE__<<
" "<<__LINE__<<
" All hits in TDS, nhit="<<hitList->size()<< std::endl;
1512 RecMdcHitCol::iterator it = hitList->begin();
1513 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< 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_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::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_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)
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()
MdcxTrackFinder(const std::string &name, ISvcLocator *pSvcLocator)
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