diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 4aeed635f919d5788c94d0d4c2133e16270ae9c5..b7b7baa4be5942c3009edcc8afa77e999aa36633 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -745,6 +745,7 @@ InitStatus CbmL1::Init() trackingIterAllSecJump.SetMaxDZ(0.1); trackingIterAllSecJump.SetMinLevelTripletStart(1); trackingIterAllSecJump.SetTargetPosSigmaXY(10, 10); + trackingIterAllSecJump.SetPrimaryFlag(false); auto trackingIterAllPrimE = L1CAIteration("AllPrimEIter"); trackingIterAllPrimE.SetTrackChi2Cut(10.f); @@ -773,6 +774,7 @@ InitStatus CbmL1::Init() trackingIterAllSecE.SetMaxDZ(0.1); trackingIterAllSecE.SetMinLevelTripletStart(1); trackingIterAllSecE.SetTargetPosSigmaXY(10, 10); + trackingIterAllSecE.SetPrimaryFlag(false); trackingIterAllSecE.SetElectronFlag(true); // Select default track finder @@ -787,6 +789,11 @@ InitStatus CbmL1::Init() trackingIterAllPrimJump.SetMaxInvMom(1.0 / 0.3); trackingIterAllSecJump.SetMaxInvMom(1.0 / 0.3); + trackingIterFastPrim.SetExtendTracksFlag(false); + trackingIterAllPrim.SetExtendTracksFlag(false); + trackingIterAllPrimJump.SetExtendTracksFlag(false); + trackingIterAllSec.SetExtendTracksFlag(false); + fInitManager.SetCAIterationsNumberCrosscheck(4); // Initialize CA track finder iterations sequence fInitManager.PushBackCAIteration(trackingIterFastPrim); @@ -812,6 +819,7 @@ InitStatus CbmL1::Init() trd2dIter1.SetTargetPosSigmaXY(1., 1.); //(1, 1); trd2dIter1.SetMinLevelTripletStart(1); trd2dIter1.SetPrimaryFlag(false); + trd2dIter1.SetExtendTracksFlag(false); auto trd2dIter2 = L1CAIteration("Trd2dIter2"); trd2dIter2.SetTrackChi2Cut(7.f); //10.f @@ -826,6 +834,7 @@ InitStatus CbmL1::Init() trd2dIter2.SetTargetPosSigmaXY(8 * 10, 6 * 10); //(1, 1); trd2dIter2.SetMinLevelTripletStart(0); trd2dIter2.SetPrimaryFlag(false); + trd2dIter2.SetExtendTracksFlag(false); // Initialize CA track finder iterations sequence @@ -841,6 +850,18 @@ InitStatus CbmL1::Init() } else { fInitManager.SetCAIterationsNumberCrosscheck(4); + + trackingIterFastPrim.SetExtendTracksFlag(true); + trackingIterAllPrim.SetExtendTracksFlag(true); + trackingIterFastPrim2.SetExtendTracksFlag(true); + trackingIterAllSec.SetExtendTracksFlag(true); + trackingIterFastPrimJump.SetExtendTracksFlag(true); + trackingIterAllPrimJump.SetExtendTracksFlag(true); + trackingIterAllSecJump.SetExtendTracksFlag(true); + trackingIterAllPrimE.SetExtendTracksFlag(true); + trackingIterAllSecE.SetExtendTracksFlag(true); + + // Initialize CA track finder iterations sequence fInitManager.PushBackCAIteration(trackingIterFastPrim); fInitManager.PushBackCAIteration(trackingIterAllPrim); @@ -862,7 +883,7 @@ InitStatus CbmL1::Init() fInitManager.SetMomentumCutOff(fMomentumCutOff); // Form parameters container - fInitManager.FormParametersContainer(); + if (!fInitManager.FormParametersContainer()) { return kERROR; } // Write to file if needed if (1 == fSTAPDataMode) { this->WriteSTAPParamObject(); } diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index 88e1b5e928ea4cdf208b2444f4294aa2602094be..86f1b1fc208def8c908ba304667fdace76b4051b 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -20,7 +20,6 @@ class L1AlgoDraw; //#define COUNTERS // diff counters (hits, doublets, ... ) // =====>dispatched<===== // #define MERGE_CLONES -// #define TRACKS_FROM_TRIPLETS_ITERATION kAllPrimIter // =====>dispatched<===== // #define HitErrors //#define GLOBAL @@ -29,10 +28,6 @@ class L1AlgoDraw; // =====>dispatched<===== // #define LAST_ITERATION kAllSecIter #define FIND_GAPED_TRACKS // use triplets with gaps // =====>dispatched<===== // #define USE_RL_TABLE -#ifndef TRACKS_FROM_TRIPLETS -#define EXTEND_TRACKS -#endif -//#define USE_EVENT_NUMBER //#endif @@ -571,11 +566,7 @@ private: kAllSecJumpIter // secondary tracks with jumped triplets }; -#ifdef TRACKS_FROM_TRIPLETS - int fNFindIterations = TRACKS_FROM_TRIPLETS_ITERATION + 1; // TODO investigate kAllPrimJumpIter & kAllSecJumpIter -#else // not TRACKS_FROM_TRIPLETS int fNFindIterations = -1; // TODO investigate kAllPrimJumpIter & kAllSecJumpIter -#endif // TRACKS_FROM_TRIPLETS #else // not FIND_GAPED_TRACKS enum @@ -622,7 +613,7 @@ private: // int TripNumThread; int fTrackingLevel {2}; // currently not used - int fGhostSuppression {1}; // currently not used + int fGhostSuppression {1}; // NOTE: Should be equal to 0 in TRACKS_FROM_TRIPLETS mode! float fMomentumCutOff {0.2}; // currently not used /// ----- Debug features ----- diff --git a/reco/L1/L1Algo/L1CAIteration.cxx b/reco/L1/L1Algo/L1CAIteration.cxx index 359ebb1ecc9dd3e03828bab56d4a2bb4792f0c0c..72ae712f5c785569a1aa54548d01e6a798f1ac03 100644 --- a/reco/L1/L1Algo/L1CAIteration.cxx +++ b/reco/L1/L1Algo/L1CAIteration.cxx @@ -40,6 +40,8 @@ L1CAIteration::L1CAIteration(const L1CAIteration& other) noexcept , fFirstStationIndex(other.fFirstStationIndex) , fIsPrimary(other.fIsPrimary) , fIsElectron(other.fIsElectron) + , fIsTrackFromTriplets(other.fIsTrackFromTriplets) + , fIfExtendTracks(other.fIfExtendTracks) { } // @@ -115,6 +117,8 @@ void L1CAIteration::Swap(L1CAIteration& other) noexcept std::swap(fFirstStationIndex, other.fFirstStationIndex); std::swap(fIsPrimary, other.fIsPrimary); std::swap(fIsElectron, other.fIsElectron); + std::swap(fIsTrackFromTriplets, other.fIsTrackFromTriplets); + std::swap(fIfExtendTracks, other.fIfExtendTracks); } // //---------------------------------------------------------------------------------------------------------------------- @@ -122,24 +126,26 @@ void L1CAIteration::Swap(L1CAIteration& other) noexcept std::string L1CAIteration::ToString(int indentLevel) const { std::stringstream aStream {}; - constexpr char indentChar = '\t'; - std::string indent(indentLevel, indentChar); + constexpr char indCh = '\t'; + std::string indent(indentLevel, indCh); aStream << indent << "L1CAIteration: " << fName << '\n'; - aStream << indent << indentChar << "Is primary: " << fIsPrimary << '\n'; - aStream << indent << indentChar << "Is electron: " << fIsElectron << '\n'; - aStream << indent << indentChar << "Track chi2 cut: " << fTrackChi2Cut << '\n'; - aStream << indent << indentChar << "Triplet chi2 cut: " << fTripletChi2Cut << '\n'; - aStream << indent << indentChar << "Doublet chi2 cut: " << fDoubletChi2Cut << '\n'; - aStream << indent << indentChar << "Pick gather: " << fPickGather << '\n'; - aStream << indent << indentChar << "Pick neighbour: " << fPickNeighbour << '\n'; - aStream << indent << indentChar << "Max inverse momentum: " << fMaxInvMom << '\n'; - aStream << indent << indentChar << "Max slope at primary vertex: " << fMaxSlopePV << '\n'; - aStream << indent << indentChar << "Max slope: " << fMaxSlope << '\n'; - aStream << indent << indentChar << "Max DZ: " << fMaxDZ << '\n'; - aStream << indent << indentChar << "Target position sigma X [cm]: " << fTargetPosSigmaX << '\n'; - aStream << indent << indentChar << "Target position sigma Y [cm]: " << fTargetPosSigmaY << '\n'; - aStream << indent << indentChar << "Min level for triplet start: " << fMinLevelTripletStart << '\n'; - aStream << indent << indentChar << "First tracking station index: " << fFirstStationIndex; + aStream << indent << indCh << "Is primary: " << fIsPrimary << '\n'; + aStream << indent << indCh << "Is electron: " << fIsElectron << '\n'; + aStream << indent << indCh << "Are tracks created from triplets: " << fIsTrackFromTriplets << '\n'; + aStream << indent << indCh << "Are tracks extended with unused hits : " << fIfExtendTracks << '\n'; + aStream << indent << indCh << "Track chi2 cut: " << fTrackChi2Cut << '\n'; + aStream << indent << indCh << "Triplet chi2 cut: " << fTripletChi2Cut << '\n'; + aStream << indent << indCh << "Doublet chi2 cut: " << fDoubletChi2Cut << '\n'; + aStream << indent << indCh << "Pick gather: " << fPickGather << '\n'; + aStream << indent << indCh << "Pick neighbour: " << fPickNeighbour << '\n'; + aStream << indent << indCh << "Max inverse momentum: " << fMaxInvMom << '\n'; + aStream << indent << indCh << "Max slope at primary vertex: " << fMaxSlopePV << '\n'; + aStream << indent << indCh << "Max slope: " << fMaxSlope << '\n'; + aStream << indent << indCh << "Max DZ: " << fMaxDZ << '\n'; + aStream << indent << indCh << "Target position sigma X [cm]: " << fTargetPosSigmaX << '\n'; + aStream << indent << indCh << "Target position sigma Y [cm]: " << fTargetPosSigmaY << '\n'; + aStream << indent << indCh << "Min level for triplet start: " << fMinLevelTripletStart << '\n'; + aStream << indent << indCh << "First tracking station index: " << fFirstStationIndex; return aStream.str(); } diff --git a/reco/L1/L1Algo/L1CAIteration.h b/reco/L1/L1Algo/L1CAIteration.h index e84361b981f5ea818020eab93e0b257c37089924..dc1d09e22e3aa003e7ef76a75292ed69ef04cb8f 100644 --- a/reco/L1/L1Algo/L1CAIteration.h +++ b/reco/L1/L1Algo/L1CAIteration.h @@ -50,6 +50,12 @@ public: /// Gets doublet chi2 upper cut float GetDoubletChi2Cut() const { return fDoubletChi2Cut; } + /// flag check: electrons/positrons - true, heavy charged - false + bool GetElectronFlag() const { return fIsElectron; } + + /// Sets flag: true - extends track candidates with unused hits + bool GetExtendTracksFlag() const { return fIfExtendTracks; } + /// Gets station index of the first station used in tracking int GetFirstStationIndex() const { return fFirstStationIndex; } @@ -77,6 +83,9 @@ public: /// Gets min value of dp/dp_error, for which two tiplets are neighbours float GetPickNeighbour() const { return fPickNeighbour; } + /// Checks flag: true - only primary tracks are searched, false - [all or only secondary?] + bool GetPrimaryFlag() const { return fIsPrimary; } + /// Gets sigma target position in X direction [cm] float GetTargetPosSigmaX() const { return fTargetPosSigmaX; } @@ -89,11 +98,18 @@ public: /// Gets triplet chi2 upper cut float GetTripletChi2Cut() const { return fTripletChi2Cut; } - /// flag check: electrons/positrons - true, heavy charged - false - bool GetElectronFlag() const { return fIsElectron; } + /// (DEBUG!) Sets flag: + /// true: + /// all the triplets found on this iteration will be converted to tracks, + /// all the iterations following after this one will be rejected from the + /// iterations sequence; + /// false (default): + /// tracks are built from triplets, and the minimal amount of hits used in + /// each track equals four. In case of primary tracks the first measurement + /// is taken from the target, and the other three measurements are taken from + /// the triplet. + bool GetTrackFromTripletsFlag() const { return fIsTrackFromTriplets; } - /// Checks flag: true - only primary tracks are searched, false - [all or only secondary?] - bool GetPrimaryFlag() const { return fIsPrimary; } /// Prints iteration options void Print(int verbosityLevel = 0) const; @@ -104,6 +120,9 @@ public: /// Sets flag: electron tracks - true, heavy ion tracks - false void SetElectronFlag(bool flag) { fIsElectron = flag; } + /// Sets flag: true - extends track candidates with unused hits + void SetExtendTracksFlag(bool flag) { fIfExtendTracks = flag; } + /// Sets index of first station used in tracking void SetFirstStationIndex(int index) { fFirstStationIndex = index; } @@ -143,6 +162,18 @@ public: /// Sets track chi2 upper cut void SetTrackChi2Cut(float input) { fTrackChi2Cut = input; } + /// (DEBUG!) Sets flag: + /// true: + /// all the triplets found on this iteration will be converted to tracks, + /// all the iterations following after this one will be rejected from the + /// iterations sequence; + /// false (default): + /// tracks are built from triplets, and the minimal amount of hits used in + /// each track equals four. In case of primary tracks the first measurement + /// is taken from the target, and the other three measurements are taken from + /// the triplet. + void SetTrackFromTripletsFlag(bool flag) { fIsTrackFromTriplets = flag; } + /// Sets triplet chi2 upper cut void SetTripletChi2Cut(float input) { fTripletChi2Cut = input; } @@ -180,6 +211,20 @@ private: bool fIsPrimary = false; ///< Flag: true - only primary tracks are searched for bool fIsElectron = false; ///< Flag: true - only electrons are searched for + /// \brief Flag to select triplets on the iteration as tracks + /// In ordinary cases, the shortest track consists from four hits. For primary track the target is accounted as + /// the first hit, and the other three hits are taken from the stations. For secondary track all the hits are selected + /// from the stations only. + /// If the fIsTrackFromTriplets flag is turned on, all of the triplets found on this iterations will be considered + /// as tracks. + /// + /// \note The only one iteration with the fIsTrackFromTriplets flag turned on can exist in the tracking iterations + /// sequence and this iteration should be the last in the tracking sequence. + bool fIsTrackFromTriplets = false; + + bool fIfExtendTracks = false; ///< Flag: true - extends track candidates with unused hits + + /// Serialization method, used to save L1Hit objects into binary or text file in a defined order friend class boost::serialization::access; template<class Archive> @@ -200,6 +245,8 @@ private: ar& fFirstStationIndex; ar& fIsPrimary; ar& fIsElectron; + ar& fIsTrackFromTriplets; + ar& fIfExtendTracks; } diff --git a/reco/L1/L1Algo/L1CATrackFinder.cxx b/reco/L1/L1Algo/L1CATrackFinder.cxx index 872c344ca481c0dbfdb408b8b35bb8efb0c2d5b6..b21a50b700a2bdede650d858b0228ec0be984b45 100644 --- a/reco/L1/L1Algo/L1CATrackFinder.cxx +++ b/reco/L1/L1Algo/L1CATrackFinder.cxx @@ -106,9 +106,6 @@ inline void L1Algo::findSingletsStep0( // input L1HitPoint& hitl = Hits_l[ilh]; -#ifdef USE_EVENT_NUMBER - Event_l[i1_V][i1_4] = hitl.track; -#endif // USE_EVENT_NUMBER HitTime_l[i1_V][i1_4] = hitl.time; HitTimeEr[i1_V][i1_4] = hitl.timeEr; @@ -216,8 +213,8 @@ inline void L1Algo::findSingletsStep1( /// input 1st stage of singlet search fld1.Set(b10, fld1Sta0.z, b11, fld1Sta1.z, b12, fld1Sta2.z); T.chi2 = 0.; - T.NDF = 2.; /// Iterations -> Number of parameters - number of measurements, - if ((isec == kAllSecIter) || (isec == kAllSecEIter) || (isec == kAllSecJumpIter)) T.NDF = fvec(0.); + T.NDF = (fpCurrentIteration->GetPrimaryFlag()) ? fvec(2.) : fvec(0.); + // TODO: iteration parameter: "Starting NDF of track parameters" // NDF = number of track parameters (6: x, y, tx, ty, qp, time) - number of measured parameters (3: x, y, time) on station or (2: x, y) on target // Alternative: Iteration can find tracks starting from target or from station: -> use a FLAG @@ -233,14 +230,15 @@ inline void L1Algo::findSingletsStep1( /// input 1st stage of singlet search T.C50 = T.C51 = T.C52 = T.C53 = T.C54 = fvec(0.); T.C22 = T.C33 = fMaxSlopePV * fMaxSlopePV / fvec(9.); if (kGlobal == fTrackingMode || kMcbm == fTrackingMode) T.C22 = T.C33 = fvec(10.); + // TODO: Why 9. and 10.? + + T.C44 = fMaxInvMom / fvec(3.) * fMaxInvMom / fvec(3.); T.C55 = timeEr * timeEr; if (fParameters.DevIsFitSingletsFromTarget()) { // TODO: doesn't work. Why? - T.x = fTargX; T.y = fTargY; - T.z = fTargZ; T.C00 = TargetXYInfo.C00; T.C10 = TargetXYInfo.C10; @@ -441,9 +439,6 @@ inline void L1Algo::findDoubletsStep0( if (fabs(time - hitm.time) > 30) continue; } -#ifdef USE_EVENT_NUMBER - if ((Event[i1_V][i1_4] != hitm.n)) continue; -#endif // USE_EVENT_NUMBER // - check whether hit belong to the window ( track position +\- errors ) - const fscal zm = hitm.Z(); // L1TrackPar T1_new = T1; @@ -495,15 +490,11 @@ inline void L1Algo::findDoubletsStep0( if (fUseHitErrors) info.sigma2 = hitm.dU() * hitm.dU(); L1FilterChi2XYC00C10C11(info, x, y, C00, C10, C11, chi2, hitm.U()); -#ifdef DO_NOT_SELECT_TRIPLETS - if (isec != TRACKS_FROM_TRIPLETS_ITERATION) -#endif // DO_NOT_SELECT_TRIPLETS + + if (!fpCurrentIteration->GetTrackFromTripletsFlag()) { if (chi2[i1_4] > fDoubletChi2Cut) continue; - // T1.t[i1_4] = hitm.time; + } -#ifdef USE_EVENT_NUMBER - T1.n[i1_4] = hitm.n; -#endif // USE_EVENT_NUMBER info = stam.backInfo; @@ -513,10 +504,9 @@ inline void L1Algo::findDoubletsStep0( // FilterTime(T1, hitm.time, hitm.timeEr); -#ifdef DO_NOT_SELECT_TRIPLETS - if (isec != TRACKS_FROM_TRIPLETS_ITERATION) -#endif // DO_NOT_SELECT_TRIPLETS + if (!fpCurrentIteration->GetTrackFromTripletsFlag()) { if (chi2[i1_4] > fDoubletChi2Cut) continue; + } i1_2.push_back(i1); #ifdef DOUB_PERFORMANCE @@ -750,14 +740,12 @@ inline void L1Algo::findTripletsStep0( // input if (fabs(T2.tx[i2_4]) > fMaxSlope) continue; if (fabs(T2.ty[i2_4]) > fMaxSlope) continue; - const fvec Pick_r22 = (fTripletChi2Cut - T2.chi2); + const fvec Pick_r22 = fTripletChi2Cut - T2.chi2 + (!fpCurrentIteration->GetTrackFromTripletsFlag() ? 0 : 1); const fscal timeError = T2.C55[i2_4]; const fscal time = T2.t[i2_4]; // find first possible hit -#ifdef DO_NOT_SELECT_TRIPLETS - if (isec == TRACKS_FROM_TRIPLETS_ITERATION) { Pick_r22 = Pick_r2 + 1; } -#endif // DO_NOT_SELECT_TRIPLETS + const fscal iz = 1.f / (T2.z[i2_4] - fParameters.GetTargetPositionZ()[0]); L1HitAreaTime area(vGridTime[&star - fParameters.GetStations().begin()], T2.x[i2_4] * iz, T2.y[i2_4] * iz, (sqrt(Pick_r22 * (T2.C00 + stam.XYInfo.C00)) + fMaxDZ * abs(T2.tx))[i2_4] * iz, @@ -787,9 +775,6 @@ inline void L1Algo::findTripletsStep0( // input if (GetMcTrackIdForUnusedHit(indM) != GetMcTrackIdForUnusedHit(indR)) { continue; } } -#ifdef USE_EVENT_NUMBER // NOTE: - if ((T2.n[i2_4] != hitr.n)) continue; -#endif // USE_EVENT_NUMBER const fscal zr = hitr.Z(); // const fscal yr = hitr.Y(); @@ -861,12 +846,11 @@ inline void L1Algo::findTripletsStep0( // input FilterTime(T_cur, hitr.time, hitr.timeEr, star.timeInfo); -#ifdef DO_NOT_SELECT_TRIPLETS - if (isec != TRACKS_FROM_TRIPLETS_ITERATION) -#endif // DO_NOT_SELECT_TRIPLETS + if (!fpCurrentIteration->GetTrackFromTripletsFlag()) { if (chi2[i2_4] > fTripletChi2Cut || C00[i2_4] < 0 || C11[i2_4] < 0 || T_cur.C55[i2_4] < 0) { continue; // chi2_triplet < CHI2_CUT } + } #ifndef FAST_CODE //TODO: optimise triplet portion limit and put a warning @@ -1221,13 +1205,9 @@ inline void L1Algo::findTripletsStep3( // input ihitl_prev = 1 + hitsl_3[i3]; -#ifdef DO_NOT_SELECT_TRIPLETS - if (isec != TRACKS_FROM_TRIPLETS_ITERATION) { + if (!fpCurrentIteration->GetTrackFromTripletsFlag()) { if (chi2 > fTripletChi2Cut) { continue; } } -#else - if (chi2 > fTripletChi2Cut) { continue; } -#endif // DO_NOT_SELECT_TRIPLETS // assert(std::isfinite(chi2) && chi2 > 0); @@ -1305,10 +1285,7 @@ inline void L1Algo::f5( // input int* nlevel) { -#ifdef TRACKS_FROM_TRIPLETS - if (isec != TRACKS_FROM_TRIPLETS_ITERATION) -#endif - + if (!fpCurrentIteration->GetTrackFromTripletsFlag()) { for (int istal = fParameters.GetNstationsActive() - 4; istal >= fFirstCAstation; istal--) { for (int tripType = 0; tripType < 3; tripType++) // tT = 0 - 123triplet, tT = 1 - 124triplet, tT = 2 - 134triplet { @@ -1383,6 +1360,7 @@ inline void L1Algo::f5( // input } } // tripType } // istal + } // if !fpCurrentIteration->GetTrackFromTripletsFlag() } /// ------------------- doublets on station ---------------------- @@ -1651,13 +1629,7 @@ inline void L1Algo::TripletsStaPort( /// creates triplets: void L1Algo::CATrackFinder() { - -#ifdef TRACKS_FROM_TRIPLETS - // TODO investigate kAllPrimJumpIter & kAllSecJumpIter - fNFindIterations = TRACKS_FROM_TRIPLETS_ITERATION + 1; -#else fNFindIterations = fParameters.GetNcaIterations(); -#endif #ifdef _OPENMP @@ -2132,20 +2104,16 @@ void L1Algo::CATrackFinder() ///= = ///==================================================================== - // #ifdef XXX - // cout<<"---- Collect track candidates. ----"<<endl; - // #endif - int min_level = - caIteration.GetMinLevelTripletStart(); // min level for start triplet. So min track length = min_level+3. + caIteration.GetMinLevelTripletStart(); // min level to start triplet. So min track length = min_level+3. // if (isec == kFastPrimJumpIter) min_level = 1; //if ((isec == kAllSecIter) || (isec == kAllSecEIter) || (isec == kAllSecJumpIter)) // min_level = 1; // only the long low momentum tracks -#ifdef TRACKS_FROM_TRIPLETS - LOG(FATAL) << "L1CATrackFinder: min_level undefined in " << __FILE__ << " : " << __LINE__; - if (isec == TRACKS_FROM_TRIPLETS_ITERATION) min_level = 0; -#endif + // TODO: SZh 04.10.2022: Why this fatal error is called? + // NOTE: This line was wrapped into TRACKS_FROM_TRIPLETS ifdef + //LOG(FATAL) << "L1CATrackFinder: min_level undefined in " << __FILE__ << " : " << __LINE__; + if (fpCurrentIteration->GetTrackFromTripletsFlag()) { min_level = 0; } // TODO: Just remove it // // min_level: lower then this triplets would never start @@ -2209,7 +2177,7 @@ void L1Algo::CATrackFinder() || fvHitKeyFlags[(*vHitsUnused)[first_trip.GetLHit()].b]) { continue; } -// ghost supression !!! +// ghost suppression !!! #ifndef FIND_GAPED_TRACKS if (/*(isec == kFastPrimIter) ||*/ (isec == kAllPrimIter) || (isec == kAllPrimEIter) || (isec == kAllSecIter) || (isec == kAllSecEIter) || (isec == kAllSecJumpIter)) { @@ -2218,10 +2186,7 @@ void L1Algo::CATrackFinder() || (isec == kAllPrimIter) || (isec == kAllPrimEIter) || (isec == kAllPrimJumpIter) || (isec == kAllSecIter) || (isec == kAllSecEIter) || (isec == kAllSecJumpIter)) { #endif -#ifdef TRACKS_FROM_TRIPLETS - if (isec != TRACKS_FROM_TRIPLETS_ITERATION) -#endif - { // ghost supression !!! + if (!fpCurrentIteration->GetTrackFromTripletsFlag()) { // ghost suppression !!! // TODO: Primary => 3 hits tracks are saved, otherwise 3 hit tracks are thrown away if (isec != kFastPrimIter && isec != kAllPrimIter && isec != kAllPrimEIter && isec != kAllSecEIter) if (first_trip.GetLevel() == 0) @@ -2264,7 +2229,6 @@ void L1Algo::CATrackFinder() best_chi2 = best_chi2 / ndf; //normalize -#ifndef TRACKS_FROM_TRIPLETS if (fGhostSuppression) { if (3 == best_L) { // if( isec == kAllSecIter ) continue; // too /*short*/ secondary track @@ -2274,7 +2238,6 @@ void L1Algo::CATrackFinder() continue; } } -#endif fTrackCandidates[thread_num].push_back(best_tr); L1Branch& tr = fTrackCandidates[thread_num].back(); tr.Set(istaF, best_L, best_chi2, first_trip.GetQp(), @@ -2415,11 +2378,9 @@ void L1Algo::CATrackFinder() else { if (tr.NHits < 3) { continue; } } -#ifdef EXTEND_TRACKS - if (kGlobal != fTrackingMode && kMcbm != fTrackingMode) { + if (fpCurrentIteration->GetExtendTracksFlag()) { if (tr.NHits != fParameters.GetNstationsActive()) BranchExtender(tr); } -#endif fscal sumTime = 0; #ifdef _OPENMP @@ -2738,7 +2699,7 @@ inline void L1Algo::CAFindTrack(int ista, L1Branch& best_tr, unsigned char& best if (curr_chi2 > fTrackChi2Cut * ndf) return; // // try to find more hits - // #ifdef EXTEND_TRACKS + // if (fpCurrentIteration->GetExtendTracksFlag()) { // // if( curr_L < min_best_l ) // if (isec != kFastPrimJumpIter && isec != kAllPrimJumpIter && isec != kAllSecJumpIter && curr_L >= 3){ // //curr_chi2 = BranchExtender(curr_tr); @@ -2746,7 +2707,7 @@ inline void L1Algo::CAFindTrack(int ista, L1Branch& best_tr, unsigned char& best // curr_L = curr_tr.Hits.size(); // // if( 2*curr_chi2 > (2*(curr_L*2-5) + 1) * 4*4 ) return; // } - // #endif // EXTEND_TRACKS + // } // -- select the best if ((curr_L > best_L) || ((curr_L == best_L) && (curr_chi2 < best_chi2))) { diff --git a/reco/L1/L1Algo/L1InitManager.cxx b/reco/L1/L1Algo/L1InitManager.cxx index cacec55524ee6f86aa1441bd8c938bfa69f16971..7249fe6df3243860a74c85b02ca2602bc85bd0ee 100644 --- a/reco/L1/L1Algo/L1InitManager.cxx +++ b/reco/L1/L1Algo/L1InitManager.cxx @@ -152,7 +152,7 @@ void L1InitManager::ClearCAIterations() // ---------------------------------------------------------------------------------------------------------------------- // NOTE: this function should be called once in the SendParameters -void L1InitManager::FormParametersContainer() +bool L1InitManager::FormParametersContainer() { // Read configuration file // NOTE: We consider parameters from the configuration file as ones with a higher priority, so all the defined @@ -184,7 +184,15 @@ void L1InitManager::FormParametersContainer() } // Check the consistency of the parameters object. If object inconsistent, it throws std::logic_error - fParameters.CheckConsistency(); + try { + fParameters.CheckConsistency(); + } + catch (const std::logic_error& err) { + LOG(error) << "L1InitManager: parameters container consistency check failed. Reason: " << err.what(); + return false; + } + + return true; } // ---------------------------------------------------------------------------------------------------------------------- diff --git a/reco/L1/L1Algo/L1InitManager.h b/reco/L1/L1Algo/L1InitManager.h index 7a159a86c80a43404118c2cc97aa47e81ce5dc3e..27820c2982885924e235078ba1ab3e38f5bdd5b1 100644 --- a/reco/L1/L1Algo/L1InitManager.h +++ b/reco/L1/L1Algo/L1InitManager.h @@ -136,7 +136,8 @@ public: void ClearSetupInfo(); /// Forms parameters container - void FormParametersContainer(); + /// \return Success flag + bool FormParametersContainer(); /// Gets ghost suppression flag int GetGhostSuppression() const { return fParameters.fGhostSuppression; } diff --git a/reco/L1/L1Algo/L1Parameters.cxx b/reco/L1/L1Algo/L1Parameters.cxx index 129392dc4158d09a1e4d55530930f1dacd462c79..9f00df300f532043e6fae8b227b0834ac2a5d55c 100644 --- a/reco/L1/L1Algo/L1Parameters.cxx +++ b/reco/L1/L1Algo/L1Parameters.cxx @@ -11,6 +11,8 @@ #include <FairLogger.h> +#include <iomanip> + //---------------------------------------------------------------------------------------------------------------------- // L1Parameters::L1Parameters() @@ -230,6 +232,38 @@ void L1Parameters::CheckConsistency() const fThickMap[iSt].CheckConsistency(); } + + /* + * Check iterations sequence + * 1. Number of iterations with TrackFromTriplets flag turned on no more then 1 + * 2. If this iteration exists, it should be the last one in the sequence + */ + { + int nIterations = std::count_if(fCAIterations.begin(), fCAIterations.end(), + [=](const L1CAIteration& it) { return it.GetTrackFromTripletsFlag(); }); + if (nIterations > 1) { + std::stringstream msg; + msg << "L1Parameters: found " << nIterations << " iterations with GetTrackFromTripletsFlag() == true:\n"; + for (const auto& iter : fCAIterations) { + if (iter.GetTrackFromTripletsFlag()) { msg << '\t' << "- " << iter.GetName() << '\n'; } + } + msg << "Only the one iteration can have GetTrackFromTripletsFlag() == true, and this iteration should be "; + msg << "the last one"; + throw std::logic_error(msg.str()); + } + + if (nIterations == 1 && !(fCAIterations.end() - 1)->GetTrackFromTripletsFlag()) { + std::stringstream msg; + msg << "L1Parameters: iteration with GetTrackFromTripletsFlag() == true is not the last in a sequence. "; + msg << "The GetTrackFromTripletsFlag() value in the iterations sequence: \n"; + for (const auto& iter : fCAIterations) { + msg << '\t' << "- " << std::setw(15) << std::setfill(' ') << iter.GetName() << ' '; + msg << std::setw(6) << std::setfill(' ') << iter.GetTrackFromTripletsFlag() << '\n'; + } + throw std::logic_error(msg.str()); + } + } + LOG(info) << "Consistency test for L1 parameters object... \033[1;32mpassed\033[0m"; }