14#ifndef ALICEO2_EVENTGEN_TPCLOOPERS_H_
15#define ALICEO2_EVENTGEN_TPCLOOPERS_H_
17#ifdef GENERATORS_WITH_TPCLOOPERS
18#include <onnxruntime_cxx_api.h>
20#include <rapidjson/document.h>
33 std::vector<double> normal_min;
34 std::vector<double> normal_max;
35 std::vector<double> outlier_center;
36 std::vector<double> outlier_scale;
38 void load(
const std::string&
filename);
40 std::vector<double> inverse_transform(
const std::vector<double>& input);
43 std::vector<double> jsonArrayToVector(
const rapidjson::Value& jsonArray);
50 ONNXGenerator(Ort::Env& shared_env,
const std::string& model_path);
52 std::vector<double> generate_sample();
66#ifdef GENERATORS_WITH_TPCLOOPERS
84 GenTPCLoopers(std::string model_pairs =
"tpcloopmodel.onnx", std::string model_compton =
"tpcloopmodelcompton.onnx",
85 std::string poisson =
"poisson.csv", std::string gauss =
"gauss.csv", std::string scaler_pair =
"scaler_pair.json",
86 std::string scaler_compton =
"scaler_compton.json");
88 Bool_t generateEvent();
90 Bool_t generateEvent(
double time_limit);
92 std::vector<TParticle> importParticles();
94 unsigned int PoissonPairs();
96 unsigned int GaussianElectrons();
98 void SetNLoopers(
unsigned int nsig_pair,
unsigned int nsig_compton);
100 void SetMultiplier(
const std::array<float, 2>& mult);
102 void setFlatGas(Bool_t flat, Int_t number = -1, Int_t nloopers_orbit = -1);
104 void setFractionPairs(
float fractionPairs);
106 void SetRate(
const std::string& rateFile,
bool isPbPb,
int intRate = 50000);
108 void SetAdjust(
float adjust = 0.f);
110 void setGeomProtection(
bool protect);
113 bool isInTPCActiveVolume(
double vx,
double vy)
const;
115 unsigned int getNLoopers()
const {
return (mNLoopersPairs + mNLoopersCompton); }
118 unsigned int getNSkipped()
const {
return mNSkippedPairs + mNSkippedCompton; }
121 std::unique_ptr<ONNXGenerator> mONNX_pair =
nullptr;
122 std::unique_ptr<ONNXGenerator> mONNX_compton =
nullptr;
123 std::unique_ptr<Scaler> mScaler_pair =
nullptr;
124 std::unique_ptr<Scaler> mScaler_compton =
nullptr;
125 double mPoisson[3] = {0.0, 0.0, 0.0};
126 double mGauss[4] = {0.0, 0.0, 0.0, 0.0};
127 std::vector<std::vector<double>> mGenPairs;
128 std::vector<std::vector<double>> mGenElectrons;
129 unsigned int mNLoopersPairs = -1;
130 unsigned int mNLoopersCompton = -1;
131 std::array<float, 2> mMultiplier = {1., 1.};
132 bool mPoissonSet =
false;
133 bool mGaussSet =
false;
136 int mCurrentEvent = 0;
137 TFile* mContextFile =
nullptr;
139 std::vector<o2::InteractionTimeRecord> mInteractionTimeRecords;
140 Bool_t mFlatGas =
false;
141 Bool_t mFlatGasOrbit =
false;
142 Int_t mFlatGasNumber = -1;
143 double mIntTimeRecMean = 1.0;
144 double mTimeLimit = 0.0;
145 double mTimeEnd = 0.0;
146 float mLoopsFractionPairs = 0.08;
147 int mInteractionRate = 50000;
148 bool mGeomProtection =
true;
149 unsigned int mNSkippedPairs = 0;
150 unsigned int mNSkippedCompton = 0;
Ort::Env global_env(ORT_LOGGING_LEVEL_WARNING, "GlobalEnv")
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...