21 auto triggerRate =
fetchNoPuCorr(ccdb, timeStamp, runNumber, sourceName);
22 if (triggerRate >= 0) {
23 return pileUpCorrection(triggerRate);
29 setupRun(runNumber, ccdb, timeStamp, 1);
30 if (sourceName.find(
"ZNC") != std::string::npos) {
31 if (runNumber < 544448) {
32 return fetchCTPratesInputsNoPuCorr(timeStamp, 25) / (sourceName.find(
"hadronic") != std::string::npos ? 28. : 1.);
34 return fetchCTPratesClassesNoPuCorr(timeStamp,
"C1ZNC-B-NOPF-CRU", 6) / (sourceName.find(
"hadronic") != std::string::npos ? 28. : 1.);
36 }
else if (sourceName ==
"T0CE") {
37 return fetchCTPratesClassesNoPuCorr(timeStamp,
"CMTVXTCE-B-NOPF");
38 }
else if (sourceName ==
"T0SC") {
39 return fetchCTPratesClassesNoPuCorr(timeStamp,
"CMTVXTSC-B-NOPF");
40 }
else if (sourceName ==
"T0VTX") {
41 if (runNumber < 534202) {
42 return fetchCTPratesClassesNoPuCorr(timeStamp,
"minbias_TVX_L0", 3);
44 double ret = fetchCTPratesClassesNoPuCorr(timeStamp,
"CMTVX-B-NOPF");
46 LOG(info) <<
"Trying different class";
47 ret = fetchCTPratesClassesNoPuCorr(timeStamp,
"CMTVX-NONE");
49 LOG(fatal) <<
"None of the classes used for lumi found";
55 LOG(error) <<
"CTP rate for " << sourceName <<
" not available";
71 double rate0 =
fetch(ccdb, orbitlimits.first, mRunNumber, sourceName);
72 double rateLast =
fetch(ccdb, orbitlimits.second, mRunNumber, sourceName);
73 double rateM =
fetch(ccdb, (orbitlimits.first + orbitlimits.second) / 2, mRunNumber, sourceName);
82 if (classname ==
"zncinp") {
88 for (
size_t i = 0;
i < clslist.size();
i++) {
89 if (ctpcls[
i].
name.find(classname) != std::string::npos) {
94 if (classIndex == -1) {
95 LOG(warn) <<
"Trigger class " << classname <<
" not found in CTPConfiguration";
102 std::vector<std::pair<double, double>> scals;
103 if (classname ==
"zncinp") {
106 std::vector<ctp::CTPClass>& ctpcls = mConfig.
getCTPClasses();
109 for (
size_t i = 0;
i < clslist.size();
i++) {
110 if (ctpcls[
i].
name.find(classname) != std::string::npos) {
115 if (classIndex == -1) {
116 LOG(warn) <<
"Trigger class " << classname <<
" not found in CTPConfiguration";
122 for (
auto const& ss : scals) {
124 lumi += pileUpCorrection(ss.first / ss.second) * ss.second;
140 if (sourceName.find(
"ZNC") != std::string::npos) {
141 if (runNumber < 544448) {
142 return getLumi(
"zncinp", 1, puCorr) / (sourceName.find(
"hadronic") != std::string::npos ? 28. : 1.);
144 return getLumi(
"C1ZNC-B-NOPF-CRU", 6, puCorr) / (sourceName.find(
"hadronic") != std::string::npos ? 28. : 1.);
146 }
else if (sourceName ==
"T0CE") {
147 return getLumi(
"CMTVXTCE-B-NOPF", 1, puCorr);
148 }
else if (sourceName ==
"T0SC") {
149 return getLumi(
"CMTVXTSC-B-NOPF", 1, puCorr);
150 }
else if (sourceName ==
"T0VTX") {
151 if (runNumber < 534202) {
152 return getLumi(
"minbias_TVX_L0", 3, puCorr);
154 double ret =
getLumi(
"CMTVX-B-NOPF", 1, puCorr);
156 LOG(info) <<
"Trying different class";
157 ret =
getLumi(
"CMTVX-NONE", 1, puCorr);
159 LOG(fatal) <<
"None of the classes used for lumi found";
165 LOG(error) <<
"CTP Lumi for " << sourceName <<
" not available";
169double CTPRateFetcher::fetchCTPratesClasses(uint64_t timeStamp,
const std::string& className,
int inputType)
171 auto triggerRate = fetchCTPratesClassesNoPuCorr(timeStamp, className, inputType);
172 if (triggerRate >= 0) {
173 return pileUpCorrection(triggerRate);
177double CTPRateFetcher::fetchCTPratesClassesNoPuCorr(uint64_t timeStamp,
const std::string& className,
int inputType)
179 std::vector<ctp::CTPClass>& ctpcls = mConfig.
getCTPClasses();
182 for (
size_t i = 0;
i < clslist.size();
i++) {
183 if (ctpcls[
i].
name.find(className) != std::string::npos) {
188 if (classIndex == -1) {
189 LOG(warn) <<
"Trigger class " << className <<
" not found in CTPConfiguration";
193 auto rate{mScalers.
getRate((uint32_t)timeStamp, classIndex, inputType, mOutsideLimits)};
196 auto rate{mScalers.
getRateGivenT(timeStamp * 1.e-3, classIndex, inputType, mOutsideLimits)};
200double CTPRateFetcher::fetchCTPratesInputs(uint64_t timeStamp,
int input)
203 if (recs[0].scalersInps.size() == 48) {
205 return pileUpCorrection(mScalers.
getRate((uint32_t)timeStamp, input, 7, mOutsideLimits).second);
207 return pileUpCorrection(mScalers.
getRateGivenT(timeStamp * 1.e-3, input, 7, mOutsideLimits).second);
210 LOG(error) <<
"Inputs not available";
214double CTPRateFetcher::fetchCTPratesInputsNoPuCorr(uint64_t timeStamp,
int input)
217 if (recs[0].scalersInps.size() == 48) {
219 return mScalers.
getRate((uint32_t)timeStamp, input, 7, mOutsideLimits).second;
221 return mScalers.
getRateGivenT(timeStamp * 1.e-3, input, 7, mOutsideLimits).second;
224 LOG(error) <<
"Inputs not available";
229double CTPRateFetcher::pileUpCorrection(
double triggerRate)
232 LOG(fatal) <<
"No filling" << std::endl;
236 double nbc = bcs.size();
238 double mu = -std::log(1 - nTriggersPerFilledBC);
244 if (runNumber == mRunNumber) {
247 mRunNumber = runNumber;
248 LOG(info) <<
"Setting up CTP scalers for run " << mRunNumber;
250 if (ptrLHCIFdata ==
nullptr) {
251 LOG(fatal) <<
"GRPLHCIFData not in database, timestamp:" << timeStamp;
253 mLHCIFdata = *ptrLHCIFdata;
254 std::map<string, string> metadata;
257 if (ptrConfig ==
nullptr) {
258 LOG(fatal) <<
"CTPRunConfig not in database, timestamp:" << timeStamp;
260 mConfig = *ptrConfig;
264 mScalers = *ptrScalers;
267 LOG(fatal) <<
"CTPRunScalers not in database, timestamp:" << timeStamp;
Header to collect LHC related constants.
std::vector< int > getFilledBCs(int dir=-1) const
T * getSpecific(std::string const &path, long timestamp=-1, MD metaData=MD())
retrieve an object of type T from CCDB as stored under path, timestamp and metaData
std::vector< CTPClass > & getCTPClasses()
std::vector< int > getTriggerClassList() const
int getRates(std::array< double, 3 > &rates, o2::ccdb::BasicCCDBManager *ccdb, int runNumber, const std::string sourceName)
double getLumiWPuCorr(const std::string &classname, int type=1)
double getLumi(o2::ccdb::BasicCCDBManager *ccdb, int runNumber, const std::string sourceName, int puCorr=0)
void setupRun(int runNumber, o2::ccdb::BasicCCDBManager *ccdb, uint64_t timeStamp, bool initScalers)
double fetchNoPuCorr(o2::ccdb::BasicCCDBManager *ccdb, uint64_t timeStamp, int runNumber, const std::string sourceName)
double getLumiNoPuCorr(const std::string &classname, int type=1)
void updateScalers(ctp::CTPRunScalers &scalers)
double fetch(o2::ccdb::BasicCCDBManager *ccdb, uint64_t timeStamp, int runNumber, const std::string sourceName)
uint64_t getLumiNoPuCorr(int classindex, int type) const
retrieves integral - same interface as getRate, no pileup correction
std::pair< double, double > getRate(uint32_t orbit, int classindex, int type, bool qc=0) const
std::pair< double, double > getRateGivenT(double timestamp, int classindex, int type, bool qc=0) const
same with absolute timestamp (not orbit) as argument
std::pair< unsigned long, unsigned long > getOrbitLimit() const
retrieves orbit boundaries of this scaler object from O2
std::vector< CTPScalerRecordO2 > & getScalerRecordO2()
std::vector< std::pair< double_t, double_t > > getRatesForIndex(int classindex, int type) const
retrieves vector of counters - same interface as getRate, needed for
const o2::BunchFilling & getBunchFilling() const
int32_t getFillNumber() const
GLuint const GLchar * name
GLint GLint GLsizei GLint GLenum GLenum type
GLuint GLsizei const GLenum * rates
constexpr double LHCRevFreq
std::string to_string(gsl::span< T, Size > span)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"