diff --git a/analysis/common/analysis_tree_converter/app/Application.cxx b/analysis/common/analysis_tree_converter/app/Application.cxx index 2a0a647eb818c75bb84e41e3fe9bfe5f7a0f91ee..5bc4cdcc478c20f925cc05eea47696db1bbe4ec6 100644 --- a/analysis/common/analysis_tree_converter/app/Application.cxx +++ b/analysis/common/analysis_tree_converter/app/Application.cxx @@ -27,7 +27,7 @@ namespace cbm::atconverter // --- Use program options fRun.SetOutput(fOpt.OutputFile().c_str()); - fRun.SetTraFile(fOpt.TraFile().c_str()); + fRun.SetTraFiles(fOpt.TraFiles()); fRun.SetRawFile(fOpt.RawFile().c_str()); fRun.SetParFile(fOpt.ParFile().c_str()); fRun.SetRecoFile(fOpt.RecoFile().c_str()); diff --git a/analysis/common/analysis_tree_converter/app/Application.h b/analysis/common/analysis_tree_converter/app/Application.h index d125f22428fd682617bea96052f053aac254e66f..0a107a6a3ba01c67f4e372f8ef258e21b8f5b93b 100644 --- a/analysis/common/analysis_tree_converter/app/Application.h +++ b/analysis/common/analysis_tree_converter/app/Application.h @@ -39,7 +39,7 @@ namespace cbm::atconverter private: const std::string& OutputFile() const; - const std::string& TraFile() const; + const std::vector<std::string>& TraFiles() const; const std::string& RawFile() const; const std::string& ParFile() const; const std::string& RecoFile() const; diff --git a/analysis/common/analysis_tree_converter/app/ProgramOptions.cxx b/analysis/common/analysis_tree_converter/app/ProgramOptions.cxx index 6f5741b7ad76d3fa8f1fca2df273a7cee075f3a6..af2ccabaa468798cc973ca07d227d4fd4fcf14e9 100644 --- a/analysis/common/analysis_tree_converter/app/ProgramOptions.cxx +++ b/analysis/common/analysis_tree_converter/app/ProgramOptions.cxx @@ -20,6 +20,7 @@ namespace po = boost::program_options; using std::string; +using std::vector; namespace cbm::atconverter { @@ -41,8 +42,8 @@ namespace cbm::atconverter auto config_add = config.add_options(); config_add("output,o", po::value<string>(&fOutput)->value_name("<file name>"), "name of the output ROOT file with analysistree data"); - config_add("transport,t", po::value<string>(&fTra)->value_name("<file nams>"), - "name of a transport ROOT file (containing MC data)"); + config_add("transport,t", po::value<vector<string>>(&fTra)->value_name("<file names>")->multitoken(), + "name of transport input sources (ROOT files)"); config_add("digitization,d", po::value<string>(&fRaw)->value_name("<file name>"), "name of the raw ROOT file containing digi data"); config_add("parameter,p", po::value<string>(&fPar)->value_name("<file name>"), diff --git a/analysis/common/analysis_tree_converter/app/ProgramOptions.h b/analysis/common/analysis_tree_converter/app/ProgramOptions.h index 3fa3798513d16c50326fc8699c2308893cdf27da..d08640595601d2b0b6a54e713054c361b2d95d83 100644 --- a/analysis/common/analysis_tree_converter/app/ProgramOptions.h +++ b/analysis/common/analysis_tree_converter/app/ProgramOptions.h @@ -17,6 +17,7 @@ #include <string> +#include <vector> namespace cbm::atconverter { @@ -44,8 +45,8 @@ namespace cbm::atconverter /** @brief Get output file name (.root format) **/ [[nodiscard]] const std::string& OutputFile() const { return fOutput; } - /** @brief Get transport file name **/ - [[nodiscard]] const std::string& TraFile() const { return fTra; } + /** @brief Get vector of transport input file names **/ + [[nodiscard]] const std::vector<std::string>& TraFiles() const { return fTra; } /** @brief Get digitization file name **/ [[nodiscard]] const std::string& RawFile() const { return fRaw; } @@ -73,7 +74,7 @@ namespace cbm::atconverter private: // members std::string fOutput = ""; ///< Output file name (ROOT format) - std::string fTra = ""; ///< Transport file name (ROOT format) + std::vector<std::string> fTra; ///< Vector of transport input file names std::string fRaw = ""; ///< Digitization file name (ROOT format) std::string fPar = ""; ///< Parameter file name (ROOT format) std::string fReco = ""; ///< Reconstruction file name (ROOT format) diff --git a/analysis/common/analysis_tree_converter/steer/Run.cxx b/analysis/common/analysis_tree_converter/steer/Run.cxx index 9da68a6f0cbda5d73ea261733854c85e09b343cd..fc5e22e44792242b629226d363e96fc33389aa76 100644 --- a/analysis/common/analysis_tree_converter/steer/Run.cxx +++ b/analysis/common/analysis_tree_converter/steer/Run.cxx @@ -113,7 +113,10 @@ namespace cbm::atconverter // --- Mirror options and configuration LOG(info) << GetName() << ": Output file is " << fOutput; - LOG(info) << GetName() << ": Transport file is " << fTra; + for (auto traFile : fTra) { + LOG(info) << GetName() << ": Transport file is " << traFile; + if (!CheckFile(traFile.Data())) throw std::runtime_error("Transport file does not exist"); + } LOG(info) << GetName() << ": Digitization file is " << fRaw; LOG(info) << GetName() << ": Parameter file is " << fPar; LOG(info) << GetName() << ": Reconstruction file is " << fReco; @@ -134,14 +137,14 @@ namespace cbm::atconverter // --- Check input, output and parameter files if (CheckFile(fOutput.Data()) && !fOverwrite) throw std::runtime_error("Output file already exists"); - if (!CheckFile(fTra.Data())) throw std::runtime_error("Transport file does not exist"); if (!CheckFile(fRaw.Data())) throw std::runtime_error("Digitizazion (raw) file does not exist"); if (!CheckFile(fPar.Data())) throw std::runtime_error("Parameter file does not exist"); if (!CheckFile(fReco.Data())) throw std::runtime_error("Reconstruction file does not exist"); // --- Input and output FairFileSource* source = new FairFileSource(fReco); - source->AddFriend(fTra); + for (auto traFile : fTra) + source->AddFriend(traFile); source->AddFriend(fRaw); fRun.SetSource(source); fRun.SetSink(new FairRootFileSink(fOutput)); @@ -188,7 +191,8 @@ namespace cbm::atconverter FairMonitor::GetMonitor()->Print(); std::cout << std::endl << std::endl; LOG(info) << GetName() << ": Execution successful"; - LOG(info) << GetName() << ": Transport file was " << fTra; + for (auto traFile : fTra) + LOG(info) << GetName() << ": Transport file was " << traFile; LOG(info) << GetName() << ": Digitization file was " << fRaw; LOG(info) << GetName() << ": Parameter file was " << fPar; LOG(info) << GetName() << ": Reconstruction file was " << fReco; @@ -213,6 +217,18 @@ namespace cbm::atconverter // -------------------------------------------------------------------------- + // ----- Set transport input sources ------------------------------------- + void Run::SetTraFiles(const std::vector<std::string> files) + { + for (auto file : files) { + const char* filename = file.c_str(); + TString traFile = filename; + fTra.push_back(traFile); + } + } + // -------------------------------------------------------------------------- + + } // namespace cbm::atconverter ClassImp(cbm::atconverter::Run) diff --git a/analysis/common/analysis_tree_converter/steer/Run.h b/analysis/common/analysis_tree_converter/steer/Run.h index 08ec6f0faa0580f93673f9419e13e85586d743ef..1239afe8d15e52360c98cf7ac3e04ceba3c27912 100644 --- a/analysis/common/analysis_tree_converter/steer/Run.h +++ b/analysis/common/analysis_tree_converter/steer/Run.h @@ -89,10 +89,10 @@ namespace cbm::atconverter void SetOutput(const char* fileName) { fOutput = fileName; } - /** @brief Set transport file name - ** @param fileName Transport file name + /** @brief Set transport input files + ** @param files Vector of transport input file names **/ - void SetTraFile(const char* fileName) { fTra = fileName; } + void SetTraFiles(const std::vector<std::string> files); /** @brief Set digitizazion (raw) file name @@ -147,7 +147,7 @@ namespace cbm::atconverter private: FairRunAna fRun {}; TString fOutput = ""; - TString fTra = ""; + std::vector<TString> fTra; TString fRaw = ""; TString fPar = ""; TString fReco = ""; diff --git a/analysis/common/analysis_tree_converter/steer/TaskFactory.cxx b/analysis/common/analysis_tree_converter/steer/TaskFactory.cxx index 4efebaf3b18da212079441dc96cc66307e592008..b1e1fbc0769af1199951882b334c8d090128ec2c 100644 --- a/analysis/common/analysis_tree_converter/steer/TaskFactory.cxx +++ b/analysis/common/analysis_tree_converter/steer/TaskFactory.cxx @@ -106,11 +106,13 @@ namespace cbm::atconverter // ----- MC data manager ------------------------------------------------ - void TaskFactory::RegisterMCDataManager(const TString& traFile) + void TaskFactory::RegisterMCDataManager(const std::vector<TString>& traFiles) { assert(fRun); CbmMCDataManager* mcManager = new CbmMCDataManager("MCDataManager", 0); - mcManager->AddFile(traFile); + for (auto traFile : traFiles) { + mcManager->AddFile(traFile); + } fRun->AddTask(mcManager); } // -------------------------------------------------------------------------- diff --git a/analysis/common/analysis_tree_converter/steer/TaskFactory.h b/analysis/common/analysis_tree_converter/steer/TaskFactory.h index 876637cbcd377041a03dde2b2ffc3970d360e455..472de4c7e017b81c32a9f9938ddb80d90bc791a5 100644 --- a/analysis/common/analysis_tree_converter/steer/TaskFactory.h +++ b/analysis/common/analysis_tree_converter/steer/TaskFactory.h @@ -31,7 +31,7 @@ namespace cbm::atconverter /** @brief MC data manager for matching ** @param traFile name of transport file **/ - void RegisterMCDataManager(const TString& traFile); + void RegisterMCDataManager(const std::vector<TString>& traFiles); /** @brief AnalysisTree Converter Manager ** @param outputFile name of AT file diff --git a/macro/PWG/common/production/config.json b/macro/PWG/common/production/config.json index defec9f9a92b4d8b9b1ebbb496fbcc86e1b41ae1..c8f4c0cbf3c622eb756f3d1c5e19193f66a334b2 100644 --- a/macro/PWG/common/production/config.json +++ b/macro/PWG/common/production/config.json @@ -151,14 +151,18 @@ "path": "/lustre/cbm/users/${USER}/mc/out/reco/${taskId}/${taskId}", "overwrite": false }, - "sEvBuildRaw": "Ideal", - "traFile": "/lustre/cbm/users/${USER}/mc/out/tra/${taskId}/${taskId}", + "sEvBuildRaw": "Ideal", + "traFiles": [ + "/lustre/cbm/users/${USER}/mc/out/tra/${taskId}/${taskId}" + ], "isL1Matching": true, "isL1EffQA": false }, "AT": { - "traFile": "/lustre/cbm/users/${USER}/mc/out/tra/${taskId}/${taskId}", + "traFiles": [ + "/lustre/cbm/users/${USER}/mc/out/tra/${taskId}/${taskId}" + ], "rawFile": "/lustre/cbm/users/${USER}/mc/out/raw/${taskId}/${taskId}", "recFile": "/lustre/cbm/users/${USER}/mc/out/reco/${taskId}/${taskId}", "unigenFile": "/lustre/cbm/users/ogolosov/mc/generators/dcmqgsm_smm/auau/pbeam12agev/mbias/root/dcmqgsm_${taskId}.root", diff --git a/macro/PWG/common/production/config_ci.json.in b/macro/PWG/common/production/config_ci.json.in index 6a0e3c03767e11086764064539042c7f7d714f50..ddb3d6a013a3a3d93df9a86aa2cce001f65f8bc6 100644 --- a/macro/PWG/common/production/config_ci.json.in +++ b/macro/PWG/common/production/config_ci.json.in @@ -152,13 +152,17 @@ "overwrite": true }, "sEvBuildRaw": "Ideal", - "traFile": "@CMAKE_BINARY_DIR@/macro/PWG/common/production/data/tra/${taskId}/${taskId}", + "traFiles": [ + "@CMAKE_BINARY_DIR@/macro/PWG/common/production/data/tra/${taskId}/${taskId}" + ], "isL1Matching": true, "isL1EffQA": true }, "AT": { - "traFile": "@CMAKE_BINARY_DIR@/macro/PWG/common/production/data/tra/${taskId}/${taskId}", + "traFiles": [ + "@CMAKE_BINARY_DIR@/macro/PWG/common/production/data/tra/${taskId}/${taskId}" + ], "rawFile": "@CMAKE_BINARY_DIR@/macro/PWG/common/production/data/raw/${taskId}/${taskId}", "recFile": "@CMAKE_BINARY_DIR@/macro/PWG/common/production/data/reco/${taskId}/${taskId}", "unigenFile": "@VMCWORKDIR@/input/urqmd.auau.10gev.centr.root", diff --git a/macro/PWG/common/production/run_analysis_tree_maker_json_config.C b/macro/PWG/common/production/run_analysis_tree_maker_json_config.C index 8da63ffd9e74a47b3f8d16051d39f10085b00ee2..a7393a2a9ddb2b97b928368a71bb27f733b59c0e 100644 --- a/macro/PWG/common/production/run_analysis_tree_maker_json_config.C +++ b/macro/PWG/common/production/run_analysis_tree_maker_json_config.C @@ -26,7 +26,7 @@ bool CheckOutFileName(TString fileName, Bool_t overwrite) return true; } -void run_analysis_tree_maker_json_config(TString traPath = "test", TString rawPath = "", TString recPath = "", +void run_analysis_tree_maker_json_config(std::string traList = "", TString rawPath = "", TString recPath = "", TString unigenFile = "", TString outPath = "", bool overwrite = true, std::string config = "", std::string tslength = "-1", bool is_event_base = false, int nEvents = 0) @@ -35,6 +35,23 @@ void run_analysis_tree_maker_json_config(TString traPath = "test", TString rawPa const float beam_mom = 12.; const float ts_length = std::stof(tslength); + // --- Read transport input files from list ------------------------------- + std::ifstream intra(traList.data()); + std::vector<TString> traFiles; + std::string line; + TString traPath; + unsigned int itra = 0; + while (std::getline(intra, line)) { + itra++; + TString traName = line + ".tra.root"; + std::cout << "Transport input " << itra << " : " << traName << std::endl; + traFiles.push_back(traName); + if (itra == 1) traPath = line; + } + if (traFiles.size() == 0) { + throw std::runtime_error("No transport files specified"); + } + // --- Logger settings ---------------------------------------------------- const TString logLevel = "INFO"; const TString logVerbosity = "LOW"; @@ -49,7 +66,6 @@ void run_analysis_tree_maker_json_config(TString traPath = "test", TString rawPa if (rawPath == "") rawPath = traPath; if (recPath == "") recPath = traPath; if (outPath == "") outPath = traPath; - TString traFile = traPath + ".tra.root"; TString geoFile = traPath + ".geo.root"; TString rawFile = rawPath + ".raw.root"; TString recFile = recPath + ".reco.root"; @@ -88,7 +104,8 @@ void run_analysis_tree_maker_json_config(TString traPath = "test", TString rawPa // ----- Reconstruction run ------------------------------------------- auto* run = new FairRunAna(); auto* inputSource = new FairFileSource(recFile); - inputSource->AddFriend(traFile); + for (auto traFile : traFiles) + inputSource->AddFriend(traFile); inputSource->AddFriend(rawFile); run->SetSource(inputSource); run->SetSink(new FairRootFileSink(outFile)); @@ -97,7 +114,8 @@ void run_analysis_tree_maker_json_config(TString traPath = "test", TString rawPa // ----- Mc Data Manager ------------------------------------------------ auto* mcManager = new CbmMCDataManager(); - mcManager->AddFile(traFile); + for (auto traFile : traFiles) + mcManager->AddFile(traFile); run->AddTask(mcManager); // ------------------------------------------------------------------------ diff --git a/macro/PWG/common/production/run_reco_json_config.C b/macro/PWG/common/production/run_reco_json_config.C index 21fb075332a108067974868aa5099e4c32b39ebd..ca641ba401b9e3906dc41b46e4057a77f1a95455 100644 --- a/macro/PWG/common/production/run_reco_json_config.C +++ b/macro/PWG/common/production/run_reco_json_config.C @@ -63,7 +63,7 @@ ** @param firstTimeSlice First time-slice (entry) to be processed ** @param output Name of output file (w/o extension .rec.root) ** @param sEvBuildRaw Option for raw event building - ** @param traFile Transport ROOT file (w/o extension .tra.root) + ** @param traList List of transport ROOT files (w/o extension .tra.root) ** @param isL1Matching Enable Hit and track matching to MC tracks ** @param isL1EffQA Option to provide L1_histo.root for QA ** @@ -118,7 +118,7 @@ bool CheckOutFileName(TString fileName, Bool_t overwrite) // -------------------------------------------------------------------------- void run_reco_json_config(TString input = "", Int_t nTimeSlices = -1, Int_t firstTimeSlice = 0, TString output = "", bool overwrite = false, TString sEvBuildRaw = "", std::string config = "", - TString traFile = "", Bool_t isL1Matching = true, Bool_t isL1EffQA = false) + std::string traList = "", Bool_t isL1Matching = true, Bool_t isL1EffQA = false) { // ======================================================================== // Adjust this part according to your requirements @@ -135,15 +135,25 @@ void run_reco_json_config(TString input = "", Int_t nTimeSlices = -1, Int_t firs // ----- In- and output file names ------------------------------------ + std::cout << "TraList = " << traList << std::endl; + std::ifstream intra(traList.data()); + std::vector<TString> traFiles; + std::string line; + while (std::getline(intra, line)) { + TString traName = line + ".tra.root"; + std::cout << "Transport input : " << traName << std::endl; + traFiles.push_back(traName); + } + if (traFiles.size() == 0) std::cout << "WARNING - No transport input; using test.tra.root instead" << std::endl; + if (input.IsNull()) input = "test"; TString rawFile = input + ".raw.root"; TString parFile = input + ".par.root"; if (output.IsNull()) output = input; TString outFile = output + ".reco.root"; TString monFile = output + ".moni_reco.root"; - if (traFile.IsNull()) traFile = input; - traFile += ".tra.root"; if (!CheckOutFileName(outFile, overwrite)) return; + if (traFiles.size() == 0) traFiles.push_back("test.tra.root"); std::cout << "Inputfile " << rawFile << std::endl; std::cout << "Outfile " << outFile << std::endl; std::cout << "Parfile " << parFile << std::endl; @@ -209,7 +219,8 @@ void run_reco_json_config(TString input = "", Int_t nTimeSlices = -1, Int_t firs FairRunAna* run = new FairRunAna(); FairFileSource* inputSource = new FairFileSource(rawFile); if (isL1Matching) { - inputSource->AddFriend(traFile); + for (auto traFile : traFiles) + inputSource->AddFriend(traFile); } run->SetSource(inputSource); run->SetSink(new FairRootFileSink(outFile)); @@ -220,7 +231,8 @@ void run_reco_json_config(TString input = "", Int_t nTimeSlices = -1, Int_t firs // ----- MCDataManager ----------------------------------- if (isL1Matching) { CbmMCDataManager* mcManager = new CbmMCDataManager("MCDataManager", 0); - mcManager->AddFile(traFile); + for (auto traFile : traFiles) + mcManager->AddFile(traFile); run->AddTask(mcManager); } // ------------------------------------------------------------------------ diff --git a/macro/PWG/common/production/run_sim_reco_json.sh b/macro/PWG/common/production/run_sim_reco_json.sh index b3575bbb6b8587130c15e2c0e69dfea1a82a58be..4d084b0630a827810626850286a8cf47172faddc 100755 --- a/macro/PWG/common/production/run_sim_reco_json.sh +++ b/macro/PWG/common/production/run_sim_reco_json.sh @@ -4,6 +4,19 @@ export RED='\033[0;31m' export GREEN='\033[1;32m' export NC='\033[0m' +function getTraList () { + traFiles=$(getJsonVal "['${step}']['traFiles']") + traList="traFiles.list" + for key in ${traFiles} + do + echo "${key}" >> "${traList}" + done + sed -i'' -e 's/\[//g' ${traList} + sed -i'' -e 's/\]//g' ${traList} + sed -i'' -e 's/,//g' ${traList} + echo ${traList} +} + steps="transport digitization reconstruction AT" source ${cbmRoot} for step in ${steps}; do @@ -23,26 +36,27 @@ for step in ${steps}; do cd ${outDir} ln -sfv ${VMCWORKDIR}/macro/run/.rootrc ${outDir} if [ ${step} == reconstruction ]; then + getTraList rawFile=$(getJsonVal "['reconstruction']['rawFile']") nTimeSlices=$(getJsonVal "['reconstruction']['nTimeSlices']") firstTimeSlice=$(getJsonVal "['reconstruction']['firstTimeSlice']") sEvBuildRaw=$(getJsonVal "['reconstruction']['sEvBuildRaw']") - traFile=$(getJsonVal "['reconstruction']['traFile']") isL1Matching=$(getJsonVal "['reconstruction']['isL1Matching']") isL1EffQA=$(getJsonVal "['reconstruction']['isL1EffQA']") echo " " echo "Run reconstruction: ${macro}(\"${rawFile}\",${nTimeSlices},${firstTimeSlice},\"${outFile}\",\ - ${overwrite},\"${sEvBuildRaw}\",\"${config}\",\"${traFile}\",${isL1Matching},${isL1EffQA})" + ${overwrite},\"${sEvBuildRaw}\",\"${config}\",\"${traList}\",${isL1Matching},${isL1EffQA})" root -b -l -q "${macro}(\"${rawFile}\",${nTimeSlices},${firstTimeSlice},\"${outFile}\",\ - ${overwrite},\"${sEvBuildRaw}\",\"${config}\",\"${traFile}\",${isL1Matching},${isL1EffQA})" &> ${log} + ${overwrite},\"${sEvBuildRaw}\",\"${config}\",\"${traList}\",${isL1Matching},${isL1EffQA})" &> ${log} if [ $? -eq 0 ]; then echo -e "${GREEN} Reconstruction executed successfully ${NC}" else echo -e "${RED} Reconstruction failed ${NC}" exit 1 fi + rm -v ${traList} elif [ ${step} == AT ]; then - traFile=$(getJsonVal "['AT']['traFile']") + getTraList rawFile=$(getJsonVal "['AT']['rawFile']") recFile=$(getJsonVal "['AT']['recFile']") unigenFile=$(getJsonVal "['AT']['unigenFile']") @@ -52,9 +66,9 @@ for step in ${steps}; do tslength=$(getJsonVal "['digitization']['timeSliceLength']") fi echo " " - echo "Run AT converter: ${macro}(\"${traFile}\",\"${rawFile}\",\"${recFile}\",\ + echo "Run AT converter: ${macro}(\"${traList}\",\"${rawFile}\",\"${recFile}\",\ \"${unigenFile}\",\"${outFile}\",${overwrite},\"${config}\",\"${tslength}\")" - root -b -l -q "${macro}(\"${traFile}\",\"${rawFile}\",\"${recFile}\",\ + root -b -l -q "${macro}(\"${traList}\",\"${rawFile}\",\"${recFile}\",\ \"${unigenFile}\",\"${outFile}\",${overwrite},\"${config}\",\"${tslength}\")" &> ${log} if [ $? -eq 0 ]; then echo -e "${GREEN} AnalysisTreeConverter executed successfully ${NC}" @@ -62,6 +76,7 @@ for step in ${steps}; do echo -e "${RED} AnalysisTreeConverter failed ${NC}" exit 1 fi + rm -v ${traList} else if [ ${step} == digitization ]; then input=$(getJsonVal "['transport']['output']['path']")