Skip to content

Commit 82fefbf

Browse files
authored
Revert "Implemented rate and collision system dependence (default)"
This reverts commit 32c0f31.
1 parent f4ed2f7 commit 82fefbf

File tree

4 files changed

+17
-87
lines changed

4 files changed

+17
-87
lines changed

Generators/include/Generators/TPCLoopersParam.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@ struct GenTPCLoopersParam : public o2::conf::ConfigurableParamHelper<GenTPCLoope
3535
std::string gauss = "${O2_ROOT}/share/Generators/egconfig/gaussian_params.csv"; // file with Gaussian parameters
3636
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
38-
std::string nclxrate = "ccdb://Users/m/mgiacalo/ClustersTrackRatio"; // file with clusters/rate information per orbit
39-
std::string colsys = "PbPb"; // collision system (PbPb or pp)
40-
int intrate = 50000; // interaction rate
4138
bool flat_gas = true; // if true, the gas density is considered flat in the TPC volume
4239
int nFlatGasLoopers = 500; // number of loopers to be generated per event in case of flat gas
4340
float fraction_pairs = 0.08; // fraction of loopers
4441
float multiplier[2] = {1., 1.}; // multiplier for pairs and compton loopers for Poissonian and Gaussian sampling
4542
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)]
4743
O2ParamDef(GenTPCLoopersParam, "GenTPCLoopers");
4844
};
4945

Generators/include/TPCLoopers.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <SimulationDataFormat/ParticleStatus.h>
1818
#include "SimulationDataFormat/MCGenProperties.h"
1919
#include "TParticle.h"
20-
#include "TF1.h"
2120
#include <filesystem>
2221

2322
#ifdef GENERATORS_WITH_TPCLOOPERS
@@ -83,14 +82,10 @@ class GenTPCLoopers
8382

8483
void SetMultiplier(std::array<float, 2> &mult);
8584

86-
void setFlatGas(Bool_t& flat, const Int_t& number, const Int_t& nloopers_orbit);
85+
void setFlatGas(Bool_t &flat, const Int_t &number = -1);
8786

8887
void setFractionPairs(float &fractionPairs);
8988

90-
void SetRate(const std::string &rateFile, const bool &isPbPb, const int &intRate);
91-
92-
void SetAdjust(const float &adjust);
93-
9489
private:
9590
std::unique_ptr<ONNXGenerator> mONNX_pair = nullptr;
9691
std::unique_ptr<ONNXGenerator> mONNX_compton = nullptr;
@@ -116,7 +111,6 @@ class GenTPCLoopers
116111
o2::steer::DigitizationContext *mCollisionContext = nullptr; // Pointer to the digitization context
117112
std::vector<o2::InteractionTimeRecord> mInteractionTimeRecords; // Interaction time records from collision context
118113
Bool_t mFlatGas = false; // Flag to indicate if flat gas loopers are used
119-
Bool_t mFlatGasOrbit = false; // Flag to indicate if flat gas loopers are per orbit
120114
Int_t mFlatGasNumber = -1; // Number of flat gas loopers per event
121115
double mIntTimeRecMean = 1.0; // Average interaction time record used for the reference
122116
double mTimeLimit = 0.0; // Time limit for the current event

