diff --git a/macro/run/run_reco.C b/macro/run/run_reco.C index 3f5cd05a713c0975575365cac960ca2ed552aa64..b5d4c71fd8d81a491ab08ae1691f9520d7921239 100644 --- a/macro/run/run_reco.C +++ b/macro/run/run_reco.C @@ -390,6 +390,11 @@ void run_reco(TString input = "", Int_t nTimeSlices = -1, Int_t firstTimeSlice = std::cout << "Using material budget file " << parFile << std::endl; l1->SetStsMaterialBudgetFileName(parFile.Data()); } + + // ---- L1Algo runtime constants selection interface example ------ + l1->GetL1Parameters()->SetMaxDoubletsPerSinglet(125); + // ---------------------------------------------------------------- + run->AddTask(l1); std::cout << "-I- " << myName << ": Added task " << l1->GetName() << std::endl; diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 75ef4b77aebc678068517145abadfafea07bf6c4..968f1653866e96d200e2366ffcf31ce1790ad93e 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -752,6 +752,14 @@ InitStatus CbmL1::Init() LOG(error) << "-E- CbmL1: Read geometry from file " << fSTAPDataDir + "geo_algo.txt was NOT successful."; } + if (fL1ParametersPtr) { + algo->SetL1Parameters(*fL1ParametersPtr); + delete fL1ParametersPtr; + } else { + LOG(error) << "-E- CbmL1: L1Parameters object was not transfered to the L1Algo core. Default parameters " + << "will be used."; + } + algo->Init(geo, fUseHitErrors, fTrackingMode, fMissingHits); geo.clear(); @@ -1622,12 +1630,14 @@ void CbmL1::WriteSTAPAlgoData() // must be called after ReadEvent // write StsHitsStartIndex and StsHitsStopIndex n = 20; for (int i = 0; i < n; i++) { - if (int(algo->fkMaxNstations) + 1 > i) fadata << algo->StsHitsStartIndex[i] << endl; - else + if (int(L1Parameters::kMaxNstations) + 1 > i) { + fadata << algo->StsHitsStartIndex[i] << endl; + } else { fadata << 0 << endl; + } }; for (int i = 0; i < n; i++) { - if (int(algo->fkMaxNstations) + 1 > i) fadata << algo->StsHitsStopIndex[i] << endl; + if (int(L1Parameters::kMaxNstations) + 1 > i) fadata << algo->StsHitsStopIndex[i] << endl; else fadata << 0 << endl; }; @@ -1651,7 +1661,7 @@ void CbmL1::WriteSTAPPerfData() // must be called after ReadEvent TString fpdata_name = fSTAPDataDir + "data_perfo.txt"; // write data for performance in file // if ( vNEvent <= maxNEvent ) { - if (1) { + if (1) { if (vNEvent == 1) fpdata.open(fpdata_name, std::fstream::out); // begin new file else @@ -1878,16 +1888,16 @@ void CbmL1::ReadSTAPAlgoData() << " have been read." << endl; } // read StsHitsStartIndex and StsHitsStopIndex - n = 20; + n = 20; // TODO: Why 20? for (int i = 0; i < n; i++) { int tmp; fadata >> tmp; - if (int(algo->fkMaxNstations) + 1 > i) (const_cast<unsigned int&>(algo->StsHitsStartIndex[i]) = tmp); + if (int(L1Parameters::kMaxNstations) + 1 > i) (const_cast<unsigned int&>(algo->StsHitsStartIndex[i]) = tmp); } for (int i = 0; i < n; i++) { int tmp; fadata >> tmp; - if (int(algo->fkMaxNstations) + 1 > i) (const_cast<unsigned int&>(algo->StsHitsStopIndex[i]) = tmp); + if (int(L1Parameters::kMaxNstations) + 1 > i) (const_cast<unsigned int&>(algo->StsHitsStopIndex[i]) = tmp); } cout << "-I- CbmL1: CATrackFinder data for event " << nEvent << " has been read from file " << fadata_name diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index a4cd0d613b9dc9d2c3ce308980c407d980593585..0094e4e85349b9d20884a7f7acfae6b93bf4bae2 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -117,6 +117,8 @@ public: TString fSTAPDataDir_ = "./", int findParticleMode_ = 0); ~CbmL1(/*if (targetFieldSlice) delete;*/); + + L1Parameters* GetL1Parameters() { return fL1ParametersPtr; } void SetStsMaterialBudgetFileName(TString fileName) { fStsMatBudgetFileName = fileName; } void SetMvdMaterialBudgetFileName(TString fileName) { fMvdMatBudgetFileName = fileName; } @@ -215,6 +217,7 @@ public: private: static CbmL1* fInstance; + L1Parameters* fL1ParametersPtr {new L1Parameters()}; ///< pointer to L1Algo parameters class instance L1AlgoInputData* fData {nullptr}; @@ -222,12 +225,12 @@ private: int nMvdPoints {0}; L1Vector<int> vMCPoints_in_Time_Slice {"CbmL1::vMCPoints_in_Time_Slice"}; - int NStation {0}; // number of all detector stations - int NMvdStations {0}; // number of mvd stations - int NStsStations {0}; // number of sts stations - int NMuchStations {0}; // number of much stations - int NTrdStations {0}; // number of trd stations - int NTOFStation {0}; // number of tof stations + int NStation {0}; ///< number of all detector stations + int NMvdStations {0}; ///< number of mvd stations + int NStsStations {0}; ///< number of sts stations + int NMuchStations {0}; ///< number of much stations + int NTrdStations {0}; ///< number of trd stations + int NTOFStation {0}; ///< number of tof stations Int_t fPerformance {0}; // 0 - w\o perf. 1 - L1-Efficiency definition. 2 - QA-Eff.definition double fTrackingTime {0.}; // time of track finding diff --git a/reco/L1/L1Algo/L1Algo.cxx b/reco/L1/L1Algo/L1Algo.cxx index 8486c58e5ddfc4c8a211d6e08ea47daf51a048f5..c43f87e0c74600afec1786f0a5efbca3d70f78ab 100644 --- a/reco/L1/L1Algo/L1Algo.cxx +++ b/reco/L1/L1Algo/L1Algo.cxx @@ -10,16 +10,16 @@ L1Algo::L1Algo(unsigned int nThreads) { SetNThreads(nThreads); - for (unsigned int i = 0; i < fkMaxNstations; i++) { + for (unsigned int i = 0; i < L1Parameters::kMaxNstations; i++) { vGridTime[i].AllocateMemory(fNThreads); } } void L1Algo::SetNThreads(unsigned int n) { - if (n > static_cast<unsigned int>(fkMaxNthreads)) { + if (n > static_cast<unsigned int>(L1Parameters::kMaxNthreads)) { // TODO: Why do we need static_cast here? LOG(fatal) << "L1Algo: n threads " << n << " is greater than the maximum " - << static_cast<unsigned int>(fkMaxNthreads) << std::endl; + << static_cast<unsigned int>(L1Parameters::kMaxNthreads); // The same } fNThreads = n; @@ -52,7 +52,7 @@ void L1Algo::SetNThreads(unsigned int n) du[i].reserve(MaxPortionTriplets / fvecLen); dv[i].reserve(MaxPortionTriplets / fvecLen); - for (unsigned int j = 0; j < fkMaxNstations; j++) { + for (unsigned int j = 0; j < L1Parameters::kMaxNstations; j++) { fTriplets[j][i].SetName(std::stringstream() << "L1Algo::fTriplets[" << i << "][" << j << "]"); } } @@ -61,6 +61,7 @@ void L1Algo::SetNThreads(unsigned int n) void L1Algo::Init(const L1Vector<fscal>& geo, const bool UseHitErrors, const TrackingMode mode, const bool MissingHits) { + fL1Parameters.Print(); // TODO: Wrap this line into debug for (int iProc = 0; iProc < 4; iProc++) { for (int i = 0; i < 8; i++) { @@ -282,7 +283,7 @@ void L1Algo::SetData(L1Vector<L1Hit>& StsHits_, int nStsStrips_, L1Vector<unsign fRecoHits_local[i].reserve(nHits); fTrackCandidates[i].clear(); fTrackCandidates[i].reserve(nHits / 10); - for (unsigned int j = 0; j < fkMaxNstations; j++) { + for (unsigned int j = 0; j < L1Parameters::kMaxNstations; j++) { fTriplets[j][i].clear(); fTriplets[j][i].reserve(2 * nHits); } diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index a737c6583a4b6d9854e571e1fdc1e545ba7b39ad..c4c5057918456ce366aa1e695aec642e4cdb560b 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -95,62 +95,68 @@ public: float GetDefaultParticleMass2() const { return fDefaultMass * fDefaultMass; } float fDefaultMass = 0.10565800; // muon mass + // NOTE: technically it is a default value, so it can be modified + // with a setter. But on other hand it is a phys constant, so we must + // think again whether to handle the numerical literal as constexpr or not + //float fDefaultMass = L1Parameters::kMuonMass; // muon mass - static constexpr unsigned int fkStationBits = 6; - static constexpr unsigned int fkThreadBits = 6; - static constexpr unsigned int fkTripletBits = 32 - fkStationBits - fkThreadBits; + /////--> moved to L1Parameters + /////static constexpr unsigned int fkStationBits = 6; + /////static constexpr unsigned int fkThreadBits = 6; + /////static constexpr unsigned int fkTripletBits = 32 - fkStationBits - fkThreadBits; - static constexpr unsigned int fkMaxNstations = (1 << fkStationBits); // 2^6 =64 - static constexpr unsigned int fkMaxNthreads = (1 << fkThreadBits); // 2^6 = 64 - static constexpr unsigned int fkMaxNtriplets = (1 << fkTripletBits); // 2^20 = 262,144 + /////static constexpr unsigned int fkMaxNstations = (1 << fkStationBits); // 2^6 =64 + /////static constexpr unsigned int fkMaxNthreads = (1 << fkThreadBits); // 2^6 = 64 + /////static constexpr unsigned int fkMaxNtriplets = (1 << fkTripletBits); // 2^20 = 262,144 - unsigned int fMaxDoubletsPerSinglet = 150; - unsigned int fMaxTripletPerDoublets = 15; + /////--> moved to L1Parameters + /////unsigned int fMaxDoubletsPerSinglet = 150; + /////unsigned int fMaxTripletPerDoublets = 15; /// pack station, thread and triplet indices to an unique triplet ID static unsigned int PackTripletId(unsigned int Station, unsigned int Thread, unsigned int Triplet) { #ifndef FAST_CODE - assert(Station < fkMaxNstations); - assert(Thread < fkMaxNthreads); - assert(Triplet < fkMaxNtriplets); + assert(Station < L1Parameters::kMaxNstations); + assert(Thread < L1Parameters::kMaxNthreads); + assert(Triplet < L1Parameters::kMaxNtriplets); #endif - constexpr unsigned int kMoveThread = fkTripletBits; - constexpr unsigned int kMoveStation = fkTripletBits + fkThreadBits; + constexpr unsigned int kMoveThread = L1Parameters::kTripletBits; + constexpr unsigned int kMoveStation = L1Parameters::kTripletBits + L1Parameters::kThreadBits; return (Station << kMoveStation) + (Thread << kMoveThread) + Triplet; } /// unpack the triplet ID to its station index static unsigned int TripletId2Station(unsigned int ID) { - constexpr unsigned int kMoveStation = fkTripletBits + fkThreadBits; + constexpr unsigned int kMoveStation = L1Parameters::kTripletBits + L1Parameters::kThreadBits; return ID >> kMoveStation; } /// unpack the triplet ID to its thread index static unsigned int TripletId2Thread(unsigned int ID) { - constexpr unsigned int kMoveThread = fkTripletBits; - constexpr unsigned int kThreadMask = (1 << fkThreadBits) - 1; + constexpr unsigned int kMoveThread = L1Parameters::kTripletBits; + constexpr unsigned int kThreadMask = (1 << L1Parameters::kThreadBits) - 1; return (ID >> kMoveThread) & kThreadMask; } /// unpack the triplet ID to its triplet index static unsigned int TripletId2Triplet(unsigned int ID) { - constexpr unsigned int kTripletMask = (1 << fkTripletBits) - 1; + constexpr unsigned int kTripletMask = (1 << L1Parameters::kTripletBits) - 1; return ID & kTripletMask; } - L1Vector<L1Triplet> fTriplets[fkMaxNstations][fkMaxNthreads] { + L1Vector<L1Triplet> fTriplets[L1Parameters::kMaxNstations][L1Parameters::kMaxNthreads] { //<-------- {"L1Algo::fTriplets"}}; // created triplets at station + thread // Track candidates created out of adjacent triplets before the final track selection. // The candidates may share any amount of hits. - L1Vector<L1Branch> fTrackCandidates[fkMaxNthreads] {"L1Algo::fTrackCandidates"}; + L1Vector<L1Branch> fTrackCandidates[L1Parameters::kMaxNthreads] {"L1Algo::fTrackCandidates"}; - Tindex fDupletPortionStopIndex[fkMaxNstations] {0}; // end of the duplet portions for the station + Tindex fDupletPortionStopIndex[L1Parameters::kMaxNstations] {0}; // end of the duplet portions for the station L1Vector<Tindex> fDupletPortionSize {"L1Algo::fDupletPortionSize"}; // N duplets in a portion // @@ -207,18 +213,18 @@ public: void SetNThreads(unsigned int n); - int NStations {0}; // number of all detector stations - int NMvdStations {0}; // number of mvd stations - int NStsStations {0}; // number of sts stations - int fNfieldStations {0}; // number of stations in the field region + int NStations {0}; ///< number of all detector stations + int NMvdStations {0}; ///< number of mvd stations + int NStsStations {0}; ///< number of sts stations + int fNfieldStations {0}; ///< number of stations in the field region - L1Station vStations[fkMaxNstations] _fvecalignment; // station info + L1Station vStations[L1Parameters::kMaxNstations] _fvecalignment; // station info L1Vector<L1Material> fRadThick {"fRadThick"}; // material for each station int NStsStrips {0}; // number of strips L1Vector<L1Hit>* vStsHits {nullptr}; // hits as a combination of front-, backstrips and z-position - L1Grid vGrid[fkMaxNstations]; // hits as a combination of front-, backstrips and z-position - L1Grid vGridTime[fkMaxNstations]; + L1Grid vGrid[L1Parameters::kMaxNstations]; // hits as a combination of front-, backstrips and z-position + L1Grid vGridTime[L1Parameters::kMaxNstations]; L1Vector<unsigned char>* fStripFlag {nullptr}; // information of hits station & using hits in tracks; @@ -240,8 +246,8 @@ public: L1Vector<L1HitPoint> vStsDontUsedHitsxy_A {"L1Algo::vStsDontUsedHitsxy_A"}; L1Vector<L1HitPoint> vStsDontUsedHitsxy_buf {"L1Algo::vStsDontUsedHitsxy_buf"}; L1Vector<L1HitPoint> vStsDontUsedHitsxy_B {"L1Algo::vStsDontUsedHitsxy_B"}; - L1Vector<L1Track> fTracks_local[fkMaxNthreads] {"L1Algo::fTracks_local"}; - L1Vector<THitI> fRecoHits_local[fkMaxNthreads] {"L1Algo::fRecoHits_local"}; + L1Vector<L1Track> fTracks_local[L1Parameters::kMaxNthreads] {"L1Algo::fTracks_local"}; + L1Vector<THitI> fRecoHits_local[L1Parameters::kMaxNthreads] {"L1Algo::fRecoHits_local"}; L1Vector<THitI> RealIHit_v {"L1Algo::RealIHit_v"}; L1Vector<THitI> RealIHit_v_buf {"L1Algo::RealIHit_v_buf"}; @@ -260,8 +266,8 @@ public: bool fMissingHits {0}; TrackingMode fTrackingMode {kSts}; - fvec EventTime[fkMaxNthreads][fkMaxNthreads] {{0}}; - fvec Err[fkMaxNthreads][fkMaxNthreads] {{0}}; + fvec EventTime[L1Parameters::kMaxNthreads][L1Parameters::kMaxNthreads] {{0}}; + fvec Err[L1Parameters::kMaxNthreads][L1Parameters::kMaxNthreads] {{0}}; /// standard sizes of the arrays @@ -280,8 +286,7 @@ public: MaxArrSize = - MaxNPortion * MaxPortionDoublets - / fkMaxNstations //200000, // standart size of big arrays // mas be 40000 for normal work in cbmroot! + MaxNPortion * MaxPortionDoublets / L1Parameters::kMaxNstations //200000, // standart size of big arrays // mas be 40000 for normal work in cbmroot! }; @@ -294,38 +299,38 @@ public: L1Vector<L1HitPoint>* vStsHitPointsUnused {nullptr}; THitI* RealIHit {nullptr}; // index in vStsHits indexed by index in vStsHitsUnused - THitI StsHitsUnusedStartIndex[fkMaxNstations + 1] {0}; - THitI StsHitsUnusedStopIndex[fkMaxNstations + 1] {0}; - THitI StsHitsUnusedStartIndexEnd[fkMaxNstations + 1] {0}; - THitI StsHitsUnusedStopIndexEnd[fkMaxNstations + 1] {0}; + THitI StsHitsUnusedStartIndex[L1Parameters::kMaxNstations + 1] {0}; + THitI StsHitsUnusedStopIndex[L1Parameters::kMaxNstations + 1] {0}; + THitI StsHitsUnusedStartIndexEnd[L1Parameters::kMaxNstations + 1] {0}; + THitI StsHitsUnusedStopIndexEnd[L1Parameters::kMaxNstations + 1] {0}; - L1Vector<int> TripForHit[2] {"L1Algo::TripForHit"}; + L1Vector<int> TripForHit[2] {"L1Algo::TripForHit"}; // TODO: what does '2' stand for? // fvec u_front[Portion/fvecLen], u_back[Portion/fvecLen]; // fvec zPos[Portion/fvecLen]; // fvec fHitTime[Portion/fvecLen]; - nsL1::vector<L1TrackPar>::TSimd fT_3[fkMaxNthreads]; + nsL1::vector<L1TrackPar>::TSimd fT_3[L1Parameters::kMaxNthreads]; - L1Vector<THitI> fhitsl_3[fkMaxNthreads] {"L1Algo::fhitsl_3"}; - L1Vector<THitI> fhitsm_3[fkMaxNthreads] {"L1Algo::fhitsm_3"}; - L1Vector<THitI> fhitsr_3[fkMaxNthreads] {"L1Algo::fhitsr_3"}; + L1Vector<THitI> fhitsl_3[L1Parameters::kMaxNthreads] {"L1Algo::fhitsl_3"}; + L1Vector<THitI> fhitsm_3[L1Parameters::kMaxNthreads] {"L1Algo::fhitsm_3"}; + L1Vector<THitI> fhitsr_3[L1Parameters::kMaxNthreads] {"L1Algo::fhitsr_3"}; - nsL1::vector<fvec>::TSimd fu_front3[fkMaxNthreads]; - nsL1::vector<fvec>::TSimd fu_back3[fkMaxNthreads]; - nsL1::vector<fvec>::TSimd fz_pos3[fkMaxNthreads]; - nsL1::vector<fvec>::TSimd fTimeR[fkMaxNthreads]; - nsL1::vector<fvec>::TSimd fTimeER[fkMaxNthreads]; - nsL1::vector<fvec>::TSimd dx[fkMaxNthreads]; - nsL1::vector<fvec>::TSimd dy[fkMaxNthreads]; - nsL1::vector<fvec>::TSimd du[fkMaxNthreads]; - nsL1::vector<fvec>::TSimd dv[fkMaxNthreads]; + nsL1::vector<fvec>::TSimd fu_front3[L1Parameters::kMaxNthreads]; + nsL1::vector<fvec>::TSimd fu_back3[L1Parameters::kMaxNthreads]; + nsL1::vector<fvec>::TSimd fz_pos3[L1Parameters::kMaxNthreads]; + nsL1::vector<fvec>::TSimd fTimeR[L1Parameters::kMaxNthreads]; + nsL1::vector<fvec>::TSimd fTimeER[L1Parameters::kMaxNthreads]; + nsL1::vector<fvec>::TSimd dx[L1Parameters::kMaxNthreads]; + nsL1::vector<fvec>::TSimd dy[L1Parameters::kMaxNthreads]; + nsL1::vector<fvec>::TSimd du[L1Parameters::kMaxNthreads]; + nsL1::vector<fvec>::TSimd dv[L1Parameters::kMaxNthreads]; - // Tindex NHits_l[fkMaxNstations]; - // Tindex NHits_l_P[fkMaxNstations]; + // Tindex NHits_l[L1Parameters::kMaxNstations]; + // Tindex NHits_l_P[L1Parameters::kMaxNstations]; /// ----- Output data ----- friend class CbmL1; @@ -359,7 +364,19 @@ public: inline __attribute__((always_inline)) static bool GetFUsed(unsigned char flag) { return (flag & 0x02) != 0; } // bool GetFUsedD ( unsigned char flag ){ return (flag&0x01)!=0; } -private: + + /// Sets L1Algo parameters object + void SetL1Parameters(const L1Parameters& other) { fL1Parameters = other; } + /// Gets a constant reference to the L1Algo parameters object + const L1Parameters& GetL1Parameters() const { return fL1Parameters; } + // TODO: We should think about, where non-constexpr L1Alog parameters can be modified. At the moment we can create a + // L1Parameters object somewhere outside the L1Algo, fill its fields there and then pass it directly to + // the L1Algo instance. + + private: + /// Object containing L1Parameters. Default consturctor is used + L1Parameters fL1Parameters; + /// ================================= FUNCTIONAL PART ================================= /// ----- Subroutines used by L1Algo::CATrackFinder() ------ diff --git a/reco/L1/L1Algo/L1BaseStationInfo.h b/reco/L1/L1Algo/L1BaseStationInfo.h index 4b5a05701d9b6127f6a555d05d604500671834e8..ed524727a22a81b1d78b305d1295038167bde926 100644 --- a/reco/L1/L1Algo/L1BaseStationInfo.h +++ b/reco/L1/L1Algo/L1BaseStationInfo.h @@ -27,11 +27,13 @@ #include <iomanip> //#include <cmath> +/// A base class which provides interface to L1Algo station geometry + class L1BaseStationInfo { -private: + private: enum { // Here we list all the fields, which must be initialized by user - /// v Basic fields initialization - /// v L1Station initialization + // Basic fields initialization + // L1Station initialization kEtype, kEtimeInfo, kEz, @@ -44,18 +46,10 @@ private: kEstripsFrontSigma, kEstripsBackPhi, kEstripsBackSigma, - /// v The last item is equal to the number of bits in fInitFlags + // The last item is equal to the number of bits in fInitFlags kEND }; - std::bitset<L1BaseStationInfo::kEND> fInitFlags; /// Set of - std::string fTypeName {"BASE"}; - L1Station fL1Station {}; - // TODO (!!!!) MUST THINK ABOUT THIS OBJECT LIFE TIME: will it be better to copy - // or to move it to the core? If the second, what should we do with - // getters? Do we need to lock them, when the fL1Station object will - // be transfered? - -public: + public: L1BaseStationInfo() { std::cout << ">>>>>> L1BaseStationInfo: Constructor called\n"; // Temporary } @@ -63,35 +57,41 @@ public: std::cout << ">>>>>> L1BaseStationInfo: Destructor called\n"; // Temporary } - ///-----------------------------------------------------------------------------------------------------/// - /// Basic methods /// - ///-----------------------------------------------------------------------------------------------------/// + //-------------------------------------------------------------------------------------------------------// + // Basic methods // + //-------------------------------------------------------------------------------------------------------// - std::string GetTypeName() const { return fTypeName; } - // Checks if all the necessary fields are initialized by user - bool IsInitialized() const { return fInitFlags.size() == fInitFlags.count(); }; - // Transfers all gathered data to L1Algo + /// Returns the name of the station (TODO: connect official naming) + std::string GetTypeName() const { return fTypeName; } + /// Checks if all the necessary fields are initialized by user + bool IsInitialized() const { return fInitFlags.size() == fInitFlags.count(); } + /// Transfers all gathered data to L1Algo (TODO) void TransferL1Station() { /**********/ } void TransferData() { /*********/ } - ///-----------------------------------------------------------------------------------------------------/// - /// Interface for L1Station object initialization /// - ///-----------------------------------------------------------------------------------------------------/// - - /// Setters + //-------------------------------------------------------------------------------------------------------// + // Interface for L1Station object initialization // + //-------------------------------------------------------------------------------------------------------// - // Sets type of station // TODO: Temporary method, must be selected automatically in the derived class + // + // Setters + // + /// Sets type of station void SetStationType(int inType) { fL1Station.type = inType; fInitFlags[kEtype] = true;} + // TODO: Temporary method, a type must be selected automatically in the derived classes void SetTimeInfo(int inTimeInfo) { fL1Station.timeInfo = inTimeInfo; fInitFlags[kEtimeInfo] = true;} + // ??? + /// Sets nominal z position of the station void SetZ(double inZ) { fL1Station.z = inZ; fInitFlags[kEz] = true; } + /// Sets min transverse size of the station void SetRmin(double inRmin) { fL1Station.Rmin = inRmin; fInitFlags[kERmin] = true; } + /// Sets max transverse size of the station void SetRmax(double inRmax) { fL1Station.Rmax = inRmax; fInitFlags[kERmax] = true; } - // Sets material thickness and radiational length, calculates their ratio ("RadThick") - // and its logarithm ("logRadThick") + /// Sets station thickness and radiational length void SetMaterial(double inThickness, double inRL) { #ifndef L1_NO_ASSERT // check for zero denominator L1_ASSERT(inRL, "Attempt of entering zero inRL (radiational length) value"); @@ -104,9 +104,9 @@ public: fInitFlags[kEmaterialInfoRL] = true; } - // Sets coefficients of the magnetic field approximation - void SetFieldSlice(const double * Cx, const double * Cy, const double * Cz) { - for (int idx = 0; idx < L1Parameters::kN_FS_COEFFS; ++idx) { + /// Sets arrays of the approximation coefficients for the field x, y and z-components, respectively + void SetFieldSlice(const double* Cx, const double* Cy, const double* Cz) { + for (int idx = 0; idx < L1Parameters::kMaxNFieldApproxCoefficients; ++idx) { fL1Station.fieldSlice.cx[idx] = Cx[idx]; fL1Station.fieldSlice.cy[idx] = Cy[idx]; fL1Station.fieldSlice.cz[idx] = Cz[idx]; @@ -114,11 +114,12 @@ public: } } - // Sets stereo angles and sigmas for front and back strips, automatically set frontInfo, backInfo, - // XYInfo, xInfo and yInfo - void SetFBStripsGeometry(double f_phi, double f_sigma, double b_phi, double b_sigma) { + /// Sets stereo angles and sigmas for front and back strips, automatically set frontInfo, backInfo, + /// XYInfo, xInfo and yInfo + void SetFrontBackStripsGeometry(double f_phi, double f_sigma, double b_phi, double b_sigma) { // TODO: may be is it better to define separate setters for these values and then calculate the // rest somewhere below? + // TODO: move into .cxx file //----- Original code from L1Algo ---------------------------------------------------------------------// double c_f = cos(f_phi); @@ -176,34 +177,48 @@ public: fInitFlags[kEstripsBackSigma] = true; } - /// Getters + // + // Getters + // + + /// Gets nominal z position of the station fvec GetZ() const { return fL1Station.z; } + /// Gets min transverse size of the station fvec GetRmin() const { return fL1Station.Rmin; } + /// Gets max transverse size of the station fvec GetRmax() const { return fL1Station.Rmax; } + /// Gets material thickness fvec GetMaterialThick() const { return fL1Station.materialInfo.thick; } // TODO: investigate if thick, RL and RadThick are useful, may be we should have only // GetMateralLogRadThick? + /// Gets the radiation length of the station material fvec GetMaterialRL() const { return fL1Station.materialInfo.RL; } // TODO: -//- - fvec GetMaterialRadThick() const { return fL1Station.materialInfo.RadThick; } // TODO: -//- + /// Gets the relative material thickness in units of the radiational length + fvec GetMaterialRadThick() const { return fL1Station.materialInfo.RadThick; } // TODO: Rename? + /// Gets log of the relative material thickness in units of the radiational length fvec GetMaterialLogRadThick() const { return fL1Station.materialInfo.logRadThick; } - // Methods to get particular element of Cx, Cy or Cz by its index + /// Gets a coefficient with idx for the field x-component approximation fvec GetFieldSliceCx(int idx) const { return fL1Station.fieldSlice.cx[idx]; } + /// Gets a coefficient with idx for the field y-component approximation fvec GetFieldSliceCy(int idx) const { return fL1Station.fieldSlice.cy[idx]; } + /// Gets a coefficient with idx for the field z-component approximation fvec GetFieldSliceCz(int idx) const { return fL1Station.fieldSlice.cz[idx]; } - // Methods to get ptr to array of Cx, Cy or Cz + /// Gets array of the coefficients for the field x-component approximation const fvec * GetFieldSliceCx() const { return fL1Station.fieldSlice.cx; } + /// Gets array of the coefficients for the field y-component approximation const fvec * GetFieldSliceCy() const { return fL1Station.fieldSlice.cy; } + /// Gets array of the coefficients for the field z-component approximation const fvec * GetFieldSliceCz() const { return fL1Station.fieldSlice.cz; } - // Methods to get strip layers geometry - ///-----------------------------------------------------------------------------------------------------/// - /// Other methods /// - ///-----------------------------------------------------------------------------------------------------/// + //-------------------------------------------------------------------------------------------------------// + // Other methods // + //-------------------------------------------------------------------------------------------------------// + /// Prints registered fields (TODO: tmp, may be one needs to wrap it into debug directives) void Print() { LOG(INFO) << "== L1Algo: station info ==========================================================="; LOG(INFO) << ""; @@ -217,7 +232,7 @@ public: LOG(INFO) << " log(X / X0): " << fL1Station.materialInfo.logRadThick[0] ; LOG(INFO) << " Field approximation coefficients:"; LOG(INFO) << " idx CX CY CZ"; - for (int idx = 0; idx < L1Parameters::kN_FS_COEFFS; ++idx) { + for (int idx = 0; idx < L1Parameters::kMaxNFieldApproxCoefficients; ++idx) { LOG(INFO) << std::setw(9) << std::setfill(' ') << idx << ' ' << std::setw(10) << std::setfill(' ') << fL1Station.fieldSlice.cx[idx][0] << ' ' << std::setw(10) << std::setfill(' ') << fL1Station.fieldSlice.cy[idx][0] << ' ' @@ -247,8 +262,20 @@ public: LOG(INFO) << ""; LOG(INFO) << "==================================================================================="; } - + private: + /// Flags set. A particular flag is up if the corresponding setter was called (experimental) + std::bitset<L1BaseStationInfo::kEND> fInitFlags; + std::string fTypeName {"BASE"}; + L1Station fL1Station {}; + // TODO (!!!!) MUST THINK ABOUT THIS OBJECT LIFE TIME: will it be better to copy + // or to move it to the core? If the second, what should we do with + // getters? Do we need to lock them, when the fL1Station object will + // be transfered? + + }; + + #endif // L1BaseStationInfo_h diff --git a/reco/L1/L1Algo/L1CATrackFinder.cxx b/reco/L1/L1Algo/L1CATrackFinder.cxx index 07170c1d5a67ccab43ed3cc44fc4ff4a2ff44a69..4c1275bb8b3a3074401f6da5ed4171c64802393f 100644 --- a/reco/L1/L1Algo/L1CATrackFinder.cxx +++ b/reco/L1/L1Algo/L1CATrackFinder.cxx @@ -540,10 +540,10 @@ inline void L1Algo::f20( #ifndef FAST_CODE //TODO: optimise triplet portion limit and put a warning -// assert(Ndoublets < fMaxDoubletsPerSinglet); +// assert(Ndoublets < fL1Parameters.GetMaxDoubletsPerSinglet()); #endif - if (Ndoublets >= fMaxDoubletsPerSinglet) { + if (Ndoublets >= fL1Parameters.GetMaxDoubletsPerSinglet()) { n2 = n2 - Ndoublets; i1_2.reduce(i1_2.size() - Ndoublets); hitsm_2.reduce(hitsm_2.size() - Ndoublets); @@ -868,9 +868,9 @@ inline void L1Algo::f30( // input #ifndef FAST_CODE //TODO: optimise triplet portion limit and put a warning -// assert(Ntriplets < fMaxTripletPerDoublets); +// assert(Ntriplets < fL1Parameters.GetMaxTripletPerDoublets()); #endif - if (Ntriplets >= fMaxTripletPerDoublets) { + if (Ntriplets >= fL1Parameters.GetMaxTripletPerDoublets()) { n3 = n3 - Ntriplets; @@ -1648,7 +1648,7 @@ void L1Algo::CATrackFinder() // static Tindex stat_nDoublets[fNFindIterations] = {0}; static Tindex stat_nTriplets[fNFindIterations] = {0}; - static Tindex stat_nLevels[fkMaxNstations - 2][fNFindIterations] = {{0}}; + static Tindex stat_nLevels[L1Parameters::kMaxNstations - 2][fNFindIterations] = {{0}}; static Tindex stat_nCalls[fNFindIterations] = {0}; // n calls of CAFindTrack static Tindex stat_nTrCandidates[fNFindIterations] = {0}; #endif @@ -1893,7 +1893,7 @@ void L1Algo::CATrackFinder() || (isec == kAllSecEIter) || (isec == kAllSecJumpIter)) MaxDZ = 0.1; - if (NStations > (int) fkMaxNstations) cout << " CATrackFinder: Error: Too many Stations" << endl; + if (NStations > (int) L1Parameters::kMaxNstations) cout << " CATrackFinder: Error: Too many Stations" << endl; } #ifndef L1_NO_ASSERT @@ -1977,9 +1977,9 @@ void L1Algo::CATrackFinder() L1Vector<THitI> hitsmG_2("L1CATrackFinder::hitsmG_2"); /// middle hits indexed by number of doublets in portion(i2) L1Vector<THitI> i1G_2( "L1CATrackFinder::i1G_2"); /// index in portion of singlets(i1) indexed by index in portion of doublets(i2) - L1Vector<char> lmDuplets[fkMaxNstations] { + L1Vector<char> lmDuplets[L1Parameters::kMaxNstations] { "L1CATrackFinder::lmDuplets"}; // is exist a doublet started from indexed by left hit - L1Vector<char> lmDupletsG[fkMaxNstations] { + L1Vector<char> lmDupletsG[L1Parameters::kMaxNstations] { "L1CATrackFinder::lmDupletsG"}; // is exist a doublet started from indexed by left hit for (int i = 0; i < NStations; i++) { @@ -2062,7 +2062,7 @@ void L1Algo::CATrackFinder() } // } - // int nlevels[fkMaxNstations]; // number of triplets with some number of neighbours. + // int nlevels[L1Parameters::kMaxNstations]; // number of triplets with some number of neighbours. // for (int il = 0; il < NStations; ++il) nlevels[il] = 0; // // f5( // input @@ -2103,7 +2103,7 @@ void L1Algo::CATrackFinder() L1Branch curr_tr; - L1Branch new_tr[fkMaxNstations]; + L1Branch new_tr[L1Parameters::kMaxNstations]; L1Branch best_tr; fscal curr_chi2 = 0; diff --git a/reco/L1/L1Algo/L1Field.h b/reco/L1/L1Algo/L1Field.h index 114313ab58c6eafca10a08ca2cb587988853bc9c..c417dd86ce56cab3d0978de3720d0e368348bcae 100644 --- a/reco/L1/L1Algo/L1Field.h +++ b/reco/L1/L1Algo/L1Field.h @@ -40,13 +40,13 @@ public: class L1FieldSlice { public: - fvec cx[L1Parameters::kN_FS_COEFFS]; - fvec cy[L1Parameters::kN_FS_COEFFS]; - fvec cz[L1Parameters::kN_FS_COEFFS]; // polinom coeff. + fvec cx[L1Parameters::kMaxNFieldApproxCoefficients]; + fvec cy[L1Parameters::kMaxNFieldApproxCoefficients]; + fvec cz[L1Parameters::kMaxNFieldApproxCoefficients]; // polinom coeff. L1FieldSlice() { - for (int i = 0; i < L1Parameters::kN_FS_COEFFS; ++i) + for (int i = 0; i < L1Parameters::kMaxNFieldApproxCoefficients; ++i) cx[i] = cy[i] = cz[i] = 0; } diff --git a/reco/L1/L1Algo/L1Parameters.h b/reco/L1/L1Algo/L1Parameters.h index 72b49c2c46c5d727cbc99cd799466a460670b3f3..ee0091d265b34e334c8089ad0e34f7800550975b 100644 --- a/reco/L1/L1Algo/L1Parameters.h +++ b/reco/L1/L1Algo/L1Parameters.h @@ -12,13 +12,84 @@ #ifndef L1Parameters_h #define L1Parameters_h 1 +#include <FairLogger.h> + class L1Parameters { -public: - ///-----------------------------------------------------------------------------------------------------/// - /// Array sizes /// - ///-----------------------------------------------------------------------------------------------------/// - // Amount of elements in cx, cy and cz coefficient arrays of L1FieldSlice - static constexpr int kN_FS_COEFFS {21}; // TODO: May be we should return the order of polynomial? + public: + //-------------------------------------------------------------------------------------------------------// + // Compile time constants // + //-------------------------------------------------------------------------------------------------------// + /// Amount of coefficients in field approximations + static constexpr int kMaxNFieldApproxCoefficients {21}; // TODO: May be it is better to use the polynomial + // order instead of this? + /// Amount of bits to code one station + static constexpr unsigned int kStationBits {6}; + /// Amount of bits to code one thread + static constexpr unsigned int kThreadBits {6}; + /// Amount of bits to code one triple + static constexpr unsigned int kTripletBits {32 - kStationBits - kThreadBits}; + + /// Max number of stations + static constexpr unsigned int kMaxNstations {1 << kStationBits}; // 2^6 = 64 + /// Max number of threads + static constexpr unsigned int kMaxNthreads {1 << kThreadBits}; // 2^6 = 64 + /// Max number of triplets + static constexpr unsigned int kMaxNtriplets {1 << kTripletBits}; // 2^20 = 1,048,576 + + public: + //-------------------------------------------------------------------------------------------------------// + // Basic methods // + //-------------------------------------------------------------------------------------------------------// + /// Default constructor + L1Parameters() = default; + /// Destructor + ~L1Parameters() = default; + /// Copy constructor + L1Parameters(const L1Parameters& /*other*/) = default; + /// Copy assignment operator + L1Parameters& operator=(const L1Parameters& /*other*/) = default; + /// Move constructor + L1Parameters(L1Parameters&& /*other*/) = default; + /// Move assignment operator + L1Parameters& operator=(L1Parameters&& /*other*/) = default; + /// Prints configuration + void Print() { + LOG(INFO) << "== L1Algo parameters =============================================================="; + LOG(INFO) << ""; + LOG(INFO) << " COMPILE TIME CONSTANTS"; + LOG(INFO) << " Bits to code one station: " << kStationBits; + LOG(INFO) << " Bits to code one thread: " << kThreadBits; + LOG(INFO) << " Bits to code one triplet: " << kTripletBits; + LOG(INFO) << " Max number of stations: " << kMaxNstations; + LOG(INFO) << " Max number of threads: " << kMaxNthreads; + LOG(INFO) << " Max number of triplets: " << kMaxNtriplets; + LOG(INFO) << ""; + LOG(INFO) << " RUNTIME CONSTANTS (CUTS)"; + LOG(INFO) << " Max number of doublets per singlet: " << fMaxDoubletsPerSinglet; + LOG(INFO) << " Max number of triplets per doublet: " << fMaxTripletPerDoublets; + LOG(INFO) << "==================================================================================="; + } + // TODO: change constant names with actual (human) names + // TODO: create a map with parameters, their description and + + public: + //-------------------------------------------------------------------------------------------------------// + // Runtime constants // + //-------------------------------------------------------------------------------------------------------// + /// Sets upper-bound cut on max number of doublets per one singlet + void SetMaxDoubletsPerSinglet(unsigned int value) { fMaxDoubletsPerSinglet = value; } + /// Sets upper-bound cut on max number of triplets per one doublet + void SetMaxTripletPerDoublets(unsigned int value) { fMaxTripletPerDoublets = value; } + + unsigned int GetMaxDoubletsPerSinglet() const { return fMaxDoubletsPerSinglet; } + unsigned int GetMaxTripletPerDoublets() const { return fMaxTripletPerDoublets; } + + + private: + /// + unsigned int fMaxDoubletsPerSinglet {150}; + /// + unsigned int fMaxTripletPerDoublets {15}; }; diff --git a/reco/L1/L1Algo/L1TrackFitter.cxx b/reco/L1/L1Algo/L1TrackFitter.cxx index a6fd48a3d9d2ccdf70fb2f2d18a4bdc74420ddb4..da68b3fc4e4727337ca0ae9c797b6ec545d9aed7 100644 --- a/reco/L1/L1Algo/L1TrackFitter.cxx +++ b/reco/L1/L1Algo/L1TrackFitter.cxx @@ -352,17 +352,19 @@ void L1Algo::L1KFTrackFitter() L1Station* sta = vStations; L1Station staFirst, staLast; - fvec x[fkMaxNstations], u[fkMaxNstations], v[fkMaxNstations], y[fkMaxNstations], time[fkMaxNstations], - timeEr[fkMaxNstations], z[fkMaxNstations]; - fvec d_x[fkMaxNstations], d_y[fkMaxNstations], d_xy[fkMaxNstations], d_u[fkMaxNstations], d_v[fkMaxNstations]; + fvec x[L1Parameters::kMaxNstations], u[L1Parameters::kMaxNstations], v[L1Parameters::kMaxNstations], + y[L1Parameters::kMaxNstations], time[L1Parameters::kMaxNstations], timeEr[L1Parameters::kMaxNstations], + z[L1Parameters::kMaxNstations]; + fvec d_x[L1Parameters::kMaxNstations], d_y[L1Parameters::kMaxNstations], d_xy[L1Parameters::kMaxNstations], + d_u[L1Parameters::kMaxNstations], d_v[L1Parameters::kMaxNstations]; fvec x_first, y_first, time_first, x_last, y_last, time_last, time_er_first, time_er_last, d_x_fst, d_y_fst, d_xy_fst, time_er_lst, d_x_lst, d_y_lst, d_xy_lst; - fvec Sy[fkMaxNstations], w[fkMaxNstations], w_time[fkMaxNstations]; + fvec Sy[L1Parameters::kMaxNstations], w[L1Parameters::kMaxNstations], w_time[L1Parameters::kMaxNstations]; fvec y_temp, x_temp; fvec fldZ0, fldZ1, fldZ2, z_start, z_end; - L1FieldValue fB[fkMaxNstations], fB_temp _fvecalignment; + L1FieldValue fB[L1Parameters::kMaxNstations], fB_temp _fvecalignment; - fvec ZSta[fkMaxNstations]; + fvec ZSta[L1Parameters::kMaxNstations]; for (int iHit = 0; iHit < nHits; iHit++) { ZSta[iHit] = sta[iHit].z; } @@ -384,7 +386,7 @@ void L1Algo::L1KFTrackFitter() for (iVec = 0; iVec < nTracks_SIMD; iVec++) { int nHitsTrack = t[iVec]->NHits; - int iSta[fkMaxNstations]; + int iSta[L1Parameters::kMaxNstations]; for (i = 0; i < nHitsTrack; i++) { const L1Hit& hit = (*vStsHits)[fRecoHits[start_hit++]]; const int ista = (*fStripFlag)[hit.f] / 4; @@ -774,18 +776,20 @@ void L1Algo::L1KFTrackFitterMuch() L1Station* sta = vStations; L1Station staFirst, staLast; - fvec x[fkMaxNstations], u[fkMaxNstations], v[fkMaxNstations], y[fkMaxNstations], time[fkMaxNstations], - timeEr[fkMaxNstations], z[fkMaxNstations]; - fvec d_x[fkMaxNstations], d_y[fkMaxNstations], d_xy[fkMaxNstations], d_u[fkMaxNstations], d_v[fkMaxNstations]; + fvec x[L1Parameters::kMaxNstations], u[L1Parameters::kMaxNstations], v[L1Parameters::kMaxNstations], + y[L1Parameters::kMaxNstations], time[L1Parameters::kMaxNstations], timeEr[L1Parameters::kMaxNstations], + z[L1Parameters::kMaxNstations]; + fvec d_x[L1Parameters::kMaxNstations], d_y[L1Parameters::kMaxNstations], d_xy[L1Parameters::kMaxNstations], + d_u[L1Parameters::kMaxNstations], d_v[L1Parameters::kMaxNstations]; fvec x_first, y_first, time_first, x_last, y_last, time_last, time_er_fst, d_x_fst, d_y_fst, d_xy_fst, time_er_lst, d_x_lst, d_y_lst, d_xy_lst, dz; - int iSta[fkMaxNstations]; - fvec Sy[fkMaxNstations], w[fkMaxNstations]; + int iSta[L1Parameters::kMaxNstations]; + fvec Sy[L1Parameters::kMaxNstations], w[L1Parameters::kMaxNstations]; fvec y_temp, x_temp; fvec fldZ0, fldZ1, fldZ2, z_start, z_end; - L1FieldValue fB[fkMaxNstations], fB_temp _fvecalignment; + L1FieldValue fB[L1Parameters::kMaxNstations], fB_temp _fvecalignment; - fvec ZSta[fkMaxNstations]; + fvec ZSta[L1Parameters::kMaxNstations]; for (int iHit = 0; iHit < nHits; iHit++) { ZSta[iHit] = sta[iHit].z; }