@@ -73,7 +73,7 @@ class GenfitTrackResult {
7373 this ->trackSeed = seedTrack;
7474
7575 try {
76- this ->track = new genfit::Track (* track) ;
76+ this ->track = track;
7777 this ->status = *(this ->track ->getFitStatus ());
7878 this ->trackRep = this ->track ->getCardinalRep ();
7979
@@ -86,9 +86,10 @@ class GenfitTrackResult {
8686 this ->nPV = this ->track ->getNumPoints () - (nFTT + nFST);
8787
8888 this ->momentum = this ->trackRep ->getMom ( this ->track ->getFittedState (0 , this ->trackRep ) );
89+ LOG_DEBUG << " GenfitTrackResult::set Track successful" << endm;
8990
9091 } catch ( genfit::Exception &e ) {
91- LOG_ERROR << " CANNOT GET TRACK " << endm;
92+ LOG_ERROR << " GenfitTrackResult cannot get track " << endm;
9293 this ->track = nullptr ;
9394 this ->trackRep = nullptr ;
9495
@@ -109,11 +110,14 @@ class GenfitTrackResult {
109110 }
110111
111112 void setFst ( Seed_t &seedFst, genfit::Track *track ){
113+ LOG_DEBUG << " GenfitTrackResult::setFSt" << endm;
112114 nFST = seedFst.size ();
113115 fstSeed = seedFst;
114116
115117 try {
116118 this ->fstTrack = new genfit::Track (*track);
119+ // make sure the McTrackId is set correctly
120+ this ->fstTrack ->setMcTrackId ( this ->track ->getMcTrackId () );
117121 this ->fstStatus = *(this ->fstTrack ->getFitStatus ());
118122 this ->fstTrackRep = this ->fstTrack ->getCardinalRep ();
119123
@@ -125,7 +129,7 @@ class GenfitTrackResult {
125129 this ->fstMomentum = this ->fstTrackRep ->getMom ( this ->fstTrack ->getFittedState (0 , this ->fstTrackRep ) );
126130
127131 } catch ( genfit::Exception &e ) {
128- LOG_ERROR << " CANNOT GET TRACK" << endm;
132+ LOG_ERROR << " CANNOT GET FST TRACK" << endm;
129133 this ->fstTrack = nullptr ;
130134 this ->fstTrackRep = nullptr ;
131135
@@ -528,6 +532,7 @@ class ForwardTrackMaker {
528532 if (mConfig .get <bool >(" TrackFitter:refitSi" , true )) {
529533 addSiHitsMc ();
530534 } else {
535+ LOG_DEBUG << " Skipping FST Hits" << endm;
531536 // skip Si refit
532537 }
533538 /* **********************************************/
@@ -656,13 +661,13 @@ class ForwardTrackMaker {
656661 }
657662
658663
659- GenfitTrackResult gtr ( track.size (), 0 , track, mTrackFitter ->getTrack () );
664+ genTrack = new genfit::Track (*mTrackFitter ->getTrack ());
665+ genTrack->setMcTrackId (idt);
666+ GenfitTrackResult gtr ( track.size (), 0 , track, genTrack );
660667
661668 // assign the fit results to be saved
662669 fitStatus = mTrackFitter ->getStatus ();
663- genTrack = new genfit::Track (*mTrackFitter ->getTrack ());
664670 trackRep = mTrackFitter ->getTrackRep ()->clone (); // Clone the track rep
665- genTrack->setMcTrackId (idt);
666671
667672 if ( mGenHistograms && genTrack->getFitStatus (genTrack->getCardinalRep ())->isFitConverged () && p.Perp () > 1e-3 ) {
668673 mHist [" FitStatus" ]->Fill (" GoodCardinal" , 1 );
@@ -679,6 +684,7 @@ class ForwardTrackMaker {
679684
680685 mTrackResults .push_back ( gtr );
681686
687+ LOG_DEBUG << " FwdTracker::fitTrack complete" << endm;
682688 } // if (mDoTrackFitting && !bailout)
683689 }
684690
@@ -774,6 +780,9 @@ class ForwardTrackMaker {
774780 */
775781 vector<Seed_t> doTrackingOnHitmapSubset ( size_t iIteration, FwdDataSource::HitMap_t &hitmap ) {
776782 long long itStart = FwdTrackerUtils::nowNanoSecond ();
783+
784+ std::vector<Seed_t> acceptedTracks;
785+ std::vector<Seed_t> rejectedTracks;
777786 /* ************************************************************/
778787 // Step 2
779788 // build 2-hit segments (setup parent child relationships)
@@ -812,6 +821,11 @@ class ForwardTrackMaker {
812821 LOG_DEBUG << TString::Format ( " nSegments=%lu" , automaton.getSegments ().size () ).Data () << endm;
813822 LOG_DEBUG << TString::Format ( " nConnections=%u" , automaton.getNumberOfConnections () ).Data () << endm;
814823
824+ if (automaton.getNumberOfConnections () > 900 ){
825+ LOG_ERROR << " Got too many connections, bailing out of tracking" << endm;
826+ return acceptedTracks;
827+ }
828+
815829 // at any point we can get a list of tracks out like this:
816830 // std::vector < std::vector< KiTrack::IHit* > > tracks = automaton.getTracks();
817831 // we can apply an optional parameter <nHits> to only get tracks with >=nHits in them
@@ -853,7 +867,7 @@ class ForwardTrackMaker {
853867 duration = (FwdTrackerUtils::nowNanoSecond () - itStart) * 1e-6 ; // milliseconds
854868 if (mGenHistograms )
855869 mHist [" Step3Duration" ]->Fill ( duration );
856- if (duration > 200 ){
870+ if (duration > 200 || automaton. getNumberOfConnections () > 900 ){
857871 LOG_WARN << " The Three Hit Criteria took more than 200ms to process, duration: " << duration << " ms" << endm;
858872 LOG_WARN << " bailing out (skipping subset HNN)" << endm;
859873 std::vector<Seed_t> acceptedTracks;
@@ -878,8 +892,6 @@ class ForwardTrackMaker {
878892
879893 // only for debug really
880894 bool findSubsets = mConfig .get <bool >(subsetPath + " :active" , true );
881- std::vector<Seed_t> acceptedTracks;
882- std::vector<Seed_t> rejectedTracks;
883895
884896 if (findSubsets) {
885897 size_t minHitsOnTrack = mConfig .get <size_t >(subsetPath + " :min-hits-on-track" , 7 );
@@ -1023,13 +1035,14 @@ class ForwardTrackMaker {
10231035 void addSiHitsMc () {
10241036 FwdDataSource::HitMap_t hitmap = mDataSource ->getFstHits ();
10251037
1026- for (size_t i = 0 ; i < mGlobalTracks .size (); i++) {
1027-
1028- if (mGlobalTracks [i]->getFitStatus (mGlobalTracks [i]->getCardinalRep ())->isFitConverged () == false || mFitMoms [i].Perp () < 1e-3 ) {
1038+ for (size_t i = 0 ; i < mTrackResults .size (); i++) {
1039+ GenfitTrackResult >r = mTrackResults [i];
1040+
1041+ if ( gtr.status .isFitConverged () == false || gtr.momentum .Perp () < 1e-3 ) {
1042+ LOG_DEBUG << " Skipping addSiHitsMc, fit failed" << endm;
10291043 return ;
10301044 }
10311045
1032-
10331046 if ( mGenHistograms ){
10341047 mHist [" FitStatus" ]->Fill (" PossibleReFit" , 1 );
10351048 }
@@ -1038,7 +1051,7 @@ class ForwardTrackMaker {
10381051
10391052 for (size_t j = 0 ; j < 3 ; j++) {
10401053 for (auto h0 : hitmap[j]) {
1041- if (dynamic_cast <FwdHit *>(h0)->_tid == mGlobalTracks [i] ->getMcTrackId ()) {
1054+ if (dynamic_cast <FwdHit *>(h0)->_tid == gtr. track ->getMcTrackId ()) {
10421055 si_hits_for_this_track[j] = h0;
10431056 break ;
10441057 }
@@ -1049,6 +1062,7 @@ class ForwardTrackMaker {
10491062 if ( si_hits_for_this_track[0 ] != nullptr ) nSiHitsFound++;
10501063 if ( si_hits_for_this_track[1 ] != nullptr ) nSiHitsFound++;
10511064 if ( si_hits_for_this_track[2 ] != nullptr ) nSiHitsFound++;
1065+ LOG_DEBUG << " Found " << nSiHitsFound << " FST Hits on this track (MC lookup)" << endm;
10521066
10531067 if ( mGenHistograms ){
10541068 this ->mHist [ " nSiHitsFound" ]->Fill ( 1 , ( si_hits_for_this_track[0 ] != nullptr ? 1 : 0 ) );
@@ -1060,14 +1074,15 @@ class ForwardTrackMaker {
10601074 if ( mGenHistograms ){
10611075 mHist [" FitStatus" ]->Fill (" AttemptReFit" , 1 );
10621076 }
1063- TVector3 p = mTrackFitter ->refitTrackWithSiHits (mGlobalTracks [i] , si_hits_for_this_track);
1077+ TVector3 p = mTrackFitter ->refitTrackWithSiHits (gtr. track , si_hits_for_this_track);
10641078
10651079 if ( mGenHistograms ){
10661080 if (p.Perp () == mFitMoms [i].Perp ()) {
10671081 mHist [" FitStatus" ]->Fill (" BadReFit" , 1 );
1068-
1082+ LOG_DEBUG << " refitTrackWithSiHits failed refit " << endm;
10691083 } else {
10701084 mHist [" FitStatus" ]->Fill (" GoodReFit" , 1 );
1085+ gtr.setFst ( si_hits_for_this_track, mTrackFitter ->getTrack () );
10711086 }
10721087 }
10731088
0 commit comments