diff --git a/core/base/CMakeLists.txt b/core/base/CMakeLists.txt index 00ff9e160c7873077696ce4bf984c3e6fe512511..567c4c3a0ed1f3ff957e67b2b0d2a9fdecf1b8af 100644 --- a/core/base/CMakeLists.txt +++ b/core/base/CMakeLists.txt @@ -25,6 +25,7 @@ set(SRCS report/CbmLatexReportElement.cxx utils/CbmUtils.cxx utils/CbmGeometryUtils.cxx + utils/CbmMcbmUtils.cxx utils/CbmMediaList.cxx utils/CbmFileUtils.cxx ) diff --git a/core/base/CbmBaseLinkDef.h b/core/base/CbmBaseLinkDef.h index 5a79379a939850719a20d4a2a51cb00be82da1f9..df3992ea8365c3e429de20e2fa224c77755c5173 100644 --- a/core/base/CbmBaseLinkDef.h +++ b/core/base/CbmBaseLinkDef.h @@ -79,4 +79,11 @@ #pragma link C++ class std::pair < TString, TString>; #pragma link C++ function Cbm::File::IsRootFile( string ); + +#pragma link C++ namespace cbm; +#pragma link C++ namespace cbm::mcbm; +#pragma link C++ function cbm::mcbm::GetSetupFromRunId(uint64_t); +// Class needed to trigger loading of the library as no fct dict in ROOT6 and CLING +#pragma link C++ class cbm::mcbm::ToForceLibLoad; + #endif diff --git a/core/base/utils/CbmMcbmUtils.cxx b/core/base/utils/CbmMcbmUtils.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e99e9f04d752e82296cf61f162d2dd42a0dffd62 --- /dev/null +++ b/core/base/utils/CbmMcbmUtils.cxx @@ -0,0 +1,54 @@ +/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Pierre-Alain Loizeau [committer] */ + +#include "CbmMcbmUtils.h" + +#include <stdexcept> + +namespace cbm +{ + namespace mcbm + { + std::string GetSetupFromRunId(uint64_t ulRunId) + { + /// General remark: only runs known to exist on disk/tape are mapped so "holes" are not an oversight + /// => if necessary exception throwing can also be added for them but anyway analysis will crash (no raw data) + + /// 2021 "CRI" runs: 1575 - 1588 = 15/07/2021 + std::string sSetupName = "mcbm_beam_2021_07_surveyed"; + if (ulRunId < 1575) { + /// Only runs at earliest in the 2021 benchmark beamtime and with all 6 systems are supported by this function + /// From mCBM redmine wiki page: "run 1575: 1st run with 6 subsystems" + throw(std::invalid_argument("RunId smaller than the earliest run mapped (1575 in 2021 campaign)")); + } + /// Setup changed multiple times between the 2022 carbon and uranium runs + else if (2060 <= ulRunId && ulRunId <= 2065) { + /// Carbon runs: 2060 - 2065 = 10/03/2022 + sSetupName = "mcbm_beam_2022_03_09_carbon"; + } + else if (2150 <= ulRunId && ulRunId <= 2160) { + /// Iron runs: 2150 - 2160 = 24-25/03/2022 + sSetupName = "mcbm_beam_2022_03_22_iron"; + } + else if (2176 <= ulRunId && ulRunId <= 2310) { + /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 + sSetupName = "mcbm_beam_2022_03_28_uranium"; + } + else if (2350 <= ulRunId && ulRunId <= 2397) { + /// Nickel runs: 2350 - 2397 = 23/05/2022 - 25/05/2022 (Lambda Benchmark but mTOF troubles) + sSetupName = "mcbm_beam_2022_05_23_nickel"; + } + else if (2454 <= ulRunId && ulRunId <= 2497) { + /// Lambda Benchmark Gold runs: 2454 - 2497 = 16/06/2022 - 18/06/2022 + sSetupName = "mcbm_beam_2022_06_16_gold"; + } + else if (2497 < ulRunId) { + /// Future runs, exception there to force implementation and support from users side + throw(std::invalid_argument("RunId bigger than latest run mapped (2497, mCBM 2022)! Please complete the map!")); + } + + return sSetupName; + } + } // namespace mcbm +} // namespace cbm diff --git a/core/base/utils/CbmMcbmUtils.h b/core/base/utils/CbmMcbmUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..0074d21d6504ec2ae5c14968d10ac41ab320e059 --- /dev/null +++ b/core/base/utils/CbmMcbmUtils.h @@ -0,0 +1,18 @@ +/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Pierre-Alain Loizeau [committer] */ + +#include <cstdint> +#include <string> + +namespace cbm +{ + namespace mcbm + { + std::string GetSetupFromRunId(uint64_t uRunId); + + /// Class needed to trigger loading of the library as no fct dict in ROOT6 and CLING + class ToForceLibLoad { + }; + } // namespace mcbm +} // namespace cbm diff --git a/macro/beamtime/mcbm2022/mcbm_digievent_reco.C b/macro/beamtime/mcbm2022/mcbm_digievent_reco.C index 75f695b2917ddc8b72c68bc600247e9db356bf07..1901e6a82cfac3e3a5915bebe185b46f848556b5 100644 --- a/macro/beamtime/mcbm2022/mcbm_digievent_reco.C +++ b/macro/beamtime/mcbm2022/mcbm_digievent_reco.C @@ -105,26 +105,16 @@ Bool_t mcbm_digievent_reco(UInt_t uRunId = 2365, // --- Load the geometry setup ---- // This is currently only required by the TRD (parameters) - TString geoSetupTag = "mcbm_beam_2021_07_surveyed"; - if (2060 <= uRunId) { - /// Setup changed multiple times between the 2022 carbon and uranium runs - if (uRunId <= 2065) { - /// Carbon runs: 2060 - 2065 = 10/03/2022 - geoSetupTag = "mcbm_beam_2022_03_09_carbon"; - } - else if (2150 <= uRunId && uRunId <= 2160) { - /// Iron runs: 2150 - 2160 = 24-25/03/2022 - geoSetupTag = "mcbm_beam_2022_03_22_iron"; - } - else if (2176 <= uRunId && uRunId <= 2310) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - geoSetupTag = "mcbm_beam_2022_03_28_uranium"; - } - else if (2352 <= uRunId) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - geoSetupTag = "mcbm_beam_2022_05_20_nickel"; - } + cbm::mcbm::ToForceLibLoad dummy; /// Needed to trigger loading of the library as no fct dict in ROOT6 and CLING + TString geoSetupTag = ""; + try { + geoSetupTag = cbm::mcbm::GetSetupFromRunId(uRunId); + } + catch (const std::invalid_argument& e) { + std::cout << "Error in mapping from runID to setup name: " << e.what() << std::endl; + return kFALSE; } + TString geoFile = srcDir + "/macro/mcbm/data/" + geoSetupTag + ".geo.root"; CbmSetup* geoSetup = CbmSetup::Instance(); geoSetup->LoadSetup(geoSetupTag); diff --git a/macro/beamtime/mcbm2022/mcbm_event_reco.C b/macro/beamtime/mcbm2022/mcbm_event_reco.C index e4640c7645f99a4d851b08d96287c7fe052ec979..5cbf432aad4f771b1bdcea35920b2f88c4c11495 100644 --- a/macro/beamtime/mcbm2022/mcbm_event_reco.C +++ b/macro/beamtime/mcbm2022/mcbm_event_reco.C @@ -117,26 +117,16 @@ Bool_t mcbm_event_reco(UInt_t uRunId = 2391, // --- Load the geometry setup ---- // This is currently only required by the TRD (parameters) - TString geoSetupTag = "mcbm_beam_2021_07_surveyed"; - if (2060 <= uRunId) { - /// Setup changed multiple times between the 2022 carbon and uranium runs - if (uRunId <= 2065) { - /// Carbon runs: 2060 - 2065 = 10/03/2022 - geoSetupTag = "mcbm_beam_2022_03_09_carbon"; - } - else if (2150 <= uRunId && uRunId <= 2160) { - /// Iron runs: 2150 - 2160 = 24-25/03/2022 - geoSetupTag = "mcbm_beam_2022_03_22_iron"; - } - else if (2176 <= uRunId && uRunId <= 2310) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - geoSetupTag = "mcbm_beam_2022_03_28_uranium"; - } - else if (2352 <= uRunId) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - geoSetupTag = "mcbm_beam_2022_05_23_nickel"; - } + cbm::mcbm::ToForceLibLoad dummy; /// Needed to trigger loading of the library as no fct dict in ROOT6 and CLING + TString geoSetupTag = ""; + try { + geoSetupTag = cbm::mcbm::GetSetupFromRunId(uRunId); + } + catch (const std::invalid_argument& e) { + std::cout << "Error in mapping from runID to setup name: " << e.what() << std::endl; + return kFALSE; } + TString geoFile = srcDir + "/macro/mcbm/data/" + geoSetupTag + ".geo.root"; CbmSetup* geoSetup = CbmSetup::Instance(); geoSetup->LoadSetup(geoSetupTag); @@ -720,16 +710,16 @@ Bool_t mcbm_event_reco(UInt_t uRunId = 2391, tofFindTracks->SetStation(15, 0, 0, 4); /* - tofFindTracks->SetStation(16, 0, 3, 2); - tofFindTracks->SetStation(17, 0, 4, 2); - tofFindTracks->SetStation(18, 0, 3, 1); + tofFindTracks->SetStation(16, 0, 3, 2); + tofFindTracks->SetStation(17, 0, 4, 2); + tofFindTracks->SetStation(18, 0, 3, 1); tofFindTracks->SetStation(19, 0, 4, 1); - tofFindTracks->SetStation(20, 0, 3, 3); + tofFindTracks->SetStation(20, 0, 3, 3); tofFindTracks->SetStation(21, 0, 4, 3); - tofFindTracks->SetStation(22, 0, 3, 0); + tofFindTracks->SetStation(22, 0, 3, 0); tofFindTracks->SetStation(23, 0, 4, 0); - tofFindTracks->SetStation(24, 0, 3, 4); - tofFindTracks->SetStation(25, 0, 4, 4); + tofFindTracks->SetStation(24, 0, 3, 4); + tofFindTracks->SetStation(25, 0, 4, 4); */ break; diff --git a/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C b/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C index bb957967f51d7c1c8a39f4c57422b5bbad570912..2648f989476a766a1ac670ceda28653a3e403bba 100644 --- a/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C +++ b/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C @@ -125,25 +125,14 @@ Bool_t mcbm_event_reco_L1(UInt_t uRunId = 2391, // --- Load the geometry setup ---- // This is currently only required by the TRD (parameters) - TString geoSetupTag = "mcbm_beam_2021_07_surveyed"; - if (2060 <= uRunId) { - /// Setup changed multiple times between the 2022 carbon and uranium runs - if (uRunId <= 2065) { - /// Carbon runs: 2060 - 2065 = 10/03/2022 - geoSetupTag = "mcbm_beam_2022_03_09_carbon"; - } - else if (2150 <= uRunId && uRunId <= 2160) { - /// Iron runs: 2150 - 2160 = 24-25/03/2022 - geoSetupTag = "mcbm_beam_2022_03_22_iron"; - } - else if (2176 <= uRunId && uRunId <= 2310) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - geoSetupTag = "mcbm_beam_2022_03_28_uranium"; - } - else if (2352 <= uRunId) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - geoSetupTag = "mcbm_beam_2022_05_23_nickel"; - } + cbm::mcbm::ToForceLibLoad dummy; /// Needed to trigger loading of the library as no fct dict in ROOT6 and CLING + TString geoSetupTag = ""; + try { + geoSetupTag = cbm::mcbm::GetSetupFromRunId(uRunId); + } + catch (const std::invalid_argument& e) { + std::cout << "Error in mapping from runID to setup name: " << e.what() << std::endl; + return kFALSE; } TString geoFile = sInpDir + "/" + geoSetupTag + ".geo.root"; diff --git a/macro/beamtime/mcbm2022/mcbm_unp_event.C b/macro/beamtime/mcbm2022/mcbm_unp_event.C index d9ddfb4a36ac900afa75c0dc55b180e8c9dfbc19..e8cebd9f0a8111445a42248db6322e52e41f3d52 100644 --- a/macro/beamtime/mcbm2022/mcbm_unp_event.C +++ b/macro/beamtime/mcbm2022/mcbm_unp_event.C @@ -367,27 +367,15 @@ Bool_t mcbm_unp_event(std::string infile, // ----- CbmSetup ----------------------------------------------------- - if (2060 <= uRunId && defaultSetupName == setupName) { - /// Setup changed multiple times between the 2022 carbon and uranium runs - if (uRunId <= 2065) { - /// Carbon runs: 2060 - 2065 = 10/03/2022 - setupName = "mcbm_beam_2022_03_09_carbon"; - } - else if (2150 <= uRunId && uRunId <= 2160) { - /// Iron runs: 2150 - 2160 = 24-25/03/2022 - setupName = "mcbm_beam_2022_03_22_iron"; - } - else if (2176 <= uRunId && uRunId <= 2310) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - setupName = "mcbm_beam_2022_03_28_uranium"; - } - else if (2350 <= uRunId && uRunId <= 2397) { - /// Nickel runs: 2350 - 2397 = 23/05/2022 - 25/05/2022 - setupName = "mcbm_beam_2022_05_23_nickel"; - } - else if (2454 <= uRunId && uRunId <= 2497) { - /// Lambda Benchmark Gold runs: 2454 - 2497 = 16/06/2022 - 18/06/2022 - setupName = "mcbm_beam_2022_06_16_gold"; + /// Do automatic mapping only if not overridden by user + if (defaultSetupName == setupName) { + cbm::mcbm::ToForceLibLoad dummy; /// Needed to trigger loading of the library as no fct dict in ROOT6 and CLING + try { + setupName = cbm::mcbm::GetSetupFromRunId(runid); + } + catch (const std::invalid_argument& e) { + std::cout << "Error in mapping from runID to setup name: " << e.what() << std::endl; + return; } if (defaultSetupName != setupName) { std::cout << "Automatic setup choice for run " << uRunId << ": " << setupName << std::endl; diff --git a/macro/run/run_unpack_online.C b/macro/run/run_unpack_online.C index f34b29975f0ce2079dcd21cfa4895dceb952af27..f5c1b5196a472d8925475bb96085c7ec0a406954 100644 --- a/macro/run/run_unpack_online.C +++ b/macro/run/run_unpack_online.C @@ -73,27 +73,15 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55 // ----- CbmSetup ----------------------------------------------------- - if (2060 <= runid && defaultSetupName == setupName) { - /// Setup changed multiple times between the 2022 carbon and uranium runs - if (runid <= 2065) { - /// Carbon runs: 2060 - 2065 = 10/03/2022 - setupName = "mcbm_beam_2022_03_09_carbon"; - } - else if (2150 <= runid && runid <= 2160) { - /// Iron runs: 2150 - 2160 = 24-25/03/2022 - setupName = "mcbm_beam_2022_03_22_iron"; - } - else if (2176 <= runid && runid <= 2310) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - setupName = "mcbm_beam_2022_03_28_uranium"; - } - else if (2350 <= runid && runid <= 2397) { - /// Nickel runs: 2350 - 2397 = 23/05/2022 - 25/05/2022 - setupName = "mcbm_beam_2022_05_23_nickel"; - } - else if (2454 <= runid && runid <= 2497) { - /// Lambda Benchmark Gold runs: 2454 - 2497 = 16/06/2022 - 18/06/2022 - setupName = "mcbm_beam_2022_06_16_gold"; + /// Do automatic mapping only if not overridden by user + if (defaultSetupName == setupName) { + cbm::mcbm::ToForceLibLoad dummy; /// Needed to trigger loading of the library as no fct dict in ROOT6 and CLING + try { + setupName = cbm::mcbm::GetSetupFromRunId(runid); + } + catch (const std::invalid_argument& e) { + std::cout << "Error in mapping from runID to setup name: " << e.what() << std::endl; + return; } if (defaultSetupName != setupName) { std::cout << "Automatic setup choice for run " << runid << ": " << setupName << std::endl; diff --git a/macro/run/run_unpack_online_bmon.C b/macro/run/run_unpack_online_bmon.C index 07802aab9b430bc64eabc80cc948646afb97d0c6..80b4113402ead03ad255485adad29068f875b2c7 100644 --- a/macro/run/run_unpack_online_bmon.C +++ b/macro/run/run_unpack_online_bmon.C @@ -65,27 +65,15 @@ void run_unpack_online_bmon(std::vector<std::string> publisher = {"tcp://localho // ----- CbmSetup ----------------------------------------------------- - if (2060 <= runid && defaultSetupName == setupName) { - /// Setup changed multiple times between the 2022 carbon and uranium runs - if (runid <= 2065) { - /// Carbon runs: 2060 - 2065 = 10/03/2022 - setupName = "mcbm_beam_2022_03_09_carbon"; + /// Do automatic mapping only if not overridden by user + if (defaultSetupName == setupName) { + cbm::mcbm::ToForceLibLoad dummy; /// Needed to trigger loading of the library as no fct dict in ROOT6 and CLING + try { + setupName = cbm::mcbm::GetSetupFromRunId(runid); } - else if (2150 <= runid && runid <= 2160) { - /// Iron runs: 2150 - 2160 = 24-25/03/2022 - setupName = "mcbm_beam_2022_03_22_iron"; - } - else if (2176 <= runid && runid <= 2310) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - setupName = "mcbm_beam_2022_03_28_uranium"; - } - else if (2350 <= runid && runid <= 2397) { - /// Nickel runs: 2350 - 2397 = 23/05/2022 - 25/05/2022 - setupName = "mcbm_beam_2022_05_23_nickel"; - } - else if (2454 <= runid && runid <= 2497) { - /// Lambda Benchmark Gold runs: 2454 - 2497 = 16/06/2022 - 18/06/2022 - setupName = "mcbm_beam_2022_06_16_gold"; + catch (const std::invalid_argument& e) { + std::cout << "Error in mapping from runID to setup name: " << e.what() << std::endl; + return; } if (defaultSetupName != setupName) { std::cout << "Automatic setup choice for run " << runid << ": " << setupName << std::endl; diff --git a/macro/run/run_unpack_tsa.C b/macro/run/run_unpack_tsa.C index abbaf51496b6a877f56ff0b94790c8915530c236..dafd149d70f3f34949fd75e3d37dd95789f80fa3 100644 --- a/macro/run/run_unpack_tsa.C +++ b/macro/run/run_unpack_tsa.C @@ -91,27 +91,15 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid // ----- CbmSetup ----------------------------------------------------- - if (2060 <= runid && defaultSetupName == setupName) { - /// Setup changed multiple times between the 2022 carbon and uranium runs - if (runid <= 2065) { - /// Carbon runs: 2060 - 2065 = 10/03/2022 - setupName = "mcbm_beam_2022_03_09_carbon"; + /// Do automatic mapping only if not overridden by user + if (defaultSetupName == setupName) { + cbm::mcbm::ToForceLibLoad dummy; /// Needed to trigger loading of the library as no fct dict in ROOT6 and CLING + try { + setupName = cbm::mcbm::GetSetupFromRunId(runid); } - else if (2150 <= runid && runid <= 2160) { - /// Iron runs: 2150 - 2160 = 24-25/03/2022 - setupName = "mcbm_beam_2022_03_22_iron"; - } - else if (2176 <= runid && runid <= 2310) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - setupName = "mcbm_beam_2022_03_28_uranium"; - } - else if (2350 <= runid && runid <= 2397) { - /// Nickel runs: 2350 - 2397 = 23/05/2022 - 25/05/2022 - setupName = "mcbm_beam_2022_05_23_nickel"; - } - else if (2454 <= runid && runid <= 2497) { - /// Lambda Benchmark Gold runs: 2454 - 2497 = 16/06/2022 - 18/06/2022 - setupName = "mcbm_beam_2022_06_16_gold"; + catch (const std::invalid_argument& e) { + std::cout << "Error in mapping from runID to setup name: " << e.what() << std::endl; + return; } if (defaultSetupName != setupName) { std::cout << "Automatic setup choice for run " << runid << ": " << setupName << std::endl; @@ -119,6 +107,7 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid } auto cbmsetup = CbmSetup::Instance(); cbmsetup->LoadSetup(setupName.c_str()); + // ------------------------------------------------------------------------ // ----- UnpackerConfigs ---------------------------------------------- diff --git a/macro/run/run_unpack_tsa_bmon.C b/macro/run/run_unpack_tsa_bmon.C index 8cc767029f5cbc976f028d601f6882d8af0399b3..c9bf7137f87fd92bc37f676bb3c6557d57466d20 100644 --- a/macro/run/run_unpack_tsa_bmon.C +++ b/macro/run/run_unpack_tsa_bmon.C @@ -78,27 +78,15 @@ void run_unpack_tsa_bmon(std::vector<std::string> infile = {"test.tsa"}, UInt_t // ----- CbmSetup ----------------------------------------------------- - if (2060 <= runid && defaultSetupName == setupName) { - /// Setup changed multiple times between the 2022 carbon and uranium runs - if (runid <= 2065) { - /// Carbon runs: 2060 - 2065 = 10/03/2022 - setupName = "mcbm_beam_2022_03_09_carbon"; + /// Do automatic mapping only if not overridden by user + if (defaultSetupName == setupName) { + cbm::mcbm::ToForceLibLoad dummy; /// Needed to trigger loading of the library as no fct dict in ROOT6 and CLING + try { + setupName = cbm::mcbm::GetSetupFromRunId(runid); } - else if (2150 <= runid && runid <= 2160) { - /// Iron runs: 2150 - 2160 = 24-25/03/2022 - setupName = "mcbm_beam_2022_03_22_iron"; - } - else if (2176 <= runid && runid <= 2310) { - /// Uranium runs: 2176 - 2310 = 30/03/2022 - 01/04/2022 - setupName = "mcbm_beam_2022_03_28_uranium"; - } - else if (2350 <= runid && runid <= 2397) { - /// Nickel runs: 2350 - 2397 = 23/05/2022 - 25/05/2022 - setupName = "mcbm_beam_2022_05_23_nickel"; - } - else if (2454 <= runid && runid <= 2497) { - /// Lambda Benchmark Gold runs: 2454 - 2497 = 16/06/2022 - 18/06/2022 - setupName = "mcbm_beam_2022_06_16_gold"; + catch (const std::invalid_argument& e) { + std::cout << "Error in mapping from runID to setup name: " << e.what() << std::endl; + return; } if (defaultSetupName != setupName) { std::cout << "Automatic setup choice for run " << runid << ": " << setupName << std::endl;