Skip to content

Commit b81a2ee

Browse files
committed
Please consider the following formatting changes
1 parent b773e93 commit b81a2ee

File tree

7 files changed

+271
-288
lines changed

7 files changed

+271
-288
lines changed

Generators/include/Generators/Generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class Generator : public FairGenerator
161161
void updateSubGeneratorInformation(o2::dataformats::MCEventHeader* header) const;
162162

163163
// loopers flag
164-
Bool_t mAddTPCLoopers = kFALSE; // Flag is automatically set to true if TPC is in readout detectors, loopers are not vetoed and transport is enabled
164+
Bool_t mAddTPCLoopers = kFALSE; // Flag is automatically set to true if TPC is in readout detectors, loopers are not vetoed and transport is enabled
165165
// collect an ID and a short description of sub-generator entities
166166
std::unordered_map<int, std::string> mSubGeneratorsIdToDesc;
167167
// the current ID of the sub-generator used in the current event (if applicable)

Generators/include/Generators/TPCLoopersParam.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ namespace eventgen
2828
** allow the user to modify them
2929
**/
3030
struct GenTPCLoopersParam : public o2::conf::ConfigurableParamHelper<GenTPCLoopersParam> {
31-
bool loopersVeto = false; // if true, no loopers are generated
32-
std::string model_pairs = "ccdb://Users/m/mgiacalo/WGAN_ExtGenPair"; // ONNX model for e+e- pair production
33-
std::string model_compton = "ccdb://Users/m/mgiacalo/WGAN_ExtGenCompton"; // ONNX model for Compton scattering
34-
std::string poisson = "${O2_ROOT}/share/Generators/egconfig/poisson_params.csv"; // file with Poissonian parameters
35-
std::string gauss = "${O2_ROOT}/share/Generators/egconfig/gaussian_params.csv"; // file with Gaussian parameters
36-
std::string scaler_pair = "${O2_ROOT}/share/Generators/egconfig/ScalerPairParams.json"; // file with scaler parameters for e+e- pair production
31+
bool loopersVeto = false; // if true, no loopers are generated
32+
std::string model_pairs = "ccdb://Users/m/mgiacalo/WGAN_ExtGenPair"; // ONNX model for e+e- pair production
33+
std::string model_compton = "ccdb://Users/m/mgiacalo/WGAN_ExtGenCompton"; // ONNX model for Compton scattering
34+
std::string poisson = "${O2_ROOT}/share/Generators/egconfig/poisson_params.csv"; // file with Poissonian parameters
35+
std::string gauss = "${O2_ROOT}/share/Generators/egconfig/gaussian_params.csv"; // file with Gaussian parameters
36+
std::string scaler_pair = "${O2_ROOT}/share/Generators/egconfig/ScalerPairParams.json"; // file with scaler parameters for e+e- pair production
3737
std::string scaler_compton = "${O2_ROOT}/share/Generators/egconfig/ScalerComptonParams.json"; // file with scaler parameters for Compton scattering
3838
std::string nclxrate = "ccdb://Users/m/mgiacalo/ClustersTrackRatio"; // file with clusters/rate information per orbit
3939
std::string colsys = "PbPb"; // collision system (PbPb or pp)
4040
int intrate = -1; // Automatic IR from collision context if -1, else user-defined interaction rate in Hz
41-
bool flat_gas = true; // if true, the gas density is considered flat in the TPC volume
42-
unsigned int nFlatGasLoopers = 500; // number of loopers to be generated per event in case of flat gas [currently unused, kept for possible future debug developments]
43-
float fraction_pairs = 0.08; // fraction of loopers [currently unused, kept for possible future debug developments]
44-
float multiplier[2] = {1., 1.}; // multiplier for pairs and compton loopers for Poissonian and Gaussian sampling
45-
unsigned int fixedNLoopers[2] = {1, 1}; // fixed number of loopers coming from pairs and compton electrons - valid if flat gas is false and both Poisson and Gaussian params files are empty
46-
float adjust_flatgas = 0.f; // adjustment for the number of flat gas loopers per orbit (in percentage, e.g. -0.1 = -10%) [-1, inf)]
41+
bool flat_gas = true; // if true, the gas density is considered flat in the TPC volume
42+
unsigned int nFlatGasLoopers = 500; // number of loopers to be generated per event in case of flat gas [currently unused, kept for possible future debug developments]
43+
float fraction_pairs = 0.08; // fraction of loopers [currently unused, kept for possible future debug developments]
44+
float multiplier[2] = {1., 1.}; // multiplier for pairs and compton loopers for Poissonian and Gaussian sampling
45+
unsigned int fixedNLoopers[2] = {1, 1}; // fixed number of loopers coming from pairs and compton electrons - valid if flat gas is false and both Poisson and Gaussian params files are empty
46+
float adjust_flatgas = 0.f; // adjustment for the number of flat gas loopers per orbit (in percentage, e.g. -0.1 = -10%) [-1, inf)]
4747
O2ParamDef(GenTPCLoopersParam, "GenTPCLoopers");
4848
};
4949

