diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt index e57ee75a653da7ffa49e822234029f989c62e34a..3f7df7475f706967e01d0240c87854d8421714f6 100644 --- a/reco/L1/CMakeLists.txt +++ b/reco/L1/CMakeLists.txt @@ -44,7 +44,6 @@ set(SRCS L1Algo/L1CATrackFinder.cxx L1Algo/L1BranchExtender.cxx L1Algo/L1TrackFitter.cxx - L1Algo/L1HitsSortHelper.cxx L1Algo/L1Grid.cxx CbmL1Performance.cxx CbmL1ReadEvent.cxx diff --git a/reco/L1/L1Algo/L1Algo.cxx b/reco/L1/L1Algo/L1Algo.cxx index d6522a659f7e8a36a72253ab3dcc192107309e35..b5039b558c6c13f050f2f3f7da48565bac8f45cc 100644 --- a/reco/L1/L1Algo/L1Algo.cxx +++ b/reco/L1/L1Algo/L1Algo.cxx @@ -87,18 +87,16 @@ void L1Algo::ReceiveInputData(L1InputData&& inputData) fInputData = std::move(inputData); // ----- Reset data arrays ------------------------------------------------------------------------------------------- - fvHitKeyFlags.reset(fInputData.GetNhitKeys()); + fvHitKeyFlags.reset(fInputData.GetNhitKeys(), 0); int nHits = fInputData.GetNhits(); NHitsIsecAll = nHits; - vNotUsedHits_A.reset(nHits); - vNotUsedHits_B.reset(nHits); - vNotUsedHits_Buf.reset(nHits); - vNotUsedHitsxy_A.reset(nHits); - vNotUsedHitsxy_buf.reset(nHits); - vNotUsedHitsxy_B.reset(nHits); - RealIHit_v.reset(nHits); - RealIHit_v_buf.reset(nHits); - RealIHit_v_buf2.reset(nHits); + fGridHits.reset(nHits); + fGridHitsBuf.reset(nHits); + fGridHits.reset(nHits); + fGridPoints.reset(nHits); + fGridPointsBuf.reset(nHits); + fGridHitIds.reset(nHits); + fGridHitIdsBuf.reset(nHits); #ifdef _OPENMP fStripToTrackLock.reset(fInputData.GetNhitKeys()); @@ -195,17 +193,17 @@ int L1Algo::GetMcTrackIdForHit(int iHit) const return CbmL1::Instance()->GetMcPoints()[iMcPoint].ID; } -int L1Algo::GetMcTrackIdForUnusedHit(int iHit) const +int L1Algo::GetMcTrackIdForGridHit(int iHit) const { - int hitId = (*RealIHitP)[iHit]; + int hitId = fGridHitIds[iHit]; int iMcPoint = CbmL1::Instance()->GetHitMCRefs()[hitId]; if (iMcPoint < 0) return -1; return CbmL1::Instance()->GetMcPoints()[iMcPoint].ID; } -const CbmL1MCTrack* L1Algo::GetMcTrackForUnusedHit(int iHit) const +const CbmL1MCTrack* L1Algo::GetMcTrackForGridHit(int iHit) const { - int id = GetMcTrackIdForUnusedHit(iHit); + int id = GetMcTrackIdForGridHit(iHit); if (id < 0) return nullptr; return &CbmL1::Instance()->GetMcTracks()[id]; } diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index 006a21fc24c40fc1a80e181e2ae74b55274fa71c..702b8d403913635465105f8d5b6735019ff17e92 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -35,7 +35,6 @@ class L1AlgoDraw; #include "L1Grid.h" #include "L1Hit.h" #include "L1HitPoint.h" -#include "L1HitsSortHelper.h" #include "L1InputData.h" #include "L1Parameters.h" #include "L1Portion.h" @@ -73,6 +72,10 @@ template<Tindex NHits> class L1AlgoEfficiencyPerformance; #endif +struct L1HitTimeInfo { + fscal fEventTimeMin {-std::numeric_limits<fscal>::max() / 2.}; + fscal fEventTimeMax {std::numeric_limits<fscal>::max() / 2.}; +}; /// Main class of L1 CA track finder algorithm /// @@ -377,9 +380,9 @@ public: int GetMcTrackIdForHit(int iHit) const; /// Get mc track ID for a hit (debug tool) - int GetMcTrackIdForUnusedHit(int iHit) const; + int GetMcTrackIdForGridHit(int iGridHit) const; - const CbmL1MCTrack* GetMcTrackForUnusedHit(int iHit) const; + const CbmL1MCTrack* GetMcTrackForGridHit(int iHit) const; private: bool checkTripletMatch(const L1Triplet& l, const L1Triplet& r, fscal& dchi2) const; @@ -402,6 +405,8 @@ private: "L1Algo::fvHitKeyFlags"}; ///< List of key flags: has been this hit or cluster already used public: + L1Vector<L1HitTimeInfo> fHitTimeInfo[L1Constants::size::kMaxNstations]; + L1Grid vGrid[L1Constants::size::kMaxNstations]; ///< L1Grid vGridTime[L1Constants::size::kMaxNstations]; ///< @@ -429,18 +434,25 @@ public: // L1Branch* pointer; unsigned int NHitsIsecAll {0}; - L1Vector<L1Hit> vNotUsedHits_A {"L1Algo::vNotUsedHits_A"}; - L1Vector<L1Hit> vNotUsedHits_B {"L1Algo::vNotUsedHits_B"}; - L1Vector<L1Hit> vNotUsedHits_Buf {"L1Algo::vNotUsedHits_Buf"}; - L1Vector<L1HitPoint> vNotUsedHitsxy_A {"L1Algo::vNotUsedHitsxy_A"}; - L1Vector<L1HitPoint> vNotUsedHitsxy_buf {"L1Algo::vNotUsedHitsxy_buf"}; - L1Vector<L1HitPoint> vNotUsedHitsxy_B {"L1Algo::vNotUsedHitsxy_B"}; + L1Vector<L1HitIndex_t> fSliceHitIds {"L1Algo::fSliceHitIds"}; ///< indices of the sub-slice hits + L1HitIndex_t fSliceHitIdsStartIndex[L1Constants::size::kMaxNstations + 1] {0}; ///< start of station hit inices + L1HitIndex_t fSliceHitIdsStopIndex[L1Constants::size::kMaxNstations + 1] {0}; ///< stop of station hit inices + + L1Vector<L1Hit> fGridHits {"L1Algo::fGridHits"}; ///< hits, ordered with respect to their grid bins + L1Vector<L1Hit> fGridHitsBuf {"L1Algo::fGridHitsBuf"}; ///< hits, ordered with respect to their grid bins + + L1Vector<L1HitIndex_t> fGridHitIds {"L1Algo::fGridHitIds"}; ///< indices of grid hits: iGridHit -> iCaHit + L1Vector<L1HitIndex_t> fGridHitIdsBuf {"L1Algo::fGridHitIdsBuf"}; ///< buffer for a new fGridHitIds + + L1Vector<L1HitPoint> fGridPoints {"L1Algo::fGridPoints"}; ///< grid points parallel to fGridHits + L1Vector<L1HitPoint> fGridPointsBuf {"L1Algo::fGridPointsBuf"}; + + L1HitIndex_t fGridHitStartIndex[L1Constants::size::kMaxNstations + 1] {0}; + L1HitIndex_t fGridHitStopIndex[L1Constants::size::kMaxNstations + 1] {0}; + L1Vector<L1Track> fTracks_local[L1Constants::size::kMaxNthreads] {"L1Algo::fTracks_local"}; L1Vector<L1HitIndex_t> fRecoHits_local[L1Constants::size::kMaxNthreads] {"L1Algo::fRecoHits_local"}; - L1Vector<L1HitIndex_t> RealIHit_v {"L1Algo::RealIHit_v"}; - L1Vector<L1HitIndex_t> RealIHit_v_buf {"L1Algo::RealIHit_v_buf"}; - L1Vector<L1HitIndex_t> RealIHit_v_buf2 {"L1Algo::RealIHit_v_buf2"}; #ifdef _OPENMP L1Vector<omp_lock_t> fStripToTrackLock {"L1Algo::fStripToTrackLock"}; @@ -460,17 +472,6 @@ public: int isec {0}; // iteration TODO: to be dispatched (S.Zharko, 21.06.2022) const L1CAIteration* fpCurrentIteration = nullptr; ///< pointer to the current CA track finder iteration - L1Vector<L1Hit>* vHitsUnused = nullptr; - L1Vector<L1HitIndex_t>* RealIHitP = nullptr; - L1Vector<L1HitIndex_t>* RealIHitPBuf = nullptr; - L1Vector<L1HitPoint>* vHitPointsUnused = nullptr; - L1HitIndex_t* RealIHit = nullptr; // index in vHits indexed by index in vHitsUnused - - L1HitIndex_t HitsUnusedStartIndex[L1Constants::size::kMaxNstations + 1] {0}; - L1HitIndex_t HitsUnusedStopIndex[L1Constants::size::kMaxNstations + 1] {0}; - L1HitIndex_t HitsUnusedStartIndexEnd[L1Constants::size::kMaxNstations + 1] {0}; - L1HitIndex_t HitsUnusedStopIndexEnd[L1Constants::size::kMaxNstations + 1] {0}; - L1Vector<int> fHitFirstTriplet {"L1Algo::fHitFirstTriplet"}; /// link hit -> first triplet { hit, *, *} L1Vector<int> fHitNtriplets {"L1Algo::fHitNtriplets"}; /// link hit ->n triplets { hit, *, *} diff --git a/reco/L1/L1Algo/L1BranchExtender.cxx b/reco/L1/L1Algo/L1BranchExtender.cxx index 9aad594f2904d6aecad6c552b8db88cf604550aa..ba15b1fcd71fe43bd4e7b25a776c1f67b06ad01b 100644 --- a/reco/L1/L1Algo/L1BranchExtender.cxx +++ b/reco/L1/L1Algo/L1BranchExtender.cxx @@ -229,18 +229,18 @@ void L1Algo::FindMoreHits(L1Branch& t, L1TrackPar& Tout, const bool dir, if (fParameters.DevIsIgnoreHitSearchAreas()) { ih++; - if ((L1HitIndex_t) ih >= (HitsUnusedStopIndex[ista] - HitsUnusedStartIndex[ista])) { break; } + if ((L1HitIndex_t) ih >= (fGridHitStopIndex[ista] - fGridHitStartIndex[ista])) { break; } } else { if (!area.GetNext(ih)) { break; } } - L1HitIndex_t globalInd = HitsUnusedStartIndex[ista] + ih; + L1HitIndex_t globalInd = fGridHitStartIndex[ista] + ih; - const L1HitPoint& hitPoint = (*vHitPointsUnused)[globalInd]; + const L1HitPoint& hitPoint = fGridPoints[globalInd]; if (hitPoint.IsSuppressed()) { continue; } - const L1Hit& hit = (*vHitsUnused)[globalInd]; + const L1Hit& hit = fGridHits[globalInd]; if (sta.timeInfo && tr.nTimeMeasurements[0] > 0) { fscal dt = hit.t - tr.t[0]; @@ -279,9 +279,9 @@ void L1Algo::FindMoreHits(L1Branch& t, L1TrackPar& Tout, const bool dir, } if (iHit_best < 0) break; - newHits.push_back((*RealIHitP)[iHit_best]); + newHits.push_back(fGridHitIds[iHit_best]); - const L1Hit& hit = (*vHitsUnused)[iHit_best]; + const L1Hit& hit = fGridHits[iHit_best]; auto [x, y] = sta.ConvUVtoXY<fvec>(hit.u, hit.v); diff --git a/reco/L1/L1Algo/L1CATrackFinder.cxx b/reco/L1/L1Algo/L1CATrackFinder.cxx index 2ca00b2142bf79cddcb9d05dd52c621da11ee7d0..10e249b9ebf34f933480d243aad6edffa66c0483 100644 --- a/reco/L1/L1Algo/L1CATrackFinder.cxx +++ b/reco/L1/L1Algo/L1CATrackFinder.cxx @@ -41,7 +41,6 @@ #include "TRandom.h" #include "TStopwatch.h" -#include "L1HitsSortHelper.h" #include "L1Timer.h" #ifdef DRAW #include "utils/L1AlgoDraw.h" @@ -352,7 +351,7 @@ inline void L1Algo::findDoubletsStep0( for (L1HitIndex_t imh = -1; true;) { // loop over the hits in the area if (fParameters.DevIsIgnoreHitSearchAreas()) { imh++; - if ((L1HitIndex_t) imh >= (HitsUnusedStopIndex[iStaM] - HitsUnusedStartIndex[iStaM])) { break; } + if ((L1HitIndex_t) imh >= (fGridHitStopIndex[iStaM] - fGridHitStartIndex[iStaM])) { break; } } else { if (!areaTime.GetNext(imh)) { break; } @@ -364,10 +363,10 @@ inline void L1Algo::findDoubletsStep0( const L1HitPoint& hitl = vHits_l[hitsl_1[i1]]; if (fParameters.DevIsMatchDoubletsViaMc()) { // trd2d - int indL = HitsUnusedStartIndex[iStaL] + hitsl_1[i1]; - int indM = HitsUnusedStartIndex[iStaM] + imh; - int iMC = GetMcTrackIdForUnusedHit(indL); - if (iMC < 0 || iMC != GetMcTrackIdForUnusedHit(indM)) { continue; } + int indL = fGridHitStartIndex[iStaL] + hitsl_1[i1]; + int indM = fGridHitStartIndex[iStaM] + imh; + int iMC = GetMcTrackIdForGridHit(indL); + if (iMC < 0 || iMC != GetMcTrackIdForGridHit(indM)) { continue; } } // check y-boundaries @@ -458,11 +457,11 @@ inline void L1Algo::findDoubletsStep0( if (dv * dv > 30. * (hitm.dV2() + hitm1.dV2())) { continue; } if (fParameters.DevIsSuppressOverlapHitsViaMc()) { - int indL = HitsUnusedStartIndex[iStaL] + hitsl_1[i1]; - int indM = HitsUnusedStartIndex[iStaM] + imh; - int indM1 = HitsUnusedStartIndex[iStaM] + hitsm_2[imh1]; - int iMC = GetMcTrackIdForUnusedHit(indL); - if ((iMC != GetMcTrackIdForUnusedHit(indM)) || (iMC != GetMcTrackIdForUnusedHit(indM1))) { continue; } + int indL = fGridHitStartIndex[iStaL] + hitsl_1[i1]; + int indM = fGridHitStartIndex[iStaM] + imh; + int indM1 = fGridHitStartIndex[iStaM] + hitsm_2[imh1]; + int iMC = GetMcTrackIdForGridHit(indL); + if ((iMC != GetMcTrackIdForGridHit(indM)) || (iMC != GetMcTrackIdForGridHit(indM1))) { continue; } } isOtherHit = true; @@ -651,7 +650,7 @@ inline void L1Algo::findTripletsStep0( // input while (true) { if (fParameters.DevIsIgnoreHitSearchAreas()) { irh1++; - if ((L1HitIndex_t) irh1 >= (HitsUnusedStopIndex[iStaR] - HitsUnusedStartIndex[iStaR])) break; + if ((L1HitIndex_t) irh1 >= (fGridHitStopIndex[iStaR] - fGridHitStartIndex[iStaR])) break; irh = irh1; } else { @@ -659,16 +658,16 @@ inline void L1Algo::findTripletsStep0( // input } // while (area.GetNext(irh)) { - //for (int irh = 0; irh < ( HitsUnusedStopIndex[iStaR] - HitsUnusedStartIndex[iStaR] ); irh++){ + //for (int irh = 0; irh < ( fGridHitStopIndex[iStaR] - fGridHitStartIndex[iStaR] ); irh++){ const L1HitPoint& hitr = vHits_r[irh]; if (hitr.IsSuppressed()) continue; if (fParameters.DevIsMatchTripletsViaMc()) { - int indL = HitsUnusedStartIndex[iStaL] + hitsl_2[i2_4]; - int indM = HitsUnusedStartIndex[iStaM] + hitsm_2_tmp[i2_4]; - int indR = HitsUnusedStartIndex[iStaR] + irh; - int mcL = GetMcTrackIdForUnusedHit(indL); - if (mcL < 0 || mcL != GetMcTrackIdForUnusedHit(indM) || mcL != GetMcTrackIdForUnusedHit(indR)) { continue; } + int indL = fGridHitStartIndex[iStaL] + hitsl_2[i2_4]; + int indM = fGridHitStartIndex[iStaM] + hitsm_2_tmp[i2_4]; + int indR = fGridHitStartIndex[iStaR] + irh; + int mcL = GetMcTrackIdForGridHit(indL); + if (mcL < 0 || mcL != GetMcTrackIdForGridHit(indM) || mcL != GetMcTrackIdForGridHit(indR)) { continue; } } const fscal zr = hitr.Z(); @@ -866,14 +865,14 @@ inline void L1Algo::findTripletsStep2(Tindex n3, int istal, int istam, int istar //if (!T3.IsEntryConsistent(false, i3_4)) continue; // prepare data - L1HitIndex_t ihit[NHits] = {(*RealIHitP)[hitsl_3[i3] + HitsUnusedStartIndex[ista[0]]], - (*RealIHitP)[hitsm_3[i3] + HitsUnusedStartIndex[ista[1]]], - (*RealIHitP)[hitsr_3[i3] + HitsUnusedStartIndex[ista[2]]]}; + L1HitIndex_t ihit[NHits] = {fGridHitIds[hitsl_3[i3] + fGridHitStartIndex[ista[0]]], + fGridHitIds[hitsm_3[i3] + fGridHitStartIndex[ista[1]]], + fGridHitIds[hitsr_3[i3] + fGridHitStartIndex[ista[2]]]}; if (fParameters.DevIsMatchTripletsViaMc()) { - int mc1 = GetMcTrackIdForUnusedHit(ihit[0]); - int mc2 = GetMcTrackIdForUnusedHit(ihit[1]); - int mc3 = GetMcTrackIdForUnusedHit(ihit[2]); + int mc1 = GetMcTrackIdForGridHit(ihit[0]); + int mc2 = GetMcTrackIdForGridHit(ihit[1]); + int mc3 = GetMcTrackIdForGridHit(ihit[2]); if ((mc1 != mc2) || (mc1 != mc3)) { continue; } } @@ -994,9 +993,9 @@ inline void L1Algo::findTripletsStep2(Tindex n3, int istal, int istam, int istar T3.SetOneEntry(i3_4, T, i3_4); { - int mc1 = GetMcTrackIdForUnusedHit(ihit[0]); - int mc2 = GetMcTrackIdForUnusedHit(ihit[1]); - int mc3 = GetMcTrackIdForUnusedHit(ihit[2]); + int mc1 = GetMcTrackIdForGridHit(ihit[0]); + int mc2 = GetMcTrackIdForGridHit(ihit[1]); + int mc3 = GetMcTrackIdForGridHit(ihit[2]); if ((mc1 >= 0) && (mc1 == mc2) && (mc1 == mc3)) { const CbmL1MCTrack& mctr = CbmL1::Instance()->GetMcTracks()[mc1]; float ev = 0; @@ -1023,9 +1022,9 @@ inline void L1Algo::findTripletsStep3( // input /// \param istam index of the middle station /// \param istar index of the right station /// \param T_3 fitted trajectories of triplets - /// \param hitsl_3 index of the left triplet hit in unused hits on the left station - /// \param hitsm_3 index of the middle triplet hit in unused hits on the middle station - /// \param hitsr_3 index of the right triplet hit in unused hits on the right station + /// \param hitsl_3 index of the left triplet hit in Grid hits on the left station + /// \param hitsm_3 index of the middle triplet hit in Grid hits on the middle station + /// \param hitsr_3 index of the right triplet hit in Grid hits on the right station #ifdef _OPENMP unsigned int Thread = omp_get_thread_num(); @@ -1052,12 +1051,12 @@ inline void L1Algo::findTripletsStep3( // input // select fscal chi2 = T3.chi2[i3_4]; // / T3.NDF[i3_4]; - const L1HitIndex_t ihitl = hitsl_3[i3] + HitsUnusedStartIndex[istal]; - const L1HitIndex_t ihitm = hitsm_3[i3] + HitsUnusedStartIndex[istam]; - const L1HitIndex_t ihitr = hitsr_3[i3] + HitsUnusedStartIndex[istar]; - L1_ASSERT(ihitl < HitsUnusedStopIndex[istal], ihitl << " < " << HitsUnusedStopIndex[istal]); - L1_ASSERT(ihitm < HitsUnusedStopIndex[istam], ihitm << " < " << HitsUnusedStopIndex[istam]); - L1_ASSERT(ihitr < HitsUnusedStopIndex[istar], ihitr << " < " << HitsUnusedStopIndex[istar]); + const L1HitIndex_t ihitl = hitsl_3[i3] + fGridHitStartIndex[istal]; + const L1HitIndex_t ihitm = hitsm_3[i3] + fGridHitStartIndex[istam]; + const L1HitIndex_t ihitr = hitsr_3[i3] + fGridHitStartIndex[istar]; + L1_ASSERT(ihitl < fGridHitStopIndex[istal], ihitl << " < " << fGridHitStopIndex[istal]); + L1_ASSERT(ihitm < fGridHitStopIndex[istam], ihitm << " < " << fGridHitStopIndex[istam]); + L1_ASSERT(ihitr < fGridHitStopIndex[istar], ihitr << " < " << fGridHitStopIndex[istar]); unsigned int Location = PackTripletId(istal, Thread, fTriplets[istal][Thread].size()); @@ -1175,9 +1174,9 @@ inline void L1Algo::f5( // input L1HitIndex_t ihitl = trip.GetLHit(); L1HitIndex_t ihitm = trip.GetMHit(); L1HitIndex_t ihitr = trip.GetRHit(); - L1_ASSERT(ihitl < HitsUnusedStopIndex[istal], ihitl << " < " << HitsUnusedStopIndex[istal]); - L1_ASSERT(ihitm < HitsUnusedStopIndex[istam], ihitm << " < " << HitsUnusedStopIndex[istam]); - L1_ASSERT(ihitr < HitsUnusedStopIndex[istar], ihitr << " < " << HitsUnusedStopIndex[istar]); + L1_ASSERT(ihitl < fGridHitStopIndex[istal], ihitl << " < " << fGridHitStopIndex[istal]); + L1_ASSERT(ihitm < fGridHitStopIndex[istam], ihitm << " < " << fGridHitStopIndex[istam]); + L1_ASSERT(ihitr < fGridHitStopIndex[istar], ihitr << " < " << fGridHitStopIndex[istar]); L1Vector<unsigned int> neighCands("L1CATrackFinder::neighCands"); // save neighbour candidates neighCands.reserve(8); // ~average is 1-2 for central, up to 5 @@ -1251,8 +1250,8 @@ inline void L1Algo::CreatePortionOfDoublets( const L1Station& stam = fParameters.GetStation(istam); // prepare data - L1HitPoint* vHits_l = &((*vHitPointsUnused)[0]) + HitsUnusedStartIndex[istal]; - L1HitPoint* vHits_m = &((*vHitPointsUnused)[0]) + HitsUnusedStartIndex[istam]; + L1HitPoint* vHits_l = &(fGridPoints[0]) + fGridHitStartIndex[istal]; + L1HitPoint* vHits_m = &(fGridPoints[0]) + fGridHitStartIndex[istam]; fvec u_front[L1Constants::size::kSingletPortionSizeVec]; fvec u_back[L1Constants::size::kSingletPortionSizeVec]; @@ -1270,8 +1269,8 @@ inline void L1Algo::CreatePortionOfDoublets( u_front, u_back, zPos, hitsl_1, t, dt2, du2, dv2); for (Tindex i = 0; i < singletPortionSize; ++i) - L1_ASSERT(hitsl_1[i] < HitsUnusedStopIndex[istal] - HitsUnusedStartIndex[istal], - hitsl_1[i] << " < " << HitsUnusedStopIndex[istal] - HitsUnusedStartIndex[istal]); + L1_ASSERT(hitsl_1[i] < fGridHitStopIndex[istal] - fGridHitStartIndex[istal], + hitsl_1[i] << " < " << fGridHitStopIndex[istal] - fGridHitStartIndex[istal]); Tindex portionSize_V = (singletPortionSize + fvec::size() - 1) / fvec::size(); @@ -1298,12 +1297,12 @@ inline void L1Algo::CreatePortionOfDoublets( hitsm_2); for (Tindex i = 0; i < static_cast<Tindex>(hitsm_2.size()); ++i) - L1_ASSERT(hitsm_2[i] < HitsUnusedStopIndex[istam] - HitsUnusedStartIndex[istam], - hitsm_2[i] << " " << HitsUnusedStopIndex[istam] - HitsUnusedStartIndex[istam]); + L1_ASSERT(hitsm_2[i] < fGridHitStopIndex[istam] - fGridHitStartIndex[istam], + hitsm_2[i] << " " << fGridHitStopIndex[istam] - fGridHitStartIndex[istam]); #ifdef DOUB_PERFORMANCE - L1HitIndex_t* RealIHitL = &((*RealIHitP)[HitsUnusedStartIndex[istal]]); - L1HitIndex_t* RealIHitM = &((*RealIHitP)[HitsUnusedStartIndex[istam]]); + L1HitIndex_t* RealIHitL = &(fGridHitIds[fGridHitStartIndex[istal]]); + L1HitIndex_t* RealIHitM = &(fGridHitIds[fGridHitStartIndex[istam]]); for (Tindex i = 0; i < n2; ++i) { // int i_4 = i%4; // int i_V = i/4; @@ -1350,10 +1349,10 @@ inline void L1Algo::CreatePortionOfTriplets( // prepare data const L1Station& star = fParameters.GetStation(istar); - L1HitPoint* vHits_m = &((*vHitPointsUnused)[0]) + HitsUnusedStartIndex[istam]; + L1HitPoint* vHits_m = &(fGridPoints[0]) + fGridHitStartIndex[istam]; L1HitPoint* vHits_r = 0; - vHits_r = &((*vHitPointsUnused)[0]) + HitsUnusedStartIndex[istar]; + vHits_r = &(fGridPoints[0]) + fGridHitStartIndex[istar]; Tindex n3 = 0; @@ -1404,11 +1403,11 @@ inline void L1Algo::CreatePortionOfTriplets( for (Tindex i = 0; i < static_cast<Tindex>(hitsl_3.size()); ++i) - L1_assert(hitsl_3[i] < HitsUnusedStopIndex[istal] - HitsUnusedStartIndex[istal]); + L1_assert(hitsl_3[i] < fGridHitStopIndex[istal] - fGridHitStartIndex[istal]); for (Tindex i = 0; i < static_cast<Tindex>(hitsm_3.size()); ++i) - L1_assert(hitsm_3[i] < HitsUnusedStopIndex[istam] - HitsUnusedStartIndex[istam]); + L1_assert(hitsm_3[i] < fGridHitStopIndex[istam] - fGridHitStartIndex[istam]); for (Tindex i = 0; i < static_cast<Tindex>(hitsr_3.size()); ++i) - L1_assert(hitsr_3[i] < HitsUnusedStopIndex[istar] - HitsUnusedStartIndex[istar]); + L1_assert(hitsr_3[i] < fGridHitStopIndex[istar] - fGridHitStartIndex[istar]); /// Add the right hits to parameters estimation. @@ -1424,9 +1423,9 @@ inline void L1Algo::CreatePortionOfTriplets( findTripletsStep2(n3, istal, istam, istar, T_3, hitsl_3, hitsm_3, hitsr_3, 1); #ifdef TRIP_PERFORMANCE - L1HitIndex_t* RealIHitL = &((*RealIHitP)[HitsUnusedStartIndex[istal]]); - L1HitIndex_t* RealIHitM = &((*RealIHitP)[HitsUnusedStartIndex[istam]]); - L1HitIndex_t* RealIHitR = &((*RealIHitP)[HitsUnusedStartIndex[istar]]); + L1HitIndex_t* RealIHitL = &(fGridHitIds[fGridHitStartIndex[istal]]); + L1HitIndex_t* RealIHitM = &(fGridHitIds[fGridHitStartIndex[istam]]); + L1HitIndex_t* RealIHitR = &(fGridHitIds[fGridHitStartIndex[istar]]); for (Tindex i = 0; i < n3; ++i) { Tindex i_4 = i % 4; Tindex i_V = i / 4; @@ -1558,14 +1557,6 @@ void L1Algo::CATrackFinder() * CATrackFinder routine setting ***********************************/ - RealIHitP = &RealIHit_v; - RealIHitPBuf = &RealIHit_v_buf; - vHitsUnused = &vNotUsedHits_B; /// array of hits used on current iteration - L1Vector<L1Hit>* vHitsUnused_buf = &vNotUsedHits_A; /// buffer for copy - - vHitPointsUnused = &vNotUsedHitsxy_B; /// array of info for hits used on current iteration - L1Vector<L1HitPoint>* vHitPointsUnused_buf = &vNotUsedHitsxy_A; - NHitsIsecAll = 0; fTracks.clear(); fRecoHits.clear(); @@ -1578,8 +1569,8 @@ void L1Algo::CATrackFinder() // #pragma omp parallel for reduction(+:nNotUsedHits) for (int ista = 0; ista < fParameters.GetNstationsActive(); ++ista) { nNotUsedHits += (fInputData.GetStopHitIndex(ista) - fInputData.GetStartHitIndex(ista)); - HitsUnusedStartIndex[ista] = fInputData.GetStartHitIndex(ista); - HitsUnusedStopIndex[ista] = fInputData.GetStopHitIndex(ista); + fGridHitStartIndex[ista] = fInputData.GetStartHitIndex(ista); + fGridHitStopIndex[ista] = fInputData.GetStopHitIndex(ista); } #ifdef XXX @@ -1603,8 +1594,6 @@ void L1Algo::CATrackFinder() // yStep = 1.25; // xStep = 2.05; - vHitsUnused = &vNotUsedHits_Buf; - for (int iS = 0; iS < fParameters.GetNstationsActive(); ++iS) { const L1Station& st = fParameters.GetStation(iS); fMaxDx[iS] = 0.; @@ -1632,15 +1621,15 @@ void L1Algo::CATrackFinder() } vGridTime[iS].BuildBins(-1, 1, -0.6, 0.6, starttime, lasttime, xStep, yStep, (lasttime - starttime + 1)); - int start = HitsUnusedStartIndex[iS]; - int nhits = HitsUnusedStopIndex[iS] - start; + int start = fGridHitStartIndex[iS]; + int nhits = fGridHitStopIndex[iS] - start; if (nhits > 0) { - vGridTime[iS].StoreHits(nhits, &(fInputData.GetHit(start)), iS, *this, start, &(vNotUsedHits_Buf[start]), - &(fInputData.GetHit(start)), &(RealIHit_v[start])); + vGridTime[iS].StoreHits(*this, iS, start, nhits, &(fInputData.GetHit(start)), &(fGridHits[start]), + &(fGridHitIds[start])); } else { // to avoid out-of-range crash in array[start] - vGridTime[iS].StoreHits(nhits, nullptr, iS, *this, start, nullptr, nullptr, nullptr); + vGridTime[iS].StoreHits(*this, iS, start, nhits, nullptr, nullptr, nullptr); } } @@ -1648,12 +1637,6 @@ void L1Algo::CATrackFinder() for (int ist = 0; ist < fParameters.GetNstationsActive(); ++ist) for (L1HitIndex_t ih = fInputData.GetStartHitIndex(ist); ih < fInputData.GetStopHitIndex(ist); ++ih) { const L1Hit& h = fInputData.GetHit(ih); - //SetFUnUsed((*fStripFlag)[h.f]); - //SetFUnUsed((*fStripFlag)[h.b]); - //L1_SHOW(fInputData.GetNhitKeys()); - //L1_SHOW(fvHitKeyFlags.size()); - //L1_SHOW(h.f); - //L1_SHOW(h.b); fvHitKeyFlags[h.f] = 0; fvHitKeyFlags[h.b] = 0; } @@ -1663,7 +1646,7 @@ void L1Algo::CATrackFinder() #pragma omp parallel for schedule(dynamic, 5) #endif for (L1HitIndex_t ih = fInputData.GetStartHitIndex(ista); ih < fInputData.GetStopHitIndex(ista); ++ih) { - CreateHitPoint(vNotUsedHits_Buf[ih], vNotUsedHitsxy_B[ih]); + CreateHitPoint(fGridHits[ih], fGridPoints[ih]); } } @@ -1706,29 +1689,22 @@ void L1Algo::CATrackFinder() #endif if (isec != 0) { - L1Vector<L1HitIndex_t>* RealIHitPTmp = RealIHitP; - RealIHitP = RealIHitPBuf; - RealIHitPBuf = RealIHitPTmp; - - L1Vector<L1Hit>* vHitsUnused_temp = vHitsUnused; - vHitsUnused = vHitsUnused_buf; - vHitsUnused_buf = vHitsUnused_temp; - L1Vector<L1HitPoint>* vHitsUnused_temp2 = vHitPointsUnused; - vHitPointsUnused = vHitPointsUnused_buf; - vHitPointsUnused_buf = vHitsUnused_temp2; + fGridHitIds.swap(fGridHitIdsBuf); + fGridHits.swap(fGridHitsBuf); + fGridPoints.swap(fGridPointsBuf); } // TODO: Replace NStations with fInitManager.GetNstationsGeom() (S.Zharko) for (int ist = 0; ist < fParameters.GetNstationsActive(); ++ist) { - for (L1HitIndex_t ih = HitsUnusedStartIndex[ist]; ih < HitsUnusedStopIndex[ist]; ++ih) { + for (L1HitIndex_t ih = fGridHitStartIndex[ist]; ih < fGridHitStopIndex[ist]; ++ih) { //SG!! fHitFirstTriplet[ih] = 0; fHitNtriplets[ih] = 0; } } /* - fHitFirstTriplet.assign(HitsUnusedStopIndex[fParameters.GetNstationsActive() - 1],0); - fHitNtriplets.assign(HitsUnusedStopIndex[fParameters.GetNstationsActive() - 1],0); + fHitFirstTriplet.assign(fGridHitStopIndex[fParameters.GetNstationsActive() - 1],0); + fHitNtriplets.assign(fGridHitStopIndex[fParameters.GetNstationsActive() - 1],0); */ { // #pragma omp task @@ -1774,10 +1750,9 @@ void L1Algo::CATrackFinder() #ifndef L1_NO_ASSERT for (int istal = fParameters.GetNstationsActive() - 1; istal >= 0; istal--) { - L1_ASSERT(HitsUnusedStopIndex[istal] >= HitsUnusedStartIndex[istal], - HitsUnusedStopIndex[istal] << " >= " << HitsUnusedStartIndex[istal]); - L1_ASSERT(HitsUnusedStopIndex[istal] <= (*vHitsUnused).size(), - HitsUnusedStopIndex[istal] << " <= " << (*vHitsUnused).size()); + L1_ASSERT(fGridHitStopIndex[istal] >= fGridHitStartIndex[istal], + fGridHitStopIndex[istal] << " >= " << fGridHitStartIndex[istal]); + L1_ASSERT(fGridHitStopIndex[istal] <= fGridHits.size(), fGridHitStopIndex[istal] << " <= " << fGridHits.size()); } #endif // L1_NO_ASSERT } @@ -1789,7 +1764,7 @@ void L1Algo::CATrackFinder() for (int istal = fParameters.GetNstationsActive() - 2; istal >= fFirstCAstation; istal--) { //start downstream chambers fSingletPortionSize[istal].clear(); - int NHits_l = HitsUnusedStopIndex[istal] - HitsUnusedStartIndex[istal]; + int NHits_l = fGridHitStopIndex[istal] - fGridHitStartIndex[istal]; int nPortions = NHits_l / L1Constants::size::kSingletPortionSize; int rest = NHits_l - nPortions * L1Constants::size::kSingletPortionSize; for (int ipp = 0; ipp < nPortions; ipp++) { @@ -1811,7 +1786,7 @@ void L1Algo::CATrackFinder() for (int istal = fParameters.GetNstationsActive() - 2; istal >= fFirstCAstation; istal--) //start downstream chambers { - int nHits = HitsUnusedStopIndex[istal] - HitsUnusedStartIndex[istal]; + int nHits = fGridHitStopIndex[istal] - fGridHitStartIndex[istal]; int NHits_P = nHits/L1Constants::size::kSingletPortionSize; @@ -1989,8 +1964,7 @@ void L1Algo::CATrackFinder() int thread_num = 0; #endif L1Triplet& first_trip = (fTriplets[istaF][iThread][itrip]); - if (fvHitKeyFlags[(*vHitsUnused)[first_trip.GetLHit()].f] - || fvHitKeyFlags[(*vHitsUnused)[first_trip.GetLHit()].b]) { + if (fvHitKeyFlags[fGridHits[first_trip.GetLHit()].f] || fvHitKeyFlags[fGridHits[first_trip.GetLHit()].b]) { continue; } // ghost suppression !!! @@ -1998,7 +1972,7 @@ void L1Algo::CATrackFinder() if (!fpCurrentIteration->GetTrackFromTripletsFlag()) { // ghost suppression !!! int nHits = 3 + first_trip.GetLevel(); - if ((*vHitsUnused)[first_trip.GetLHit()].iSt == 0) { + if (fGridHits[first_trip.GetLHit()].iSt == 0) { if (nHits < fpCurrentIteration->GetMinNhitsStation0()) { continue; } } else { @@ -2015,7 +1989,7 @@ void L1Algo::CATrackFinder() // curr_tr.Lengtha = 0; curr_tr.ista = 0; curr_tr.fHits.clear(); - curr_tr.fHits.push_back((*RealIHitP)[first_trip.GetLHit()]); + curr_tr.fHits.push_back(fGridHitIds[first_trip.GetLHit()]); curr_tr.NHits = 1; curr_L = 1; @@ -2264,10 +2238,10 @@ void L1Algo::CATrackFinder() // suppress strips of suppressed hits for (int ista = 0; ista < fParameters.GetNstationsActive(); ++ista) { - for (L1HitIndex_t ih = HitsUnusedStartIndex[ista]; ih < HitsUnusedStopIndex[ista]; ih++) { - const L1HitPoint& hp = (*vHitPointsUnused)[ih]; + for (L1HitIndex_t ih = fGridHitStartIndex[ista]; ih < fGridHitStopIndex[ista]; ih++) { + const L1HitPoint& hp = fGridPoints[ih]; if (hp.IsSuppressed()) { - int hitId = (*RealIHitP)[ih]; + int hitId = fGridHitIds[ih]; const L1Hit& hit = fInputData.GetHit(hitId); fvHitKeyFlags[hit.f] = 1; fvHitKeyFlags[hit.b] = 1; @@ -2286,24 +2260,24 @@ void L1Algo::CATrackFinder() int NHitsOnStation = 0; for (int ista = 0; ista < fParameters.GetNstationsActive(); ++ista) { - int start = HitsUnusedStartIndex[ista]; - int Nelements = HitsUnusedStopIndex[ista] - start; + int start = fGridHitStartIndex[ista]; + int Nelements = fGridHitStopIndex[ista] - start; L1Hit* staHits = nullptr; // to avoid out-of-range error in ..[start] L1HitIndex_t* staHitIndices = nullptr; L1HitPoint* staHitPoints = nullptr; if (Nelements > 0) { - staHits = &((*vHitsUnused)[start]); - staHitIndices = &((*RealIHitP)[start]); - staHitPoints = &((*vHitPointsUnused)[start]); + staHits = &(fGridHits[start]); + staHitIndices = &(fGridHitIds[start]); + staHitPoints = &(fGridPoints[start]); } int NHitsOnStationTmp = NHitsOnStation; - vGridTime[ista].UpdateIterGrid(Nelements, staHits, RealIHitPBuf, staHitIndices, vHitsUnused_buf, - vHitPointsUnused_buf, staHitPoints, NHitsOnStation, ista, *this, fvHitKeyFlags); + vGridTime[ista].UpdateIterGrid(Nelements, staHits, fGridHitIdsBuf, staHitIndices, fGridHitsBuf, fGridPointsBuf, + staHitPoints, NHitsOnStation, ista, *this, fvHitKeyFlags); - HitsUnusedStartIndex[ista] = NHitsOnStationTmp; - HitsUnusedStopIndex[ista] = NHitsOnStation; + fGridHitStartIndex[ista] = NHitsOnStationTmp; + fGridHitStopIndex[ista] = NHitsOnStation; } #ifdef XXX @@ -2319,7 +2293,7 @@ void L1Algo::CATrackFinder() // #ifdef DRAW // draw->ClearVeiw(); // // draw->DrawInfo(); - // draw->DrawRestHits(HitsUnusedStartIndex, HitsUnusedStopIndex, RealIHit); + // draw->DrawRestHits(fGridHitStartIndex, fGridHitStopIndex, RealIHit); // draw->DrawRecoTracks(); // draw->SaveCanvas("Reco_"+isec+"_"); // draw->DrawAsk(); @@ -2329,13 +2303,13 @@ void L1Algo::CATrackFinder() // fL1Pulls->Build(1); // #endif #ifdef COUNTERS - // stat_nHits[isec] += (vHitsUnused*)->Size(); + // stat_nHits[isec] += (fGridHits*)->Size(); cout << "iter = " << isec << endl; cout << " NSinglets = " << stat_nSinglets[isec] / stat_N << endl; // cout << " NDoublets = " << stat_nDoublets[isec]/stat_N << endl; cout << " NTriplets = " << stat_nTriplets[isec] / stat_N << endl; - cout << " NHitsUnused = " << stat_nHits[isec] / stat_N << endl; + cout << " NfGridHit = " << stat_nHits[isec] / stat_N << endl; #endif // COUNTERS } @@ -2395,8 +2369,8 @@ void L1Algo::CATrackFinder() NDup=0, DupSize=0, NTrip=0, TripSize=0, NBranches=0, BranchSize=0, NTracks=0, TrackSize=0 ; NTimes++; - NHits += vHitsUnused->size(); - HitSize += vHitsUnused->size()*sizeof(L1Hit); + NHits += fGridHits.size(); + HitSize += fGridHits.size()*sizeof(L1Hit); NStrips+= vStrips.size(); StripSize += vStrips.size()*sizeof(fscal) + (*fStripFlag).size()*sizeof(unsigned char); NStripsB+= (*fStripFlagB).size(); @@ -2477,31 +2451,31 @@ inline void L1Algo::CAFindTrack(int ista, L1Branch& best_tr, unsigned char& best const L1HitIndex_t& ihitr = curr_trip->GetRHit(); - //if (!GetFUsed((*fStripFlag)[(*vHitsUnused)[ihitm].f] | (*fStripFlag)[(*vHitsUnused)[ihitm].b])) { + //if (!GetFUsed((*fStripFlag)[fGridHits[ihitm].f] | (*fStripFlag)[fGridHits[ihitm].b])) { //L1_SHOW(fInputData.GetNhitKeys()); //L1_SHOW(fvHitKeyFlags.size()); - //L1_SHOW((*vHitsUnused)[ihitm].f); - //L1_SHOW((*vHitsUnused)[ihitm].b); - if (!(fvHitKeyFlags[(*vHitsUnused)[ihitm].f] || fvHitKeyFlags[(*vHitsUnused)[ihitm].b])) { + //L1_SHOW(fGridHits[ihitm].f); + //L1_SHOW(fGridHits[ihitm].b); + if (!(fvHitKeyFlags[fGridHits[ihitm].f] || fvHitKeyFlags[fGridHits[ihitm].b])) { - // curr_tr.Hits.push_back((*RealIHitP)[ihitm]); + // curr_tr.Hits.push_back(fGridHitIds[ihitm]); - curr_tr.fHits.push_back((*RealIHitP)[ihitm]); + curr_tr.fHits.push_back(fGridHitIds[ihitm]); curr_tr.NHits++; curr_L++; } - //if (!GetFUsed((*fStripFlag)[(*vHitsUnused)[ihitr].f] | (*fStripFlag)[(*vHitsUnused)[ihitr].b])) { + //if (!GetFUsed((*fStripFlag)[fGridHits[ihitr].f] | (*fStripFlag)[fGridHits[ihitr].b])) { //L1_SHOW(fInputData.GetNhitKeys()); //L1_SHOW(fvHitKeyFlags.size()); - //L1_SHOW((*vHitsUnused)[ihitr].f); - //L1_SHOW((*vHitsUnused)[ihitr].b); - if (!(fvHitKeyFlags[(*vHitsUnused)[ihitr].f] || fvHitKeyFlags[(*vHitsUnused)[ihitr].b])) { + //L1_SHOW(fGridHits[ihitr].f); + //L1_SHOW(fGridHits[ihitr].b); + if (!(fvHitKeyFlags[fGridHits[ihitr].f] || fvHitKeyFlags[fGridHits[ihitr].b])) { - //curr_tr.Hits.push_back((*RealIHitP)[ihitr]); - curr_tr.fHits.push_back((*RealIHitP)[ihitr]); + //curr_tr.Hits.push_back(fGridHitIds[ihitr]); + curr_tr.fHits.push_back(fGridHitIds[ihitr]); curr_tr.NHits++; @@ -2554,8 +2528,8 @@ inline void L1Algo::CAFindTrack(int ista, L1Branch& best_tr, unsigned char& best fscal dchi2 = 0.; if (!checkTripletMatch(*curr_trip, new_trip, dchi2)) continue; - if (fvHitKeyFlags[(*vHitsUnused)[new_trip.GetLHit()].f] - || fvHitKeyFlags[(*vHitsUnused)[new_trip.GetLHit()].b]) { //hits are used + if (fvHitKeyFlags[fGridHits[new_trip.GetLHit()].f] + || fvHitKeyFlags[fGridHits[new_trip.GetLHit()].b]) { //hits are used // no used hits allowed -> compare and store track if ((curr_L > best_L) || ((curr_L == best_L) && (curr_chi2 < best_chi2))) { best_tr = curr_tr; @@ -2571,12 +2545,12 @@ inline void L1Algo::CAFindTrack(int ista, L1Branch& best_tr, unsigned char& best if (0) { //SGtrd2d debug!! - int mc01 = GetMcTrackIdForUnusedHit(curr_trip->GetLHit()); - int mc02 = GetMcTrackIdForUnusedHit(curr_trip->GetMHit()); - int mc03 = GetMcTrackIdForUnusedHit(curr_trip->GetRHit()); - int mc11 = GetMcTrackIdForUnusedHit(new_trip.GetLHit()); - int mc12 = GetMcTrackIdForUnusedHit(new_trip.GetMHit()); - int mc13 = GetMcTrackIdForUnusedHit(new_trip.GetRHit()); + int mc01 = GetMcTrackIdForGridHit(curr_trip->GetLHit()); + int mc02 = GetMcTrackIdForGridHit(curr_trip->GetMHit()); + int mc03 = GetMcTrackIdForGridHit(curr_trip->GetRHit()); + int mc11 = GetMcTrackIdForGridHit(new_trip.GetLHit()); + int mc12 = GetMcTrackIdForGridHit(new_trip.GetMHit()); + int mc13 = GetMcTrackIdForGridHit(new_trip.GetRHit()); if ((mc01 == mc02) && (mc02 == mc03)) { cout << " sta " << ista << " mc0 " << mc01 << " " << mc02 << " " << mc03 << " mc1 " << mc11 << " " << mc12 << " " << mc13 << " chi2 " << curr_chi2 / (2 * (curr_L + 2) - 4) << " new " @@ -2596,7 +2570,7 @@ inline void L1Algo::CAFindTrack(int ista, L1Branch& best_tr, unsigned char& best // add new hit new_tr[ista] = curr_tr; - new_tr[ista].fHits.push_back((*RealIHitP)[new_trip.GetLHit()]); + new_tr[ista].fHits.push_back(fGridHitIds[new_trip.GetLHit()]); new_tr[ista].NHits++; const int new_ista = ista + new_trip.GetMSta() - new_trip.GetLSta(); diff --git a/reco/L1/L1Algo/L1Grid.cxx b/reco/L1/L1Algo/L1Grid.cxx index 0ef7ba5e3e2c60551d7126e8673e46f0a3f5a7a5..6f0d182412a1bf09af34031b674a11fcc9d5d95d 100644 --- a/reco/L1/L1Algo/L1Grid.cxx +++ b/reco/L1/L1Algo/L1Grid.cxx @@ -37,8 +37,8 @@ inline void memset(T* dest, T i, size_t num) } -void L1Grid::UpdateIterGrid(unsigned int Nelements, L1Hit* hits, L1Vector<L1HitIndex_t>* indicesBuf, - L1HitIndex_t* indices, L1Vector<L1Hit>* hits2, L1Vector<L1HitPoint>* pointsBuf, +void L1Grid::UpdateIterGrid(unsigned int Nelements, L1Hit* hits, L1Vector<L1HitIndex_t>& indicesBuf, + L1HitIndex_t* indices, L1Vector<L1Hit>& hitsBuf, L1Vector<L1HitPoint>& pointsBuf, L1HitPoint* points, int& NHitsOnStation, char iS, L1Algo& Algo, const L1Vector<unsigned char>& vSFlag) { @@ -107,9 +107,9 @@ void L1Grid::UpdateIterGrid(unsigned int Nelements, L1Hit* hits, L1Vector<L1HitI const L1HitIndex_t& index1 = fHitsInBin[x] + fFirstHitInBin[bin]; - (*hits2)[index1 + NHitsOnStation] = hits[x]; - (*indicesBuf)[index1 + NHitsOnStation] = indices[x]; - (*pointsBuf)[index1 + NHitsOnStation] = points[x]; + hitsBuf[index1 + NHitsOnStation] = hits[x]; + indicesBuf[index1 + NHitsOnStation] = indices[x]; + pointsBuf[index1 + NHitsOnStation] = points[x]; } } } @@ -166,27 +166,26 @@ void L1Grid::BuildBins(float yMin, float yMax, float zMin, float zMax, float tMi } -void L1Grid::StoreHits(L1HitIndex_t nhits, const L1Hit* hits, char iS, L1Algo& Algo, L1HitIndex_t n, L1Hit* hitsBuf1, - const L1Hit* hits1, L1HitIndex_t* indices1) +void L1Grid::StoreHits(L1Algo& Algo, char iS, L1HitIndex_t firstHitIndex, L1HitIndex_t nHits, const L1Hit hits[], + L1Hit gridHits[], L1HitIndex_t gridHitIds[]) { - fscal xs = 0; - fscal ys = 0; + fscal x = 0; + fscal y = 0; fFirstHitInBin.reset(fN + 2, 0); #ifdef _OPENMP -#pragma omp parallel for firstprivate(xs, ys) +#pragma omp parallel for firstprivate(x, y) #endif - for (L1HitIndex_t x = 0; x < nhits; x++) { - Algo.GetHitCoor((hits)[x], xs, ys, iS); - - - fHitsInBin[x] = fFirstHitInBin[GetBinBounded(xs, ys, (hits)[x].t) + 1]; + for (L1HitIndex_t ih = 0; ih < nHits; ih++) { + Algo.GetHitCoor((hits)[ih], x, y, iS); + auto bin = GetBinBounded(x, y, (hits)[ih].t); + fHitsInBin[ih] = fFirstHitInBin[bin + 1]; #ifdef _OPENMP #pragma omp atomic #endif - fFirstHitInBin[GetBinBounded(xs, ys, (hits)[x].t) + 1]++; + fFirstHitInBin[bin + 1]++; } @@ -214,22 +213,14 @@ void L1Grid::StoreHits(L1HitIndex_t nhits, const L1Hit* hits, char iS, L1Algo& A } -#pragma omp parallel for firstprivate(xs, ys) - for (L1HitIndex_t x = 0; x < nhits; x++) { - - Algo.GetHitCoor((hits1)[x], xs, ys, iS); - - - const L1HitIndex_t& bin = GetBinBounded(xs, ys, (hits1)[x].t); - +#pragma omp parallel for firstprivate(x, y) + for (L1HitIndex_t ih = 0; ih < nHits; ih++) { + Algo.GetHitCoor((hits)[ih], x, y, iS); + auto bin = GetBinBounded(x, y, (hits)[ih].t); { - - const L1HitIndex_t& index1 = fHitsInBin[x] + fFirstHitInBin[bin]; - - (hitsBuf1)[index1] = hits[x]; - - - (indices1)[index1] = x + n; + const L1HitIndex_t& index1 = fFirstHitInBin[bin] + fHitsInBin[ih]; + gridHits[index1] = hits[ih]; + gridHitIds[index1] = firstHitIndex + ih; } } } diff --git a/reco/L1/L1Algo/L1Grid.h b/reco/L1/L1Algo/L1Grid.h index 448145d786eeac5a68a6c997629e047028f71395..03d2d487dab999845bc6c5912af289b826382f59 100644 --- a/reco/L1/L1Algo/L1Grid.h +++ b/reco/L1/L1Algo/L1Grid.h @@ -43,8 +43,8 @@ public: ~L1Grid() = default; - void StoreHits(L1HitIndex_t nhits, const L1Hit* hits, char iS, L1Algo& Algo, L1HitIndex_t n, L1Hit* hitsBuf1, - const L1Hit* hits1, L1HitIndex_t* indices1); + void StoreHits(L1Algo& Algo, char iS, L1HitIndex_t firstHitIndex, L1HitIndex_t nHits, const L1Hit hits[], + L1Hit gridHits[], L1HitIndex_t gridHitIds[]); void CreatePar0(float yMin, float yMax, float zMin, float zMax, float sy, float sz); void BuildBins(float yMin, float yMax, float zMin, float zMax, float tMin, float tMax, float sy, float sz, float st); @@ -101,9 +101,9 @@ public: // }; - void UpdateIterGrid(unsigned int Nelements, L1Hit* hits, L1Vector<L1HitIndex_t>* indicesBuf, L1HitIndex_t* indices, - L1Vector<L1Hit>* hits2, L1Vector<L1HitPoint>* pointsBuf, L1HitPoint* points, int& NHitsOnStation, - char iS, L1Algo& Algo, const L1Vector<unsigned char>& vSFlag); + void UpdateIterGrid(unsigned int Nelements, L1Hit* hits, L1Vector<L1HitIndex_t>& indicesBuf, L1HitIndex_t* indices, + L1Vector<L1Hit>& hitsBuf, L1Vector<L1HitPoint>& pointsBuf, L1HitPoint* points, + int& NHitsOnStation, char iS, L1Algo& Algo, const L1Vector<unsigned char>& vSFlag); private: diff --git a/reco/L1/L1Algo/L1HitsSortHelper.cxx b/reco/L1/L1Algo/L1HitsSortHelper.cxx deleted file mode 100644 index 5030ff54c82817d6f4e12aba61b4a8db96c34010..0000000000000000000000000000000000000000 --- a/reco/L1/L1Algo/L1HitsSortHelper.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2012-2020 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt - SPDX-License-Identifier: GPL-3.0-only - Authors: Igor Kulakov [committer], Valentina Akishina */ - -#include "L1HitsSortHelper.h" - -#include <algorithm> -#include <vector> - -#include "L1Grid.h" -#include "L1Hit.h" -#include "L1HitPoint.h" - -using std::vector; - -L1HitsSortHelper::L1HitsSortHelper(vector<L1Hit>& hits, vector<L1HitPoint>& points, vector<L1HitIndex_t>& indices, - const L1Grid* grid, L1HitIndex_t* iStart, L1HitIndex_t* iStop, int nStations, - int nDontUsedHits) - : fD() - , fHits(hits) - , fPoints(points) - , fIndices(indices) - , fGrid(grid) - , fHitsUnusedStartIndex(iStart) - , fHitsUnusedStopIndex(iStop) - , fNStations(nStations) - , fnDontUsedHits(nDontUsedHits) -{ - L1_ASSERT(hits.size() == points.size(), hits.size() << " " << points.size()); - const int NHits = fnDontUsedHits; - fD.resize(NHits); - //float x,y=0; - for (int iS = 0; iS < fNStations; ++iS) - for (L1HitIndex_t i = fHitsUnusedStartIndex[iS]; i < fHitsUnusedStopIndex[iS]; i++) { - fD[i].h = &(hits[i]); - fD[i].p = &(points[i]); - fD[i].i = indices[i]; - // StripsToCoor(fD[i].p->U(),fD[i].p->V(), x, y, vStations[iS]); - // NOTE: Use vStations[iS].ConvUVtoXY() istead - // fD[i].bin = fGrid[iS].GetBinBounded(x[0], y[0]); - } -} - -void L1HitsSortHelper::Sort() -{ - for (int iS = 0; iS < fNStations; ++iS) { - std::sort(fD.begin() + fHitsUnusedStartIndex[iS], fD.begin() + fHitsUnusedStopIndex[iS], - L1HitsSortHelperData::compare); - } - - vector<L1Hit> hits = fHits; - vector<L1HitPoint> points = fPoints; - const int NHits = fD.size(); - for (int i = 0; i < NHits; i++) { - hits[i] = *fD[i].h; - points[i] = *fD[i].p; - fIndices[i] = fD[i].i; - } - fHits = hits; - fPoints = points; -} diff --git a/reco/L1/L1Algo/L1HitsSortHelper.h b/reco/L1/L1Algo/L1HitsSortHelper.h deleted file mode 100644 index 50236c95735258ed3fb2cf893a48f6e8242ce478..0000000000000000000000000000000000000000 --- a/reco/L1/L1Algo/L1HitsSortHelper.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2012-2020 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt - SPDX-License-Identifier: GPL-3.0-only - Authors: Igor Kulakov [committer], Maksym Zyzak */ - -#ifndef _L1HitsL1HitsSortHelper_h_ -#define _L1HitsL1HitsSortHelper_h_ - -#include <algorithm> -#include <vector> - -#include "L1Grid.h" -#include "L1Hit.h" -#include "L1HitPoint.h" - -using std::vector; - -struct L1HitsSortHelperData { - L1Hit* h; - L1HitPoint* p; - unsigned int bin; - L1HitIndex_t i; - - static bool compare(const L1HitsSortHelperData& a, const L1HitsSortHelperData& b) - { - return a.bin < b.bin || (a.bin == b.bin && a.p->V() < b.p->V()); - } -}; - -class L1HitsSortHelper { -public: - L1HitsSortHelper(vector<L1Hit>& hits, vector<L1HitPoint>& points, vector<L1HitIndex_t>& indices, const L1Grid* grid, - L1HitIndex_t* iStart, L1HitIndex_t* iStop, int nStations, int nDontUsedHits); - - void Sort(); - -private: - vector<L1HitsSortHelperData> fD; - vector<L1Hit>& fHits; - vector<L1HitPoint>& fPoints; - vector<L1HitIndex_t>& fIndices; - const L1Grid* fGrid; - L1HitIndex_t *fHitsUnusedStartIndex, *fHitsUnusedStopIndex; - int fNStations; - int fnDontUsedHits; - - L1HitsSortHelper(const L1HitsSortHelper&); - L1HitsSortHelper& operator=(const L1HitsSortHelper&); -}; - -#endif diff --git a/reco/L1/L1Algo/L1TrackPar.h b/reco/L1/L1Algo/L1TrackPar.h index 10eb77615bebea405ac417f1adfe8b7b47f2515b..6fe8491644a3d960a8f2e804517c062950e671bb 100644 --- a/reco/L1/L1Algo/L1TrackPar.h +++ b/reco/L1/L1Algo/L1TrackPar.h @@ -84,12 +84,12 @@ public: void InitVelocityRange(fscal minP); - static constexpr float kClightNs {29.9792458}; // the speed of light cm/ns - static constexpr float kClightNsInv {1. / 29.9792458}; // inverse speed of light - static constexpr float kProtonMass = 0.93827208816; - static constexpr float kPionMass = 0.1395703918; - static constexpr float kMuonMass = 0.105658375523; - static constexpr float kElectronMass = 0.0005109989500015; + static constexpr fscal kClightNs {29.9792458}; // the speed of light cm/ns + static constexpr fscal kClightNsInv {1. / 29.9792458}; // inverse speed of light + static constexpr fscal kProtonMass = 0.93827208816; + static constexpr fscal kPionMass = 0.1395703918; + static constexpr fscal kMuonMass = 0.105658375523; + static constexpr fscal kElectronMass = 0.0005109989500015; } _fvecalignment; diff --git a/reco/L1/L1Algo/L1Vector.h b/reco/L1/L1Algo/L1Vector.h index 5c77cd0b1dde9e9fa82005366510529a8b8d47d7..258b875b69efa79763eacdd7dacdc604658003ff 100644 --- a/reco/L1/L1Algo/L1Vector.h +++ b/reco/L1/L1Algo/L1Vector.h @@ -90,6 +90,16 @@ public: return *this; } + /// Swap operator + void swap(L1Vector& v) noexcept + { + //LOG(info) << "\033[1;32mCALL L1Vector swap operator\033[0m"; + if (this != &v) { + std::swap(fName, v.fName); + Tbase::swap(v); + } + } + void SetName(const std::string& s) { fName = s; } void SetName(const std::basic_ostream<char>& s)