forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiagnostic.h
More file actions
113 lines (101 loc) · 4.43 KB
/
Diagnostic.h
File metadata and controls
113 lines (101 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file Diagnostic.h
/// \brief Definition of the TOF cluster
#ifndef ALICEO2_TOF_DIAGNOSTIC_H
#define ALICEO2_TOF_DIAGNOSTIC_H
#include <map>
#include <TObject.h>
#include <gsl/gsl>
#include "CommonDataFormat/TFIDInfo.h"
namespace o2
{
namespace tof
{
/// \class Diagnostic
/// \brief Diagnostic class for TOF
///
class Diagnostic
{
public:
Diagnostic() = default;
uint32_t fill(ULong64_t pattern);
uint32_t fill(ULong64_t pattern, uint32_t frequency);
uint32_t getFrequency(ULong64_t pattern) const; // Get frequency
uint32_t getFrequencyROW() const { return getFrequency(0); } // Readout window frequency
uint32_t getFrequencyEmptyCrate(int crate) const { return getFrequency(getEmptyCrateKey(crate)); } // empty crate frequency
uint32_t getFrequencyEmptyTOF() const { return getFrequency(1); } // empty crate frequency
uint32_t fillNoisy(int channel, int frequency = 1) { return fill(getNoisyChannelKey(channel), frequency); }
uint32_t fillROW() { return fill(0); }
uint32_t fillEmptyCrate(int crate, uint32_t frequency = 1) { return fill(getEmptyCrateKey(crate), frequency); }
uint32_t fillEmptyTOF(uint32_t frequency = 1) { return fill(1, frequency); }
static ULong64_t getEmptyCrateKey(int crate);
static ULong64_t getNoisyChannelKey(int channel);
static ULong64_t getDRMKey(int crate) { return 1000000 + crate * 1000; }
static ULong64_t getDRMerrorKey(int crate, int error) { return getDRMKey(crate) + error; }
uint32_t getFrequencyDRM(int crate) const { return getFrequency(getDRMKey(crate)); }
uint32_t getFrequencyDRMerror(int crate, int error) const { return getFrequency(getDRMerrorKey(crate, error)); }
uint32_t fillDRM(int crate, uint32_t frequency) { return fill(getDRMKey(crate), frequency); }
uint32_t fillDRMerror(int crate, int error, uint32_t frequency) { return fill(getDRMerrorKey(crate, error), frequency); }
static ULong64_t getTRMKey(int crate, int trm);
void print(bool longFormat = false) const;
void clear() { mVector.clear(); }
void fill(const Diagnostic& diag); // for calibration
void fill(const gsl::span<const o2::tof::Diagnostic>){}; // for calibration
void merge(const Diagnostic* prev);
void getNoisyMap(Bool_t* output, int noisyThr = 1) const; // set true in output channel array
void getNoisyLevelMap(Char_t* output) const; // set true in output channel array
bool isNoisyChannel(int channel, int thr = 0) const;
unsigned long size() const { return mVector.size(); }
ULong64_t getPattern(int i) const
{
auto iter = mVector.begin();
for (; i-- > 0;) {
iter++;
}
return iter->first;
}
static int getSlot(ULong64_t pattern) { return (pattern & 68719476735) / 4294967296; }
static int getCrate(ULong64_t pattern) { return (pattern & 8796093022207) / 68719476736; }
static int getChannel(ULong64_t pattern)
{
if (getSlot(pattern) == 14) {
return (pattern & 262143);
}
return -1;
}
static int getNoisyLevel(ULong64_t pattern)
{
if (getChannel(pattern)) {
if (pattern & (1 << 20)) {
return 3;
} else if (pattern & (1 << 19)) {
return 2;
} else {
return 1;
}
}
return 0;
}
const std::map<ULong64_t, uint32_t>& getVector() const { return mVector; }
int getTimeStamp() const { return mTimestamp; }
void setTimeStamp(int val) { mTimestamp = val; }
void setTFIDInfo(const o2::dataformats::TFIDInfo& val) { mTFinfo = val; }
const o2::dataformats::TFIDInfo& getTFIDInfo() const { return mTFinfo; }
private:
std::map<ULong64_t, uint32_t> mVector; // diagnostic frequency vector (key/pattern , frequency)
int mTimestamp = 0; //! timestamp in seconds
o2::dataformats::TFIDInfo mTFinfo; // TF id info
ClassDefNV(Diagnostic, 3);
};
} // namespace tof
} // namespace o2
#endif