Project
Loading...
Searching...
No Matches
CalibTOFapi.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef ALICEO2_TOF_CALIBTOFAPI_H_
17#define ALICEO2_TOF_CALIBTOFAPI_H_
18
19#include <iostream>
23#include "TOFBase/Geo.h"
27
28class TH2F;
29
30namespace o2
31{
32namespace tof
33{
34
36{
37
42
43 public:
44 static o2::tof::Diagnostic doDRMerrCalibFromQCHisto(const TH2F* histo, const char* file_output_name);
45
46 void resetDia();
47 CalibTOFapi() = default;
48 CalibTOFapi(const std::string url);
49 CalibTOFapi(long timestamp, o2::dataformats::CalibLHCphaseTOF* phase, o2::dataformats::CalibTimeSlewingParamTOF* slew, Diagnostic* dia = nullptr, Diagnostic* diaDRM = nullptr) : mTimeStamp(timestamp), mLHCphase(phase), mSlewParam(slew), mDiaFreq(dia), mDiaDRMFreq(diaDRM) {}
51 {
52 if (mLHCphase) {
53 // delete mLHCphase;
54 }
55 if (mSlewParam) {
56 // delete mSlewParam;
57 }
58 if (mDiaFreq) {
59 // delete mDiaFreq;
60 }
61 if (mDiaDRMFreq) {
62 // delete mDiaDRMFreq;
63 }
64 }
65
66 void setTimeStamp(long t)
67 {
68 mTimeStamp = t;
69 }
70 void setURL(const std::string url)
71 {
72 auto& mgr = CcdbManager::instance();
73 mgr.setURL(url);
74 }
75 void readLHCphase();
77 void readTimeSlewingParamFromFile(const char* filename);
82 void readActiveMap();
84 void writeLHCphase(LhcPhase* phase, std::map<std::string, std::string> metadataLHCphase, uint64_t minTimeSTamp, uint64_t maxTimeStamp);
85 void writeTimeSlewingParam(SlewParam* param, std::map<std::string, std::string> metadataChannelCalib, uint64_t minTimeSTamp, uint64_t maxTimeStamp = 0);
86 float getTimeCalibration(int ich, float tot) const;
87 float getTimeCalibration(int ich, float tot, float phase) const;
88 float getTimeDecalibration(int ich, float tot) const;
89 bool isProblematic(int ich);
90 bool isNoisy(int ich);
91 bool isOff(int ich);
92 float getFractionUnderPeak(int ich) const { return mSlewParam->getFractionUnderPeak(ich); }
93 float currentLHCphase() const { return mLHCphase->getLHCphase(mTimeStamp); }
94
95 SlewParam* getSlewParam() { return mSlewParam; }
96 SlewParam& getSlewParamObj() { return *mSlewParam; }
97 void setSlewParam(SlewParam* obj) { mSlewParam = obj; }
98 LhcPhase* getLhcPhase() { return mLHCphase; }
99 void setLhcPhase(LhcPhase* obj) { mLHCphase = obj; }
100 Diagnostic* getDiagnostic() { return mDiaFreq; }
101 void setDiagnostic(Diagnostic* obj) { mDiaFreq = obj; }
102 Diagnostic* getDiagnosticDRM() { return mDiaDRMFreq; }
103 void setDiagnosticDRM(Diagnostic* obj) { mDiaDRMFreq = obj; }
104
105 int getNoisyThreshold() const { return mNoisyThreshold; }
106 void setNoisyThreshold(int val) { mNoisyThreshold = val; }
107 float getEmptyTOFProb() const { return mEmptyTOF; }
108 const float* getEmptyCratesProb() const { return mEmptyCrateProb; }
109 const std::vector<std::pair<int, float>>& getNoisyProb() const { return mNoisy; }
110 const std::vector<std::pair<int, float>>& getTRMerrorProb() const { return mTRMerrorProb; }
111 const std::vector<int>& getTRMmask() const { return mTRMmask; }
112
113 void resetTRMErrors();
114 void processError(int crate, int trm, int mask);
115 bool isChannelError(int channel) const;
116 bool checkTRMPolicy(int mask) const;
117 void resetDRMErrors();
118 void processErrorDRM(int crate, int codeErr);
119 bool isChannelDRMError(int channel) const;
120 bool checkDRMPolicy(int mask) const;
121
122 void setDRMCriticalErrorMask(uint32_t val) { mDRMCriticalErrorMask = val; }
123 uint32_t getDRMCriticalErrorMask() const { return mDRMCriticalErrorMask; }
124 float getDRMprobError(int crate, int type) const { return mErrorInDRM[crate][type]; }
125
126 // DRM error codes inherited by EDRMDiagnostic_t in CompressedDataFormat.h (shifted by 4 bits)
127 static const int DRM_ERRINDEX_SHIFT = 4;
143
144 private:
145 long mTimeStamp;
146 LhcPhase* mLHCphase = nullptr;
147 SlewParam* mSlewParam = nullptr;
148 Diagnostic* mDiaFreq = nullptr;
149 Diagnostic* mDiaDRMFreq = nullptr;
150
151 // info from diagnostic
152 int mNoisyThreshold = 1;
153 float mEmptyTOF = 0;
154 float mEmptyCrateProb[Geo::kNCrate] = {};
155 std::vector<std::pair<int, float>> mNoisy;
156 std::vector<std::pair<int, float>> mTRMerrorProb;
157 std::vector<int> mTRMmask;
158 float mErrorInDRM[Geo::kNCrate][N_DRM_ERRORS] = {};
159 uint32_t mDRMCriticalErrorMask = 0;
160
161 bool mIsErrorCh[Geo::NCHANNELS] = {};
162 std::vector<int> mFillErrChannel;
163 bool mIsOffCh[Geo::NCHANNELS] = {};
164 bool mIsNoisy[Geo::NCHANNELS] = {};
165 bool mIsErrorDRMCh[Geo::NCHANNELS] = {};
166 std::vector<int> mFillErrDRMChannel;
167
168 ClassDefNV(CalibTOFapi, 2);
169};
170} // namespace tof
171} // namespace o2
172#endif
std::string url
Class to store the output of the matching to TOF for calibration.
Class to store the output of the matching to TOF for calibration.
Definition of the TOF cluster.
uint64_t phase
Definition RawEventData.h:7
static BasicCCDBManager & instance()
float getLHCphase(int timestamp) const
float getFractionUnderPeak(int sector, int channel) const
void readDiagnosticDRMFrequencies()
bool isChannelError(int channel) const
void writeLHCphase(LhcPhase *phase, std::map< std::string, std::string > metadataLHCphase, uint64_t minTimeSTamp, uint64_t maxTimeStamp)
CalibTOFapi(long timestamp, o2::dataformats::CalibLHCphaseTOF *phase, o2::dataformats::CalibTimeSlewingParamTOF *slew, Diagnostic *dia=nullptr, Diagnostic *diaDRM=nullptr)
Definition CalibTOFapi.h:49
void setSlewParam(SlewParam *obj)
Definition CalibTOFapi.h:97
void readTimeSlewingParamFromFile(const char *filename)
const float * getEmptyCratesProb() const
const std::vector< std::pair< int, float > > & getNoisyProb() const
const std::vector< std::pair< int, float > > & getTRMerrorProb() const
void writeTimeSlewingParam(SlewParam *param, std::map< std::string, std::string > metadataChannelCalib, uint64_t minTimeSTamp, uint64_t maxTimeStamp=0)
void loadDiagnosticDRMFrequencies()
bool checkTRMPolicy(int mask) const
static const int DRM_ERRINDEX_SHIFT
float getFractionUnderPeak(int ich) const
Definition CalibTOFapi.h:92
uint32_t getDRMCriticalErrorMask() const
LhcPhase * getLhcPhase()
Definition CalibTOFapi.h:98
void setTimeStamp(long t)
Definition CalibTOFapi.h:66
float getDRMprobError(int crate, int type) const
SlewParam * getSlewParam()
Definition CalibTOFapi.h:95
void setNoisyThreshold(int val)
float getEmptyTOFProb() const
static o2::tof::Diagnostic doDRMerrCalibFromQCHisto(const TH2F *histo, const char *file_output_name)
bool isNoisy(int ich)
Diagnostic * getDiagnostic()
void processError(int crate, int trm, int mask)
void loadActiveMap(TOFFEElightInfo *fee)
void setDiagnosticDRM(Diagnostic *obj)
void setLhcPhase(LhcPhase *obj)
Definition CalibTOFapi.h:99
float currentLHCphase() const
Definition CalibTOFapi.h:93
SlewParam & getSlewParamObj()
Definition CalibTOFapi.h:96
int getNoisyThreshold() const
bool isChannelDRMError(int channel) const
void setURL(const std::string url)
Definition CalibTOFapi.h:70
float getTimeDecalibration(int ich, float tot) const
bool checkDRMPolicy(int mask) const
bool isProblematic(int ich)
float getTimeCalibration(int ich, float tot) const
const std::vector< int > & getTRMmask() const
Diagnostic * getDiagnosticDRM()
void processErrorDRM(int crate, int codeErr)
void setDiagnostic(Diagnostic *obj)
void setDRMCriticalErrorMask(uint32_t val)
Diagnostic class for TOF.
Definition Diagnostic.h:32
@ kNCrate
Definition Geo.h:97
static constexpr int NCHANNELS
Definition Geo.h:126
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLuint GLfloat * val
Definition glcorearb.h:1582
GLenum GLfloat param
Definition glcorearb.h:271
GLint GLuint mask
Definition glcorearb.h:291
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()