Generators/include/TPCLoopers.h

Lines changed: 77 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,32 @@ extern Ort::Env global_env;
2626

2727
// This class is responsible for loading the scaler parameters from a JSON file
2828
// and applying the inverse transformation to the generated data.
29-
struct Scaler
30-
{
31-
std::vector<double> normal_min;
32-
std::vector<double> normal_max;
33-
std::vector<double> outlier_center;
34-
std::vector<double> outlier_scale;
29+
struct Scaler {
30+
std::vector<double> normal_min;
31+
std::vector<double> normal_max;
32+
std::vector<double> outlier_center;
33+
std::vector<double> outlier_scale;
3534

36-
void load(const std::string &filename);
35+
void load(const std::string& filename);
3736

38-
std::vector<double> inverse_transform(const std::vector<double> &input);
37+
std::vector<double> inverse_transform(const std::vector<double>& input);
3938

40-
private:
41-
std::vector<double> jsonArrayToVector(const rapidjson::Value &jsonArray);
39+
private:
40+
std::vector<double> jsonArrayToVector(const rapidjson::Value& jsonArray);
4241
};
4342

4443
// This class loads the ONNX model and generates samples using it.
4544
class ONNXGenerator
4645
{
47-
public:
48-
ONNXGenerator(Ort::Env &shared_env, const std::string &model_path);
46+
public:
47+
ONNXGenerator(Ort::Env& shared_env, const std::string& model_path);
4948

50-
std::vector<double> generate_sample();
49+
std::vector<double> generate_sample();
5150

52-
private:
53-
Ort::Env &env;
54-
Ort::Session session;
55-
TRandom3 rand_gen;
51+
private:
52+
Ort::Env& env;
53+
Ort::Session session;
54+
TRandom3 rand_gen;
5655
};
5756
#endif // GENERATORS_WITH_TPCLOOPERS
5857

@@ -64,67 +63,67 @@ namespace eventgen
6463
#ifdef GENERATORS_WITH_TPCLOOPERS
6564
class GenTPCLoopers
6665
{
67-
public:
68-
GenTPCLoopers(std::string model_pairs = "tpcloopmodel.onnx", std::string model_compton = "tpcloopmodelcompton.onnx",
69-
std::string poisson = "poisson.csv", std::string gauss = "gauss.csv", std::string scaler_pair = "scaler_pair.json",
70-
std::string scaler_compton = "scaler_compton.json");
71-
72-
Bool_t generateEvent();
73-
74-
Bool_t generateEvent(double &time_limit);
75-
76-
std::vector<TParticle> importParticles();
77-
78-
unsigned int PoissonPairs();
79-
80-
unsigned int GaussianElectrons();
81-
82-
void SetNLoopers(unsigned int &nsig_pair, unsigned int &nsig_compton);
83-
84-
void SetMultiplier(std::array<float, 2> &mult);
85-
86-
void setFlatGas(Bool_t& flat, const Int_t& number, const Int_t& nloopers_orbit);
87-
88-
void setFractionPairs(float &fractionPairs);
89-
90-
void SetRate(const std::string &rateFile, const bool &isPbPb, const int &intRate);
91-
92-
void SetAdjust(const float &adjust);
93-
94-
unsigned int getNLoopers() const { return (mNLoopersPairs + mNLoopersCompton); }
95-
96-
private:
97-
std::unique_ptr<ONNXGenerator> mONNX_pair = nullptr;
98-
std::unique_ptr<ONNXGenerator> mONNX_compton = nullptr;
99-
std::unique_ptr<Scaler> mScaler_pair = nullptr;
100-
std::unique_ptr<Scaler> mScaler_compton = nullptr;
101-
double mPoisson[3] = {0.0, 0.0, 0.0}; // Mu, Min and Max of Poissonian
102-
double mGauss[4] = {0.0, 0.0, 0.0, 0.0}; // Mean, Std, Min, Max
103-
std::vector<std::vector<double>> mGenPairs;
104-
std::vector<std::vector<double>> mGenElectrons;
105-
unsigned int mNLoopersPairs = -1;
106-
unsigned int mNLoopersCompton = -1;
107-
std::array<float, 2> mMultiplier = {1., 1.};
108-
bool mPoissonSet = false;
109-
bool mGaussSet = false;
110-
// Random number generator
111-
TRandom3 mRandGen;
112-
// Masses of the electrons and positrons
113-
TDatabasePDG *mPDG = TDatabasePDG::Instance();
114-
double mMass_e = mPDG->GetParticle(11)->Mass();
115-
double mMass_p = mPDG->GetParticle(-11)->Mass();
116-
int mCurrentEvent = 0; // Current event number, used for adaptive loopers
117-
TFile *mContextFile = nullptr; // Input collision context file
118-
o2::steer::DigitizationContext *mCollisionContext = nullptr; // Pointer to the digitization context
119-
std::vector<o2::InteractionTimeRecord> mInteractionTimeRecords; // Interaction time records from collision context
120-
Bool_t mFlatGas = false; // Flag to indicate if flat gas loopers are used
121-
Bool_t mFlatGasOrbit = false; // Flag to indicate if flat gas loopers are per orbit
122-
Int_t mFlatGasNumber = -1; // Number of flat gas loopers per event
123-
double mIntTimeRecMean = 1.0; // Average interaction time record used for the reference
124-
double mTimeLimit = 0.0; // Time limit for the current event
125-
double mTimeEnd = 0.0; // Time limit for the last event
126-
float mLoopsFractionPairs = 0.08; // Fraction of loopers from Pairs
127-
int mInteractionRate = 50000; // Interaction rate in Hz
66+
public:
67+
GenTPCLoopers(std::string model_pairs = "tpcloopmodel.onnx", std::string model_compton = "tpcloopmodelcompton.onnx",
68+
std::string poisson = "poisson.csv", std::string gauss = "gauss.csv", std::string scaler_pair = "scaler_pair.json",
69+
std::string scaler_compton = "scaler_compton.json");
70+
71+
Bool_t generateEvent();
72+
73+
Bool_t generateEvent(double& time_limit);
74+
75+
std::vector<TParticle> importParticles();
76+
77+
unsigned int PoissonPairs();
78+
79+
unsigned int GaussianElectrons();
80+
81+
void SetNLoopers(unsigned int& nsig_pair, unsigned int& nsig_compton);
82+
83+
void SetMultiplier(std::array<float, 2>& mult);
84+
85+
void setFlatGas(Bool_t& flat, const Int_t& number, const Int_t& nloopers_orbit);
86+
87+
void setFractionPairs(float& fractionPairs);
88+
89+
void SetRate(const std::string& rateFile, const bool& isPbPb, const int& intRate);
90+
91+
void SetAdjust(const float& adjust);
92+
93+
unsigned int getNLoopers() const { return (mNLoopersPairs + mNLoopersCompton); }
94+
95+
private:
96+
std::unique_ptr<ONNXGenerator> mONNX_pair = nullptr;
97+
std::unique_ptr<ONNXGenerator> mONNX_compton = nullptr;
98+
std::unique_ptr<Scaler> mScaler_pair = nullptr;
99+
std::unique_ptr<Scaler> mScaler_compton = nullptr;
100+
double mPoisson[3] = {0.0, 0.0, 0.0}; // Mu, Min and Max of Poissonian
101+
double mGauss[4] = {0.0, 0.0, 0.0, 0.0}; // Mean, Std, Min, Max
102+
std::vector<std::vector<double>> mGenPairs;
103+
std::vector<std::vector<double>> mGenElectrons;
104+
unsigned int mNLoopersPairs = -1;
105+
unsigned int mNLoopersCompton = -1;
106+
std::array<float, 2> mMultiplier = {1., 1.};
107+
bool mPoissonSet = false;
108+
bool mGaussSet = false;
109+
// Random number generator
110+
TRandom3 mRandGen;
111+
// Masses of the electrons and positrons
112+
TDatabasePDG* mPDG = TDatabasePDG::Instance();
113+
double mMass_e = mPDG->GetParticle(11)->Mass();
114+
double mMass_p = mPDG->GetParticle(-11)->Mass();
115+
int mCurrentEvent = 0; // Current event number, used for adaptive loopers
116+
TFile* mContextFile = nullptr; // Input collision context file
117+
o2::steer::DigitizationContext* mCollisionContext = nullptr; // Pointer to the digitization context
118+
std::vector<o2::InteractionTimeRecord> mInteractionTimeRecords; // Interaction time records from collision context
119+
Bool_t mFlatGas = false; // Flag to indicate if flat gas loopers are used
120+
Bool_t mFlatGasOrbit = false; // Flag to indicate if flat gas loopers are per orbit
121+
Int_t mFlatGasNumber = -1; // Number of flat gas loopers per event
122+
double mIntTimeRecMean = 1.0; // Average interaction time record used for the reference
123+
double mTimeLimit = 0.0; // Time limit for the current event
124+
double mTimeEnd = 0.0; // Time limit for the last event
125+
float mLoopsFractionPairs = 0.08; // Fraction of loopers from Pairs
126+
int mInteractionRate = 50000; // Interaction rate in Hz
128127
};
129128
#endif // GENERATORS_WITH_TPCLOOPERS
130129

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"normal": {
3-
"min": [
4-
-0.0108811147511005,
5-
-0.0098758740350604,
6-
-0.0103233363479375,
7-
-260.0542297363281,
8-
-259.80059814453125
9-
],
10-
"max": [
11-
0.0108060473576188,
12-
0.0103057539090514,
13-
0.0106524610891938,
14-
260.0343933105469,
15-
259.62890625
16-
]
17-
},
18-
"outlier": {
19-
"center": [
20-
-71.39387130737305,
21-
96791.23828125
22-
],
23-
"scale": [
24-
265.9389114379883,
25-
230762.30981445312
26-
]
27-
}
2+
"normal": {
3+
"min": [
4+
-0.0108811147511005,
5+
-0.0098758740350604,
6+
-0.0103233363479375,
7+
-260.0542297363281,
8+
-259.80059814453125
9+
],
10+
"max": [
11+
0.0108060473576188,
12+
0.0103057539090514,
13+
0.0106524610891938,
14+
260.0343933105469,
15+
259.62890625
16+
]
17+
},
18+
"outlier": {
19+
"center": [
20+
-71.39387130737305,
21+
96791.23828125
22+
],
23+
"scale": [
24+
265.9389114379883,
25+
230762.30981445312
26+
]
27+
}
2828
}
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
{
2-
"normal": {
3-
"min": [
4-
-0.0073022879660129,
5-
-0.0077305701561272,
6-
-0.0076750442385673,
7-
-0.0082916170358657,
8-
-0.0079681202769279,
9-
-0.0077468422241508,
10-
-255.6164093017578,
11-
-252.9441680908203
12-
],
13-
"max": [
14-
0.007688719779253,
15-
0.0077241472899913,
16-
0.0075828479602932,
17-
0.00813714787364,
18-
0.0083825681358575,
19-
0.0073839174583554,
20-
256.2904968261719,
21-
253.4925842285156
22-
]
23-
},
24-
"outlier": {
25-
"center": [
26-
-79.66580963134766,
27-
141535.640625
28-
],
29-
"scale": [
30-
250.8921127319336,
31-
222363.16015625
32-
]
33-
}
2+
"normal": {
3+
"min": [
4+
-0.0073022879660129,
5+
-0.0077305701561272,
6+
-0.0076750442385673,
7+
-0.0082916170358657,
8+
-0.0079681202769279,
9+
-0.0077468422241508,
10+
-255.6164093017578,
11+
-252.9441680908203
12+
],
13+
"max": [
14+
0.007688719779253,
15+
0.0077241472899913,
16+
0.0075828479602932,
17+
0.00813714787364,
18+
0.0083825681358575,
19+
0.0073839174583554,
20+
256.2904968261719,
21+
253.4925842285156
22+
]
23+
},
24+
"outlier": {
25+
"center": [
26+
-79.66580963134766,
27+
141535.640625
28+
],
29+
"scale": [
30+
250.8921127319336,
31+
222363.16015625
32+
]
33+
}
3434
}

