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

ctprate #13730

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft

ctprate #13730

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
2 changes: 1 addition & 1 deletion DataFormats/Detectors/CTP/include/DataFormatsCTP/Scalers.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class CTPRunScalers
std::pair<double, double> getRate(uint32_t orbit, int classindex, int type) const;

/// same with absolute timestamp (not orbit) as argument
std::pair<double, double> getRateGivenT(double timestamp, int classindex, int type) const;
std::pair<double, double> getRateGivenT(double timestamp, int classindex, int type, bool qc = 0) const;

/// retrieves integral for class
std::array<uint64_t, 7> getIntegralForClass(int i) const
Expand Down
6 changes: 3 additions & 3 deletions DataFormats/Detectors/CTP/src/CTPRateFetcher.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ double CTPRateFetcher::fetchCTPratesClassesNoPuCorr(uint64_t timeStamp, const st
LOG(warn) << "Trigger class " << className << " not found in CTPConfiguration";
return -2.;
}
auto rate{mScalers.getRateGivenT(timeStamp * 1.e-3, classIndex, inputType)};
auto rate{mScalers.getRateGivenT(timeStamp * 1.e-3, classIndex, inputType, 1)};
return rate.second;
}
double CTPRateFetcher::fetchCTPratesInputs(uint64_t timeStamp, int input)
{
std::vector<ctp::CTPScalerRecordO2>& recs = mScalers.getScalerRecordO2();
if (recs[0].scalersInps.size() == 48) {
return pileUpCorrection(mScalers.getRateGivenT(timeStamp * 1.e-3, input, 7).second);
return pileUpCorrection(mScalers.getRateGivenT(timeStamp * 1.e-3, input, 7, 1).second);
} else {
LOG(error) << "Inputs not available";
return -1.;
Expand All @@ -101,7 +101,7 @@ double CTPRateFetcher::fetchCTPratesInputsNoPuCorr(uint64_t timeStamp, int input
{
std::vector<ctp::CTPScalerRecordO2>& recs = mScalers.getScalerRecordO2();
if (recs[0].scalersInps.size() == 48) {
return mScalers.getRateGivenT(timeStamp * 1.e-3, input, 7).second;
return mScalers.getRateGivenT(timeStamp * 1.e-3, input, 7, 1).second;
} else {
LOG(error) << "Inputs not available";
return -1.;
Expand Down
22 changes: 17 additions & 5 deletions DataFormats/Detectors/CTP/src/Scalers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ std::pair<double, double> CTPRunScalers::getRate(uint32_t orbit, int classindex,
// rate in Hz at a certain orbit number within the run
// type - 7 : inputs
// type - 1..6 : lmb,lma,l0b,l0a,l1b,l1a
std::pair<double, double> CTPRunScalers::getRateGivenT(double timestamp, int classindex, int type) const
std::pair<double, double> CTPRunScalers::getRateGivenT(double timestamp, int classindex, int type, bool qc) const
{
if (mScalerRecordO2.size() <= 1) {
LOG(error) << "not enough data";
Expand Down Expand Up @@ -775,12 +775,24 @@ std::pair<double, double> CTPRunScalers::getRateGivenT(double timestamp, int cla
return -1; // wrong type
}
};
if (nextindex == 0 || nextindex == mScalerRecordO2.size()) {
if (nextindex == 0) {
// orbit is out of bounds
LOG(info) << "query timestamp " << (long)timestamp << " out of bounds; Just returning the global rate";
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
if (qc == 0) {
LOG(info) << "query timestamp " << (long)timestamp << " before first record; Just returning the global rate";
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
} else {
LOG(info) << "query timestamp " << (long)timestamp << " before first record; Returning the first rate";
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* first rate */ calcRate(0, 1));
}
} else if (nextindex == mScalerRecordO2.size()) {
if (qc == 0) {
LOG(info) << "query timestamp " << (long)timestamp << " after last record; Just returning the global rate";
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
} else {
LOG(info) << "query timestamp " << (long)timestamp << " after last record; Returning the last rate";
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* last rate */ calcRate(mScalerRecordO2.size() - 2, mScalerRecordO2.size() - 1));
}
} else {

return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ calcRate(nextindex - 1, nextindex));
}
return std::make_pair(-1., -1.);
Expand Down
Loading