Skip to content

Commit 9994527

Browse files
authored
Set TPCLoopers as debug generator (#2265)
This change makes it possible to use the external generator for debug purposes.
1 parent 2d83347 commit 9994527

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

MC/config/common/external/generator/TPCLoopers.C

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@
77
#include "CCDB/CcdbApi.h"
88
#include "DetectorsRaw/HBFUtils.h"
99

10+
//** This external generator is now used for development purposes only.
11+
//** Fast simulated TPC loopers are automatically integrated as detector effect in O2
12+
//** starting from the O2PDPSuite::MC-prod-2026-v3-1 official release (05/02/2026)
13+
//** Previous cocktails configurations using this generator must not be used anymore for recent tags,
14+
//** as they will increase the default TPC loopers contribution.
15+
//** For support: Marco Giacalone <marco.giacalone@cern.ch>.
16+
1017
// Static Ort::Env instance for multiple onnx model loading
1118
static Ort::Env global_env(ORT_LOGGING_LEVEL_WARNING, "GlobalEnv");
1219

1320
// This class is responsible for loading the scaler parameters from a JSON file
1421
// and applying the inverse transformation to the generated data.
15-
struct Scaler
22+
struct Scaler_debug
1623
{
1724
std::vector<double> normal_min;
1825
std::vector<double> normal_max;
@@ -71,10 +78,10 @@ private:
7178
};
7279

7380
// This class loads the ONNX model and generates samples using it.
74-
class ONNXGenerator
81+
class ONNXGenerator_debug
7582
{
7683
public:
77-
ONNXGenerator(Ort::Env &shared_env, const std::string &model_path)
84+
ONNXGenerator_debug(Ort::Env &shared_env, const std::string &model_path)
7885
: env(shared_env), session(env, model_path.c_str(), Ort::SessionOptions{})
7986
{
8087
// Create session options
@@ -129,12 +136,12 @@ namespace o2
129136
namespace eventgen
130137
{
131138

132-
class GenTPCLoopers : public Generator
139+
class GenTPCLoopers_debug : public Generator
133140
{
134141
public:
135-
GenTPCLoopers(std::string model_pairs = "tpcloopmodel.onnx", std::string model_compton = "tpcloopmodelcompton.onnx",
136-
std::string poisson = "poisson.csv", std::string gauss = "gauss.csv", std::string scaler_pair = "scaler_pair.json",
137-
std::string scaler_compton = "scaler_compton.json")
142+
GenTPCLoopers_debug(std::string model_pairs = "tpcloopmodel.onnx", std::string model_compton = "tpcloopmodelcompton.onnx",
143+
std::string poisson = "poisson.csv", std::string gauss = "gauss.csv", std::string scaler_pair = "scaler_pair.json",
144+
std::string scaler_compton = "scaler_compton.json")
138145
{
139146
// Checking if the model files exist and are not empty
140147
std::ifstream model_file[2];
@@ -200,11 +207,11 @@ class GenTPCLoopers : public Generator
200207
mGaussSet = true;
201208
}
202209
}
203-
mONNX_pair = std::make_unique<ONNXGenerator>(global_env, model_pairs);
204-
mScaler_pair = std::make_unique<Scaler>();
210+
mONNX_pair = std::make_unique<ONNXGenerator_debug>(global_env, model_pairs);
211+
mScaler_pair = std::make_unique<Scaler_debug>();
205212
mScaler_pair->load(scaler_pair);
206-
mONNX_compton = std::make_unique<ONNXGenerator>(global_env, model_compton);
207-
mScaler_compton = std::make_unique<Scaler>();
213+
mONNX_compton = std::make_unique<ONNXGenerator_debug>(global_env, model_compton);
214+
mScaler_compton = std::make_unique<Scaler_debug>();
208215
mScaler_compton->load(scaler_compton);
209216
Generator::setTimeUnit(1.0);
210217
Generator::setPositionUnit(1.0);
@@ -525,10 +532,10 @@ class GenTPCLoopers : public Generator
525532
}
526533

527534
private:
528-
std::unique_ptr<ONNXGenerator> mONNX_pair = nullptr;
529-
std::unique_ptr<ONNXGenerator> mONNX_compton = nullptr;
530-
std::unique_ptr<Scaler> mScaler_pair = nullptr;
531-
std::unique_ptr<Scaler> mScaler_compton = nullptr;
535+
std::unique_ptr<ONNXGenerator_debug> mONNX_pair = nullptr;
536+
std::unique_ptr<ONNXGenerator_debug> mONNX_compton = nullptr;
537+
std::unique_ptr<Scaler_debug> mScaler_pair = nullptr;
538+
std::unique_ptr<Scaler_debug> mScaler_compton = nullptr;
532539
double mPoisson[3] = {0.0, 0.0, 0.0}; // Mu, Min and Max of Poissonian
533540
double mGauss[4] = {0.0, 0.0, 0.0, 0.0}; // Mean, Std, Min, Max
534541
std::vector<std::vector<double>> mGenPairs;
@@ -629,7 +636,7 @@ FairGenerator *
629636
}
630637
model_pairs = isAlien[0] || isCCDB[0] ? local_names[0] : model_pairs;
631638
model_compton = isAlien[1] || isCCDB[1] ? local_names[1] : model_compton;
632-
auto generator = new o2::eventgen::GenTPCLoopers(model_pairs, model_compton, poisson, gauss, scaler_pair, scaler_compton);
639+
auto generator = new o2::eventgen::GenTPCLoopers_debug(model_pairs, model_compton, poisson, gauss, scaler_pair, scaler_compton);
633640
generator->SetNLoopers(nloopers_pairs, nloopers_compton);
634641
generator->SetMultiplier(mult);
635642
return generator;
@@ -700,7 +707,7 @@ Generator_TPCLoopersFlat(std::string model_pairs = "tpcloopmodel.onnx", std::str
700707
}
701708
model_pairs = isAlien[0] || isCCDB[0] ? local_names[0] : model_pairs;
702709
model_compton = isAlien[1] || isCCDB[1] ? local_names[1] : model_compton;
703-
auto generator = new o2::eventgen::GenTPCLoopers(model_pairs, model_compton, "", "", scaler_pair, scaler_compton);
710+
auto generator = new o2::eventgen::GenTPCLoopers_debug(model_pairs, model_compton, "", "", scaler_pair, scaler_compton);
704711
generator->setFractionPairs(fraction_pairs);
705712
generator->setFlatGas(flat_gas, loops_num, nloopers_orbit);
706713
return generator;
@@ -772,7 +779,7 @@ Generator_TPCLoopersOrbitRef(std::string model_pairs = "tpcloopmodel.onnx", std:
772779
model_pairs = isAlien[0] || isCCDB[0] ? local_names[0] : model_pairs;
773780
model_compton = isAlien[1] || isCCDB[1] ? local_names[1] : model_compton;
774781
nclxrate = isAlien[2] || isCCDB[2] ? local_names[2] : nclxrate;
775-
auto generator = new o2::eventgen::GenTPCLoopers(model_pairs, model_compton, "", "", scaler_pair, scaler_compton);
782+
auto generator = new o2::eventgen::GenTPCLoopers_debug(model_pairs, model_compton, "", "", scaler_pair, scaler_compton);
776783
generator->SetRate(nclxrate, isPbPb, intrate);
777784
// Adjust can be negative (-1 maximum) or positive to decrease or increase the number of loopers per orbit
778785
generator->SetAdjust(adjust);

0 commit comments

Comments
 (0)