1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/IDataManagerSvc.h"
7#include "GaudiKernel/PropertyMgr.h"
8#include "GaudiKernel/INTupleSvc.h"
27#include "GaudiKernel/IPartPropSvc.h"
49 Algorithm(name, pSvcLocator)
52 declareProperty(
"ExtTrackSeedMode", m_ExtTrackSeedMode = 1);
53 declareProperty(
"CompareWithMcHit", m_CompareWithMcHit = 0);
54 declareProperty(
"FittingMethod", m_fittingMethod = 1);
55 declareProperty(
"EmcShowerSeedMode",m_EmcShowerSeedMode = 0);
56 declareProperty(
"MucHitSeedMode", m_MucHitSeedMode = 0);
57 declareProperty(
"ConfigFile", m_configFile =
"MucConfig.xml");
58 declareProperty(
"Blind", m_Blind =
false);
59 declareProperty(
"NtOutput", m_NtOutput = 0);
60 declareProperty(
"MsOutput", m_MsOutput =
false);
67 MsgStream log(
msgSvc(), name());
68 log << MSG::INFO <<
"in initialize()" << endreq;
71 IPartPropSvc* p_PartPropSvc;
72 static const bool CREATEIFNOTTHERE(
true);
73 StatusCode PartPropStatus = service(
"PartPropSvc", p_PartPropSvc, CREATEIFNOTTHERE);
74 if (!PartPropStatus.isSuccess() || 0 == p_PartPropSvc) {
75 log << MSG::WARNING <<
" Could not initialize Particle Properties Service" << endreq;
76 return PartPropStatus;
78 m_particleTable = p_PartPropSvc->PDT();
84 m_NHitsFoundTotal = 0;
86 m_NHitsMisFoundTotal = 0;
87 m_NHitsLostByMdcTotal = 0;
88 m_NHitsLostByExtTotal = 0;
91 m_NTracksRecoTotal = 0;
92 m_NTracksLostByMdcTotal = 0;
93 m_NTracksLostByExtTotal = 0;
94 m_NTracksMdcGhostTotal = 0;
96 for(
int i = 0; i < 20; i++) m_NHitsLost.push_back(0);
97 for(
int i = 0; i < 10; i++) m_NHitsLostInGap.push_back(0);
100 StatusCode sc = service(
"MucGeomSvc", mucGeomSvc);
101 if (sc == StatusCode::SUCCESS) {
106 return StatusCode::FAILURE;
108 m_MucRecHitContainer = 0;
115 if ( nt1 ) { m_tuple = nt1;}
118 m_tuple =
ntupleSvc()->book (
"FILE401/T", CLID_RowWiseTuple,
"MucTrkRecon N-Tuple");
120 sc = m_tuple->addItem (
"posx", m_posx);
121 sc = m_tuple->addItem (
"posy", m_posy);
122 sc = m_tuple->addItem (
"posz", m_posz);
123 sc = m_tuple->addItem (
"posx_ext", m_posx_ext);
124 sc = m_tuple->addItem (
"posy_ext", m_posy_ext);
125 sc = m_tuple->addItem (
"posz_ext", m_posz_ext);
126 sc = m_tuple->addItem (
"posxsigma", m_posx_sigma);
127 sc = m_tuple->addItem (
"posysigma", m_posy_sigma);
128 sc = m_tuple->addItem (
"poszsigma", m_posz_sigma);
129 sc = m_tuple->addItem (
"Depth", m_depth);
130 sc = m_tuple->addItem (
"Distance",m_Distance);
131 sc = m_tuple->addItem (
"MaxHits", m_MaxHits);
132 sc = m_tuple->addItem (
"Chi2", m_Chi2);
133 sc = m_tuple->addItem (
"Dist_x", m_Dist_x);
134 sc = m_tuple->addItem (
"Dist_y", m_Dist_y);
135 sc = m_tuple->addItem (
"Dist_z", m_Dist_z);
136 sc = m_tuple->addItem (
"px_mc", m_px_mc);
137 sc = m_tuple->addItem (
"py_mc", m_py_mc);
138 sc = m_tuple->addItem (
"pz_mc", m_pz_mc);
139 sc = m_tuple->addItem (
"emctrack",m_emctrack);
140 sc = m_tuple->addItem (
"muchasdigi",m_muc_digi);
142 sc = m_tuple->addItem (
"part", m_part);
143 sc = m_tuple->addItem (
"seg", m_seg);
144 sc = m_tuple->addItem (
"gap", m_gap);
145 sc = m_tuple->addItem (
"strip", m_strip);
146 sc = m_tuple->addItem (
"diff", m_diff);
147 sc = m_tuple->addItem (
"distance",m_distance);
148 sc = m_tuple->addItem (
"run", m_run);
149 sc = m_tuple->addItem (
"event", m_event);
153 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple) << endmsg;
160 return StatusCode::SUCCESS;
166 MsgStream log(
msgSvc(), name());
167 log << MSG::INFO <<
"in execute()" << endreq;
170 StatusCode sc = StatusCode::SUCCESS;
175 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
177 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
181 log << MSG::INFO <<
"Event: "<<m_totalEvent<<
"\tcurrent run: "<<eventHeader->runNumber()<<
"\tcurrent event: "<< eventHeader->eventNumber()<<endreq;
184 if(m_CompareWithMcHit==1){
185 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
186 if (!mcParticleCol) {
187 log << MSG::FATAL <<
"Could not find McParticle" << endreq;
191 McParticleCol::iterator iter_mc = mcParticleCol->begin();
195 int pid = (*iter_mc)->particleProperty();
201 if(m_particleTable->particle( pid )){
202 charge = (int)m_particleTable->particle( pid )->charge();
203 mass = m_particleTable->particle( pid )->mass();
205 else log << MSG::ERROR <<
"no this particle id in particle table, please check data" <<endreq;
206 }
else if ( pid <0 ) {
207 if(m_particleTable->particle( -pid )){
208 charge = (int)m_particleTable->particle( -pid )->charge();
210 mass = m_particleTable->particle( -pid )->mass();
212 else log << MSG::ERROR <<
"no this particle id in particle table, please check data" <<endreq;
214 log << MSG::WARNING <<
"wrong particle id, please check data" <<endreq;
223 HepLorentzVector initialMomentum = (*iter_mc)->initialFourMomentum();
224 HepLorentzVector initialPos = (*iter_mc)->initialPosition();
226 m_px_mc = initialMomentum.px();
227 m_py_mc = initialMomentum.py();
228 m_pz_mc = initialMomentum.pz();
232 log << MSG::INFO <<
" particleId = " << (*iter_mc)->particleProperty() << endreq;
237 SmartDataPtr<MucDigiCol> mucDigiCol(eventSvc(),
"/Event/Digi/MucDigiCol");
239 log << MSG::FATAL <<
"Could not find MUC digi" << endreq;
240 return( StatusCode::FAILURE);
242 MucDigiCol::iterator iter4 = mucDigiCol->begin();
243 for (;iter4 != mucDigiCol->end(); iter4++, digiId++) {
245 log << MSG::INFO <<
"Total MUC digis:\t" << digiId << endreq;
246 if( digiId == 0 )
return ( StatusCode::SUCCESS);
279 if (m_CompareWithMcHit) {
283 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
284 if (!mcParticleCol) {
285 log << MSG::FATAL <<
"Could not find McParticle" << endreq;
288 McParticleCol::iterator iter_mc = mcParticleCol->begin();
291 SmartDataPtr<Event::MucMcHitCol> aMucMcHitCol(eventSvc(),
"/Event/MC/MucMcHitCol");
293 log << MSG::WARNING <<
"Could not find MucMcHitCol" << endreq;
297 log << MSG::DEBUG <<
"MucMcHitCol contains " << aMucMcHitCol->size() <<
" Hits " << endreq;
298 MucMcHitCol::iterator iter_MucMcHit = aMucMcHitCol->begin();
299 for (; iter_MucMcHit != aMucMcHitCol->end(); iter_MucMcHit++) {
300 mucID = (*iter_MucMcHit)->identify();
302 log << MSG::DEBUG <<
" MucMcHit " <<
" : "
307 <<
" Track Id " << (*iter_MucMcHit)->getTrackIndex()
308 <<
" pos x " << (*iter_MucMcHit)->getPositionX()
309 <<
" pos y " << (*iter_MucMcHit)->getPositionY()
310 <<
" pos z " << (*iter_MucMcHit)->getPositionZ()
314 for (iter_mc = mcParticleCol->begin(); iter_mc != mcParticleCol->end(); iter_mc++) {
315 if ( (*iter_mc)->trackIndex() == (*iter_MucMcHit)->getTrackIndex() ) {
316 assocMcPart = *iter_mc;
320 if (assocMcPart == 0) {
321 log << MSG::WARNING <<
"No Corresponding Mc Particle found for this MucMcHit" << endreq;
324 MucMcHit *assocMucMcHit = *iter_MucMcHit;
327 if (relMcMuc == 0) log << MSG::DEBUG <<
"relMcMuc not created " << endreq;
330 if(!addstat)
delete relMcMuc;
334 log << MSG::DEBUG <<
" Fill McPartToMucHitTab, size " << assocMcMuc.
size() << endreq;
335 iter_mc = mcParticleCol->begin();
336 for (;iter_mc != mcParticleCol->end(); iter_mc++) {
337 log << MSG::DEBUG <<
" Track index " << (*iter_mc)->trackIndex()
338 <<
" particleId = " << (*iter_mc)->particleProperty()
341 vector< McPartToMucHitRel* > vecMucMcHit = assocMcMuc.
getRelByFirst(*iter_mc);
342 vector< McPartToMucHitRel* >::iterator iter_MucMcHit = vecMucMcHit.begin();
343 for (; iter_MucMcHit != vecMucMcHit.end(); iter_MucMcHit++) {
344 mucID = (*iter_MucMcHit)->getSecond()->identify();
348 <<
" MC Particle index "
349 << (*iter_MucMcHit)->getFirst()->trackIndex()
350 <<
" contains " <<
" MucMcHit "
377 if (!m_MucRecHitContainer) {
380 m_MucRecHitContainer->
Clear();
384 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
385 DataObject *mucRecHitCol;
386 eventSvc()->findObject(
"/Event/Recon/MucRecHitCol",mucRecHitCol);
387 if(mucRecHitCol != NULL) {
388 dataManSvc->clearSubTree(
"/Event/Recon/MucRecHitCol");
389 eventSvc()->unregisterObject(
"/Event/Recon/MucRecHitCol");
392 sc = eventSvc()->registerObject(
"/Event/Recon/MucRecHitCol", aMucRecHitCol);
394 log << MSG::ERROR <<
"/Event/Recon/MucRecHitCol not registerd!" << endreq;
395 return( StatusCode::FAILURE);
398 log << MSG::INFO <<
"Add digis" << endreq;
399 MucDigiCol::iterator iter_Muc = mucDigiCol->begin();
401 for (;iter_Muc != mucDigiCol->end(); iter_Muc++, mucDigiId++) {
402 mucID = (*iter_Muc)->identify();
408 m_MucRecHitContainer->
AddHit(part, seg, gap, strip);
410 log << MSG::DEBUG <<
" digit" << mucDigiId <<
" : "
414 <<
" strip " << strip
423 DataObject *aReconEvent ;
424 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
425 if(aReconEvent==NULL) {
428 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon",aReconEvent);
429 if(sc!=StatusCode::SUCCESS) {
430 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
431 return( StatusCode::FAILURE);
434 StatusCode fr = eventSvc()->findObject(
"/Event/Recon",aReconEvent);
435 if(fr!=StatusCode::SUCCESS) {
436 log << MSG::WARNING <<
"Could not find register ReconEvent, will create it" <<endreq;
437 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon",aReconEvent);
438 if(sc!=StatusCode::SUCCESS) {
439 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
440 return( StatusCode::FAILURE);
444 DataObject *mucTrackCol;
445 eventSvc()->findObject(
"/Event/Recon/RecMucTrackCol",mucTrackCol);
446 if(mucTrackCol != NULL) {
447 dataManSvc->clearSubTree(
"/Event/Recon/RecMucTrackCol");
448 eventSvc()->unregisterObject(
"/Event/Recon/RecMucTrackCol");
451 sc = eventSvc()->registerObject(
"/Event/Recon/RecMucTrackCol", aRecMucTrackCol);
452 if(sc!=StatusCode::SUCCESS) {
453 log << MSG::FATAL <<
"Could not register MUC track collection" << endreq;
454 return( StatusCode::FAILURE);
458 SmartDataPtr<RecMucTrackCol> findRecMucTrackCol(eventSvc(),
"/Event/Recon/RecMucTrackCol");
459 if (!findRecMucTrackCol) {
460 log << MSG::FATAL <<
"Could not find RecMucTrackCol" << endreq;
461 return( StatusCode::FAILURE);
463 aRecMucTrackCol->clear();
469 SmartDataPtr<RecExtTrackCol> aExtTrackCol(eventSvc(),
"/Event/Recon/RecExtTrackCol");
471 log << MSG::WARNING <<
"Can't find ExtTrackCol in TDS!" << endreq;
475 SmartDataPtr<RecMdcTrackCol> aMdcTrackCol(eventSvc(),
"/Event/Recon/RecMdcTrackCol");
477 log << MSG::WARNING <<
"Can't find MdcTrackCol in TDS!" << endreq;
483 SmartDataPtr<RecEmcShowerCol> aShowerCol(eventSvc(),
"/Event/Recon/RecEmcShowerCol");
485 log << MSG::WARNING <<
"Could not find RecEmcShowerCol" << endreq;
499 log << MSG::INFO <<
"Add tracks info, ExtTrackSeedMode = " << m_ExtTrackSeedMode <<
", EmcShowerSeedMode = " << m_EmcShowerSeedMode << endreq;
501 if (m_ExtTrackSeedMode == 1)
503 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
504 if (!mcParticleCol) {
505 log << MSG::FATAL <<
"Could not find McParticle" << endreq;
507 return( StatusCode::SUCCESS);
509 McParticleCol::iterator iter_mc = mcParticleCol->begin();
511 int trackIndex = -99;
512 for (
int iTrack = 0;iter_mc != mcParticleCol->end(); iter_mc++, iTrack++) {
513 if(!(*iter_mc)->primaryParticle())
continue;
514 int pid = (*iter_mc)->particleProperty();
519 if(m_particleTable->particle( pid )){
520 charge = (int)m_particleTable->particle( pid )->charge();
521 mass = m_particleTable->particle( pid )->mass();
523 else log << MSG::ERROR <<
"no this particle id in particle table, please check data" <<endreq;
526 if(m_particleTable->particle( -pid )){
527 charge = (int)m_particleTable->particle( -pid )->charge();
529 mass = m_particleTable->particle( -pid )->mass();
531 else log << MSG::ERROR <<
"no this particle id in particle table, please check data" <<endreq;
533 log << MSG::WARNING <<
"wrong particle id, please check data" <<endreq;
538 <<
" neutral particle charge = 0!!! ...just skip it !"
543 trackIndex = (*iter_mc)->trackIndex();
544 log << MSG::DEBUG <<
"iTrack " << iTrack <<
" index " << trackIndex
545 <<
" particleId = " << (*iter_mc)->particleProperty()
550 aTrack->
setId(muctrackId);
552 HepLorentzVector initialMomentum = (*iter_mc)->initialFourMomentum();
553 HepLorentzVector initialPos = (*iter_mc)->initialPosition();
554 float theta0 = initialMomentum.theta();
555 float phi0 = initialMomentum.phi();
559 float x0 = initialPos.x();
560 float y0 = initialPos.y();
561 float z0 = initialPos.z();
563 Hep3Vector startPos(x0, y0, z0);
564 Hep3Vector startP(initialMomentum.px(), initialMomentum.py(), initialMomentum.pz());
565 log << MSG::DEBUG <<
"startP " << startP <<
" startPos "<<startPos<< endreq;
566 Hep3Vector endPos(0, 0, 0), endP;
572 aTrack->
SetExtMucPos( endPos.x(), endPos.y(), endPos.z() );
574 aTrack->
SetMucPos( endPos.x(), endPos.y(), endPos.z() );
588 log << MSG::INFO <<
"Add track, trkIndex: " << trackIndex <<
"\tmucTrkId: " << muctrackId << endreq;
589 aRecMucTrackCol->add(aTrack);
593 else if (m_ExtTrackSeedMode == 2)
595 if (!aExtTrackCol || !aMdcTrackCol) {
596 log << MSG::WARNING <<
"Can't find ExtTrackCol or MdcTrackCol in TDS!" << endreq;
597 return StatusCode::SUCCESS;
600 int trackIndex = -99;
607 RecExtTrackCol::iterator iter_ExtTrack = aExtTrackCol->begin();
608 RecMdcTrackCol::iterator iter_MdcTrack = aMdcTrackCol->begin();
610 for (;iter_ExtTrack != aExtTrackCol->end() && iter_MdcTrack != aMdcTrackCol->end(); iter_ExtTrack++, iter_MdcTrack++, iExtTrack++)
612 trackIndex = (*iter_ExtTrack)->GetTrackId();
613 log << MSG::DEBUG <<
"iExtTrack " << iExtTrack <<
" index " << trackIndex <<
" MucPos "
614 << iExtTrack << (*iter_ExtTrack)->mucPosition().x() <<
" "
615 << (*iter_ExtTrack)->mucPosition().y() <<
" "
616 << (*iter_ExtTrack)->mucPosition().z() <<
" r "
617 << (*iter_ExtTrack)->mucPosition().r() << endreq;
619 if((*iter_ExtTrack)->mucPosition().x() == -99 &&
620 (*iter_ExtTrack)->mucPosition().y() == -99 &&
621 (*iter_ExtTrack)->mucPosition().z() == -99)
623 log << MSG::INFO <<
"Bad ExtTrack, trackIndex: " << trackIndex <<
", skip" << endreq;
628 krechi = (*iter_ExtTrack)->MucKalchi2();
629 kdof= (*iter_ExtTrack)->MucKaldof();
630 kdep = (*iter_ExtTrack)->MucKaldepth();
631 kbrLay = (*iter_ExtTrack)->MucKalbrLastLayer();
632 kecLay = (*iter_ExtTrack)->MucKalecLastLayer();
633 if(kdof<=0)krechi = 0.;
634 else krechi = krechi/kdof;
639 aTrack->
setId(muctrackId);
653 Hep3Vector mdcMomentum = (*iter_MdcTrack)->p3();
654 Hep3Vector mucPos = (*iter_ExtTrack)->mucPosition();
655 Hep3Vector mucMomentum = (*iter_ExtTrack)->mucMomentum();
658 aTrack->
SetMdcMomentum( mdcMomentum.x(), mdcMomentum.y(), mdcMomentum.z() );
659 aTrack->
SetExtMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
662 aTrack->
SetMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
663 aTrack->
SetMucMomentum( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
665 aTrack->
SetCurrentDir( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
668 log << MSG::INFO <<
"Add track, trkIndex: " << trackIndex <<
"\tmucTrkId: " << muctrackId << endreq;
669 aRecMucTrackCol->add(aTrack);
673 else if(m_ExtTrackSeedMode == 3)
677 log << MSG::WARNING <<
"Can't find MdcTrackCol in TDS!" << endreq;
678 return StatusCode::SUCCESS;
681 log<< MSG::INFO <<
"Mdc track size: "<<aMdcTrackCol->size()<<endreq;
683 int trackIndex = -99;
684 for(RecMdcTrackCol::iterator iter_mdc1 = aMdcTrackCol->begin(); iter_mdc1 != aMdcTrackCol->end(); iter_mdc1++){
689 trackIndex = (*iter_mdc1)->trackId();
690 HepVector helix = (*iter_mdc1)->helix();
693 float x0 = helix[0] *
cos(helix[1]);
694 float y0 = helix[0] *
sin(helix[1]);
701 float dx = -1*
sin(helix[1]);
702 float dy =
cos(helix[1]);
709 aTrack->
setId(muctrackId);
715 Hep3Vector mucPos(x0,y0,z0);
716 Hep3Vector mucMomentum(dx,dy,dz);
727 log << MSG::INFO <<
"Add track, trkIndex: " << trackIndex <<
"\tmucTrkId: " << muctrackId << endreq;
728 aRecMucTrackCol->add(aTrack);
732 else {log << MSG::INFO <<
"ExtTrackSeedMode error!"<<endreq; }
735 if(m_EmcShowerSeedMode == 1)
737 int trackIndex = 999;
738 RecEmcShowerCol::iterator iShowerCol;
739 for(iShowerCol=aShowerCol->begin(); iShowerCol!=aShowerCol->end(); iShowerCol++)
747 aTrack->
setId(muctrackId);
750 Hep3Vector mucPos = (*iShowerCol)->position();
751 Hep3Vector mucMomentum = (*iShowerCol)->position();
753 aTrack->
SetExtMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
756 aTrack->
SetMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
757 aTrack->
SetMucMomentum( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
759 aTrack->
SetCurrentDir( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
763 log << MSG::INFO <<
"Add track, trkIndex: " << trackIndex <<
"\tmucTrkId: " << muctrackId << endreq;
764 aRecMucTrackCol->add(aTrack);
770 log << MSG::DEBUG <<
" track container filled " << endreq;
773 log << MSG::INFO <<
"Start tracking..." << endreq;
776 for(
int iTrack = 0; iTrack < (int)aRecMucTrackCol->size(); iTrack++)
778 log << MSG::DEBUG <<
"iTrack " << iTrack << endreq;
779 aTrack = (*aRecMucTrackCol)[iTrack];
784 if(currentPos.mag() <
kMinor) {
785 log << MSG::WARNING <<
"No MUC intersection in track " << iTrack << endreq;
790 int firstHitFound[2] = { 0, 0};
791 int firstHitGap[2] = {-1, -1};
801 float xInsct, yInsct, zInsct;
802 aTrack->
Project(iPart, iGap, xInsct, yInsct, zInsct, seg);
803 if(m_MsOutput) cout <<
"part " << iPart <<
" gap " << iGap <<
" x " << xInsct <<
" y " << yInsct <<
" z " << zInsct <<
" seg " << seg << endl;
805 if(seg == -1)
continue;
809 for(
int iDeltaSeg = 0; iDeltaSeg <
kNSegSearch; iDeltaSeg++)
824 for (
int iHit = 0; iHit < m_MucRecHitContainer->
GetGapHitCount(iPart, iSeg, iGap); iHit++)
826 log << MSG::DEBUG <<
"iSeg " << iSeg <<
" iHit " << iHit << endreq;
827 MucRecHit* pHit = m_MucRecHitContainer->
GetHit(iPart, iSeg, iGap, iHit);
831 log << MSG::WARNING <<
"MucRecTrkExt: null pointer to pHit" << endreq;
840 log << MSG::DEBUG <<
"distance = " << setw(8) << dX <<
" size " << setw(4) << window << endreq;
844 m_part = iPart; m_seg = iSeg; m_gap = iGap; m_strip = pHit->
Strip();
845 m_diff = -99; m_tuple->write();
848 if (fabs(dX) < window)
870 if (firstHitGap[orient] == -1) firstHitGap[orient] = iGap;
871 firstHitFound[orient] = 1;
874 log << MSG::DEBUG <<
" part " << iPart <<
" seg " << iSeg <<
" gap " << iGap
875 <<
" strip " << setw(2) << pHit->
Strip() <<
" attatched" << endreq;
876 log << MSG::DEBUG <<
"current total hits " << aTrack->
GetTotalHits() << endreq;
879 m_NHitsLostInGap[iGap]++;
890 if(m_ExtTrackSeedMode != 3 && !m_Blind) {
891 if (firstHitFound[orient] && firstHitGap[orient] != iGap) aTrack->
CorrectDir();
899 aTrack->
LineFit(m_fittingMethod);
901 log << MSG::INFO <<
"Fit track done! trackIndex: " << aTrack->
trackId() <<
", mucId: " << aTrack->
id() <<
", RecMode: " << aTrack->
GetRecMode() << endreq;
905 m_depth = aTrack->
depth();
908 m_Chi2 = aTrack->
chi2();
916 m_emctrack = m_emcrec;
922 vector<MucRecHit*> attachedHits = aTrack->
GetHits();
924 vector<float> distanceHits = aTrack->
getDistHits();
928 for(
int i=0; i< expectedHits.size(); i++)
934 for(
int j=0; j< attachedHits.size(); j++)
938 if(attachedHits.size()==distanceHits.size())
940 m_part = jhit->
Part(); m_seg = jhit->
Seg(); m_gap = jhit->
Gap();
941 m_strip = jhit->
Strip();
942 m_distance = distanceHits[j];
943 m_Distance = distanceHits_quad[j];
956 log << MSG::DEBUG <<
"track Index " << aTrack->
trackId()
957 << setw(2) << mucDigiCol->size() - nHitsAttached <<
" of "
958 << setw(2) << mucDigiCol->size() <<
" lost " << endreq;
968 if(m_MucHitSeedMode == 1)
970 MucRecHit *pHit = 0 ,*pHit0 = 0, *pHit1 = 0;
977 bool hit0 =
false, hit1 =
false;
int firstgap0 = -1, firstgap1 = -1;
int nStrip0 = 0, nStrip1 = 0;
978 Hep3Vector posHit0, posHit1;
982 for (
int iHit0 = 0; iHit0 < count; iHit0++)
985 pHit = m_MucRecHitContainer->
GetHit(iPart, iSeg, iGap, iHit0);
987 log << MSG::FATAL <<
"MucRecRoadFinder-E10 " <<
" part " << iPart
988 <<
" seg " << iSeg <<
" gap " << iGap <<
" null pointer"
997 if(orient == 1 && hit0 ==
false){
1001 if(iGap == firstgap0){
1006 if(orient == 0 && hit1 ==
false){
1010 if(iGap == firstgap1){
1035 int trackIndex = 999;
1038 aTrack->
setId(muctrackId);
1043 Hep3Vector mucPos, mucMomentum;
1045 mucMomentum.set(posHit0.x(),posHit0.y(),posHit1.z());
1046 mucPos = mucMomentum * 0.9;
1049 mucMomentum.set(posHit0.x(),posHit1.y(),posHit0.z()*0.5+posHit1.z()*0.5);
1050 mucPos = mucMomentum * 0.9;
1053 aTrack->
SetExtMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
1056 aTrack->
SetMucPos( mucPos.x(), mucPos.y(), mucPos.z() );
1057 aTrack->
SetMucMomentum( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
1059 aTrack->
SetCurrentDir( mucMomentum.x(), mucMomentum.y(), mucMomentum.z() );
1062 aRecMucTrackCol->add(aTrack);
1068 m_depth = aTrack->
depth();
1071 m_Chi2 = aTrack->
chi2();
1087 int nTracksTotal = 0;
1088 int nTracksFound = 0;
1089 int nTracksLost = 0;
1090 int nTracksLostByExt = 0;
1091 int nTracksMisFound = 0;
1093 int nDigisTotal = 0;
1097 int nHitsMisFound = 0;
1303 m_NDigisTotal += nDigisTotal;
1304 m_NHitsTotal += nHitsTotal;
1305 m_NHitsFoundTotal += nHitsFound;
1306 m_NHitsLostTotal += nHitsLost;
1307 m_NHitsMisFoundTotal += nHitsMisFound;
1310 m_NTracksTotal += nTracksTotal;
1311 m_NTracksRecoTotal += nTracksFound;
1312 m_NTracksLostByMdcTotal += nTracksLost;
1313 m_NTracksLostByExtTotal += nTracksLostByExt;
1314 m_NTracksMdcGhostTotal += nTracksMisFound;
1315 if (aRecMucTrackCol->size() > 0)
1317 RecMucTrack *aRecMucTrack = (*aRecMucTrackCol)[0];
1332 if(m_NtOutput>=1) m_tuple->write();
1333 return StatusCode::SUCCESS;
1339 MsgStream log(
msgSvc(), name());
1340 log << MSG::INFO <<
"in finalize()" << endreq;
1342 log << MSG::INFO <<
" In " << m_NDigisTotal <<
" total MucDigis " << endreq;
1343 log << MSG::INFO <<
" In " << m_NHitsTotal <<
" total MucMcHits " << endreq;
1344 log << MSG::INFO << m_NHitsFoundTotal <<
" hits found in Reco tracks, " << endreq;
1345 log << MSG::INFO << m_NHitsLostTotal <<
" hits lost (not found), of which "
1346 << m_NHitsLostByMdcTotal <<
" lost because Mdc track not constructed "
1347 << m_NHitsLostByExtTotal <<
" lost because Ext track not intersect with muc " << endreq;
1348 log << MSG::INFO << m_NHitsMisFoundTotal <<
" hits mis found (not belong to this track, but mis attached)" << endreq;
1350 log << MSG::INFO <<
" In " << m_NTracksTotal <<
" total Mc tracks " << endreq;
1351 log << MSG::INFO << m_NTracksRecoTotal <<
" tracks found " << endreq;
1352 log << MSG::INFO << m_NTracksLostByMdcTotal <<
" tracks lost because Mdc track not constructed " << endreq;
1353 log << MSG::INFO << m_NTracksLostByExtTotal <<
" tracks lost because Ext track not intersect with muc " << endreq;
1354 log << MSG::INFO << m_NTracksMdcGhostTotal <<
" tracks are Mdc ghost tracks " << endreq;
1373 return StatusCode::SUCCESS;
1379 MsgStream log(
msgSvc(), name());
1388 int firstHitFound[2] = { 0, 0};
1389 int firstHitGap[2] = {-1, -1};
1397 float xInsct, yInsct, zInsct;
1398 aTrack->
Project(iPart, iGap, xInsct, yInsct, zInsct, seg);
1399 log << MSG::INFO <<
"part " << iPart <<
" gap " << iGap <<
" x " << xInsct <<
" y " << yInsct <<
" z " << zInsct <<
" seg " << seg << endreq;
1409 for(
int iDeltaSeg = 0; iDeltaSeg <
kNSegSearch; iDeltaSeg++)
1421 for (
int iHit = 0; iHit < m_MucRecHitContainer->
GetGapHitCount(iPart, iSeg, iGap); iHit++)
1423 log << MSG::DEBUG <<
"iSeg " << iSeg <<
" iHit " << iHit << endreq;
1424 MucRecHit* pHit = m_MucRecHitContainer->
GetHit(iPart, iSeg, iGap, iHit);
1428 log << MSG::WARNING <<
"MucRecTrkExt: null pointer to pHit" << endreq;
1435 log << MSG::DEBUG <<
"distance = " << setw(8) << dX <<
" size " << setw(4) << window << endreq;
1438 if (fabs(dX) < window)
1464 if (firstHitGap[orient] == -1) firstHitGap[orient] = iGap;
1465 firstHitFound[orient] = 1;
1469 log << MSG::DEBUG <<
" part " << iPart <<
" seg " << iSeg <<
" gap " << iGap
1470 <<
" strip " << setw(2) << pHit->
Strip() <<
" attatched" << endreq;
1471 log << MSG::DEBUG <<
"current total hits " << aTrack->
GetTotalHits() << endreq;
1475 m_NHitsLostInGap[iGap]++;
1487 if (firstHitFound[orient] && firstHitGap[orient] != iGap) aTrack->
CorrectDir();
1495 aTrack->
LineFit(m_fittingMethod);
1506 if(mom.mag()<0.6) mom_id = 0;
1507 else if(mom.mag()<0.8) mom_id = 1;
1508 else if(mom.mag()<1) mom_id = 2;
double sin(const BesAngle a)
double cos(const BesAngle a)
ObjectVector< MucRecHit > MucRecHitCol
const int kDeltaSeg[kNSegSearch]
const float kWindowSize_Mom_Gap[4][9]
const float kFirstHitWindowRatio
ObjectVector< RecMucTrack > RecMucTrackCol
void setkalbrLastLayer(int br)
int maxHitsInLayer() const
void setkalecLastLayer(int ec)
void setkalRechi2(double ch)
void setkalDepth(double de)
void init()
Initialize the internal pointer to an ObjectList of relations.
unsigned long size() const
This method returns the number of relations in the table.
bool addRelation(Relation< T1, T2 > *rel)
std::vector< Relation< T1, T2 > * > getRelByFirst(const T1 *pobj) const
MucGeoGap * GetGap(const int part, const int seg, const int gap) const
Get a pointer to the gap identified by (part,seg,gap).
static MucGeoGeneral * Instance()
Get a pointer to the single instance of MucGeoGeneral.
static int barrel_ec(const Identifier &id)
Values of different levels.
static int layer(const Identifier &id)
static int channel(const Identifier &id)
static int segment(const Identifier &id)
static value_type getPartNum()
static value_type getSegNum(int part)
static value_type getGapNum(int part)
void Clear()
Remove all hit objects from the container, and destroy them.
MucRecHit * GetHit(const MucRecHitID hitID)
Get a MucRecHit object by hit identifier.
void AddHit(const Identifier id)
void SetMucRecHitCol(MucRecHitCol *p)
int GetGapHitCount(const MucRecHitID gapID)
How many hits are there in this gap?
Hep3Vector GetCenterPos() const
Get Center position of the strip (global coords).
int Part() const
Get Part.
int Strip() const
Get Strip.
void SetHitMode(int recmode)
void TrackFinding(RecMucTrack *aTrack)
float getWindowSize(Hep3Vector mom, int part, int seg, int gap)
MucRecTrkExt(const std::string &name, ISvcLocator *pSvcLocator)
int GetTotalHits() const
How many hits in all does this track contain?
void LineFit(int fittingMethod)
Line fit with hits on a seg with max hits.
void CorrectPos()
Correct current position of this trajectory.
void CorrectDir()
Correct direction of this trajectory.
void ComputeTrackInfo(int fittingmethod)
Get corresponding monte carlo track pointer.
void pushExtDistHits(float dist)
vector< float > getExtDistHits() const
void SetMdcMomentum(const float px, const float py, const float pz)
set start moment of the track in Mdc.
Hep3Vector getMucPos() const
start position of this track in Muc.
Hep3Vector getMucPosSigma() const
void AttachInsct(Hep3Vector insct)
Attach the intersection to this trajectory.
void SetExtMucPos(const float x, const float y, const float z)
set start position of ext track in Muc. (compute from MdcPos MdcMomentum or get from ExtTrack)
void SetExtTrackID(int id)
set Ext track id. for compute from mdc myself
void SetMdcPos(const float x, const float y, const float z)
set start position of the track in Mdc.
void SetCurrentDir(const float x, const float y, const float z)
set current direction of the trajectory.
void SetExtTrack(RecExtTrack *extTrack)
set Ext track point.
void setTrackId(const int trackId)
set the index for this track.
Hep3Vector GetExtMucDistance() const
Distance match of the ext track with muc track in first layer.
void GetMdcExtTrack(Hep3Vector mdcStartPos, Hep3Vector mdcStartMomentum, int charge, Hep3Vector &mucStartPos, Hep3Vector &mucStartMomentum)
compute ext track myself from mdc.
Hep3Vector GetMucStripPos() const
Hep3Vector GetCurrentDir() const
Current direction.
Hep3Vector getMdcMomentum() const
momentum of this track in Mdc
Hep3Vector CalculateInsct(const int part, const int seg, const int gap)
Calculate intersection from all hits attached on this gap.
void Project(const int &part, const int &gap, float &x, float &y, float &z, int &seg)
Where does the trajectory of this track intersect a specific gap?
vector< float > getQuadDistHits() const
void SetMucMomentum(const float px, const float py, const float pz)
set start moment of the track in Muc.
Hep3Vector GetCurrentInsct() const
Current intersection.
void SetExtMucMomentum(const float px, const float py, const float pz)
set start moment of ext track in Muc.
vector< MucRecHit * > GetHits() const
Get all hits on this track.
void AttachHit(MucRecHit *hit)
set corresponding monte carlo track pointer.
Hep3Vector GetCurrentPos() const
Current position.
void SetCurrentInsct(const float x, const float y, const float z)
set current intersection of the trajectory with strip plane.
void SetCurrentPos(const float x, const float y, const float z)
set current position of the trajectory.
vector< MucRecHit * > GetExpectedHits() const
void SetRecMode(int recmode)
void SetMucPos(const float x, const float y, const float z)
set start position of the track in Muc. (after line fit and correction)
float GetHitDistance2(const MucRecHit *hit)
no abs value
vector< float > getDistHits() const
Event::Relation< Event::McParticle, Event::MucMcHit > McPartToMucHitRel