2323#include " TOFBase/Geo.h"
2424#include " DataFormatsTOF/Diagnostic.h"
2525#include " DataFormatsTOF/TOFFEElightInfo.h"
26+ #include " DataFormatsTOF/CompressedDataFormat.h"
27+
28+ class TH2F ;
2629
2730namespace o2
2831{
@@ -38,10 +41,12 @@ class CalibTOFapi
3841 using CcdbApi = o2::ccdb::CcdbApi;
3942
4043 public:
44+ static o2::tof::Diagnostic doDRMerrCalibFromQCHisto (const TH2F* histo, const char * file_output_name);
45+
4146 void resetDia ();
4247 CalibTOFapi () = default ;
4348 CalibTOFapi (const std::string url);
44- CalibTOFapi (long timestamp, o2::dataformats::CalibLHCphaseTOF* phase, o2::dataformats::CalibTimeSlewingParamTOF* slew, Diagnostic* dia = nullptr ) : mTimeStamp (timestamp), mLHCphase (phase), mSlewParam (slew), mDiaFreq (dia) {}
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 ) {}
4550 ~CalibTOFapi ()
4651 {
4752 if (mLHCphase ) {
@@ -53,6 +58,9 @@ class CalibTOFapi
5358 if (mDiaFreq ) {
5459 // delete mDiaFreq;
5560 }
61+ if (mDiaDRMFreq ) {
62+ // delete mDiaDRMFreq;
63+ }
5664 }
5765
5866 void setTimeStamp (long t)
@@ -69,6 +77,8 @@ class CalibTOFapi
6977 void readTimeSlewingParamFromFile (const char * filename);
7078 void readDiagnosticFrequencies ();
7179 void loadDiagnosticFrequencies ();
80+ void readDiagnosticDRMFrequencies ();
81+ void loadDiagnosticDRMFrequencies ();
7282 void readActiveMap ();
7383 void loadActiveMap (TOFFEElightInfo* fee);
7484 void writeLHCphase (LhcPhase* phase, std::map<std::string, std::string> metadataLHCphase, uint64_t minTimeSTamp, uint64_t maxTimeStamp);
@@ -89,6 +99,8 @@ class CalibTOFapi
8999 void setLhcPhase (LhcPhase* obj) { mLHCphase = obj; }
90100 Diagnostic* getDiagnostic () { return mDiaFreq ; }
91101 void setDiagnostic (Diagnostic* obj) { mDiaFreq = obj; }
102+ Diagnostic* getDiagnosticDRM () { return mDiaDRMFreq ; }
103+ void setDiagnosticDRM (Diagnostic* obj) { mDiaDRMFreq = obj; }
92104
93105 int getNoisyThreshold () const { return mNoisyThreshold ; }
94106 void setNoisyThreshold (int val) { mNoisyThreshold = val; }
@@ -102,12 +114,39 @@ class CalibTOFapi
102114 void processError (int crate, int trm, int mask);
103115 bool isChannelError (int channel) const ;
104116 bool checkTRMPolicy (int mask) const ;
117+ void resetDRMErrors ();
118+ void processErrorDRM (int crate, int mask);
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 ;
128+ enum DRMcodes {
129+ DRM_HEADER_MISSING = o2::tof::diagnostic::DRM_HEADER_MISSING >> DRM_ERRINDEX_SHIFT,
130+ DRM_TRAILER_MISSING = o2::tof::diagnostic::DRM_TRAILER_MISSING >> DRM_ERRINDEX_SHIFT,
131+ DRM_FEEID_MISMATCH = o2::tof::diagnostic::DRM_FEEID_MISMATCH >> DRM_ERRINDEX_SHIFT,
132+ DRM_ORBIT_MISMATCH = o2::tof::diagnostic::DRM_ORBIT_MISMATCH >> DRM_ERRINDEX_SHIFT,
133+ DRM_CRC_MISMATCH = o2::tof::diagnostic::DRM_CRC_MISMATCH >> DRM_ERRINDEX_SHIFT,
134+ DRM_ENAPARTMASK_DIFFER = o2::tof::diagnostic::DRM_ENAPARTMASK_DIFFER >> DRM_ERRINDEX_SHIFT,
135+ DRM_CLOCKSTATUS_WRONG = o2::tof::diagnostic::DRM_CLOCKSTATUS_WRONG >> DRM_ERRINDEX_SHIFT,
136+ DRM_FAULTSLOTMASK_NOTZERO = o2::tof::diagnostic::DRM_FAULTSLOTMASK_NOTZERO >> DRM_ERRINDEX_SHIFT,
137+ DRM_READOUTTIMEOUT_NOTZERO = o2::tof::diagnostic::DRM_READOUTTIMEOUT_NOTZERO >> DRM_ERRINDEX_SHIFT,
138+ DRM_EVENTWORDS_MISMATCH = o2::tof::diagnostic::DRM_EVENTWORDS_MISMATCH >> DRM_ERRINDEX_SHIFT,
139+ DRM_DIAGNOSTIC_SPARE1 = o2::tof::diagnostic::DRM_DIAGNOSTIC_SPARE1 >> DRM_ERRINDEX_SHIFT,
140+ DRM_DECODE_ERROR = o2::tof::diagnostic::DRM_DECODE_ERROR >> DRM_ERRINDEX_SHIFT,
141+ N_DRM_ERRORS = 12
142+ };
105143
106144 private:
107- long mTimeStamp ; // /< timeStamp for queries
108- LhcPhase* mLHCphase = nullptr ; // /< object for LHC phase
109- SlewParam* mSlewParam = nullptr ; // /< object for timeslewing (containing info also for offset and problematic)
110- Diagnostic* mDiaFreq = nullptr ; // /< object for Diagnostic Frequency
145+ long mTimeStamp ; // /< timeStamp for queries
146+ LhcPhase* mLHCphase = nullptr ; // /< object for LHC phase
147+ SlewParam* mSlewParam = nullptr ; // /< object for timeslewing (containing info also for offset and problematic)
148+ Diagnostic* mDiaFreq = nullptr ; // /< object for Diagnostic Frequency
149+ Diagnostic* mDiaDRMFreq = nullptr ; // /< object for Diagnostic Frequency
111150
112151 // info from diagnostic
113152 int mNoisyThreshold = 1 ; // /< threshold to be noisy
@@ -116,13 +155,17 @@ class CalibTOFapi
116155 std::vector<std::pair<int , float >> mNoisy ; // /< probTRMerror
117156 std::vector<std::pair<int , float >> mTRMerrorProb ; // /< probTRMerror
118157 std::vector<int > mTRMmask ; // /< mask error for TRM
158+ float mErrorInDRM [Geo::kNCrate ][N_DRM_ERRORS] = {}; // /< probability of DRM error
159+ uint32_t mDRMCriticalErrorMask = 0 ; // /< bit mask for critical DRM errors (e.g. Orbit Mismatch -> 1 << 7, see DataFormats/Detectors/TOF/include/DataFormatsTOF/CompressedDataFormat.h)
119160
120- bool mIsErrorCh [Geo::NCHANNELS] = {}; // /< channels in error (TRM)
121- std::vector<int > mFillErrChannel ; // /< last error channels filled
122- bool mIsOffCh [Geo::NCHANNELS] = {}; // /< channels in error (TRM)
123- bool mIsNoisy [Geo::NCHANNELS] = {}; // /< noisy channels
161+ bool mIsErrorCh [Geo::NCHANNELS] = {}; // /< channels in error (TRM)
162+ std::vector<int > mFillErrChannel ; // /< last error channels filled
163+ bool mIsOffCh [Geo::NCHANNELS] = {}; // /< channels in error (TRM)
164+ bool mIsNoisy [Geo::NCHANNELS] = {}; // /< noisy channels
165+ bool mIsErrorDRMCh [Geo::NCHANNELS] = {}; // /< channels in error (DRM)
166+ std::vector<int > mFillErrDRMChannel ; // /< last error channels filled
124167
125- ClassDefNV (CalibTOFapi, 1 );
168+ ClassDefNV (CalibTOFapi, 2 );
126169};
127170} // namespace tof
128171} // namespace o2
0 commit comments