Skip to content

Commit 6ce5195

Browse files
committed
Fix
1 parent 64730cb commit 6ce5195

1 file changed

Lines changed: 22 additions & 26 deletions

File tree

MC/config/common/external/generator/TPCLoopers.C

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,6 @@ class GenTPCLoopers : public Generator
207207
mScaler_compton->load(scaler_compton);
208208
Generator::setTimeUnit(1.0);
209209
Generator::setPositionUnit(1.0);
210-
mContextFile = std::filesystem::exists("collisioncontext.root") ? TFile::Open("collisioncontext.root") : nullptr;
211-
mCollisionContext = mContextFile ? (o2::steer::DigitizationContext *)mContextFile->Get("DigitizationContext") : nullptr;
212-
mInteractionTimeRecords = mCollisionContext ? mCollisionContext->getEventRecords() : std::vector<o2::InteractionTimeRecord>{};
213-
if (mInteractionTimeRecords.empty())
214-
{
215-
LOG(warn) << "Error: No interaction time records found in the collision context!";
216-
exit(1);
217-
} else {
218-
LOG(info) << "Interaction Time records has " << mInteractionTimeRecords.size() << " entries.";
219-
mCollisionContext->printCollisionSummary();
220-
}
221-
for (int c = 0; c < mInteractionTimeRecords.size() - 1; c++)
222-
{
223-
mIntTimeRecMean += mInteractionTimeRecords[c + 1].bc2ns() - mInteractionTimeRecords[c].bc2ns();
224-
}
225-
mIntTimeRecMean /= (mInteractionTimeRecords.size() - 1); // Average interaction time record used for the reference
226210
}
227211

228212
Bool_t generateEvent() override
@@ -234,11 +218,11 @@ class GenTPCLoopers : public Generator
234218
if (mFlatGas)
235219
{
236220
unsigned int nLoopers, nLoopersPairs, nLoopersCompton;
237-
LOG(info) << "mCurrentEvent is " << mCurrentEvent;
238-
LOG(info) << "Current event time: " << ((mCurrentEvent < mInteractionTimeRecords.size() - 1) ? std::to_string(mInteractionTimeRecords[mCurrentEvent + 1].bc2ns() - mInteractionTimeRecords[mCurrentEvent].bc2ns()) : std::to_string(mIntTimeRecMean)) << " ns";
239-
LOG(info) << "Current time offset wrt BC: " << mInteractionTimeRecords[mCurrentEvent].getTimeOffsetWrtBC() << " ns";
221+
LOG(debug) << "mCurrentEvent is " << mCurrentEvent;
222+
LOG(debug) << "Current event time: " << ((mCurrentEvent < mInteractionTimeRecords.size() - 1) ? std::to_string(mInteractionTimeRecords[mCurrentEvent + 1].bc2ns() - mInteractionTimeRecords[mCurrentEvent].bc2ns()) : std::to_string(mIntTimeRecMean)) << " ns";
223+
LOG(debug) << "Current time offset wrt BC: " << mInteractionTimeRecords[mCurrentEvent].getTimeOffsetWrtBC() << " ns";
240224
mTimeLimit = (mCurrentEvent < mInteractionTimeRecords.size() - 1) ? mInteractionTimeRecords[mCurrentEvent + 1].bc2ns() - mInteractionTimeRecords[mCurrentEvent].bc2ns() : mIntTimeRecMean;
241-
// With Flat Gas number of loopers are adapted based on time interval widths
225+
// With flat gas the number of loopers are adapted based on time interval widths
242226
nLoopers = mFlatGasNumber * (mTimeLimit / mIntTimeRecMean);
243227
nLoopersPairs = static_cast<unsigned int>(std::round(nLoopers * mLoopsFractionPairs));
244228
nLoopersCompton = nLoopers - nLoopersPairs;
@@ -422,14 +406,26 @@ class GenTPCLoopers : public Generator
422406
LOG(warn) << "Warning: Number of loopers per event must be non-negative! Switching option off.";
423407
mFlatGas = false;
424408
mFlatGasNumber = -1;
425-
}
426-
else
427-
{
409+
} else {
428410
mFlatGasNumber = number;
411+
mContextFile = std::filesystem::exists("collisioncontext.root") ? TFile::Open("collisioncontext.root") : nullptr;
412+
mCollisionContext = mContextFile ? (o2::steer::DigitizationContext *)mContextFile->Get("DigitizationContext") : nullptr;
413+
mInteractionTimeRecords = mCollisionContext ? mCollisionContext->getEventRecords() : std::vector<o2::InteractionTimeRecord>{};
414+
if (mInteractionTimeRecords.empty())
415+
{
416+
LOG(error) << "Error: No interaction time records found in the collision context!";
417+
exit(1);
418+
} else {
419+
LOG(info) << "Interaction Time records has " << mInteractionTimeRecords.size() << " entries.";
420+
mCollisionContext->printCollisionSummary();
421+
}
422+
for (int c = 0; c < mInteractionTimeRecords.size() - 1; c++)
423+
{
424+
mIntTimeRecMean += mInteractionTimeRecords[c + 1].bc2ns() - mInteractionTimeRecords[c].bc2ns();
425+
}
426+
mIntTimeRecMean /= (mInteractionTimeRecords.size() - 1); // Average interaction time record used as reference
429427
}
430-
}
431-
else
432-
{
428+
} else {
433429
mFlatGasNumber = -1;
434430
}
435431
LOG(info) << "Flat gas loopers: " << (mFlatGas ? "ON" : "OFF") << ", Reference loopers number per event: " << mFlatGasNumber;

0 commit comments

Comments
 (0)