diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt index 6030fd375f2b53e3694c02e3443f3ad8a5981296..f56f35c3b4c44d590019eef124bf8c2104eff20e 100644 --- a/reco/L1/CMakeLists.txt +++ b/reco/L1/CMakeLists.txt @@ -134,6 +134,7 @@ L1Algo/L1HitsSortHelper.cxx L1Algo/L1Grid.cxx CbmL1Performance.cxx CbmL1ReadEvent.cxx +L1Algo/L1Station.cxx L1Algo/L1TrackParFit.cxx L1Algo/L1Event.cxx L1Algo/L1EventMatch.cxx @@ -275,7 +276,7 @@ Install(FILES CbmL1Counters.h L1Algo/L1InitManager.h L1Algo/L1CAIteration.h L1Algo/L1Parameters.h - L1Algo/utils/L1AlgoFunctions.h + L1Algo/utils/L1Utils.h vectors/vec_arithmetic.h vectors/std_alloc.h DESTINATION include diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 7d1ff1efe9682841cbf48e5f7a3204be88c686b9..1042707d8500bf696b7a28a58e528701fa71f7c2 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -745,7 +745,7 @@ InitStatus CbmL1::Init() } } - // TODO: replace these values to L1Parameters + // TODO: replace these values to L1Parameters (S.Zh.) geo.push_back(fTrackingLevel); geo.push_back(fMomentumCutOff); geo.push_back(fGhostSuppression); @@ -796,11 +796,11 @@ InitStatus CbmL1::Init() // Step 4: initialize IDs of detectors active in tracking - // TODO: temporary for tests, must be initialized somewhere in run_reco.C or similar + // TODO: temporary for tests, must be initialized somewhere in run_reco.C or similar (S.Zh.) fActiveTrackingDetectorIDs = {L1DetectorID::kMvd, L1DetectorID::kSts}; initMan->SetActiveDetectorIDs(fActiveTrackingDetectorIDs); - constexpr double PI = 3.14159265358; // TODO: why cmath is not used? + constexpr double PI = 3.14159265358; // TODO: why cmath is not used? (S.Zh.) // Step 5: initialize number of stations for each detector ID initMan->SetStationsNumberCrosscheck(L1DetectorID::kMvd, NMvdStations); @@ -818,7 +818,8 @@ InitStatus CbmL1::Init() CbmKFTube& t = CbmKF::Instance()->vMvdMaterial[iSt]; auto stationInfo = L1BaseStationInfo(L1DetectorID::kMvd, iSt); - stationInfo.SetStationType(1); // MVD // TODO: to be exchanged with specific flags (timeInfo, fieldInfo etc.) + stationInfo.SetStationType(1); + // MVD // TODO: to be exchanged with specific flags (timeInfo, fieldInfo etc.) (S.Zh.) stationInfo.SetTimeInfo(0); stationInfo.SetZ(t.z); stationInfo.SetMaterial(t.dz, t.RadLength); @@ -838,7 +839,7 @@ InitStatus CbmL1::Init() for (int iSt = 0; iSt < NStsStations; ++iSt) { // NOTE: example using smart pointers auto cbmSts = CbmStsSetup::Instance()->GetStation(iSt); std::unique_ptr<L1BaseStationInfo> stationInfo(new L1BaseStationInfo(L1DetectorID::kSts, iSt)); - // TODO: replace with std::make_unique, when C++14 is avaliable!!!! + // TODO: replace with std::make_unique, when C++14 is avaliable!!!! (S.Zh.) // auto stsStation = std::make_unique<L1BaseStationInfo>(L1DetectorID::kSts, iSt); stationInfo->SetStationType(0); // STS stationInfo->SetTimeInfo(1); @@ -854,7 +855,6 @@ InitStatus CbmL1::Init() stationInfo->SetMaterial(cbmSts->GetSensorD(), cbmSts->GetRadLength()); // Setup strips geometry - // TODO: why fscal instead of double in initialization? fscal stsFrontPhi = cbmSts->GetSensorRotation() + cbmSts->GetSensorStereoAngle(0) * PI / 180.; fscal stsBackPhi = cbmSts->GetSensorRotation() + cbmSts->GetSensorStereoAngle(1) * PI / 180.; fscal stsFrontSigma = cbmSts->GetSensorPitch(0) / sqrt(12); @@ -871,10 +871,11 @@ InitStatus CbmL1::Init() CbmMuchLayer* layer = station->GetLayer(muchLayerID); auto stationInfo = L1BaseStationInfo(L1DetectorID::kMuch, iSt); - stationInfo.SetStationType(2); // MVD // TODO: to be exchanged with specific flags (timeInfo, fieldInfo etc.) + stationInfo.SetStationType(2); + // MVD // TODO: to be exchanged with specific flags (timeInfo, fieldInfo etc.) (S.Zh.) stationInfo.SetTimeInfo(1); stationInfo.SetZ(layer->GetZ()); - stationInfo.SetMaterial(layer->GetDz(), 0); // TODO: Why rad len is 0????? + stationInfo.SetMaterial(layer->GetDz(), 0); // TODO: Why rad len is 0????? (S.Zh.) stationInfo.SetXmax(100.); stationInfo.SetYmax(100.); stationInfo.SetRmin(0.); @@ -2071,7 +2072,7 @@ void CbmL1::ReadSTAPAlgoData() << " have been read." << endl; } // read StsHitsStartIndex and StsHitsStopIndex - n = 20; // TODO: Why 20? + n = 20; // TODO: Why 20? (S.Zh.) for (int i = 0; i < n; i++) { int tmp; fadata >> tmp; diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index efd73cbaa127b36805ff71f93345e6540f7f09fa..8be4660f0e56857582852910d7e4cddaf5f8cd50 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -99,7 +99,7 @@ enum class L1DetectorID }; -// TODO: insert documentation! +// TODO: insert documentation! (S.Zh.) // /// L1Algo runtime constants modification can be performed in run_reco.C. Example: /// @@ -144,7 +144,7 @@ public: L1Parameters* GetL1Parameters() { return &fL1Parameters; } /// Gets a set of active detectors used in tracking - // TODO: think about return (value, reference or const reference?) + // TODO: think about return (value, reference or const reference?) (S.Zh.) std::set<L1DetectorID> GetActiveTrackingDetectorIDs() const { return fActiveTrackingDetectorIDs; } /// Sets a vector of detectors used in tracking void SetActiveTrackingDetectorIDs(const std::set<L1DetectorID>& init) { fActiveTrackingDetectorIDs = init; } diff --git a/reco/L1/L1Algo/L1Algo.cxx b/reco/L1/L1Algo/L1Algo.cxx index 9cce9ea106d0c7a620a080e099c3f15f67e1e88b..97f9be3d8367eed11a212f8e84b31264326f870f 100644 --- a/reco/L1/L1Algo/L1Algo.cxx +++ b/reco/L1/L1Algo/L1Algo.cxx @@ -17,9 +17,9 @@ L1Algo::L1Algo(unsigned int nThreads) void L1Algo::SetNThreads(unsigned int n) { - if (n > static_cast<unsigned int>(L1Parameters::kMaxNthreads)) { // TODO: Why do we need static_cast here? + if (n > static_cast<unsigned int>(L1Parameters::kMaxNthreads)) { LOG(fatal) << "L1Algo: n threads " << n << " is greater than the maximum " - << static_cast<unsigned int>(L1Parameters::kMaxNthreads); // The same + << static_cast<unsigned int>(L1Parameters::kMaxNthreads); } fNThreads = n; @@ -61,7 +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 + fL1Parameters.Print(); // TODO: Wrap this line into debug (S.Zh.) for (int iProc = 0; iProc < 4; iProc++) { for (int i = 0; i < 8; i++) { @@ -231,7 +231,7 @@ void L1Algo::Init(const L1Vector<fscal>& geo, const bool UseHitErrors, const Tra // Get number of stations int NStationsNew = fInitManager.GetStationsNumber(); - // TODO: we must to get rid of station specification in the L1Algo + // TODO: we must to get rid of station specification in the L1Algo (S.Zh.) int NMvdStationsNew = fInitManager.GetStationsNumber(static_cast<L1DetectorID>(0)); int NStsStationsNew = fInitManager.GetStationsNumber(static_cast<L1DetectorID>(1)); int NfieldStationsNew = NMvdStationsNew + NStsStationsNew; diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index 9c4069f18679107b3de42c3390ec30eeb8d60897..86fd0dde615c086270781f81bbc2285d1ab37e80 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -101,7 +101,7 @@ public: float GetDefaultParticleMass2() const { return fDefaultMass * fDefaultMass; } float fDefaultMass = 0.10565800; // muon mass - // TODO: make fDefaultMass a private member + // TODO: make fDefaultMass a private member (S.Zh.) /// pack station, thread and triplet indices to an unique triplet ID static unsigned int PackTripletId(unsigned int Station, unsigned int Thread, unsigned int Triplet) @@ -209,7 +209,7 @@ public: int fNfieldStations {0}; ///< number of stations in the field region - // TODO: Replace _fvecalignment with C++11 alignas(16) attibute, see vStationsNew + // TODO: Replace _fvecalignment with C++11 alignas(16) attibute, see vStationsNew (S.Zh.) L1Station vStations[L1Parameters::kMaxNstations] _fvecalignment; // station info alignas(16) std::array<L1Station, L1Parameters::kMaxNstations> fStationsNew; L1Vector<L1Material> fRadThick {"fRadThick"}; // material for each station @@ -363,9 +363,9 @@ public: 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 + // TODO: We should think about, where non-constexpr L1Algo 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. + // the L1Algo instance. (S.Zh.) L1InitManager* GetL1InitManager() { return &fInitManager; } private: diff --git a/reco/L1/L1Algo/L1BaseStationInfo.cxx b/reco/L1/L1Algo/L1BaseStationInfo.cxx index 6561e60c6df3aa02d372f9f0dd73b513b89ccb36..0bbeafbf0ecefcaa09fbc8ba97282d566097244a 100644 --- a/reco/L1/L1Algo/L1BaseStationInfo.cxx +++ b/reco/L1/L1Algo/L1BaseStationInfo.cxx @@ -33,7 +33,7 @@ // L1BaseStationInfo::L1BaseStationInfo() noexcept { - LOG(DEBUG) << "L1BaseStationInfo: Default constructor called for " << this << '\n'; // Temporary + LOG(debug) << "L1BaseStationInfo: Default constructor called for " << this << '\n'; // Temporary } //----------------------------------------------------------------------------------------------------------------------// @@ -42,16 +42,16 @@ L1BaseStationInfo::L1BaseStationInfo(L1DetectorID detectorID, int stationID) noe : fDetectorID(detectorID) , fStationID(stationID) { - LOG(DEBUG) << "L1BaseStationInfo: Constructor (detectorID, stationID) called for " << this << '\n'; // Temporary - fInitFlags[kEDetectorID] = true; - fInitFlags[kEStationID] = true; + LOG(debug) << "L1BaseStationInfo: Constructor (detectorID, stationID) called for " << this << '\n'; // Temporary + fInitFlags[keDetectorID] = true; + fInitFlags[keStationID] = true; } //----------------------------------------------------------------------------------------------------------------------// // L1BaseStationInfo::~L1BaseStationInfo() noexcept { - LOG(DEBUG) << "L1BaseStationInfo: Destructor called for " << this << '\n'; // Temporary + LOG(debug) << "L1BaseStationInfo: Destructor called for " << this << '\n'; // Temporary } //----------------------------------------------------------------------------------------------------------------------// @@ -210,9 +210,9 @@ const L1Station& L1BaseStationInfo::GetL1Station() const // void L1BaseStationInfo::SetStationID(int inID) { - if (!fInitFlags[kEStationID]) { + if (!fInitFlags[keStationID]) { fStationID = inID; - fInitFlags[kEStationID] = true; + fInitFlags[keStationID] = true; } else { LOG(warn) << "L1BaseStationInfo::SetStationID: Attempt of station ID redifinition"; @@ -223,9 +223,9 @@ void L1BaseStationInfo::SetStationID(int inID) // void L1BaseStationInfo::SetDetectorID(L1DetectorID inID) { - if (!fInitFlags[kEDetectorID]) { + if (!fInitFlags[keDetectorID]) { fDetectorID = inID; - fInitFlags[kEDetectorID] = true; + fInitFlags[keDetectorID] = true; } else { LOG(warn) << "L1BaseStationInfo::SetDetectorID: Attempt of detector ID redifinition"; @@ -236,9 +236,9 @@ void L1BaseStationInfo::SetDetectorID(L1DetectorID inID) // void L1BaseStationInfo::SetStationType(int inType) { - if (!fInitFlags[kEtype]) { + if (!fInitFlags[keType]) { fL1Station.type = inType; - fInitFlags[kEtype] = true; + fInitFlags[keType] = true; } else { LOG(warn) << "L1BaseStationInfo::SetStationType: Attempt of station type redifinition"; @@ -250,7 +250,7 @@ void L1BaseStationInfo::SetStationType(int inType) void L1BaseStationInfo::SetTimeInfo(int inTimeInfo) { fL1Station.timeInfo = inTimeInfo; - fInitFlags[kEtimeInfo] = true; + fInitFlags[keTimeInfo] = true; } //----------------------------------------------------------------------------------------------------------------------// @@ -259,7 +259,7 @@ void L1BaseStationInfo::SetZ(double inZ) { fL1Station.z = inZ; // setting simd vector of single-precision floats, which is passed to high performanced L1Algo fZPos = inZ; // setting precised value to use in field approximation etc - fInitFlags[kEz] = true; + fInitFlags[keZ] = true; } //----------------------------------------------------------------------------------------------------------------------// @@ -267,7 +267,7 @@ void L1BaseStationInfo::SetZ(double inZ) void L1BaseStationInfo::SetRmin(double inRmin) { fL1Station.Rmin = inRmin; - fInitFlags[kERmin] = true; + fInitFlags[keRmin] = true; } //----------------------------------------------------------------------------------------------------------------------// @@ -275,7 +275,7 @@ void L1BaseStationInfo::SetRmin(double inRmin) void L1BaseStationInfo::SetRmax(double inRmax) { fL1Station.Rmax = inRmax; - fInitFlags[kERmax] = true; + fInitFlags[keRmax] = true; } //----------------------------------------------------------------------------------------------------------------------// @@ -289,15 +289,15 @@ void L1BaseStationInfo::SetMaterial(double inThickness, double inRL) fL1Station.materialInfo.RL = inRL; fL1Station.materialInfo.RadThick = fL1Station.materialInfo.thick / fL1Station.materialInfo.RL; fL1Station.materialInfo.logRadThick = log(fL1Station.materialInfo.RadThick); - fInitFlags[kEmaterialInfoThick] = true; - fInitFlags[kEmaterialInfoRL] = true; + fInitFlags[keMaterialInfoThick] = true; + fInitFlags[keMaterialInfoRL] = true; } //----------------------------------------------------------------------------------------------------------------------// // void L1BaseStationInfo::SetFieldSlice(const double* Cx, const double* Cy, const double* Cz) { - if (fInitFlags[kEfieldSlice]) { + if (fInitFlags[keFieldSlice]) { LOG(warn) << "L1BaseStationInfo::SetFieldSlice: Attempt to redifine field slice for station with detectorID = " << static_cast<int>(fDetectorID) << " and stationID = " << fStationID << ". Redifinition ignored"; return; @@ -309,24 +309,25 @@ void L1BaseStationInfo::SetFieldSlice(const double* Cx, const double* Cy, const fL1Station.fieldSlice.cz[idx] = Cz[idx]; } - fInitFlags[kEfieldSlice] = true; + fInitFlags[keFieldSlice] = true; } //----------------------------------------------------------------------------------------------------------------------// // void L1BaseStationInfo::SetFieldSlice(const std::function<void(const double (&xyz)[3], double (&B)[3])>& getFieldValue) { - if (fInitFlags[kEfieldSlice]) { + if (fInitFlags[keFieldSlice]) { LOG(warn) << "L1BaseStationInfo::SetFieldSlice: Attempt to redifine field slice for station with detectorID = " << static_cast<int>(fDetectorID) << " and stationID = " << fStationID << ". Redifinition ignored"; return; } #ifndef L1_NO_ASSERT // check for zero denominator - L1_ASSERT(fInitFlags[kEz], "Attempt to set magnetic field slice before setting z position of the station"); - L1_ASSERT(fInitFlags[kEXmax], "Attempt to set magnetic field slice before setting Xmax size of the station"); - L1_ASSERT(fInitFlags[kEYmax], "Attempt to set magnetic field slice before setting Ymax size of the station"); + L1_ASSERT(fInitFlags[keZ], "Attempt to set magnetic field slice before setting z position of the station"); + L1_ASSERT(fInitFlags[keXmax], "Attempt to set magnetic field slice before setting Xmax size of the station"); + L1_ASSERT(fInitFlags[keYmax], "Attempt to set magnetic field slice before setting Ymax size of the station"); #endif + // TODO: Change names of variables according to convention (S.Zh.) constexpr int M = L1Parameters::kMaxFieldApproxPolynomialOrder; constexpr int N = L1Parameters::kMaxNFieldApproxCoefficients; constexpr int D = 3; ///> number of dimensions @@ -394,16 +395,13 @@ void L1BaseStationInfo::SetFieldSlice(const std::function<void(const double (&xy fL1Station.fieldSlice.cz[j] = A[j][N + 2] / A[j][j]; } - fInitFlags[kEfieldSlice] = true; + fInitFlags[keFieldSlice] = true; } //----------------------------------------------------------------------------------------------------------------------// // void L1BaseStationInfo::SetFrontBackStripsGeometry(double frontPhi, double frontSigma, double backPhi, double backSigma) { - // TODO: may be is it better to define separate setters for these values and then calculate the - // rest somewhere below? - //----- Original code from L1Algo ---------------------------------------------------------------------// double cFront = cos(frontPhi); double sFront = sin(frontPhi); @@ -450,10 +448,10 @@ void L1BaseStationInfo::SetFrontBackStripsGeometry(double frontPhi, double front fL1Station.yInfo.sigma2 = fL1Station.XYInfo.C11; //-----------------------------------------------------------------------------------------------------// - fInitFlags[kEstripsFrontPhi] = true; - fInitFlags[kEstripsFrontSigma] = true; - fInitFlags[kEstripsBackPhi] = true; - fInitFlags[kEstripsBackSigma] = true; + fInitFlags[keStripsFrontPhi] = true; + fInitFlags[keStripsFrontSigma] = true; + fInitFlags[keStripsBackPhi] = true; + fInitFlags[keStripsBackSigma] = true; } //----------------------------------------------------------------------------------------------------------------------// @@ -461,7 +459,7 @@ void L1BaseStationInfo::SetFrontBackStripsGeometry(double frontPhi, double front void L1BaseStationInfo::SetXmax(double aSize) { fXmax = aSize; - fInitFlags[kEXmax] = true; + fInitFlags[keXmax] = true; } //----------------------------------------------------------------------------------------------------------------------// @@ -469,5 +467,5 @@ void L1BaseStationInfo::SetXmax(double aSize) void L1BaseStationInfo::SetYmax(double aSize) { fYmax = aSize; - fInitFlags[kEYmax] = true; + fInitFlags[keYmax] = true; } diff --git a/reco/L1/L1Algo/L1BaseStationInfo.h b/reco/L1/L1Algo/L1BaseStationInfo.h index c120652e7c246ba50568ba4a75d01bb712c8c897..ba46bbf1f6b026e7de2e9d4140c683b3cb8b78d7 100644 --- a/reco/L1/L1Algo/L1BaseStationInfo.h +++ b/reco/L1/L1Algo/L1BaseStationInfo.h @@ -29,25 +29,25 @@ private: enum { // Here we list all the fields, which must be initialized by user // Basic fields initialization - kEDetectorID, - kEStationID, - kEXmax, - kEYmax, + keDetectorID, + keStationID, + keXmax, + keYmax, // L1Station initialization - kEtype, - kEtimeInfo, - kEz, - kERmin, - kERmax, - kEmaterialInfoThick, - kEmaterialInfoRL, - kEfieldSlice, - kEstripsFrontPhi, - kEstripsFrontSigma, - kEstripsBackPhi, - kEstripsBackSigma, + keType, + keTimeInfo, + keZ, + keRmin, + keRmax, + keMaterialInfoThick, + keMaterialInfoRL, + keFieldSlice, + keStripsFrontPhi, + keStripsFrontSigma, + keStripsBackPhi, + keStripsBackSigma, // The last item is equal to the number of bits in fInitFlags - kEND + keEnd }; public: @@ -112,12 +112,10 @@ public: /// Gets material thickness fvec GetMaterialThickness() 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 GetMaterialRadLength() const { return fL1Station.materialInfo.RL; } // TODO: -//- + fvec GetMaterialRadLength() const { return fL1Station.materialInfo.RL; } /// Gets the relative material thickness in units of the radiational length - fvec GetMaterialRadThick() const { return fL1Station.materialInfo.RadThick; } // TODO: Rename? + fvec GetMaterialRadThick() const { return fL1Station.materialInfo.RadThick; } /// Gets log of the relative material thickness in units of the radiational length fvec GetMaterialLogRadThick() const { return fL1Station.materialInfo.logRadThick; } @@ -143,7 +141,7 @@ public: /// Gets a reference to L1Station info field of the L1BaseStation info const L1Station& GetL1Station() const; /// Gets a reference to Bitset object of initialization bits - const std::bitset<L1BaseStationInfo::kEND>& GetInitFlags() const { return fInitFlags; } + const std::bitset<L1BaseStationInfo::keEnd>& GetInitFlags() const { return fInitFlags; } // @@ -156,7 +154,7 @@ public: void SetDetectorID(L1DetectorID inID); /// Sets type of station - void SetStationType(int inType); // TODO: this is a temporary solution since + void SetStationType(int inType); // TODO: this is a temporary solution (S.Zh.) /// Sets flag: 0 - time information is not provided by this detector type // 1 - time information is provided by the detector and can be used in tracking void SetTimeInfo(int inTimeInfo); @@ -197,7 +195,7 @@ private: double fYmax {0}; ///< Maximum distance between station center and its edge in y direction double fZPos {0}; ///< z position of the station in double precision, used in field approximation L1Station fL1Station {}; ///< L1Station structure, describes a station in L1Algo - std::bitset<L1BaseStationInfo::kEND> fInitFlags; ///< Class fileds initialization flags + std::bitset<L1BaseStationInfo::keEnd> fInitFlags; ///< Class fileds initialization flags }; /// swap function for two L1BaseStationInfo objects, expected to be used instead of std::swap diff --git a/reco/L1/L1Algo/L1Def.h b/reco/L1/L1Algo/L1Def.h index 883f6f1890325545cbe13e2f23c7575ff6f4ae43..f60d2607d534b6c44dbca71b877671c08ce4ba11 100644 --- a/reco/L1/L1Algo/L1Def.h +++ b/reco/L1/L1Algo/L1Def.h @@ -63,13 +63,4 @@ T finite(T x) typedef int index_type; -/// Hash for unordered_map with enum class keys -struct EnumClassHash { - template<typename T> - int operator()(T t) const - { - return static_cast<int>(t); - } -}; - #endif diff --git a/reco/L1/L1Algo/L1InitManager.cxx b/reco/L1/L1Algo/L1InitManager.cxx index d91106d2174bdfc68a5658fa59c25e347a0d8ce8..8ab9f5c7e3d0a259b78d52258cafd38ee0c6dd80 100644 --- a/reco/L1/L1Algo/L1InitManager.cxx +++ b/reco/L1/L1Algo/L1InitManager.cxx @@ -20,25 +20,25 @@ void L1InitManager::AddStation(const L1BaseStationInfo& inStation) { // Check if other fields were defined already // Active detector IDs - if (!fInitFlags[L1InitManager::kEactiveDetectorIDs]) { + if (!fInitFlags[L1InitManager::keActiveDetectorIDs]) { LOG(error) << "L1InitManager::AddStation: station initialization called before the active detectors set had been " "initialized"; - assert((fInitFlags[L1InitManager::kEactiveDetectorIDs])); + assert((fInitFlags[L1InitManager::keActiveDetectorIDs])); } // Number of stations check - if (!fInitFlags[L1InitManager::kEstationsNumberCrosscheck]) { + if (!fInitFlags[L1InitManager::keStationsNumberCrosscheck]) { LOG(error) << "L1InitManager::AddStation: station initialization called before the numbers of stations for each detector " << "had been initialized"; - assert((fInitFlags[L1InitManager::kEstationsNumberCrosscheck])); + assert((fInitFlags[L1InitManager::keStationsNumberCrosscheck])); } // Field function - if (!fInitFlags[L1InitManager::kEfieldFunction]) { + if (!fInitFlags[L1InitManager::keFieldFunction]) { LOG(error) << "L1InitManager::AddStation: station initialization called before the magnetic field function was intialized"; - assert((fInitFlags[L1InitManager::kEfieldFunction])); + assert((fInitFlags[L1InitManager::keFieldFunction])); } // Check activeness of this station type @@ -66,7 +66,7 @@ void L1InitManager::AddStation(const L1BaseStationInfo& inStation) insertionResult.first->Print(); LOG(error) << ">>> A dublicating L1BaseStationInfo object:"; inStation.Print(); - assert((insertionResult.second)); // TODO: rewrite the assertion + assert((insertionResult.second)); } } LOG(debug) << "L1InitManager: adding a station with stationID = " << inStation.GetStationID() @@ -106,8 +106,8 @@ void L1InitManager::PrintStations(int verbosityLevel) const void L1InitManager::TransferL1StationArray(std::array<L1Station, L1Parameters::kMaxNstations>& destinationArray) { /// First of all, we must check if L1Station was properly initialized - // TODO: actually, false condition will never reached (must thing about it, may be remove assertions from - // CheckStationInfo and leave only warnings and flag) + // TODO: actually, false condition will never reached (must think about it, may be remove assertions from + // CheckStationInfo and leave only warnings and flag) (S.Zh.) bool ifStationsInitialized = CheckStationsInfo(); if (!ifStationsInitialized) { LOG(error) << "L1InitManager::TransferL1StationArray: attempt to pass unitialized L1Station array to L1Algo core"; @@ -153,18 +153,18 @@ int L1InitManager::GetStationsNumber(L1DetectorID detectorID) const // void L1InitManager::SetActiveDetectorIDs(const std::set<L1DetectorID>& detectorIDs) { - // TODO: To think about redifinition possibilities: should it be allowed or not? + // TODO: To think about redifinition possibilities: should it be allowed or not? (S.Zh.) fActiveDetectorIDs = detectorIDs; - fInitFlags[L1InitManager::kEactiveDetectorIDs] = true; + fInitFlags[L1InitManager::keActiveDetectorIDs] = true; } //----------------------------------------------------------------------------------------------------------------------- // void L1InitManager::SetFieldFunction(const std::function<void(const double (&xyz)[3], double (&B)[3])>& fieldFunction) { - if (!fInitFlags[L1InitManager::kEfieldFunction]) { + if (!fInitFlags[L1InitManager::keFieldFunction]) { fFieldFunction = fieldFunction; - fInitFlags[L1InitManager::kEfieldFunction] = true; + fInitFlags[L1InitManager::keFieldFunction] = true; } else { LOG(warn) << "L1InitManager::SetFieldFunction: attemt to reinitialize the field function. Ignored"; @@ -184,7 +184,7 @@ void L1InitManager::SetStationsNumberCrosscheck(L1DetectorID detectorID, int nSt // Check if all the station numbers for active detectors are initialized now: LOG(debug) << "SetStationsNumberCrosscheck called for detectorID = " << static_cast<int>(detectorID); - if (!fInitFlags[L1InitManager::kEstationsNumberCrosscheck]) { + if (!fInitFlags[L1InitManager::keStationsNumberCrosscheck]) { bool ifInitialized = true; for (auto item : fActiveDetectorIDs) { if (fStationsNumberCrosscheck.find(item) == fStationsNumberCrosscheck.end()) { @@ -194,16 +194,16 @@ void L1InitManager::SetStationsNumberCrosscheck(L1DetectorID detectorID, int nSt break; } } - fInitFlags[L1InitManager::kEstationsNumberCrosscheck] = ifInitialized; + fInitFlags[L1InitManager::keStationsNumberCrosscheck] = ifInitialized; } - LOG(debug) << "InitResult: " << fInitFlags[L1InitManager::kEstationsNumberCrosscheck]; + LOG(debug) << "InitResult: " << fInitFlags[L1InitManager::keStationsNumberCrosscheck]; } //----------------------------------------------------------------------------------------------------------------------- // void L1InitManager::SetTargetPosition(double x, double y, double z) { - if (fInitFlags[L1InitManager::kEtargetPos]) { + if (fInitFlags[L1InitManager::keTargetPos]) { LOG(warn) << "L1InitManager::SetTargetPosition: attempt to reinitialize the target position. Ignore"; return; } @@ -211,31 +211,31 @@ void L1InitManager::SetTargetPosition(double x, double y, double z) fTargetPos[0] = x; fTargetPos[1] = y; fTargetPos[2] = z; - fInitFlags[L1InitManager::kEtargetPos] = true; + fInitFlags[L1InitManager::keTargetPos] = true; } //----------------------------------------------------------------------------------------------------------------------- // void L1InitManager::InitTargetField(double zStep) { - if (fInitFlags[L1InitManager::kEprimaryVertexField]) { + if (fInitFlags[L1InitManager::kePrimaryVertexField]) { LOG(warn) << "L1InitManager::InitTargetField: attempt to reinitialize the field value and field region " << "near target. Ignore"; return; } // Check for field function - if (!fInitFlags[L1InitManager::kEfieldFunction]) { + if (!fInitFlags[L1InitManager::keFieldFunction]) { LOG(error) << "L1InitManager::InitTargetField: attempt to initialze the field value and field region near " << "target before initializing field function"; - assert((fInitFlags[L1InitManager::kEfieldFunction])); + assert((fInitFlags[L1InitManager::keFieldFunction])); } // Check for target defined - if (!fInitFlags[L1InitManager::kEtargetPos]) { + if (!fInitFlags[L1InitManager::keTargetPos]) { LOG(error) << "L1InitManager::InitTargetField: attempt to initialize the field value and field region near " << "target before the target position initialization"; - assert((fInitFlags[L1InitManager::kEtargetPos])); + assert((fInitFlags[L1InitManager::keTargetPos])); } constexpr int numberOfDimensions {3}; @@ -257,7 +257,7 @@ void L1InitManager::InitTargetField(double zStep) fTargetFieldRegion.Set(B[0], z[0], B[1], z[1], B[2], z[2]); fTargetFieldValue = B[0]; - fInitFlags[L1InitManager::kEprimaryVertexField] = true; + fInitFlags[L1InitManager::kePrimaryVertexField] = true; } @@ -265,10 +265,10 @@ void L1InitManager::InitTargetField(double zStep) // bool L1InitManager::CheckStationsInfo() { - if (!fInitFlags[L1InitManager::kEstationsInfo]) { + if (!fInitFlags[L1InitManager::keStationsInfo]) { bool ifInitPassed = true; - if (!fInitFlags[L1InitManager::kEifStationNumbersChecked]) { + if (!fInitFlags[L1InitManager::keIfStationNumbersChecked]) { for (const auto& itemDetector : fActiveDetectorIDs) { int actualStationsNumber = GetStationsNumber(itemDetector); int expectedStationsNumber = fStationsNumberCrosscheck.at(itemDetector); @@ -280,7 +280,7 @@ bool L1InitManager::CheckStationsInfo() ifInitPassed = false; } } - fInitFlags[L1InitManager::kEifStationNumbersChecked] = ifInitPassed; + fInitFlags[L1InitManager::keIfStationNumbersChecked] = ifInitPassed; } if (!ifInitPassed) { LOG(error) << "L1InitManager::CheckStationsInfo: initialization failed"; @@ -293,16 +293,16 @@ bool L1InitManager::CheckStationsInfo() LOG(fatal) << "Actual total number of registered stations (" << totalStationsNumber << ") is larger then designed one (" << L1Parameters::kMaxNstations << "). Please, select another set of active tracking detectors"; - // TODO: We have to provide an instruction of how to increase the kMaxNstations number keeping the code consistent + // TODO: We have to provide an instruction of how to increase the kMaxNstations number keeping the code consistent (S.Zh.) assert((totalStationsNumber <= L1Parameters::kMaxNstations)); } - fInitFlags[L1InitManager::kEstationsInfo] = true; + fInitFlags[L1InitManager::keStationsInfo] = true; } else { LOG(warn) << "L1InitManager: L1BaseStationInfo set has already been initialized"; } // NOTE: we return a flag here to reduce a number of calls outside the funcition. In other hands we keep this flag // to be consistent with other class fields initialization rules - return fInitFlags[L1InitManager::kEstationsInfo]; + return fInitFlags[L1InitManager::keStationsInfo]; } diff --git a/reco/L1/L1Algo/L1InitManager.h b/reco/L1/L1Algo/L1InitManager.h index dbf042b7ae323c36136f36e34a2403b2e425b82b..83e84596b5054613a1df907a82843c253abd7aa3 100644 --- a/reco/L1/L1Algo/L1InitManager.h +++ b/reco/L1/L1Algo/L1InitManager.h @@ -14,6 +14,7 @@ #include "L1BaseStationInfo.h" #include "L1Field.h" #include "L1Parameters.h" +#include "utils/L1Utils.h" //#include <string> #include <bitset> @@ -59,15 +60,15 @@ class L1InitManager { private: enum { - kEactiveDetectorIDs, ///< If the detector sequence is set - kEstationsNumberCrosscheck, ///< If the crosscheck station numbers were setup - kEfieldFunction, ///< If magnetic field getter funciton is set - kEtargetPos, ///< If target position was defined - kEprimaryVertexField, ///< If magnetic field value and region defined at primary vertex - kEifStationNumbersChecked, ///< If the station number was already checked - kEstationsInfo, ///< If all the planned stations were added to the manager - kEL1StationTransfered, ///< If the L1Station vector was already transfered to destination array - kEND + keActiveDetectorIDs, ///< If the detector sequence is set + keStationsNumberCrosscheck, ///< If the crosscheck station numbers were setup + keFieldFunction, ///< If magnetic field getter funciton is set + keTargetPos, ///< If target position was defined + kePrimaryVertexField, ///< If magnetic field value and region defined at primary vertex + keIfStationNumbersChecked, ///< If the station number was already checked + keStationsInfo, ///< If all the planned stations were added to the manager + keL1StationTransfered, ///< If the L1Station vector was already transfered to destination array + keEnd }; public: @@ -99,7 +100,6 @@ public: /// Adds another station of a given type using pointer to a L1BaseStationInfo object void AddStation(const L1BaseStationInfo* inStationPtr) { AddStation(*inStationPtr); } /// Adds another station of a given type using std::unique_ptr-wraped pointer to L1BaseStationInfo - // TODO: Test weaknesses here void AddStation(const std::unique_ptr<L1BaseStationInfo>& inStationUniquePtr) { AddStation(*inStationUniquePtr); } /// Initializes L1Algo: transfers all caputred data to the L1 tracking core void Init() const; @@ -121,7 +121,7 @@ public: int GetStationsNumber(L1DetectorID detectorID) const; /// Gets a target position const std::array<double, 3>& GetTargetPosition() const { return fTargetPos; } - // TODO: define enum of dimensions.... + // TODO: define enum of dimensions.... (S.Zh.) /// Gets a L1FieldRegion object at primary vertex const L1FieldRegion& GetTargetFieldRegion() const { return fTargetFieldRegion; } /// Gets a L1FieldValue object at primary vertex @@ -142,19 +142,19 @@ public: /// Calculates L1FieldValue and L1FieldReference values for a selected step in z coordinate from the target position /// \param zStep step between nodal points - // TODO: Consider posibility for linear approximation + // TODO: Consider posibility for linear approximation (S.Zh.) void InitTargetField(double zStep); private: /// Checker for L1BaseStationInfo set /// \return true if all L1BaseStationInfo objects were initialized properly. Similar effect can be achieved by - /// calling the fInitFlags[L1InitManager::kEstationsInfo] flag + /// calling the fInitFlags[L1InitManager::keStationsInfo] flag bool CheckStationsInfo(); /* Basic fields */ - std::bitset<L1InitManager::kEND> fInitFlags {}; ///< Initialization flags + std::bitset<L1InitManager::keEnd> fInitFlags {}; ///< Initialization flags std::set<L1DetectorID> fActiveDetectorIDs {}; ///< Set of tracking detectors, active during this analysis session /* Target fields */ @@ -165,7 +165,7 @@ private: std::set<L1BaseStationInfo> fStationsInfo {}; ///< Set of L1BaseStationInfo objects /// Map of station numbers used for initialization crosscheck - std::unordered_map<L1DetectorID, int, EnumClassHash> fStationsNumberCrosscheck {}; + std::unordered_map<L1DetectorID, int, L1Utils::EnumClassHash> fStationsNumberCrosscheck {}; /// A function which returns magnetic field vector B in a radius-vector xyz std::function<void(const double (&xyz)[3], double (&B)[3])> fFieldFunction { [](const double (&)[3], double (&)[3]) {}}; diff --git a/reco/L1/L1Algo/L1Parameters.h b/reco/L1/L1Algo/L1Parameters.h index d8e8ec2baccb1443f732337abaf82648f9d03e41..da5ba6cb1a0f49faeb26e1bc65bad36e310db4ee 100644 --- a/reco/L1/L1Algo/L1Parameters.h +++ b/reco/L1/L1Algo/L1Parameters.h @@ -19,9 +19,8 @@ //#include <string> //#include <unordered_map> -#include "L1Def.h" // For EnumClassHash #include "L1Vector.h" -//#include "utils/L1AlgoFunctions.h" +//#include "utils/L1Utils.h" //#define L1ALGODEV @@ -47,7 +46,7 @@ // // // Type for mapping L1CATrackFinder parameters, which are dependent from the current track finder iteration // template <typename T> -// using L1CATrackFinderIterParameterMap_t = std::unordered_map<L1CATrackFinderIter, T, EnumClassHash>; +// using L1CATrackFinderIterParameterMap_t = std::unordered_map<L1CATrackFinderIter, T, L1Utils::EnumClassHash>; // // ////// > Will be moved to separate class // const L1CATrackFinderIterParameterMap_t<std::string> kTrackFinderIterNames = { @@ -218,7 +217,7 @@ public: private: /// Aux method for printing mapped Track Finder parameters - ///template <typename T> // NOTE: moved to L1AlgoFunctions.h + ///template <typename T> // NOTE: moved to L1Utils.h ///void PrintTrackFinderIterParameters(const std::string& parName, const L1CATrackFinderIterParameterMap_t<T>& parMap) ///{ /// std::stringstream token; // Is used because LOG() automatically sets '\n' to the end of the string diff --git a/reco/L1/L1Algo/L1Station.cxx b/reco/L1/L1Algo/L1Station.cxx new file mode 100644 index 0000000000000000000000000000000000000000..72eff039d6880340d704eecdb8d7f5bc9b685666 --- /dev/null +++ b/reco/L1/L1Algo/L1Station.cxx @@ -0,0 +1,50 @@ +/* Copyright (C) 2007-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +#include <iomanip> +#include <FairLogger.h> +#include "L1Station.h" + +// TODO: Improve log style (S.Zh.) +void L1Station::Print() const +{ + LOG(info) << "==== L1Station object at " << this; + LOG(info) << "- L1Station fields:"; + LOG(info) << "--- Station type ID: " << type; + LOG(info) << "--- z position: " << z[0]; + LOG(info) << "--- Rmin: " << Rmin[0]; + LOG(info) << "--- Rmax: " << Rmax[0]; + LOG(info) << "--- Thickness (X), cm: " << materialInfo.thick[0]; + LOG(info) << "--- Radiational length (X0), cm: " << materialInfo.RL[0]; + LOG(info) << "--- X / X0: " << materialInfo.RadThick[0]; + LOG(info) << "--- log(X / X0): " << materialInfo.logRadThick[0]; + LOG(info) << "--- Field approximation coefficients:"; + LOG(info) << " idx CX CY CZ"; + for (int idx = 0; idx < 21; ++idx) { + LOG(info) << std::setw(9) << std::setfill(' ') << idx << ' ' << std::setw(10) << std::setfill(' ') + << fieldSlice.cx[idx][0] << ' ' << std::setw(10) << std::setfill(' ') << fieldSlice.cy[idx][0] << ' ' + << std::setw(10) << std::setfill(' ') << fieldSlice.cz[idx][0]; + } + LOG(info) << "--- Strips geometry:"; + LOG(info) << "----- Front:"; + LOG(info) << "------- cos(phi): " << frontInfo.cos_phi[0]; + LOG(info) << "------- sin(phi): " << frontInfo.sin_phi[0]; + LOG(info) << "------- sigma2: " << frontInfo.sigma2[0]; + LOG(info) << "----- Back:"; + LOG(info) << "------- cos(phi): " << backInfo.cos_phi[0]; + LOG(info) << "------- sin(phi): " << backInfo.sin_phi[0]; + LOG(info) << "------- sigma2: " << backInfo.sigma2[0]; + LOG(info) << "----- XY cov matrix:"; + LOG(info) << "------- C00: " << XYInfo.C00[0]; + LOG(info) << "------- C10: " << XYInfo.C10[0]; + LOG(info) << "------- C11: " << XYInfo.C11[0]; + LOG(info) << "----- X layer:"; + LOG(info) << "------- cos(phi): " << xInfo.cos_phi[0]; + LOG(info) << "------- sin(phi): " << xInfo.sin_phi[0]; + LOG(info) << "------- sigma2: " << xInfo.sigma2[0]; + LOG(info) << "----- Y layer:"; + LOG(info) << "------- cos(phi): " << yInfo.cos_phi[0]; + LOG(info) << "------- sin(phi): " << yInfo.sin_phi[0]; + LOG(info) << "------- sigma2: " << yInfo.sigma2[0]; +} diff --git a/reco/L1/L1Algo/L1Station.h b/reco/L1/L1Algo/L1Station.h index 1daa7bb1d6828e3f79fca2d7c3fc06c5aca38cf5..bbde36398fb711c2aaaaada3857b02d5bd0eca0e 100644 --- a/reco/L1/L1Algo/L1Station.h +++ b/reco/L1/L1Algo/L1Station.h @@ -10,34 +10,8 @@ #include "L1UMeasurementInfo.h" #include "L1XYMeasurementInfo.h" - -#define L1Station_h_TMP_DEBUG 1 - -#ifdef L1Station_h_TMP_DEBUG -#include <iomanip> -#endif // L1Station_h_TMP_DEBUG - class L1Station { - public: - // TODO: rewrite initialization (default values to fields, remove constructor (check struct)) - //L1Station() - // : type(0) - // , timeInfo(0) - // , z(0) - // , Rmin(0) - // , Rmax(0) - // , Sy(0) - // , /// z-position, min & max station radius, field integral - // materialInfo() - // , fieldSlice() - // , frontInfo() - // , backInfo() - // , xInfo() - // , yInfo() - // , XYInfo() - //{ - //} // TODO: test this constructors //L1Station(const L1Station &) = default; @@ -59,52 +33,9 @@ public: L1UMeasurementInfo yInfo {}; L1XYMeasurementInfo XYInfo {}; - - void Print() const - { -#ifdef L1Station_h_TMP_DEBUG - LOG(info) << "==== L1Station object at " << this; - LOG(info) << "- L1Station fields:"; - LOG(info) << "--- Station type ID: " << type; - LOG(info) << "--- z position: " << z[0]; - LOG(info) << "--- Rmin: " << Rmin[0]; - LOG(info) << "--- Rmax: " << Rmax[0]; - LOG(info) << "--- Thickness (X), cm: " << materialInfo.thick[0]; - LOG(info) << "--- Radiational length (X0), cm: " << materialInfo.RL[0]; - LOG(info) << "--- X / X0: " << materialInfo.RadThick[0]; - LOG(info) << "--- log(X / X0): " << materialInfo.logRadThick[0]; - LOG(info) << "--- Field approximation coefficients:"; - LOG(info) << " idx CX CY CZ"; - for (int idx = 0; idx < 21; ++idx) { - LOG(info) << std::setw(9) << std::setfill(' ') << idx << ' ' << std::setw(10) << std::setfill(' ') - << fieldSlice.cx[idx][0] << ' ' << std::setw(10) << std::setfill(' ') << fieldSlice.cy[idx][0] << ' ' - << std::setw(10) << std::setfill(' ') << fieldSlice.cz[idx][0]; - } - LOG(info) << "--- Strips geometry:"; - LOG(info) << "----- Front:"; - LOG(info) << "------- cos(phi): " << frontInfo.cos_phi[0]; - LOG(info) << "------- sin(phi): " << frontInfo.sin_phi[0]; - LOG(info) << "------- sigma2: " << frontInfo.sigma2[0]; - LOG(info) << "----- Back:"; - LOG(info) << "------- cos(phi): " << backInfo.cos_phi[0]; - LOG(info) << "------- sin(phi): " << backInfo.sin_phi[0]; - LOG(info) << "------- sigma2: " << backInfo.sigma2[0]; - LOG(info) << "----- XY cov matrix:"; - LOG(info) << "------- C00: " << XYInfo.C00[0]; - LOG(info) << "------- C10: " << XYInfo.C10[0]; - LOG(info) << "------- C11: " << XYInfo.C11[0]; - LOG(info) << "----- X layer:"; - LOG(info) << "------- cos(phi): " << xInfo.cos_phi[0]; - LOG(info) << "------- sin(phi): " << xInfo.sin_phi[0]; - LOG(info) << "------- sigma2: " << xInfo.sigma2[0]; - LOG(info) << "----- Y layer:"; - LOG(info) << "------- cos(phi): " << yInfo.cos_phi[0]; - LOG(info) << "------- sin(phi): " << yInfo.sin_phi[0]; - LOG(info) << "------- sigma2: " << yInfo.sigma2[0]; - LOG(info) << ""; -#endif // L1Station_h_TMP_DEBUG - } + /// Prints object fields + void Print() const; } _fvecalignment; -#endif +#endif // L1Station_h diff --git a/reco/L1/L1Algo/utils/L1Utils.h b/reco/L1/L1Algo/utils/L1Utils.h new file mode 100644 index 0000000000000000000000000000000000000000..d5bcc8d0e87e89ad9087b8438f4cddb3eea534f8 --- /dev/null +++ b/reco/L1/L1Algo/utils/L1Utils.h @@ -0,0 +1,73 @@ +/* Copyright (C) 2016-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +/************************************************************************************************************ + * @file L1Utilities.h + * @brief File contains some general purpose functions for + * @since 12.01.2022 + ***********************************************************************************************************/ + +#include <iomanip> +#include <map> +#include <sstream> +#include <string> +#include <unordered_map> + +/// Class contains some usefull functions, which could be used in any other classes +struct L1Utils { + + /// Hash for unordered_map with enum class keys + struct EnumClassHash { + template<typename T> + int operator()(T t) const + { + return static_cast<int>(t); + } + }; + + + /// Template function, which sets a value to an element of the map with a particular key + /// \param key Key of the element to be modified + /// \param value New value of the element under the selected key + /// \param aMap A reference to the map, which element is to be modified + template<class Key, class T, class Hash = std::hash<Key>> + static void SetSingleValueToMap(Key key, T value, std::unordered_map<Key, T, Hash>& aMap) + { + aMap[key] = value; + } + + /// Template function, which sets a value to ALL elements of the map + /// \param value New value of the element under the selected key + /// \param aMap A reference to the map, which element is to be modified + template<class Key, class T, class Hash = std::hash<Key>> + static void SetSameValueToMap(T value, std::unordered_map<Key, T, Hash>& aMap) + { + for (auto it = aMap.begin(); it != aMap.end(); ++it) { + it->second = value; + } + } + + /// Template function, which resets the elements of one map with the values defined in another map + /// \param inMap A constant reference to the map containing new parameters + /// \param aMap A reference to the map, which is going to be modified + template<class Key, class T, class Hash = std::hash<Key>> + static void SetMappedValuesToMap(const std::unordered_map<Key, T, Hash>& inMap, std::unordered_map<Key, T, Hash>& aMap) + { + for (auto it = aMap.begin(); it != aMap.end(); ++it) { + if (inMap.find(it->first) != inMap.end()) { it->second = inMap.at(it->first); } + } + } + + /// Template function to represent mapped contents into std::string + /// NOTE: operator<< must be defined for value of the map + template<class Key, class T, class Hash = std::hash<Key>> + static std::string RepresentMapWithString(const std::unordered_map<Key, T, Hash>& aMap, int entryWidth = 15) + { + std::stringstream token; + for (auto it = aMap.begin(); it != aMap.end(); ++it) { + token << std::setw(entryWidth) << std::setfill(' ') << it->second << ' '; + } + return token.str(); + } +};