Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctpdev: FV0 to lumi #10349

Merged
merged 2 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DataFormats/Detectors/CTP/include/DataFormatsCTP/LumiInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ struct LumiInfo {
LumiInfo() = default;
uint32_t orbit = 0; // orbit of TF when was updated
uint32_t nHBFCounted = 0; // length of interval in HB
uint32_t nHBFCountedFV0 = 0;
uint64_t counts = 0; // counts in the interval for the nominal lumi detector (FT0)
uint64_t countsFV0 = 0; // connts for FV0 (less reliable)
float getLumi() const { return nHBFCounted > 0 ? float(counts / (nHBFCounted * o2::constants::lhc::LHCOrbitMUS * 1e-6)) : 0.f; }
float getLumiFV0() const { return nHBFCounted > 0 ? float(countsFV0 / (nHBFCounted * o2::constants::lhc::LHCOrbitMUS * 1e-6)) : 0.f; }
float getLumiFV0() const { return nHBFCountedFV0 > 0 ? float(countsFV0 / (nHBFCountedFV0 * o2::constants::lhc::LHCOrbitMUS * 1e-6)) : 0.f; }
float getLumiError() const { return nHBFCounted > 0 ? float(std::sqrt(counts) / (nHBFCounted * o2::constants::lhc::LHCOrbitMUS * 1e-6)) : 0.f; }
float getLumiFV0Error() const { return nHBFCounted > 0 ? float(std::sqrt(countsFV0) / (nHBFCounted * o2::constants::lhc::LHCOrbitMUS * 1e-6)) : 0.f; }
float getLumiFV0Error() const { return nHBFCountedFV0 > 0 ? float(std::sqrt(countsFV0) / (nHBFCountedFV0 * o2::constants::lhc::LHCOrbitMUS * 1e-6)) : 0.f; }
ClassDefNV(LumiInfo, 2);
};
} // namespace ctp
Expand Down
12 changes: 8 additions & 4 deletions Detectors/CTP/workflow/include/CTPWorkflow/RawDecoderSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ class RawDecoderSpec : public framework::Task
// for lumi
bool mDoLumi = true;
//
gbtword80_t mTVXMask = 0x4; // TVX is 3rd input
gbtword80_t mTVXMask = 0x4; // TVX is 3rd input
gbtword80_t mVBAMask = 0x20; // VBA is 6 th input
LumiInfo mOutputLumiInfo;
bool mVerbose = false;
uint64_t mCounts = 0;
uint64_t mCountsT = 0;
uint64_t mCountsV = 0;
uint32_t mNTFToIntegrate = 1;
uint32_t mNHBIntegrated = 0;
std::deque<size_t> mHistory;
uint32_t mNHBIntegratedT = 0;
uint32_t mNHBIntegratedV = 0;
std::deque<size_t> mHistoryT;
std::deque<size_t> mHistoryV;
};