Generators/src/Generator.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ bool Generator::initLoopersGen()
170170
try {
171171
// Create the TPC loopers generator with the provided parameters
172172
mLoopersGen = std::make_unique<o2::eventgen::GenTPCLoopers>(model_pairs, model_compton, poisson, gauss, scaler_pair, scaler_compton);
173-
const auto &intrate = loopersParam.intrate;
173+
const auto& intrate = loopersParam.intrate;
174174
// Configure the generator with flat gas loopers defined per orbit with clusters/track info
175175
// If intrate is negative (default), automatic IR from collisioncontext.root will be used
176176
if (flat_gas) {
@@ -209,7 +209,7 @@ Bool_t
209209
Generator::finalizeEvent()
210210
{
211211
#ifdef GENERATORS_WITH_TPCLOOPERS
212-
if(mAddTPCLoopers) {
212+
if (mAddTPCLoopers) {
213213
if (!mLoopersGen) {
214214
LOG(error) << "Loopers generator not initialized";
215215
return kFALSE;
@@ -268,7 +268,7 @@ Bool_t
268268
}
269269

270270
/** Event finalization**/
271-
if(!finalizeEvent()) {
271+
if (!finalizeEvent()) {
272272
LOG(error) << "ReadEvent failed in finalizeEvent";
273273
return kFALSE;
274274
}

0 commit comments

Comments
 (0)