Skip to content

Commit e01e682

Browse files
lietavashahor02
authored andcommitted
dev: modification of getRate needed for qc
1 parent 89375b5 commit e01e682

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

DataFormats/Detectors/CTP/include/DataFormatsCTP/Scalers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class CTPRunScalers
128128
std::pair<double, double> getRate(uint32_t orbit, int classindex, int type) const;
129129

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

133133
/// retrieves integral for class
134134
std::array<uint64_t, 7> getIntegralForClass(int i) const

DataFormats/Detectors/CTP/src/CTPRateFetcher.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ double CTPRateFetcher::fetchCTPratesClassesNoPuCorr(uint64_t timeStamp, const st
8484
LOG(warn) << "Trigger class " << className << " not found in CTPConfiguration";
8585
return -2.;
8686
}
87-
auto rate{mScalers.getRateGivenT(timeStamp * 1.e-3, classIndex, inputType)};
87+
auto rate{mScalers.getRateGivenT(timeStamp * 1.e-3, classIndex, inputType, 1)};
8888
return rate.second;
8989
}
9090
double CTPRateFetcher::fetchCTPratesInputs(uint64_t timeStamp, int input)
9191
{
9292
std::vector<ctp::CTPScalerRecordO2>& recs = mScalers.getScalerRecordO2();
9393
if (recs[0].scalersInps.size() == 48) {
94-
return pileUpCorrection(mScalers.getRateGivenT(timeStamp * 1.e-3, input, 7).second);
94+
return pileUpCorrection(mScalers.getRateGivenT(timeStamp * 1.e-3, input, 7, 1).second);
9595
} else {
9696
LOG(error) << "Inputs not available";
9797
return -1.;
@@ -101,7 +101,7 @@ double CTPRateFetcher::fetchCTPratesInputsNoPuCorr(uint64_t timeStamp, int input
101101
{
102102
std::vector<ctp::CTPScalerRecordO2>& recs = mScalers.getScalerRecordO2();
103103
if (recs[0].scalersInps.size() == 48) {
104-
return mScalers.getRateGivenT(timeStamp * 1.e-3, input, 7).second;
104+
return mScalers.getRateGivenT(timeStamp * 1.e-3, input, 7, 1).second;
105105
} else {
106106
LOG(error) << "Inputs not available";
107107
return -1.;

DataFormats/Detectors/CTP/src/Scalers.cxx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ std::pair<double, double> CTPRunScalers::getRate(uint32_t orbit, int classindex,
723723
// rate in Hz at a certain orbit number within the run
724724
// type - 7 : inputs
725725
// type - 1..6 : lmb,lma,l0b,l0a,l1b,l1a
726-
std::pair<double, double> CTPRunScalers::getRateGivenT(double timestamp, int classindex, int type) const
726+
std::pair<double, double> CTPRunScalers::getRateGivenT(double timestamp, int classindex, int type, bool qc) const
727727
{
728728
if (mScalerRecordO2.size() <= 1) {
729729
LOG(error) << "not enough data";
@@ -775,12 +775,24 @@ std::pair<double, double> CTPRunScalers::getRateGivenT(double timestamp, int cla
775775
return -1; // wrong type
776776
}
777777
};
778-
if (nextindex == 0 || nextindex == mScalerRecordO2.size()) {
778+
if (nextindex == 0) {
779779
// orbit is out of bounds
780-
LOG(info) << "query timestamp " << (long)timestamp << " out of bounds; Just returning the global rate";
781-
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
780+
if(qc == 0) {
781+
LOG(info) << "query timestamp " << (long)timestamp << " before first record; Just returning the global rate";
782+
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
783+
} else {
784+
LOG(info) << "query timestamp " << (long)timestamp << " before first record; Returning the first rate";
785+
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* first rate */ calcRate(0,1) );
786+
}
787+
} else if(nextindex == mScalerRecordO2.size()){
788+
if(qc == 0) {
789+
LOG(info) << "query timestamp " << (long)timestamp << " after last record; Just returning the global rate";
790+
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
791+
} else {
792+
LOG(info) << "query timestamp " << (long)timestamp << " after last record; Returning the last rate";
793+
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* last rate */ calcRate(mScalerRecordO2.size() - 2, mScalerRecordO2.size() - 1) );
794+
}
782795
} else {
783-
784796
return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ calcRate(nextindex - 1, nextindex));
785797
}
786798
return std::make_pair(-1., -1.);

0 commit comments

Comments
 (0)