Skip to content

Commit fef755c

Browse files
authored
Fix decreasing time trend of loopers in last event (#2102)
1 parent ba0105c commit fef755c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <rapidjson/document.h>
66
#include "CCDB/CCDBTimeStampUtils.h"
77
#include "CCDB/CcdbApi.h"
8+
#include "DetectorsRaw/HBFUtils.h"
89

910
// Static Ort::Env instance for multiple onnx model loading
1011
static Ort::Env global_env(ORT_LOGGING_LEVEL_WARNING, "GlobalEnv");
@@ -219,9 +220,9 @@ class GenTPCLoopers : public Generator
219220
{
220221
unsigned int nLoopers, nLoopersPairs, nLoopersCompton;
221222
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 event time: " << ((mCurrentEvent < mInteractionTimeRecords.size() - 1) ? std::to_string(mInteractionTimeRecords[mCurrentEvent + 1].bc2ns() - mInteractionTimeRecords[mCurrentEvent].bc2ns()) : std::to_string(mTimeEnd - mInteractionTimeRecords[mCurrentEvent].bc2ns())) << " ns";
223224
LOG(debug) << "Current time offset wrt BC: " << mInteractionTimeRecords[mCurrentEvent].getTimeOffsetWrtBC() << " ns";
224-
mTimeLimit = (mCurrentEvent < mInteractionTimeRecords.size() - 1) ? mInteractionTimeRecords[mCurrentEvent + 1].bc2ns() - mInteractionTimeRecords[mCurrentEvent].bc2ns() : mIntTimeRecMean;
225+
mTimeLimit = (mCurrentEvent < mInteractionTimeRecords.size() - 1) ? mInteractionTimeRecords[mCurrentEvent + 1].bc2ns() - mInteractionTimeRecords[mCurrentEvent].bc2ns() : mTimeEnd - mInteractionTimeRecords[mCurrentEvent].bc2ns();
225226
// With flat gas the number of loopers are adapted based on time interval widths
226227
nLoopers = mFlatGasNumber * (mTimeLimit / mIntTimeRecMean);
227228
nLoopersPairs = static_cast<unsigned int>(std::round(nLoopers * mLoopsFractionPairs));
@@ -424,6 +425,12 @@ class GenTPCLoopers : public Generator
424425
mIntTimeRecMean += mInteractionTimeRecords[c + 1].bc2ns() - mInteractionTimeRecords[c].bc2ns();
425426
}
426427
mIntTimeRecMean /= (mInteractionTimeRecords.size() - 1); // Average interaction time record used as reference
428+
const auto& hbfUtils = o2::raw::HBFUtils::Instance();
429+
// Get the start time of the second orbit after the last interaction record
430+
const auto& lastIR = mInteractionTimeRecords.back();
431+
o2::InteractionRecord finalOrbitIR(0, lastIR.orbit + 2); // Final orbit, BC = 0
432+
mTimeEnd = finalOrbitIR.bc2ns();
433+
LOG(debug) << "Final orbit start time: " << mTimeEnd << " ns while last interaction record time is " << mInteractionTimeRecords.back().bc2ns() << " ns";
427434
}
428435
} else {
429436
mFlatGasNumber = -1;
@@ -470,6 +477,7 @@ class GenTPCLoopers : public Generator
470477
Int_t mFlatGasNumber = -1; // Number of flat gas loopers per event
471478
double mIntTimeRecMean = 1.0; // Average interaction time record used for the reference
472479
double mTimeLimit = 0.0; // Time limit for the current event
480+
double mTimeEnd = 0.0; // Time limit for the last event
473481
float mLoopsFractionPairs = 0.08; // Fraction of loopers from Pairs
474482
};
475483

0 commit comments

Comments
 (0)