13#include <fairlogger/Logger.h>
27 drmDia.
fillDRM(
j - 1, histo->GetBinContent(1,
j));
28 for (
int i = 2;
i <= histo->GetXaxis()->GetNbins();
i++) {
29 if (histo->GetBinContent(1,
j)) {
30 if (histo->GetBinContent(
i,
j) > 0) {
37 TFile* fo =
new TFile(file_output_name,
"RECREATE");
38 fo->WriteObjectAny(&drmDia, drmDia.Class_Name(),
"ccdb_object");
40 LOG(
debug) <<
"DRM error ccdb object created in " << file_output_name <<
" with this content";
51 mTRMerrorProb.clear();
69 long timems =
long(mTimeStamp) * 1000;
70 LOG(
debug) <<
"TOF get active map with timestamp (ms) = " << timems;
71 auto fee = mgr.getForTimeStamp<
TOFFEElightInfo>(
"TOF/Calib/FEELIGHT", timems);
82 LOG(info) <<
"read Active map (TOFFEELIGHT) for TOF ";
90 LOG(info) <<
"Active map (TOFFEELIGHT) not available in ccdb";
102 long timems =
long(mTimeStamp) * 1000;
103 LOG(info) <<
"TOF get LHCphase with timestamp (ms) = " << timems;
104 mLHCphase = mgr.getForTimeStamp<
LhcPhase>(
"TOF/Calib/LHCphase", timems);
106 LOG(info) <<
"read LHCphase for TOF " << mLHCphase->
getLHCphase(mTimeStamp);
108 LOG(info) <<
"LHC phase not available in ccdb";
121 long timems =
long(mTimeStamp) * 1000;
122 LOG(info) <<
"TOF get time calibrations with timestamp (ms) = " << timems;
123 mSlewParam = mgr.getForTimeStamp<
SlewParam>(
"TOF/Calib/ChannelCalib", timems);
125 LOG(info) <<
"read TimeSlewingParam for TOF";
127 LOG(info) <<
"TimeSlewingParam for TOF not available in ccdb";
136 mSlewParam = (
SlewParam*)
f->Get(
"ccdb_object");
147 long timems =
long(mTimeStamp) * 1000;
148 LOG(info) <<
"TOF get TRM Diagnostics with timestamp (ms) = " << timems;
149 mDiaFreq = mgr.getForTimeStamp<
Diagnostic>(
"TOF/Calib/Diagnostic", timems);
159 long timems =
long(mTimeStamp) * 1000;
160 LOG(info) <<
"TOF get DRM Diagnostics with timestamp (ms) = " << timems;
161 mDiaFreq = mgr.getForTimeStamp<
Diagnostic>(
"TOF/Calib/TRMerrors", timems);
196 mEmptyCrateProb[
i] = ncrate[
i] / nrow;
199 const auto vectorDia = mDiaFreq->
getVector();
201 for (
auto pair : vectorDia) {
202 auto key = pair.first;
205 if (slot < 13 && slot > 2) {
207 int crateslot = icrate * 100 + slot;
208 mTRMerrorProb.push_back(std::make_pair(crateslot, pair.second / (nrow - ncrate[icrate])));
209 mTRMmask.push_back(
key - mDiaFreq->
getTRMKey(icrate, slot));
219 int crate = channel / NCH_PER_CRATE;
220 float prob = pair.second / (nrow - ncrate[crate]);
221 mNoisy.push_back(std::make_pair(channel, prob));
226 std::sort(mTRMerrorProb.begin(), mTRMerrorProb.end(), [](
const auto&
a,
const auto&
b) {
227 return a.first < b.first;
230 std::sort(mNoisy.begin(), mNoisy.end(), [](
const auto&
a,
const auto&
b) {
231 return a.first < b.first;
236 for (
auto [ch, p] : mNoisy) {
238 if (ich != -1 && prob > 0.5) {
239 mIsNoisy[ich] =
true;
247 if (ich != -1 && prob > 0.5) {
248 mIsNoisy[ich] =
true;
256 mDiaDRMFreq->
print();
261 if (DRMcounters < 1) {
263 mErrorInDRM[ic][ie] = 0.;
275 if (frequency > 1E-6) {
276 LOG(
debug) <<
"DRMmap: Crate = " << ic <<
" - error = " << ie <<
" - frequency = " << frequency;
278 mErrorInDRM[ic][ie] = frequency;
292 api.
init(mgr.getURL());
305 api.
init(mgr.getURL());
306 if (maxTimeStamp == 0) {
309 api.
storeAsTFileAny(
param,
"TOF/Calib/ChannelCalib", metadataChannelCalib, minTimeStamp, maxTimeStamp);
328 return mIsNoisy[ich];
335 return mIsOffCh[ich];
346 if (!mLHCphase || !mSlewParam) {
347 LOG(warning) <<
"Either LHC phase or slewing object null: mLHCphase = " << mLHCphase <<
", mSlewParam = " << mSlewParam;
369 LOG(warning) <<
"slewing object null: mSlewParam = " << mSlewParam;
396 for (
auto index : mFillErrChannel) {
397 mIsErrorCh[
index] =
false;
400 mFillErrChannel.clear();
407 for (
auto index : mFillErrDRMChannel) {
408 mIsErrorDRMCh[
index] =
false;
411 mFillErrDRMChannel.clear();
421 int ech = (crate << 12) + ((trm - 3) << 8);
422 for (
int i = ech;
i < ech + 256;
i++) {
427 mIsErrorCh[channel] =
true;
428 mFillErrChannel.push_back(channel);
436 int mask = 1 << codeErr;
442 LOG(
debug) <<
"DRMmask: crate = " << crate <<
" - mask = " <<
mask <<
" - critical mask = " << mDRMCriticalErrorMask;
444 for (
int trm = 3; trm < 13; trm++) {
445 int ech = (crate << 12) + ((trm - 3) << 8);
446 for (
int i = ech;
i < ech + 256;
i++) {
448 if (channel == -1 || mIsErrorDRMCh[channel] ==
true) {
452 mIsErrorDRMCh[channel] =
true;
453 mFillErrDRMChannel.push_back(channel);
469 return !(mDRMCriticalErrorMask &
mask);
476 return mIsErrorCh[channel];
483 if (mIsErrorDRMCh[channel]) {
487 return mIsErrorDRMCh[channel];
ClassImp(o2::tof::CalibTOFapi)
Class to use TOF calibration (decalibration, calibration)
static BasicCCDBManager & instance()
int storeAsTFileAny(const T *obj, std::string const &path, std::map< std::string, std::string > const &metadata, long startValidityTimestamp=-1, long endValidityTimestamp=-1, std::vector< char >::size_type maxSize=0) const
void init(std::string const &hosts)
void readDiagnosticDRMFrequencies()
bool isChannelError(int channel) const
void loadDiagnosticFrequencies()
void writeLHCphase(LhcPhase *phase, std::map< std::string, std::string > metadataLHCphase, uint64_t minTimeSTamp, uint64_t maxTimeStamp)
void readTimeSlewingParamFromFile(const char *filename)
void writeTimeSlewingParam(SlewParam *param, std::map< std::string, std::string > metadataChannelCalib, uint64_t minTimeSTamp, uint64_t maxTimeStamp=0)
void readDiagnosticFrequencies()
void loadDiagnosticDRMFrequencies()
bool checkTRMPolicy(int mask) const
static const int DRM_ERRINDEX_SHIFT
void readTimeSlewingParam()
static o2::tof::Diagnostic doDRMerrCalibFromQCHisto(const TH2F *histo, const char *file_output_name)
void processError(int crate, int trm, int mask)
void loadActiveMap(TOFFEElightInfo *fee)
bool isChannelDRMError(int channel) const
void setURL(const std::string url)
float getTimeDecalibration(int ich, float tot) const
bool checkDRMPolicy(int mask) const
bool isProblematic(int ich)
float getTimeCalibration(int ich, float tot) const
void processErrorDRM(int crate, int codeErr)
Diagnostic class for TOF.
uint32_t getFrequencyROW() const
void print(bool longFormat=false) const
uint32_t getFrequencyEmptyCrate(int crate) const
uint32_t fillDRMerror(int crate, int error, uint32_t frequency)
static int getCrate(ULong64_t pattern)
uint32_t getFrequencyDRM(int crate) const
static ULong64_t getTRMKey(int crate, int trm)
static int getChannel(ULong64_t pattern)
uint32_t getFrequencyDRMerror(int crate, int error) const
uint32_t getFrequencyEmptyTOF() const
const std::map< ULong64_t, uint32_t > & getVector() const
bool isNoisyChannel(int channel, int thr=0) const
static int getSlot(ULong64_t pattern)
uint32_t fillDRM(int crate, uint32_t frequency)
static constexpr Int_t NSTRIPXSECTOR
static constexpr Int_t NPADS
static Int_t getCHFromECH(int echan)
static void getVolumeIndices(Int_t index, Int_t *detId)
static constexpr int NCHANNELS
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
bool getChannelEnabled(int idx) const
static constexpr int NCHANNELS
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"