From 7a049115eb8587b701d6dce8f723a19e65ef05e2 Mon Sep 17 00:00:00 2001 From: Pascal Raisig <praisig@ikf.uni-frankfurt.de> Date: Fri, 22 Jan 2021 12:22:26 +0100 Subject: [PATCH] Add ascii parameter loading for Trd To fix the tests for these macros, the Trd parameters need to be loaded from the ascii file db. Since, during the tests no par.root file from the unpacking is available --- macro/beamtime/mcbm2020/mcbm_build_and_reco.C | 41 +++++++++++++++++-- .../mcbm2020/mcbm_build_and_reco_kronos.C | 37 ++++++++++++++++- macro/beamtime/mcbm2020/mcbm_event_reco.C | 35 +++++++++++++++- .../mcbm2020/mcbm_event_reco_kronos.C | 37 ++++++++++++++++- macro/beamtime/mcbm2020/mcbm_reco.C | 35 +++++++++++++++- macro/beamtime/mcbm2020/mcbm_reco_kronos.C | 36 +++++++++++++++- 6 files changed, 209 insertions(+), 12 deletions(-) diff --git a/macro/beamtime/mcbm2020/mcbm_build_and_reco.C b/macro/beamtime/mcbm2020/mcbm_build_and_reco.C index 114865dfd9..95f0b46f6c 100644 --- a/macro/beamtime/mcbm2020/mcbm_build_and_reco.C +++ b/macro/beamtime/mcbm2020/mcbm_build_and_reco.C @@ -27,13 +27,21 @@ void mcbm_build_and_reco(UInt_t uRunId = 28, // ----- In- and output file names ------------------------------------ - TString inFile = Form("./data/unp_mcbm_%i.root", uRunId); - TString parFileIn = Form("./data/unp_mcbm_params_%i.root", uRunId); - TString geoFile = paramDir + "mcbm2020_reco.geo.root"; // Created in sim. run + TString inFile = Form("./data/unp_mcbm_%i.root", uRunId); + TString parFileIn = Form("./data/unp_mcbm_params_%i.root", uRunId); TString parFileOut = Form("./data/reco_mcbm_evt_win_params_%u.root", uRunId); TString outFile = Form("./data/reco_mcbm_evt_win_%u.root", uRunId); // ------------------------------------------------------------------------ + // --- Load the geometry setup ---- + // This is currently only required by the TRD (parameters) + std::string geoSetupTag = "mcbm_beam_2020_03"; + TString geoFile = + paramDir + geoSetupTag.data() + ".geo.root"; // Created in sim. run + CbmSetup* geoSetup = CbmSetup::Instance(); + geoSetup->LoadSetup(geoSetupTag.data()); + TList* parFileList = new TList(); + // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; @@ -198,6 +206,29 @@ void mcbm_build_and_reco(UInt_t uRunId = 28, // ----- Local reconstruction in TRD ---------------------------------- + // Load parameters <- they are required by the hit producer. + // For now, it is enough to load the default ascii parameters + // if no root file is existing from the unpacking process. + TString geoTagTrd = ""; + bool isActiveTrd = + (geoSetup->GetGeoTag(ECbmModuleId::kTrd, geoTagTrd)) ? true : false; + if (!isActiveTrd) { + LOG(warning) << Form( + "TRD - parameter loading - Trd not found in CbmSetup(%s) -> parameters " + "can not be loaded correctly!", + geoSetupTag.data()); + } else { + TString paramFilesTrd( + Form("%s/parameters/trd/trd_%s", srcDir.Data(), geoTagTrd.Data())); + std::vector<std::string> paramFilesVecTrd; + CbmTrdParManager::GetParFileExtensions(¶mFilesVecTrd); + for (auto parIt : paramFilesVecTrd) { + parFileList->Add( + new TObjString(Form("%s.%s.par", paramFilesTrd.Data(), parIt.data()))); + } + } + // -- end trd parameters + // -- beginn trd reco Double_t triggerThreshold = 0.5e-6; // Default CbmTrdClusterFinder* trdCluster = new CbmTrdClusterFinder(); trdCluster->SetNeighbourEnable(true, false); @@ -247,8 +278,10 @@ void mcbm_build_and_reco(UInt_t uRunId = 28, FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); FairParRootFileIo* parIo3 = new FairParRootFileIo(); parIo1->open(parFileIn.Data(), "READ"); - parIo3->open(parFileOut.Data(), "RECREATE"); rtdb->setFirstInput(parIo1); + parIo2->open(parFileList, "in"); + rtdb->setSecondInput(parIo2); + parIo3->open(parFileOut.Data(), "RECREATE"); // ------------------------------------------------------------------------ diff --git a/macro/beamtime/mcbm2020/mcbm_build_and_reco_kronos.C b/macro/beamtime/mcbm2020/mcbm_build_and_reco_kronos.C index 2e34db6e56..f4d5108754 100644 --- a/macro/beamtime/mcbm2020/mcbm_build_and_reco_kronos.C +++ b/macro/beamtime/mcbm2020/mcbm_build_and_reco_kronos.C @@ -64,11 +64,19 @@ void mcbm_build_and_reco_kronos(UInt_t uRunIdx = 28, // ----- In- and output file names ------------------------------------ - TString geoFile = paramDir + "mcbm2020_reco.geo.root"; // Created in sim. run TString parFileOut = Form("./data/reco_mcbm_evt_win_params_%u.root", uRunId); TString outFile = Form("./data/reco_mcbm_evt_win_%u.root", uRunId); // ------------------------------------------------------------------------ + // --- Load the geometry setup ---- + // This is currently only required by the TRD (parameters) + std::string geoSetupTag = "mcbm_beam_2020_03"; + TString geoFile = + paramDir + geoSetupTag.data() + ".geo.root"; // Created in sim. run + CbmSetup* geoSetup = CbmSetup::Instance(); + geoSetup->LoadSetup(geoSetupTag.data()); + TList* parFileList = new TList(); + // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; @@ -233,6 +241,29 @@ void mcbm_build_and_reco_kronos(UInt_t uRunIdx = 28, // ----- Local reconstruction in TRD ---------------------------------- + // Load parameters <- they are required by the hit producer. + // For now, it is enough to load the default ascii parameters + // if no root file is existing from the unpacking process. + TString geoTagTrd = ""; + bool isActiveTrd = + (geoSetup->GetGeoTag(ECbmModuleId::kTrd, geoTagTrd)) ? true : false; + if (!isActiveTrd) { + LOG(warning) << Form( + "TRD - parameter loading - Trd not found in CbmSetup(%s) -> parameters " + "can not be loaded correctly!", + geoSetupTag.data()); + } else { + TString paramFilesTrd( + Form("%s/parameters/trd/trd_%s", srcDir.Data(), geoTagTrd.Data())); + std::vector<std::string> paramFilesVecTrd; + CbmTrdParManager::GetParFileExtensions(¶mFilesVecTrd); + for (auto parIt : paramFilesVecTrd) { + parFileList->Add( + new TObjString(Form("%s.%s.par", paramFilesTrd.Data(), parIt.data()))); + } + } + // -- end trd parameters + // -- beginn trd reco Double_t triggerThreshold = 0.5e-6; // Default CbmTrdClusterFinder* trdCluster = new CbmTrdClusterFinder(); trdCluster->SetNeighbourEnable(true, false); @@ -282,8 +313,10 @@ void mcbm_build_and_reco_kronos(UInt_t uRunIdx = 28, FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); FairParRootFileIo* parIo3 = new FairParRootFileIo(); parIo1->open(parFileIn.Data(), "READ"); - parIo3->open(parFileOut.Data(), "RECREATE"); rtdb->setFirstInput(parIo1); + parIo2->open(parFileList, "in"); + rtdb->setSecondInput(parIo2); + parIo3->open(parFileOut.Data(), "RECREATE"); // ------------------------------------------------------------------------ diff --git a/macro/beamtime/mcbm2020/mcbm_event_reco.C b/macro/beamtime/mcbm2020/mcbm_event_reco.C index 372de87bbd..ff8aa4d97f 100644 --- a/macro/beamtime/mcbm2020/mcbm_event_reco.C +++ b/macro/beamtime/mcbm2020/mcbm_event_reco.C @@ -24,10 +24,18 @@ void mcbm_event_reco(Int_t runId = 831, Int_t nTimeslices = 300) { // ----- In- and output file names ------------------------------------ TString inFile = Form("./data/unp_mcbm_%i.root", runId); TString parFile = Form("./data/unp_mcbm_params_%i.root", runId); - TString geoFile = paramDir + "mcbm2020_reco.geo.root"; // Created in sim. run TString outFile = Form("./data/reco_mcbm_%i.root", runId); // ------------------------------------------------------------------------ + // --- Load the geometry setup ---- + // This is currently only required by the TRD (parameters) + std::string geoSetupTag = "mcbm_beam_2020_03"; + TString geoFile = + paramDir + geoSetupTag.data() + ".geo.root"; // Created in sim. run + CbmSetup* geoSetup = CbmSetup::Instance(); + geoSetup->LoadSetup(geoSetupTag.data()); + TList* parFileList = new TList(); + // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; @@ -130,6 +138,29 @@ void mcbm_event_reco(Int_t runId = 831, Int_t nTimeslices = 300) { // ----- Local reconstruction in TRD ---------------------------------- + // Load parameters <- they are required by the hit producer. + // For now, it is enough to load the default ascii parameters + // if no root file is existing from the unpacking process. + TString geoTagTrd = ""; + bool isActiveTrd = + (geoSetup->GetGeoTag(ECbmModuleId::kTrd, geoTagTrd)) ? true : false; + if (!isActiveTrd) { + LOG(warning) << Form( + "TRD - parameter loading - Trd not found in CbmSetup(%s) -> parameters " + "can not be loaded correctly!", + geoSetupTag.data()); + } else { + TString paramFilesTrd( + Form("%s/parameters/trd/trd_%s", srcDir.Data(), geoTagTrd.Data())); + std::vector<std::string> paramFilesVecTrd; + CbmTrdParManager::GetParFileExtensions(¶mFilesVecTrd); + for (auto parIt : paramFilesVecTrd) { + parFileList->Add( + new TObjString(Form("%s.%s.par", paramFilesTrd.Data(), parIt.data()))); + } + } + // -- end trd parameters + // -- beginn trd reco Double_t triggerThreshold = 0.5e-6; // Default CbmTrdClusterFinder* trdCluster = new CbmTrdClusterFinder(); trdCluster->SetNeighbourEnable(true, false); @@ -179,6 +210,8 @@ void mcbm_event_reco(Int_t runId = 831, Int_t nTimeslices = 300) { FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); parIo1->open(parFile.Data(), "UPDATE"); rtdb->setFirstInput(parIo1); + parIo2->open(parFileList, "in"); + rtdb->setSecondInput(parIo2); // ------------------------------------------------------------------------ diff --git a/macro/beamtime/mcbm2020/mcbm_event_reco_kronos.C b/macro/beamtime/mcbm2020/mcbm_event_reco_kronos.C index c52aa9730f..b99fd0b0cc 100644 --- a/macro/beamtime/mcbm2020/mcbm_event_reco_kronos.C +++ b/macro/beamtime/mcbm2020/mcbm_event_reco_kronos.C @@ -29,11 +29,19 @@ void mcbm_event_reco(Int_t runId = 831, Int_t nTimeslices = 300) { Form("/lustre/cbm/users/ploizeau/mcbm2020/unp_evt_data_7f229b3f_20201103/" "unp_mcbm_params_%i.root", runId); - TString geoFile = paramDir + "mcbm2020_reco.geo.root"; // Created in sim. run TString parFileOut = Form("./data/reco_mcbm_params_%i.root", runId); TString outFile = Form("./data/reco_mcbm_%i.root", runId); // ------------------------------------------------------------------------ + // --- Load the geometry setup ---- + // This is currently only required by the TRD (parameters) + std::string geoSetupTag = "mcbm_beam_2020_03"; + TString geoFile = + paramDir + geoSetupTag.data() + ".geo.root"; // Created in sim. run + CbmSetup* geoSetup = CbmSetup::Instance(); + geoSetup->LoadSetup(geoSetupTag.data()); + TList* parFileList = new TList(); + // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; @@ -134,6 +142,29 @@ void mcbm_event_reco(Int_t runId = 831, Int_t nTimeslices = 300) { // ----- Local reconstruction in TRD ---------------------------------- + // Load parameters <- they are required by the hit producer. + // For now, it is enough to load the default ascii parameters + // if no root file is existing from the unpacking process. + TString geoTagTrd = ""; + bool isActiveTrd = + (geoSetup->GetGeoTag(ECbmModuleId::kTrd, geoTagTrd)) ? true : false; + if (!isActiveTrd) { + LOG(warning) << Form( + "TRD - parameter loading - Trd not found in CbmSetup(%s) -> parameters " + "can not be loaded correctly!", + geoSetupTag.data()); + } else { + TString paramFilesTrd( + Form("%s/parameters/trd/trd_%s", srcDir.Data(), geoTagTrd.Data())); + std::vector<std::string> paramFilesVecTrd; + CbmTrdParManager::GetParFileExtensions(¶mFilesVecTrd); + for (auto parIt : paramFilesVecTrd) { + parFileList->Add( + new TObjString(Form("%s.%s.par", paramFilesTrd.Data(), parIt.data()))); + } + } + // -- end trd parameters + // -- beginn trd reco Double_t triggerThreshold = 0.5e-6; // Default CbmTrdClusterFinder* trdCluster = new CbmTrdClusterFinder(); trdCluster->SetNeighbourEnable(true, false); @@ -183,8 +214,10 @@ void mcbm_event_reco(Int_t runId = 831, Int_t nTimeslices = 300) { FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); FairParRootFileIo* parIo3 = new FairParRootFileIo(); parIo1->open(parFileIn.Data(), "READ"); - parIo3->open(parFileOut.Data(), "RECREATE"); rtdb->setFirstInput(parIo1); + parIo2->open(parFileList, "in"); + rtdb->setSecondInput(parIo2); + parIo3->open(parFileOut.Data(), "RECREATE"); // ------------------------------------------------------------------------ diff --git a/macro/beamtime/mcbm2020/mcbm_reco.C b/macro/beamtime/mcbm2020/mcbm_reco.C index f593d587c1..e17246e511 100644 --- a/macro/beamtime/mcbm2020/mcbm_reco.C +++ b/macro/beamtime/mcbm2020/mcbm_reco.C @@ -24,10 +24,18 @@ void mcbm_reco(Int_t runId = 831, Int_t nTimeslices = 0) { // ----- In- and output file names ------------------------------------ TString inFile = Form("./data/unp_mcbm_%i.root", runId); TString parFile = Form("./data/unp_mcbm_params_%i.root", runId); - TString geoFile = paramDir + "mcbm2020_reco.geo.root"; // Created in sim. run TString outFile = Form("./data/reco_mcbm_%i.root", runId); // ------------------------------------------------------------------------ + // --- Load the geometry setup ---- + // This is currently only required by the TRD (parameters) + std::string geoSetupTag = "mcbm_beam_2020_03"; + TString geoFile = + paramDir + geoSetupTag.data() + ".geo.root"; // Created in sim. run + CbmSetup* geoSetup = CbmSetup::Instance(); + geoSetup->LoadSetup(geoSetupTag.data()); + TList* parFileList = new TList(); + // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; @@ -113,6 +121,29 @@ void mcbm_reco(Int_t runId = 831, Int_t nTimeslices = 0) { // ----- Local reconstruction in TRD ---------------------------------- + // Load parameters <- they are required by the hit producer. + // For now, it is enough to load the default ascii parameters + // if no root file is existing from the unpacking process. + TString geoTagTrd = ""; + bool isActiveTrd = + (geoSetup->GetGeoTag(ECbmModuleId::kTrd, geoTagTrd)) ? true : false; + if (!isActiveTrd) { + LOG(warning) << Form( + "TRD - parameter loading - Trd not found in CbmSetup(%s) -> parameters " + "can not be loaded correctly!", + geoSetupTag.data()); + } else { + TString paramFilesTrd( + Form("%s/parameters/trd/trd_%s", srcDir.Data(), geoTagTrd.Data())); + std::vector<std::string> paramFilesVecTrd; + CbmTrdParManager::GetParFileExtensions(¶mFilesVecTrd); + for (auto parIt : paramFilesVecTrd) { + parFileList->Add( + new TObjString(Form("%s.%s.par", paramFilesTrd.Data(), parIt.data()))); + } + } + // -- end trd parameters + // -- beginn trd reco Double_t triggerThreshold = 0.5e-6; // Default CbmTrdClusterFinder* trdCluster = new CbmTrdClusterFinder(); trdCluster->SetNeighbourEnable(true, false); @@ -162,6 +193,8 @@ void mcbm_reco(Int_t runId = 831, Int_t nTimeslices = 0) { FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); parIo1->open(parFile.Data(), "UPDATE"); rtdb->setFirstInput(parIo1); + parIo2->open(parFileList, "in"); + rtdb->setSecondInput(parIo2); // ------------------------------------------------------------------------ diff --git a/macro/beamtime/mcbm2020/mcbm_reco_kronos.C b/macro/beamtime/mcbm2020/mcbm_reco_kronos.C index 8eccacdd6d..2df5370781 100644 --- a/macro/beamtime/mcbm2020/mcbm_reco_kronos.C +++ b/macro/beamtime/mcbm2020/mcbm_reco_kronos.C @@ -28,11 +28,19 @@ void mcbm_reco_kronos(Int_t runId = 831, Int_t nTimeslices = 0) { Form("/lustre/cbm/users/ploizeau/mcbm2020/unp_evt_data_7f229b3f_20201103/" "unp_mcbm_params_%i.root", runId); - TString geoFile = paramDir + "mcbm2020_reco.geo.root"; // Created in sim. run TString parFileOut = Form("./data/reco_mcbm_params_%i.root", runId); TString outFile = Form("./data/reco_mcbm_%i.root", runId); // ------------------------------------------------------------------------ + // --- Load the geometry setup ---- + // This is currently only required by the TRD (parameters) + std::string geoSetupTag = "mcbm_beam_2020_03"; + TString geoFile = + paramDir + geoSetupTag.data() + ".geo.root"; // Created in sim. run + CbmSetup* geoSetup = CbmSetup::Instance(); + geoSetup->LoadSetup(geoSetupTag.data()); + TList* parFileList = new TList(); + // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; @@ -118,6 +126,28 @@ void mcbm_reco_kronos(Int_t runId = 831, Int_t nTimeslices = 0) { // ----- Local reconstruction in TRD ---------------------------------- + // Load parameters <- they are required by the hit producer. + // For now, it is enough to load the default ascii parameters + // if no root file is existing from the unpacking process. + TString geoTagTrd = ""; + bool isActiveTrd = + (geoSetup->GetGeoTag(ECbmModuleId::kTrd, geoTagTrd)) ? true : false; + if (!isActiveTrd) { + LOG(warning) << Form( + "TRD - parameter loading - Trd not found in CbmSetup(%s) -> parameters " + "can not be loaded correctly!", + geoSetupTag.data()); + } else { + TString paramFilesTrd( + Form("%s/parameters/trd/trd_%s", srcDir.Data(), geoTagTrd.Data())); + std::vector<std::string> paramFilesVecTrd; + CbmTrdParManager::GetParFileExtensions(¶mFilesVecTrd); + for (auto parIt : paramFilesVecTrd) { + parFileList->Add( + new TObjString(Form("%s.%s.par", paramFilesTrd.Data(), parIt.data()))); + } + } + // -- end trd parameters Double_t triggerThreshold = 0.5e-6; // Default CbmTrdClusterFinder* trdCluster = new CbmTrdClusterFinder(); trdCluster->SetNeighbourEnable(true, false); @@ -167,8 +197,10 @@ void mcbm_reco_kronos(Int_t runId = 831, Int_t nTimeslices = 0) { FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); FairParRootFileIo* parIo3 = new FairParRootFileIo(); parIo1->open(parFileIn.Data(), "READ"); - parIo3->open(parFileOut.Data(), "RECREATE"); rtdb->setFirstInput(parIo1); + parIo2->open(parFileList, "in"); + rtdb->setSecondInput(parIo2); + parIo3->open(parFileOut.Data(), "RECREATE"); // ------------------------------------------------------------------------ -- GitLab