diff --git a/algo/ca/core/pars/CaConfigReader.cxx b/algo/ca/core/pars/CaConfigReader.cxx index bcf12b183b03071ee519bf3ab05db6b59286e467..d59fda12b85fd5f0321b27031edcc4ffa60ae45f 100644 --- a/algo/ca/core/pars/CaConfigReader.cxx +++ b/algo/ca/core/pars/CaConfigReader.cxx @@ -123,6 +123,8 @@ void ConfigReader::Read() fpInitManager->SetMaxTripletPerDoublets( GetNode([](YAML::Node n) { return n["core"]["track_finder"]["max_triplets_per_doublet"]; }).as<unsigned int>()); + ReadMisalignmentTolerance(); + if (fVerbose >= 1) { LOG(info) << "- reading developement parameters"; } @@ -336,6 +338,69 @@ std::vector<std::set<int>> ConfigReader::ReadInactiveStationMap() return vGeoIdToTrackingStatus; } +// --------------------------------------------------------------------------------------------------------------------- +// +void ConfigReader::ReadMisalignmentTolerance() +{ + // Check, if the "misalignment_tolerance" branch exists either in the user config or in the main config + + std::string sNodePath = "ca/core/common/misalignment_tolerance"; + + YAML::Node node(YAML::NodeType::Undefined); + + try { + node = this->GetNode([](YAML::Node n) { return n["core"]["common"]["misalignment_tolerance"]; }); + } + catch (const std::exception&) { + } + + if (!node) { + std::stringstream msg; + msg << "Ca ConfigReader: misalignment_tolerance node was not found\n "; + if (fUserConfigNode) { + msg << " either in the user config (path: " << fsUserConfigPath; + msg << " or "; + } + else { + msg << " "; + } + + msg << "in the main config (path: " << fsMainConfigPath << ")"; + LOG(info) << msg.str(); + LOG(info) << "Ca ConfigReader: run with zero misalignment tolerance"; + return; + } + + + std::unordered_map<std::string, int> mDetNameToID; + for (int iDet = 0; iDet < constants::size::MaxNdetectors; ++iDet) { + auto detName = boost::algorithm::to_lower_copy(fpInitManager->GetDetectorName(static_cast<EDetectorID>(iDet))); + if (!detName.empty()) { + mDetNameToID[detName] = iDet; + } + } + + for (const auto& item : node) { + std::string stName = boost::algorithm::to_lower_copy(item.first.as<std::string>()); + + auto it = mDetNameToID.find(stName); + if (it == mDetNameToID.end()) { + std::stringstream msg; + msg << "Illegal station name in the configuration branch \"" << sNodePath << "\": \"" << stName << "\""; + throw std::runtime_error(msg.str()); + } + int iDetSystem = it->second; + auto v = item.second.as<std::vector<double>>(); + if (v.size() != 3) { + std::stringstream msg; + msg << "Illegal number of misalignbment tolerances in configuration branch \"" << sNodePath << "\": \"" << stName + << "\": " << v.size() << " values were passed, while 3 values are expected"; + throw std::runtime_error(msg.str()); + } + fpInitManager->SetMisalignmentTolerance(static_cast<EDetectorID>(iDetSystem), v[0], v[1], v[2]); + } +} + // --------------------------------------------------------------------------------------------------------------------- // Iteration ConfigReader::ReadSingleCAIteration(const YAML::Node& node, const Iteration& defaultIter) const diff --git a/algo/ca/core/pars/CaConfigReader.h b/algo/ca/core/pars/CaConfigReader.h index 780f8920f8e38354c976f4e463c9f4c1f79621a1..b67132c1348791cd611824519a657980ec7ad179 100644 --- a/algo/ca/core/pars/CaConfigReader.h +++ b/algo/ca/core/pars/CaConfigReader.h @@ -69,6 +69,9 @@ namespace cbm::algo::ca /// \return A vector of sets of disabled station local indexes vs. the the detector index std::vector<std::set<int>> ReadInactiveStationMap(); + /// \brief Reads the misalignment tolerance + void ReadMisalignmentTolerance(); + /// \brief Accesses a node either from user config or from main config /// \param fn A function, which returns a YAML::Node reference object /// \note If the node is not found in both configs diff --git a/algo/ca/core/pars/CaInitManager.h b/algo/ca/core/pars/CaInitManager.h index 131e1fc69e37d5e4c36719ec62bfe46e45eaf9e4..f71c85475436cdfb1a89382eef199813bc3542cf 100644 --- a/algo/ca/core/pars/CaInitManager.h +++ b/algo/ca/core/pars/CaInitManager.h @@ -237,26 +237,14 @@ namespace cbm::algo::ca /// \brief Sets misalignment parameters in X direction /// \param detectorId Index of the detector system - /// \param value Misalignment value - void SetMisalignmentX(EDetectorID detectorId, float value) + /// \param x Misalignment tolerance in x [cm] + /// \param y Misalignment tolerance in y [cm] + /// \param t Misalignment tolerance in t [ns] + void SetMisalignmentTolerance(EDetectorID detectorId, double x, double y, double t) { - fParameters.fMisalignmentX[static_cast<int>(detectorId)] = value; - } - - /// \brief Sets misalignment parameters in Y direction - /// \param detectorId Index of the detector system - /// \param value Misalignment value - void SetMisalignmentY(EDetectorID detectorId, float value) - { - fParameters.fMisalignmentY[static_cast<int>(detectorId)] = value; - } - - /// \brief Sets miscalibration of Time - /// \param detectorId Index of the detector system - /// \param value Miscalibration value - void SetMisalignmentT(EDetectorID detectorId, float value) - { - fParameters.fMisalignmentT[static_cast<int>(detectorId)] = value; + fParameters.fMisalignmentX[static_cast<int>(detectorId)] = x; + fParameters.fMisalignmentY[static_cast<int>(detectorId)] = y; + fParameters.fMisalignmentT[static_cast<int>(detectorId)] = t; } /// \brief Takes parameters object from the init-manager instance diff --git a/algo/ca/core/pars/CaParameters.cxx b/algo/ca/core/pars/CaParameters.cxx index aa1e70ec9353b5d78942cad114d07f30388e3ac4..333b286fe4a5223675726adca499568fb2e8721f 100644 --- a/algo/ca/core/pars/CaParameters.cxx +++ b/algo/ca/core/pars/CaParameters.cxx @@ -323,6 +323,27 @@ std::string Parameters<DataT>::ToString(int verbosity, int indentLevel) const msg << setw(10) << matMap.GetZref() << '\n'; } + msg << indent << indentCh << clrs::CLb << "MISALIGNMENT TOLERANCES:\n" << clrs::CL; + msg << indent << indentCh; + msg << setw(9) << "Active ID"; + msg << setw(9) << "dx[cm]"; + msg << setw(9) << "dy[cm]"; + msg << setw(9) << "dt[ns]" << '\n'; + + for (int iDet = 0; iDet < constants::size::MaxNdetectors; ++iDet) { + for (int iStLocal = 0; iStLocal < this->GetNstationsGeometry(static_cast<EDetectorID>(iDet)); ++iStLocal) { + int iStActive = this->GetStationIndexActive(iStLocal, static_cast<EDetectorID>(iDet)); + if (iStActive < 0) { + continue; + } + msg << indent << indentCh; + msg << setw(9) << iStActive; + msg << setw(9) << fMisalignmentX[iDet]; + msg << setw(9) << fMisalignmentY[iDet]; + msg << setw(9) << fMisalignmentT[iDet] << '\n'; + } + } + msg << indent << clrs::CLb << "DEV FLAGS:" << clrs::CL << " (for debug only)\n"; msg << indent << indentCh << "Hits search area is ignored: " << fDevIsIgnoreHitSearchAreas << '\n'; msg << indent << indentCh << "Non-approx. field is used: " << fDevIsMatchDoubletsViaMc << '\n'; diff --git a/macro/L1/configs/ca_params_mcbm.yaml b/macro/L1/configs/ca_params_mcbm.yaml index 336d368b8b745011e5e81d0d7c6a9bc0c98cf57b..d2ed450988e006c8dc866f3817a099999342ae91 100644 --- a/macro/L1/configs/ca_params_mcbm.yaml +++ b/macro/L1/configs/ca_params_mcbm.yaml @@ -28,6 +28,13 @@ ca: #inactive_stations: ['MUCH'] inactive_stations: ['MUCH'] + # Misalignment tolerances x[cm], y[cm], t[ns] + misalignment_tolerance: + sts: [0.2, 0.2, 100.0] + much: [0.2, 0.2, 100.0] + trd: [0.2, 0.2, 100.0] + tof: [0.2, 0.2, 100.0] + # Random seed random_seed: 1 diff --git a/macro/beamtime/mcbm2022/mcbm_digievent_display.C b/macro/beamtime/mcbm2022/mcbm_digievent_display.C index a4f597eede74d581039c9255d1bc22c72a22f834..8695ad0203641f584f5ab3a4d3d625b528984cd7 100644 --- a/macro/beamtime/mcbm2022/mcbm_digievent_display.C +++ b/macro/beamtime/mcbm2022/mcbm_digievent_display.C @@ -500,9 +500,6 @@ Bool_t mcbm_digievent_display(UInt_t uRunId = 2391, l1->DisableTrackingStation(cbm::algo::ca::EDetectorID::kMuch, 1); l1->DisableTrackingStation(cbm::algo::ca::EDetectorID::kMuch, 2); } - l1->SetMisalignmentSts(.2, .2, 100.); - l1->SetMisalignmentTrd(.2, .2, 100.); - l1->SetMisalignmentTof(.2, .2, 100.); run->AddTask(l1); diff --git a/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C b/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C index e58c3d951c2ac774b657aa77c269ae69e4bc50a8..4482012a19a367c9df6509931103e45f97c1ca76 100644 --- a/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C +++ b/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C @@ -606,10 +606,6 @@ Bool_t mcbm_event_reco_L1(UInt_t uRunId = 2570, l1->SetVerbose(3); run->AddTask(l1); - l1->SetMisalignmentSts(.2, .2, 10.); - l1->SetMisalignmentTrd(.2, .2, 10.); - l1->SetMisalignmentTof(.2, .2, 10.); - CbmL1GlobalTrackFinder* globalTrackFinder = new CbmL1GlobalTrackFinder(); FairTask* globalFindTracks = new CbmL1GlobalFindTracksEvents(globalTrackFinder); run->AddTask(globalFindTracks); diff --git a/macro/beamtime/mcbm2022/mcbm_reco.C b/macro/beamtime/mcbm2022/mcbm_reco.C index a763ea4cd63dc7b1208cafc7b62fe0f6c24af8fb..cb1d14f36a10a3aba59c96492ce9e6a3af868a7b 100644 --- a/macro/beamtime/mcbm2022/mcbm_reco.C +++ b/macro/beamtime/mcbm2022/mcbm_reco.C @@ -528,9 +528,6 @@ Bool_t mcbm_reco(UInt_t uRunId = 2391, CbmL1* l1 = new CbmL1("L1", 0); // <= Disable verbose mode l1->SetMcbmMode(); - l1->SetMisalignmentSts(.2, .2, 10.); - l1->SetMisalignmentTrd(.2, .2, 10.); - l1->SetMisalignmentTof(.2, .2, 10.); run->AddTask(l1); diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 8b43048cae1da1ee3fef51efc499b6e458cfdafc..4696aea69887d3733a6a3690008a35651373facd 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -214,11 +214,6 @@ InitStatus CbmL1::Init() fUseMUCH = true; fUseTRD = true; fUseTOF = true; - TString tag; - CbmSetup::Instance()->GetGeoTag(ECbmModuleId::kMuch, tag); - if (tag.Contains("mcbm")) { // currently disable tracking in much for all mcbm setups - fUseMUCH = false; - } // fInitManager.DevSetIgnoreHitSearchAreas(true); // uncomment for debug } @@ -361,18 +356,6 @@ InitStatus CbmL1::Init() } fInitManager.SetActiveDetectorIDs(vActiveTrackingDetectorIDs); - // ********************************* - // ** Misalignment initialization ** - // ********************************* - - for (int iDet = 0; iDet != static_cast<int>(cbm::algo::ca::EDetectorID::kEND); ++iDet) { - auto detId = cbm::algo::ca::EDetectorID(iDet); - fInitManager.SetMisalignmentX(detId, fvMisalignment[detId][0]); - fInitManager.SetMisalignmentY(detId, fvMisalignment[detId][1]); - fInitManager.SetMisalignmentT(detId, fvMisalignment[detId][2]); - LOG(info) << "CbmL1: misalignment for " << cbm::ca::kDetName[detId] << " is set to " << fvMisalignment[detId][0] - << " " << fvMisalignment[detId][1] << " " << fvMisalignment[detId][2]; - } // ************************************* // ** Stations layout initialization ** @@ -458,7 +441,7 @@ InitStatus CbmL1::Init() for (int iSt = 0; iSt < nTrdStationsGeom; ++iSt) { auto stationInfo = ca::StationInitializer(ca::EDetectorID::kTrd, iSt); // TODO: SZh 15.08.2022: Replace station type with ca::EDetectorID - stationInfo.SetStationType((iSt == 1 || iSt == 3) ? 6 : 3); // MuCh + stationInfo.SetStationType(3); stationInfo.SetTimeInfo(!bDisableTime && trdInterface->IsTimeInfoProvided(iSt)); stationInfo.SetFieldStatus(0); stationInfo.SetZref(trdInterface->GetZref(iSt)); diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index 8bfd589ec32498af00f11b3c9b4c3bdb96e6f896..fb798ece097dbdd423e1ee83e426c226f2430be0 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -249,15 +249,6 @@ class CbmL1 : public FairTask { void SetMcbmMode() { fTrackingMode = ca::Framework::TrackingMode::kMcbm; } void SetGlobalMode() { fTrackingMode = ca::Framework::TrackingMode::kGlobal; } - /// Sets misalignment of the detector - void SetMisalignment(ca::EDetectorID det, float dx, float dy, float dt) { fvMisalignment[det] = {{dx, dy, dt}}; } - - void SetMisalignmentMvd(float dx, float dy, float dt) { SetMisalignment(ca::EDetectorID::kMvd, dx, dy, dt); } - void SetMisalignmentSts(float dx, float dy, float dt) { SetMisalignment(ca::EDetectorID::kSts, dx, dy, dt); } - void SetMisalignmentMuch(float dx, float dy, float dt) { SetMisalignment(ca::EDetectorID::kMuch, dx, dy, dt); } - void SetMisalignmentTrd(float dx, float dy, float dt) { SetMisalignment(ca::EDetectorID::kTrd, dx, dy, dt); } - void SetMisalignmentTof(float dx, float dy, float dt) { SetMisalignment(ca::EDetectorID::kTof, dx, dy, dt); } - ca::TrackingMonitor fMonitor{}; ///< Tracking monitor // void SetTrackingLevel( Int_t iLevel ){ fTrackingLevel = iLevel; } @@ -430,9 +421,6 @@ class CbmL1 : public FairTask { ca::InitManager fInitManager; ///< Tracking parameters data manager std::shared_ptr<ca::DataManager> fpIODataManager = nullptr; ///< Input-output data manager - cbm::ca::DetIdArr_t<std::array<float, 3>> fvMisalignment = {{{{0.}}}}; ///< Misalignment - // (so many braces are needed to satisfy the clang compiler) - public: // ** Basic data members **