Skip to content

Commit

Permalink
Ctpdev: ctpRateFetcher (#12791)
Browse files Browse the repository at this point in the history
* dev:debuging ctpRateFetcher

* clang

* fixes

* clang

* fixes

* ctpRateF.C moved to O2Physics

* clang

* fix
  • Loading branch information
lietava authored Mar 5, 2024
1 parent 989671a commit 4c82740
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
2 changes: 2 additions & 0 deletions DataFormats/Detectors/CTP/include/DataFormatsCTP/Scalers.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class CTPRunScalers
std::vector<uint32_t> getClassIndexes() const;
int getScalerIndexForClass(uint32_t cls) const;
std::vector<CTPScalerRecordO2>& getScalerRecordO2() { return mScalerRecordO2; };
std::vector<CTPScalerRecordRaw>& getScalerRecordRaw() { return mScalerRecordRaw; };
void setEpochTime(std::time_t tt, int index) { mScalerRecordRaw[index].epochTime = tt; };
int readScalers(const std::string& rawscalers);
int convertRawToO2();
int checkConsistency(const CTPScalerO2& scal0, const CTPScalerO2& scal1, errorCounters& eCnts) const;
Expand Down
27 changes: 14 additions & 13 deletions DataFormats/Detectors/CTP/src/Scalers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
using namespace o2::ctp;
void errorCounters::printStream(std::ostream& stream) const
{
stream << "Counter warnings diff 1 lmBlmA:" << lmBlmAd1 << " lmAl0B:" << lmAl0Bd1 << " l0Bl0A:" << l0Bl0Ad1 << " l0Al1B: " << l0Al1Bd1 << " l1Bl1A:" << l1Bl1Ad1;
stream << std::endl;
stream << "Counter errorrs: lmB:" << lmB << " l0B:" << l0B << " l1B:" << l1B << " lmA:" << lmA << " l0A:" << l0A << " l1A:" << l1A;
stream << " lmBlmA:" << lmBlmA << " lmAl0B:" << lmAl0B << " l0Bl0A:" << l0Bl0A << " l0Al1B: " << l0Al1B << " l1Bl1A:" << l1Bl1A;
stream << std::endl;
// stream << "Counter warnings diff 1 lmBlmA:" << lmBlmAd1 << " lmAl0B:" << lmAl0Bd1 << " l0Bl0A:" << l0Bl0Ad1 << " l0Al1B: " << l0Al1Bd1 << " l1Bl1A:" << l1Bl1Ad1;
// stream << std::endl;
if (lmB + l0B + l1B + lmA + l0A + l1A + lmBlmA + lmAl0B + l0Bl0A + l0Al1B + l1Bl1A) {
stream << "Counter errorrs: lmB:" << lmB << " l0B:" << l0B << " l1B:" << l1B << " lmA:" << lmA << " l0A:" << l0A << " l1A:" << l1A;
stream << " lmBlmA:" << lmBlmA << " lmAl0B:" << lmAl0B << " l0Bl0A:" << l0Bl0A << " l0Al1B: " << l0Al1B << " l1Bl1A:" << l1Bl1A;
stream << std::endl;
}
}
void CTPScalerRaw::printStream(std::ostream& stream) const
{
Expand Down Expand Up @@ -498,20 +500,19 @@ int CTPRunScalers::updateOverflows(const CTPScalerRaw& scal0, const CTPScalerRaw
int CTPRunScalers::updateOverflowsInps(const CTPScalerRecordRaw& rec0, const CTPScalerRecordRaw& rec1, std::array<uint32_t, 48>& overflow) const
{
static int iPrint = 0;
if (mRunNumber < 545367) {
uint32_t NINPS = 48;
if (rec0.scalersInps.size() < NINPS) {
if (iPrint < 1) {
LOG(info) << "CTP Input scalers not available for run:" << mRunNumber;
LOG(warning) << "Input scalers not available. Size:" << rec0.scalersInps.size();
iPrint++;
}
return 0;
}
uint32_t NINPS = 48;
if (rec0.scalersInps.size() < NINPS) {
LOG(error) << "updateOverflowsInps.size < 48:" << rec0.scalersInps.size();
return 1;
}
if (rec1.scalersInps.size() < NINPS) {
LOG(error) << "updateOverflowsInps.size < 48:" << rec1.scalersInps.size();
if (iPrint < 1) {
LOG(warning) << "Input scalers not available. Size:" << rec0.scalersInps.size();
iPrint++;
}
return 2;
}
for (uint32_t i = 0; i < NINPS; i++) {
Expand Down
1 change: 1 addition & 0 deletions Detectors/CTP/macro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ o2_add_test_root_macro(PlotOrbit.C
PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP
O2::CCDB
LABELS ctp)

19 changes: 11 additions & 8 deletions Detectors/CTP/macro/GetScalersForRun.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
// or submit itself to any jurisdiction.

#if !defined(__CLING__) || defined(__ROOTCLING__)
#include <TMath.h>
#include <CCDB/BasicCCDBManager.h>
#include <DataFormatsCTP/Configuration.h>
#include "ctpRateFetcher.h"
#include <DataFormatsParameters/GRPLHCIFData.h>
#include "Common/CCDB/ctpRateFetcher.h"
#endif
using namespace o2::ctp;

Expand All @@ -23,11 +25,8 @@ void GetScalersForRun(int runNumber = 0, int fillN = 0, bool test = 1)
}
std::string mCCDBPathCTPScalers = "CTP/Calib/Scalers";
std::string mCCDBPathCTPConfig = "CTP/Config/Config";
// o2::ccdb::CcdbApi api;
// api.init("http://alice-ccdb.cern.ch"); // alice-ccdb.cern.ch
// api.init("http://ccdb-test.cern.ch:8080");

auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
// ccdbMgr.setURL("http://ccdb-test.cern.ch:8080");
auto soreor = ccdbMgr.getRunDuration(runNumber);
uint64_t timeStamp = (soreor.second - soreor.first) / 2 + soreor.first;
std::cout << "Timestamp:" << timeStamp << std::endl;
Expand All @@ -43,7 +42,6 @@ void GetScalersForRun(int runNumber = 0, int fillN = 0, bool test = 1)
std::string srun = std::to_string(runNumber);
metadata.clear(); // can be empty
metadata["runNumber"] = srun;
ccdbMgr.setURL("http://ccdb-test.cern.ch:8080");
auto ctpscalers = ccdbMgr.getSpecific<CTPRunScalers>(mCCDBPathCTPScalers, timeStamp, metadata);
if (ctpscalers == nullptr) {
LOG(info) << "CTPRunScalers not in database, timestamp:" << timeStamp;
Expand Down Expand Up @@ -129,10 +127,15 @@ void GetScalersForRun(int runNumber = 0, int fillN = 0, bool test = 1)
if (iznc != 255) {
std::cout << "ZNC class:";
// uint64_t integral = recs[recs.size() - 1].scalers[iznc].l1After - recs[0].scalers[iznc].l1After;
auto zncrate = ctpscalers->getRateGivenT(0, iznc, 6);
auto zncrate = ctpscalers->getRateGivenT(timeStamp * 1.e-3, iznc, 6);
std::cout << "ZNC class rate:" << zncrate.first / 28. << std::endl;
} else {
std::cout << "ZNC class not available" << std::endl;
std::cout << "ZNC class not available, rate from input:" << std::endl;
}
auto zncinprate = ctpscalers->getRateGivenT((timeStamp + 100) * 1.e-3, 25, 7);
std::cout << "ZNC inp rate:" << zncinprate.first / 28. << " " << zncinprate.second / 28. << std::endl;

// ctpRateFetcher ctprate;
// auto fetcherRate = ctprate.fetch(&ccdbMgr, timeStamp, runNumber, "ZNChadronic");
// std::cout << "Result from the fetcher (ZNC): " << fetcherRate << std::endl;
}
14 changes: 10 additions & 4 deletions Detectors/CTP/macro/PlotOrbit.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ void PlotOrbit(int runNumber)
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
// Timestamp
auto soreor = ccdbMgr.getRunDuration(runNumber);
uint64_t timeStamp = (soreor.second - soreor.first) / 2 + soreor.first;
// uint64_t timeStamp = (soreor.second - soreor.first) / 2 + soreor.first;
uint64_t timeStamp = soreor.first + 60 * 1000;
std::cout << "Timestamp:" << timeStamp << std::endl;
//
// Scalers
std::string srun = std::to_string(runNumber);
std::map<string, string> metadata;
Expand All @@ -45,7 +47,9 @@ void PlotOrbit(int runNumber)
return;
}
scl->convertRawToO2();
std::vector<CTPScalerRecordO2> recs = scl->getScalerRecordO2();
// return ;
std::vector<CTPScalerRecordRaw> recs = scl->getScalerRecordRaw();
std::cout << "raw rec size:" << recs.size() << std::endl;
//
//
// Anal
Expand All @@ -55,10 +59,12 @@ void PlotOrbit(int runNumber)
int64_t timeL = recs[recs.size() - 1].epochTime;
double_t Trun = timeL - time0;
// double_t orbit0 = recs[0].intRecord.orbit;
int64_t orbit0 = scl->getOrbitLimit().first;
int64_t orbitL = scl->getOrbitLimit().second;
int64_t orbit0 = scl->getOrbitLimitFromRaw().first;
int64_t orbitL = scl->getOrbitLimitFromRaw().second;
int n = recs.size() - 1;
std::cout << " Run duration:" << Trun << " Scalers size:" << n + 1 << std::endl;
std::cout << "Orbit0:" << orbit0 << " orbitL:" << orbitL << std::endl;
return;
Double_t x[n], orbit[n];
// Double_t tcetsctoznc[n], tcetoznc[n], vchtoznc[n];
for (int i = 0; i < n; i++) {
Expand Down

0 comments on commit 4c82740

Please sign in to comment.