/// \brief Creating DataProcessorSpec for the CTP
Expand Down
61 changes: 43 additions & 18 deletions Detectors/CTP/workflow/src/RawDecoderSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
std::vector<InputSpec> filter{InputSpec{"filter", ConcreteDataTypeMatcher{"CTP", "RAWDATA"}, Lifetime::Timeframe}};
o2::framework::DPLRawParser parser(ctx.inputs(), filter);
std::vector<LumiInfo> lumiPointsHBF1;
uint64_t countsMB = 0;
uint64_t countsMBT = 0;
uint64_t countsMBV = 0;
uint32_t payloadCTP;
uint32_t orbit0 = 0;
bool first = true;
Expand Down Expand Up @@ -110,8 +111,9 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
std::vector<gbtword80_t> diglets;
if (orbit0 != triggerOrbit) {
if (mDoLumi && payloadCTP == o2::ctp::NIntRecPayload) { // create lumi per HB
lumiPointsHBF1.emplace_back(LumiInfo{triggerOrbit, 0, countsMB});
countsMB = 0;
lumiPointsHBF1.emplace_back(LumiInfo{triggerOrbit, 0, 0, countsMBT, countsMBV});
countsMBT = 0;
countsMBV = 0;
}
remnant = 0;
size_gbt = 0;
Expand All @@ -138,7 +140,11 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
if (mDoLumi && payloadCTP == o2::ctp::NIntRecPayload) {
gbtword80_t pld = (diglet >> 12) & mTVXMask;
if (pld.count() != 0) {
countsMB++;
countsMBT++;
}
pld = (diglet >> 12) & mVBAMask;
if (pld.count() != 0) {
countsMBV++;
}
}
if (!mDoDigits) {
Expand All @@ -159,7 +165,11 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
if (mDoLumi && payloadCTP == o2::ctp::NIntRecPayload) {
gbtword80_t pld = (remnant >> 12) & mTVXMask;
if (pld.count() != 0) {
countsMB++;
countsMBT++;
}
pld = (remnant >> 12) & mVBAMask;
if (pld.count() != 0) {
countsMBV++;
}
}
if (!mDoDigits) {
Expand All @@ -177,27 +187,42 @@ void RawDecoderSpec::run(framework::ProcessingContext& ctx)
ctx.outputs().snapshot(o2::framework::Output{"CTP", "DIGITS", 0, o2::framework::Lifetime::Timeframe}, mOutputDigits);
}
if (mDoLumi) {
lumiPointsHBF1.emplace_back(LumiInfo{orbit0, 0, countsMB});
uint32_t tfCounts = 0;
lumiPointsHBF1.emplace_back(LumiInfo{orbit0, 0, 0, countsMBT, countsMBV});
uint32_t tfCountsT = 0;
uint32_t tfCountsV = 0;
for (auto const& lp : lumiPointsHBF1) {
tfCounts += lp.counts;
tfCountsT += lp.counts;
tfCountsV += lp.countsFV0;
}
// LOG(info) << "Lumi rate:" << tfCounts/(128.*88e-6);
mHistory.push_back(tfCounts);
mCounts += tfCounts;
if (mHistory.size() <= mNTFToIntegrate) {
mNHBIntegrated += lumiPointsHBF1.size();
// FT0
mHistoryT.push_back(tfCountsT);
mCountsT += tfCountsT;
if (mHistoryT.size() <= mNTFToIntegrate) {
mNHBIntegratedT += lumiPointsHBF1.size();
} else {
mCountsT -= mHistoryT.front();
mHistoryT.pop_front();
}
// FV0
mHistoryV.push_back(tfCountsV);
mCountsV += tfCountsV;
if (mHistoryV.size() <= mNTFToIntegrate) {
mNHBIntegratedV += lumiPointsHBF1.size();
} else {
mCounts -= mHistory.front();
mHistory.pop_front();
mCountsV -= mHistoryV.front();
mHistoryV.pop_front();
}
if (mNHBIntegrated) {
//
if (mNHBIntegratedT || mNHBIntegratedV) {
mOutputLumiInfo.orbit = lumiPointsHBF1[0].orbit;
}
mOutputLumiInfo.counts = mCounts;
mOutputLumiInfo.nHBFCounted = mNHBIntegrated;
mOutputLumiInfo.counts = mCountsT;
mOutputLumiInfo.countsFV0 = mCountsV;
mOutputLumiInfo.nHBFCounted = mNHBIntegratedT;
mOutputLumiInfo.nHBFCountedFV0 = mNHBIntegratedV;
if (mVerbose) {
LOGP(info, "Orbit {}: {} counts in {} HBFs -> lumi = {:.3e}+-{:.3e}", mOutputLumiInfo.orbit, mCounts, mNHBIntegrated, mOutputLumiInfo.getLumi(), mOutputLumiInfo.getLumiError());
LOGP(info, "Orbit {}: {}/{} counts T/V in {}/{} HBFs -> lumiT = {:.3e}+-{:.3e} lumiV = {:.3e}+-{:.3e}", mOutputLumiInfo.orbit, mCountsT, mCountsV, mNHBIntegratedT, mNHBIntegratedV, mOutputLumiInfo.getLumi(), mOutputLumiInfo.getLumiError(), mOutputLumiInfo.getLumiFV0(), mOutputLumiInfo.getLumiFV0Error());
}
ctx.outputs().snapshot(o2::framework::Output{"CTP", "LUMI", 0, o2::framework::Lifetime::Timeframe}, mOutputLumiInfo);
}
Expand Down