Generators/src/Generator.cxx

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ bool Generator::initLoopersGen()
9292
const auto& loopersParam = o2::eventgen::GenTPCLoopersParam::Instance();
9393
std::string model_pairs = gSystem->ExpandPathName(loopersParam.model_pairs.c_str());
9494
std::string model_compton = gSystem->ExpandPathName(loopersParam.model_compton.c_str());
95-
std::string nclxrate = gSystem->ExpandPathName(loopersParam.nclxrate.c_str());
9695
const auto& scaler_pair = gSystem->ExpandPathName(loopersParam.scaler_pair.c_str());
9796
const auto& scaler_compton = gSystem->ExpandPathName(loopersParam.scaler_compton.c_str());
9897
const auto& poisson = gSystem->ExpandPathName(loopersParam.poisson.c_str());
@@ -111,10 +110,10 @@ bool Generator::initLoopersGen()
111110
std::array<float, 2> multiplier = {loopersParam.multiplier[0], loopersParam.multiplier[1]};
112111
unsigned int nLoopersPairs = loopersParam.fixedNLoopers[0];
113112
unsigned int nLoopersCompton = loopersParam.fixedNLoopers[1];
114-
const std::array<std::string, 3> models = {model_pairs, model_compton, nclxrate};
115-
const std::array<std::string, 3> local_names = {"WGANpair.onnx", "WGANcompton.onnx", "nclxrate.root"};
116-
const std::array<bool, 3> isAlien = {models[0].starts_with("alien://"), models[1].starts_with("alien://"), models[2].starts_with("alien://")};
117-
const std::array<bool, 3> isCCDB = {models[0].starts_with("ccdb://"), models[1].starts_with("ccdb://"), models[2].starts_with("ccdb://")};
113+
const std::array<std::string, 2> models = {model_pairs, model_compton};
114+
const std::array<std::string, 2> local_names = {"WGANpair.onnx", "WGANcompton.onnx"};
115+
const std::array<bool, 2> isAlien = {models[0].starts_with("alien://"), models[1].starts_with("alien://")};
116+
const std::array<bool, 2> isCCDB = {models[0].starts_with("ccdb://"), models[1].starts_with("ccdb://")};
118117
if (std::any_of(isAlien.begin(), isAlien.end(), [](bool v) { return v; })) {
119118
if (!gGrid) {
120119
TGrid::Connect("alien://");
@@ -154,25 +153,14 @@ bool Generator::initLoopersGen()
154153
}
155154
model_pairs = isAlien[0] || isCCDB[0] ? local_names[0] : model_pairs;
156155
model_compton = isAlien[1] || isCCDB[1] ? local_names[1] : model_compton;
157-
nclxrate = isAlien[2] || isCCDB[2] ? local_names[2] : nclxrate;
158156
try {
159157
// Create the TPC loopers generator with the provided parameters
160158
mLoopersGen = std::make_unique<o2::eventgen::GenTPCLoopers>(model_pairs, model_compton, poisson, gauss, scaler_pair, scaler_compton);
161-
auto& colsys = loopersParam.colsys;
162-
auto &intrate = loopersParam.intrate;
163-
// Configure the generator with flat gas loopers defined per orbit with clusters/track info
159+
160+
// Configure the generator with flat gas loopers if enabled (default)
164161
if (flat_gas) {
165-
if (colsys != "PbPb" && colsys != "pp") {
166-
LOG(fatal) << "Error: collision system must be either 'PbPb' or 'pp'";
167-
exit(1);
168-
} else {
169-
if (intrate <= 0) {
170-
LOG(fatal) << "Error: interaction rate must be positive!";
171-
exit(1);
172-
}
173-
mLoopersGen->SetRate(nclxrate, (colsys == "PbPb") ? true : false, intrate);
174-
mLoopersGen->SetAdjust(loopersParam.adjust_flatgas);
175-
}
162+
mLoopersGen->setFlatGas(flat_gas, nFlatGasLoopers);
163+
mLoopersGen->setFractionPairs(fraction_pairs);
176164
} else {
177165
// Otherwise, Poisson+Gauss sampling or fixed number of loopers will be used
178166
// Multiplier is applied only with distribution sampling

Generators/src/TPCLoopers.cxx

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ Bool_t GenTPCLoopers::generateEvent()
197197
LOG(debug) << "Current time offset wrt BC: " << mInteractionTimeRecords[mCurrentEvent].getTimeOffsetWrtBC() << " ns";
198198
mTimeLimit = (mCurrentEvent < mInteractionTimeRecords.size() - 1) ? mInteractionTimeRecords[mCurrentEvent + 1].bc2ns() - mInteractionTimeRecords[mCurrentEvent].bc2ns() : mTimeEnd - mInteractionTimeRecords[mCurrentEvent].bc2ns();
199199
// With flat gas the number of loopers are adapted based on time interval widths
200-
// The denominator is either the LHC orbit (if mFlatGasOrbit is true) or the mean interaction time record interval
201-
nLoopers = mFlatGasOrbit ? (mFlatGasNumber * (mTimeLimit / o2::constants::lhc::LHCOrbitNS)) : (mFlatGasNumber * (mTimeLimit / mIntTimeRecMean));
200+
nLoopers = mFlatGasNumber * (mTimeLimit / mIntTimeRecMean);
202201
nLoopersPairs = static_cast<unsigned int>(std::round(nLoopers * mLoopsFractionPairs));
203202
nLoopersCompton = nLoopers - nLoopersPairs;
204203
SetNLoopers(nLoopersPairs, nLoopersCompton);
@@ -367,34 +366,22 @@ void GenTPCLoopers::SetMultiplier(std::array<float, 2>& mult)
367366
}
368367
}
369368

370-
void GenTPCLoopers::setFlatGas(Bool_t& flat, const Int_t& number = -1, const Int_t& nloopers_orbit = -1)
369+
void GenTPCLoopers::setFlatGas(Bool_t& flat, const Int_t& number)
371370
{
372371
mFlatGas = flat;
373372
if (mFlatGas) {
374-
if (nloopers_orbit > 0) {
375-
mFlatGasOrbit = true;
376-
mFlatGasNumber = nloopers_orbit;
377-
LOG(info) << "Flat gas loopers will be generated using orbit reference.";
373+
if (number < 0) {
374+
LOG(warn) << "Warning: Number of loopers per event must be non-negative! Switching option off.";
375+
mFlatGas = false;
376+
mFlatGasNumber = -1;
378377
} else {
379-
mFlatGasOrbit = false;
380-
if (number < 0) {
381-
LOG(warn) << "Warning: Number of loopers per event must be non-negative! Switching option off.";
382-
mFlatGas = false;
383-
mFlatGasNumber = -1;
384-
} else {
385-
mFlatGasNumber = number;
386-
}
387-
}
388-
if (mFlatGas) {
378+
mFlatGasNumber = number;
389379
mContextFile = std::filesystem::exists("collisioncontext.root") ? TFile::Open("collisioncontext.root") : nullptr;
390380
mCollisionContext = mContextFile ? (o2::steer::DigitizationContext*)mContextFile->Get("DigitizationContext") : nullptr;
391381
mInteractionTimeRecords = mCollisionContext ? mCollisionContext->getEventRecords() : std::vector<o2::InteractionTimeRecord>{};
392382
if (mInteractionTimeRecords.empty()) {
393383
LOG(error) << "Error: No interaction time records found in the collision context!";
394384
exit(1);
395-
} else {
396-
LOG(info) << "Interaction Time records has " << mInteractionTimeRecords.size() << " entries.";
397-
mCollisionContext->printCollisionSummary();
398385
}
399386
for (int c = 0; c < mInteractionTimeRecords.size() - 1; c++) {
400387
mIntTimeRecMean += mInteractionTimeRecords[c + 1].bc2ns() - mInteractionTimeRecords[c].bc2ns();
@@ -410,7 +397,7 @@ void GenTPCLoopers::setFlatGas(Bool_t& flat, const Int_t& number = -1, const Int
410397
} else {
411398
mFlatGasNumber = -1;
412399
}
413-
LOG(info) << "Flat gas loopers: " << (mFlatGas ? "ON" : "OFF") << ", Reference loopers number per " << (mFlatGasOrbit ? "orbit " : "event ") << mFlatGasNumber;
400+
LOG(info) << "Flat gas loopers: " << (mFlatGas ? "ON" : "OFF") << ", Reference loopers number per event: " << mFlatGasNumber;
414401
}
415402

416403
void GenTPCLoopers::setFractionPairs(float& fractionPairs)
@@ -423,40 +410,5 @@ void GenTPCLoopers::setFractionPairs(float& fractionPairs)
423410
LOG(info) << "Pairs fraction set to: " << mLoopsFractionPairs;
424411
}
425412

426-
void GenTPCLoopers::SetRate(const std::string &rateFile, const bool &isPbPb = true, const int &intRate = 50000)
427-
{
428-
// Checking if the rate file exists and is not empty
429-
TFile rate_file(rateFile.c_str(), "READ");
430-
if (!rate_file.IsOpen() || rate_file.IsZombie()) {
431-
LOG(fatal) << "Error: Rate file is empty or does not exist!";
432-
exit(1);
433-
}
434-
const char* fitName = isPbPb ? "fitPbPb" : "fitpp";
435-
auto fit = (TF1*)rate_file.Get(fitName);
436-
if (!fit) {
437-
LOG(fatal) << "Error: Could not find fit function '" << fitName << "' in rate file!";
438-
exit(1);
439-
}
440-
auto ref = static_cast<int>(std::floor(fit->Eval(intRate / 1000.))); // fit expects rate in kHz
441-
rate_file.Close();
442-
if (ref <= 0) {
443-
LOG(fatal) << "Computed flat gas number reference per orbit is <=0";
444-
exit(1);
445-
} else {
446-
LOG(info) << "Set flat gas number to " << ref << " loopers per orbit using " << fitName << " from " << intRate << " Hz interaction rate.";
447-
auto flat = true;
448-
setFlatGas(flat, -1, ref);
449-
}
450-
}
451-
452-
void GenTPCLoopers::SetAdjust(const float& adjust = 0.f)
453-
{
454-
if (mFlatGas && mFlatGasOrbit && adjust >= -1.f && adjust != 0.f) {
455-
LOG(info) << "Adjusting flat gas number per orbit by " << adjust * 100.f << "%";
456-
mFlatGasNumber = static_cast<int>(std::round(mFlatGasNumber * (1.f + adjust)));
457-
LOG(info) << "New flat gas number per orbit: " << mFlatGasNumber;
458-
}
459-
}
460-
461413
} // namespace eventgen
462414
} // namespace o2

0 commit comments

Comments
 (0)