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;
116 static bool ownsContextCollisions();
119 static bool ownsCollision(
const std::vector<o2::steer::EventPart>& parts,
int source);
122 void setupContextCoverage();
124 unsigned int getNLoopers()
const {
return (mNLoopersPairs + mNLoopersCompton); }
127 unsigned int getNSkipped()
const {
return mNSkippedPairs + mNSkippedCompton; }
130 std::unique_ptr<ONNXGenerator> mONNX_pair =
nullptr;
131 std::unique_ptr<ONNXGenerator> mONNX_compton =
nullptr;
132 std::unique_ptr<Scaler> mScaler_pair =
nullptr;
133 std::unique_ptr<Scaler> mScaler_compton =
nullptr;
134 double mPoisson[3] = {0.0, 0.0, 0.0};
135 double mGauss[4] = {0.0, 0.0, 0.0, 0.0};
136 std::vector<std::vector<double>> mGenPairs;
137 std::vector<std::vector<double>> mGenElectrons;
138 unsigned int mNLoopersPairs = -1;
139 unsigned int mNLoopersCompton = -1;
140 std::array<float, 2> mMultiplier = {1., 1.};
141 bool mPoissonSet =
false;
142 bool mGaussSet =
false;
145 int mCurrentEvent = 0;
146 TFile* mContextFile =
nullptr;
148 std::vector<o2::InteractionTimeRecord> mInteractionTimeRecords;
149 Bool_t mFlatGas =
false;
150 Bool_t mFlatGasOrbit =
false;
151 Int_t mFlatGasNumber = -1;
152 double mIntTimeRecMean = 1.0;
153 double mTimeLimit = 0.0;
154 double mTimeEnd = 0.0;
156 std::vector<double> mEventLooperTime;
157 float mLoopsFractionPairs = 0.08;
158 int mInteractionRate = 50000;
159 bool mGeomProtection =
true;
160 unsigned int mNSkippedPairs = 0;
161 unsigned int mNSkippedCompton = 0;
Ort::Env global_env(ORT_LOGGING_LEVEL_WARNING, "GlobalEnv")
GLsizei GLsizei GLchar * source
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...