12#ifndef O2_CTP_RAWDECODER_H
13#define O2_CTP_RAWDECODER_H
29namespace reco_workflow
36class RawDecoderSpec :
public framework::Task
63 void integrateLumi(
const std::array<double, o2::constants::lhc::LHCMaxBunches>& tfCounts1,
const std::array<double, o2::constants::lhc::LHCMaxBunches>& tfCounts2, int64_t unixTime, uint32_t nOrbitsThisTF);
64 void writeMassiLinePerBC(
int bc, int64_t unixTime,
double lumi,
double lumiErr,
double correctedRate,
double correctedLumi,
double mu);
73 bool mDoDigits =
true;
75 int mMaxInputSize = 0;
76 bool mMaxInputSizeFatal = 0;
81 bool mVerbose =
false;
82 uint64_t mCountsT = 0;
83 uint64_t mCountsV = 0;
84 uint32_t mNTFToIntegrate = 1;
85 uint32_t mNHBIntegrated = 0;
86 uint32_t mNHBIntegratedT = 0;
87 uint32_t mNHBIntegratedV = 0;
88 uint32_t mNHBToIntegrate = 1;
89 uint32_t mFirstOrbit = 0;
90 uint32_t mOrbitsInCurrentWindow = 0;
91 uint32_t mTFsInCurrentWindow = 0;
92 double mWindowStartTime = 0.0;
93 bool mDecodeinputs = 0;
94 std::deque<size_t> mHistoryT;
95 std::deque<size_t> mHistoryV;
98 int mLostDueToShiftInps = 0;
102 int mTCRRejected = 0;
103 std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsEA{};
104 std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsEB{};
105 std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsA{};
106 std::array<uint64_t, o2::ctp::CTP_NCLASSES> mClsB{};
107 bool mCheckConsistency =
false;
108 std::array<double, o2::constants::lhc::LHCMaxBunches> mCountsPerBC1{};
109 std::array<double, o2::constants::lhc::LHCMaxBunches> mCountsPerBC2{};
110 double totalTime = 0.0;
111 uint32_t mOrbitsPerTF = 0;
113 std::bitset<3564> mLHCBCs;
115 std::array<double, o2::constants::lhc::LHCMaxBunches> mTotalCountsPerBC1{};
116 std::array<double, o2::constants::lhc::LHCMaxBunches> mTotalCountsPerBC2{};
117 double mTotalElapsedTime = 0.0;
119 std::string mFillNumber =
"unknown";
120 std::string mMassiOutDir;
122 double mOrbitResetTimeSec = 0.0;
123 bool mStableBeams =
false;
124 std::map<int, std::ofstream> mMassiFiles;
126 double mCrossSection = 1.0;
127 double mTFsInMin = 0.0;
128 uint32_t mPrevTFLastOrbit = 0;
129 bool mHavePrevTF =
false;
130 int mRunStartTime = 0;
133 std::array<double, o2::constants::lhc::LHCMaxBunches> countsPerBC1{};
134 std::array<double, o2::constants::lhc::LHCMaxBunches> countsPerBC2{};
136 uint32_t nOrbitsThisTF;
138 std::map<uint32_t, PendingTF> mPendingTFs;
139 uint32_t mReorderDepth = 5;
140 void flushReadyTFs();
141 void flushAllPendingTFs();
142 std::pair<double, double> pileupCorrection(
double rate)
const;
definition of CTPDigit, CTPInputDigit
Digits tw Raw translation.
void run(framework::ProcessingContext &ctx) final
Run conversion of raw data to cells.
void computeLumiPerBC(const o2::pmr::vector< CTPDigit > &ctpdigits, uint32_t firstOrbit, uint32_t orbitsPerTF)
Compute per BC luminosity from the interaction counts from CTP digits.
void writeMassiLinePerBC(int bc, int64_t unixTime, double lumi, double lumiErr, double correctedRate, double correctedLumi, double mu)
~RawDecoderSpec() override=default
Destructor.
void writeMassiLineLumi(int64_t unixTime, double lumi, double lumiErr)
void integrateLumi(const std::array< double, o2::constants::lhc::LHCMaxBunches > &tfCounts1, const std::array< double, o2::constants::lhc::LHCMaxBunches > &tfCounts2, int64_t unixTime, uint32_t nOrbitsThisTF)
Integrate luminosity per BC over multiple time frames.
void init(framework::InitContext &ctx) final
Initializing the RawDecoderSpec.
void fetchRunInfo(int runNumber)
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
RawDecoderSpec(bool digits, bool lumi)
Constructor.
void updateTimeDependentParams(framework::ProcessingContext &pc)
int yearFromUnixTime(int64_t unixTime) const
int64_t unixTimeForOrbitStart(uint32_t orbit) const
constexpr double LHCOrbitMUS
o2::framework::DataProcessorSpec getRawDecoderSpec(bool askSTFDist, bool digits, bool lumi)
Creating DataProcessorSpec for the CTP.
std::vector< T, fair::mq::pmr::polymorphic_allocator< T > > vector
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< Digit > digits