Skip to content

Commit

Permalink
clang
Browse files Browse the repository at this point in the history
  • Loading branch information
lietava committed Feb 6, 2025
1 parent 3912667 commit b967709
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ class CTPRateFetcher
void setupRun(int runNumber, o2::ccdb::BasicCCDBManager* ccdb, uint64_t timeStamp, bool initScalers);
void updateScalers(ctp::CTPRunScalers& scalers);
int getRates(std::array<double, 3>& rates, o2::ccdb::BasicCCDBManager* ccdb, int runNumber, const std::string sourceName); // rates at start,stop and middle of the run
double getLumi(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, const std::string sourceName, int puCorr = 0); // total lumi for a run
double getLumi(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, const std::string sourceName, int puCorr = 0); // total lumi for a run
double getLumiNoPuCorr(const std::string& classname, int type = 1);
double getLumiWPuCorr(const std::string& classname, int type = 1);
void setOrbit(bool orb) { mOrbit = orb; } // use orbit instead of time
void setOrbit(bool orb) { mOrbit = orb; } // use orbit instead of time
void setOutsideLimits(bool qc) { mOutsideLimits = qc; } // return first/last rate of time outside of run

private:
double fetchCTPratesInputs(uint64_t timeStamp, int input);
double fetchCTPratesClasses(uint64_t timeStamp, const std::string& className, int inputType = 1);
double fetchCTPratesInputsNoPuCorr(uint64_t timeStamp, int input);
double fetchCTPratesClassesNoPuCorr(uint64_t timeStamp, const std::string& className, int inputType = 1);
double getLumi(const std::string& classname,int type = 1, int puCorr = 0);
double getLumi(const std::string& classname, int type = 1, int puCorr = 0);
double pileUpCorrection(double rate);
int mRunNumber = -1;
bool mOutsideLimits = 0;
Expand Down
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 @@ -145,7 +145,7 @@ class CTPRunScalers
}
/// retrieves integral - same interface as getRate, no pileup correction
uint64_t getLumiNoPuCorr(int classindex, int type) const;
/// retrieves vector of counters - same interface as getRate, needed for
/// retrieves vector of counters - same interface as getRate, needed for
std::vector<std::pair<double_t, double_t>> getRatesForIndex(int classindex, int type) const;
/// retrieves time boundaries of this scaler object from O2 scalers
std::pair<unsigned long, unsigned long> getTimeLimit() const
Expand Down
28 changes: 14 additions & 14 deletions DataFormats/Detectors/CTP/src/CTPRateFetcher.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ int CTPRateFetcher::getRates(std::array<double, 3>& rates, o2::ccdb::BasicCCDBMa
}
double CTPRateFetcher::getLumiNoPuCorr(const std::string& classname, int type)
{
if(classname == "zncinp") {
return mScalers.getLumiNoPuCorr(26,7);
if (classname == "zncinp") {
return mScalers.getLumiNoPuCorr(26, 7);
}
std::vector<ctp::CTPClass>& ctpcls = mConfig.getCTPClasses();
std::vector<int> clslist = mConfig.getTriggerClassList();
Expand All @@ -99,9 +99,9 @@ double CTPRateFetcher::getLumiNoPuCorr(const std::string& classname, int type)
}
double CTPRateFetcher::getLumiWPuCorr(const std::string& classname, int type)
{
std::vector<std::pair<double,double>> scals;
if(classname == "zncinp") {
scals = mScalers.getRatesForIndex(26,7);
std::vector<std::pair<double, double>> scals;
if (classname == "zncinp") {
scals = mScalers.getRatesForIndex(26, 7);
} else {
std::vector<ctp::CTPClass>& ctpcls = mConfig.getCTPClasses();
std::vector<int> clslist = mConfig.getTriggerClassList();
Expand All @@ -116,18 +116,18 @@ double CTPRateFetcher::getLumiWPuCorr(const std::string& classname, int type)
LOG(warn) << "Trigger class " << classname << " not found in CTPConfiguration";
return -1;
}
scals = mScalers.getRatesForIndex(classIndex,type);
scals = mScalers.getRatesForIndex(classIndex, type);
}
double lumi = 0;
for(auto const& ss: scals){
//std::cout << ss.first << " " << ss.second << " " << pileUpCorrection(ss.first/ss.second) << std::endl;
lumi += pileUpCorrection(ss.first/ss.second)*ss.second;
for (auto const& ss : scals) {
// std::cout << ss.first << " " << ss.second << " " << pileUpCorrection(ss.first/ss.second) << std::endl;
lumi += pileUpCorrection(ss.first / ss.second) * ss.second;
}
return lumi;
}
double CTPRateFetcher::getLumi(const std::string& classname,int type, int puCorr)
double CTPRateFetcher::getLumi(const std::string& classname, int type, int puCorr)
{
if(puCorr){
if (puCorr) {
return getLumiWPuCorr(classname, type);
} else {
return getLumiNoPuCorr(classname, type);
Expand All @@ -136,15 +136,15 @@ double CTPRateFetcher::getLumi(const std::string& classname,int type, int puCorr

double CTPRateFetcher::getLumi(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, const std::string sourceName, int puCorr)
{
//setupRun(runNumber, ccdb, timeStamp, 1);
// setupRun(runNumber, ccdb, timeStamp, 1);
if (sourceName.find("ZNC") != std::string::npos) {
if (runNumber < 544448) {
return getLumi("zncinp", 1, puCorr) / (sourceName.find("hadronic") != std::string::npos ? 28. : 1.);
} else {
return getLumi("C1ZNC-B-NOPF-CRU", 6, puCorr) / (sourceName.find("hadronic") != std::string::npos ? 28. : 1.);
}
} else if (sourceName == "T0CE") {
return getLumi("CMTVXTCE-B-NOPF", 1 , puCorr);
return getLumi("CMTVXTCE-B-NOPF", 1, puCorr);
} else if (sourceName == "T0SC") {
return getLumi("CMTVXTSC-B-NOPF", 1, puCorr);
} else if (sourceName == "T0VTX") {
Expand All @@ -154,7 +154,7 @@ double CTPRateFetcher::getLumi(o2::ccdb::BasicCCDBManager* ccdb, int runNumber,
double ret = getLumi("CMTVX-B-NOPF", 1, puCorr);
if (ret == -1.) {
LOG(info) << "Trying different class";
ret = getLumi("CMTVX-NONE", 1,puCorr);
ret = getLumi("CMTVX-NONE", 1, puCorr);
if (ret < 0) {
LOG(fatal) << "None of the classes used for lumi found";
}
Expand Down
80 changes: 40 additions & 40 deletions DataFormats/Detectors/CTP/src/Scalers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -665,66 +665,66 @@ uint64_t CTPRunScalers::getLumiNoPuCorr(int classindex, int type) const
const auto s1 = mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[classindex];
switch (type) {
case 1:
return (s1.lmBefore - s0.lmBefore);
return (s1.lmBefore - s0.lmBefore);
case 2:
return (s1.lmAfter - s0.lmAfter);
return (s1.lmAfter - s0.lmAfter);
case 3:
return (s1.l0Before - s0.l0Before);
return (s1.l0Before - s0.l0Before);
case 4:
return (s1.l0After - s0.l0After);
return (s1.l0After - s0.l0After);
case 5:
return (s1.l1Before - s0.l1Before);
return (s1.l1Before - s0.l1Before);
case 6:
return (s1.l1After - s0.l1After);
return (s1.l1After - s0.l1After);
default:
LOG(error) << "Wrong type:" << type;
return -1; // wrong type
LOG(error) << "Wrong type:" << type;
return -1; // wrong type
}
} else if (type == 7) {
auto s0 = mScalerRecordO2[0].scalersInps[classindex]; // type CTPScalerO2*
auto s1 = mScalerRecordO2[mScalerRecordO2.size() - 1].scalersInps[classindex];
return (s1 - s0);
} else {
LOG(error) << "Wrong type:" << type;
return -1; // wrong type
LOG(error) << "Wrong type:" << type;
return -1; // wrong type
}
};
//
std::vector<std::pair<double_t,double_t>> CTPRunScalers::getRatesForIndex(int classindex, int type) const
std::vector<std::pair<double_t, double_t>> CTPRunScalers::getRatesForIndex(int classindex, int type) const
{
std::vector<std::pair<double_t,double_t>> scals;
for(int i = 0; i < mScalerRecordO2.size() - 1; i++) {
double_t diff = 0;
//double_t timeDiff = mScalerRecordO2[i + 1].epochTime - mScalerRecordO2[i].epochTime;
double_t timeDiff = (mScalerRecordO2[i + 1].intRecord.orbit - mScalerRecordO2[i].intRecord.orbit) * o2::constants::lhc::LHCOrbitMUS/1.e6;
if (type < 7) {
const auto s0 = mScalerRecordO2[i].scalers[classindex];
const auto s1 = mScalerRecordO2[i+1].scalers[classindex];
if(type == 1) {
diff = s1.lmBefore - s0.lmBefore;
} else if(type == 2) {
diff = s1.lmAfter - s0.lmAfter;
} else if(type == 3){
diff = s1.l0Before - s0.l0Before;
} else if(type == 4) {
diff = s1.l0After - s0.l0After;
} else if(type == 5) {
diff = s1.l1Before - s0.l1Before;
} else if(type == 6) {
diff = s1.l1After - s0.l1After;
std::vector<std::pair<double_t, double_t>> scals;
for (int i = 0; i < mScalerRecordO2.size() - 1; i++) {
double_t diff = 0;
// double_t timeDiff = mScalerRecordO2[i + 1].epochTime - mScalerRecordO2[i].epochTime;
double_t timeDiff = (mScalerRecordO2[i + 1].intRecord.orbit - mScalerRecordO2[i].intRecord.orbit) * o2::constants::lhc::LHCOrbitMUS / 1.e6;
if (type < 7) {
const auto s0 = mScalerRecordO2[i].scalers[classindex];
const auto s1 = mScalerRecordO2[i + 1].scalers[classindex];
if (type == 1) {
diff = s1.lmBefore - s0.lmBefore;
} else if (type == 2) {
diff = s1.lmAfter - s0.lmAfter;
} else if (type == 3) {
diff = s1.l0Before - s0.l0Before;
} else if (type == 4) {
diff = s1.l0After - s0.l0After;
} else if (type == 5) {
diff = s1.l1Before - s0.l1Before;
} else if (type == 6) {
diff = s1.l1After - s0.l1After;
} else {
LOG(error) << "Wrong type:" << type;
return scals; // wrong type
}
} else if (type == 7) {
auto s0 = mScalerRecordO2[i].scalersInps[classindex]; // type CTPScalerO2*
auto s1 = mScalerRecordO2[i + 1].scalersInps[classindex];
diff = s1 - s0;
} else {
LOG(error) << "Wrong type:" << type;
return scals; // wrong type
}
} else if (type == 7) {
auto s0 = mScalerRecordO2[i].scalersInps[classindex]; // type CTPScalerO2*
auto s1 = mScalerRecordO2[i + 1].scalersInps[classindex];
diff = s1 - s0;
} else {
LOG(error) << "Wrong type:" << type;
return scals; // wrong type
}
scals.emplace_back(std::pair<double_t,double_t>{diff,timeDiff});
scals.emplace_back(std::pair<double_t, double_t>{diff, timeDiff});
}
return scals;
};
Expand Down
6 changes: 3 additions & 3 deletions Detectors/CTP/macro/GetRates.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#endif
using namespace o2::ctp;

void GetRates(int run=559617)
void GetRates(int run = 559617)
{
uint64_t inputmaskCum = 0, classmackCum = 0;
int ntrigSel = 0;

auto& cmb = o2::ccdb::BasicCCDBManager::instance();
auto ctpcfg = cmb.getSpecificForRun<o2::ctp::CTPConfiguration>("CTP/Config/Config", run);
if (!ctpcfg) {
Expand All @@ -38,7 +38,7 @@ void GetRates(int run=559617)
uint64_t inputmask = 0;
if (trgclass.descriptor != nullptr) {
inputmask = trgclass.descriptor->getInputsMask();
//LOGP(info, "inputmask: {:#x}", inputmask);
// LOGP(info, "inputmask: {:#x}", inputmask);
}
trgclass.printStream(std::cout);
// std::cout << indexInList << ": " << trgclass.name << ", input mask 0x" << std::hex << inputmask << ", class mask 0x" << trgclass.classMask << std::dec << std::endl;
Expand Down
12 changes: 6 additions & 6 deletions Detectors/CTP/macro/TestGetRates.C
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ using namespace o2::ctp;
void TestGetRates(int runN = 0)
{
std::vector<int> runs;
std::vector<std::string> codes = {"T0VTX", "T0VTX","ZNChadronic","ZNChadronic","T0VTX"};
if(runN == 0) {
runs = {529066,539218,544013,544518,557251};
std::vector<std::string> codes = {"T0VTX", "T0VTX", "ZNChadronic", "ZNChadronic", "T0VTX"};
if (runN == 0) {
runs = {529066, 539218, 544013, 544518, 557251};
} else {
runs.push_back(runN);
}
auto& ccdb = o2::ccdb::BasicCCDBManager::instance();
int i = 0;
for(auto const& runNumber: runs) {
for (auto const& runNumber : runs) {
// Opening run
std::pair<int64_t, int64_t> pp = ccdb.getRunDuration(runNumber);
long ts = pp.first + 60;
//std::cout << "Run duration:" << pp.first << " " << pp.second << std::endl;
std::cout << "===> RUN:" << runNumber << " duration:" << (pp.second - pp.first)/1000. << std::endl;
// std::cout << "Run duration:" << pp.first << " " << pp.second << std::endl;
std::cout << "===> RUN:" << runNumber << " duration:" << (pp.second - pp.first) / 1000. << std::endl;

CTPRateFetcher fetcher;
fetcher.setupRun(runNumber, &ccdb, ts, 1);
Expand Down

0 comments on commit b967709

Please sign in to comment.