Skip to content

Commit b773e93

Browse files
committed
Improved logging + colsys check
1 parent 19e77a3 commit b773e93

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

Generators/src/Generator.cxx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ Generator::Generator() : FairGenerator("ALICEo2", "ALICEo2 Generator"),
5050
if (transport) {
5151
bool tpcActive = (std::find(simConfig.getReadoutDetectors().begin(), simConfig.getReadoutDetectors().end(), "TPC") != simConfig.getReadoutDetectors().end());
5252
if (tpcActive) {
53-
if(initLoopersGen()){
53+
if (initLoopersGen()) {
5454
mAddTPCLoopers = kTRUE;
5555
}
56+
} else {
57+
LOG(info) << "TPC not active in readout detectors: loopers fast generator disabled.";
5658
}
5759
}
60+
} else {
61+
LOG(info) << "Loopers fast generator turned OFF with veto flag.";
5862
}
5963
#endif
6064
}
@@ -78,8 +82,12 @@ Generator::Generator(const Char_t* name, const Char_t* title) : FairGenerator(na
7882
if (initLoopersGen()) {
7983
mAddTPCLoopers = kTRUE;
8084
}
85+
} else {
86+
LOG(info) << "TPC not active in readout detectors: loopers fast generator disabled.";
8187
}
8288
}
89+
} else {
90+
LOG(info) << "Loopers fast generator turned OFF with veto flag.";
8391
}
8492
#endif
8593
}
@@ -97,8 +105,14 @@ bool Generator::initLoopersGen()
97105
const auto& scaler_compton = gSystem->ExpandPathName(loopersParam.scaler_compton.c_str());
98106
const auto& poisson = gSystem->ExpandPathName(loopersParam.poisson.c_str());
99107
const auto& gauss = gSystem->ExpandPathName(loopersParam.gauss.c_str());
100-
auto flat_gas = loopersParam.flat_gas;
108+
const auto& flat_gas = loopersParam.flat_gas;
109+
const auto& colsys = loopersParam.colsys;
101110
if (flat_gas) {
111+
if (colsys != "PbPb" && colsys != "pp") {
112+
LOG(warning) << "Automatic background loopers configuration supports only 'pp' and 'PbPb' systems.";
113+
LOG(warning) << "Fast loopers generator will remain OFF.";
114+
return kFALSE;
115+
}
102116
bool isContext = std::filesystem::exists("collisioncontext.root");
103117
if (!isContext) {
104118
LOG(warning) << "Warning: No collisioncontext.root file found!";
@@ -156,17 +170,12 @@ bool Generator::initLoopersGen()
156170
try {
157171
// Create the TPC loopers generator with the provided parameters
158172
mLoopersGen = std::make_unique<o2::eventgen::GenTPCLoopers>(model_pairs, model_compton, poisson, gauss, scaler_pair, scaler_compton);
159-
auto& colsys = loopersParam.colsys;
160-
auto &intrate = loopersParam.intrate;
173+
const auto &intrate = loopersParam.intrate;
161174
// Configure the generator with flat gas loopers defined per orbit with clusters/track info
175+
// If intrate is negative (default), automatic IR from collisioncontext.root will be used
162176
if (flat_gas) {
163-
if (colsys != "PbPb" && colsys != "pp") {
164-
LOG(fatal) << "Error: collision system must be either 'PbPb' or 'pp'";
165-
exit(1);
166-
} else {
167-
mLoopersGen->SetRate(nclxrate, (colsys == "PbPb") ? true : false, intrate);
168-
mLoopersGen->SetAdjust(loopersParam.adjust_flatgas);
169-
}
177+
mLoopersGen->SetRate(nclxrate, (colsys == "PbPb") ? true : false, intrate);
178+
mLoopersGen->SetAdjust(loopersParam.adjust_flatgas);
170179
} else {
171180
// Otherwise, Poisson+Gauss sampling or fixed number of loopers per event will be used
172181
// Multiplier is applied only with distribution sampling

Generators/src/TPCLoopers.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ GenTPCLoopers::GenTPCLoopers(std::string model_pairs, std::string model_compton,
141141
scaler_file[0].close();
142142
scaler_file[1].close();
143143
// Checking if the poisson file exists and it's not empty
144-
if (poisson != "")
144+
if (poisson != "" && poisson != "None" && poisson != "none")
145145
{
146146
std::ifstream poisson_file(poisson);
147147
if (!poisson_file.is_open() || poisson_file.peek() == std::ifstream::traits_type::eof())
@@ -157,7 +157,7 @@ GenTPCLoopers::GenTPCLoopers(std::string model_pairs, std::string model_compton,
157157
}
158158
}
159159
// Checking if the gauss file exists and it's not empty
160-
if (gauss != "")
160+
if (gauss != "" && gauss != "None" && gauss != "none")
161161
{
162162
std::ifstream gauss_file(gauss);
163163
if (!gauss_file.is_open() || gauss_file.peek() == std::ifstream::traits_type::eof())
@@ -205,9 +205,11 @@ Bool_t GenTPCLoopers::generateEvent()
205205
// Set number of loopers if poissonian params are available
206206
if (mPoissonSet) {
207207
mNLoopersPairs = static_cast<unsigned int>(std::round(mMultiplier[0] * PoissonPairs()));
208+
LOG(debug) << "Generated loopers pairs (Poisson): " << mNLoopersPairs;
208209
}
209210
if (mGaussSet) {
210211
mNLoopersCompton = static_cast<unsigned int>(std::round(mMultiplier[1] * GaussianElectrons()));
212+
LOG(debug) << "Generated compton electrons (Gauss): " << mNLoopersCompton;
211213
}
212214
// Generate pairs
213215
for (int i = 0; i < mNLoopersPairs; ++i) {

0 commit comments

Comments
 (0)