Project
Loading...
Searching...
No Matches
Scalers.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 _CTP_SCALERS_H_
17#define _CTP_SCALERS_H_
20#include <map>
21#include <bitset>
22#include <ctime>
23
24namespace o2
25{
26namespace ctp
27{
32 errorCounters() = default;
33 void printStream(std::ostream& stream) const;
34 uint32_t lmB = 0, l0B = 0, l1B = 0, lmA = 0, l0A = 0, l1A = 0; // decreasing counters
35 uint32_t lmBlmA = 0, lmAl0B = 0, l0Bl0A = 0, l0Al1B = 0, l1Bl1A = 0; // between levels countres
36 uint32_t lmBlmAd1 = 0, lmAl0Bd1 = 0, l0Bl0Ad1 = 0, l0Al1Bd1 = 0, l1Bl1Ad1 = 0; // between levels countres - diff =1 - just warning
37 uint32_t MAXPRINT = 3;
38};
40 CTPScalerRaw() = default;
41 uint32_t classIndex;
42 uint32_t lmBefore;
43 uint32_t lmAfter;
44 uint32_t l0Before;
45 uint32_t l0After;
46 uint32_t l1Before;
47 uint32_t l1After;
48 void printStream(std::ostream& stream) const;
50};
53 CTPScalerO2() = default;
54 void createCTPScalerO2FromRaw(const CTPScalerRaw& raw, const std::array<uint32_t, 6>& overfow);
55 uint32_t classIndex;
56 uint64_t lmBefore;
57 uint64_t lmAfter;
58 uint64_t l0Before;
59 uint64_t l0After;
60 uint64_t l1Before;
61 uint64_t l1After;
62 void printStream(std::ostream& stream) const;
63 void printFromZero(std::ostream& stream, CTPScalerO2& scaler0) const;
65};
67 CTPScalerRecordRaw() = default;
69 double_t epochTime;
70 std::vector<CTPScalerRaw> scalers;
71 // std::vector<uint32_t> scalersDets;
72 std::vector<uint32_t> scalersInps;
73 void printStream(std::ostream& stream) const;
75};
77 CTPScalerRecordO2() = default;
79 double_t epochTime;
80 std::vector<CTPScalerO2> scalers;
81 // std::vector<uint64_t> scalersDets;
82 std::vector<uint64_t> scalersInps;
83 void printStream(std::ostream& stream) const;
84 void printFromZero(std::ostream& stream, CTPScalerRecordO2& record0) const;
86};
88{
89 public:
90 //
91 // static constexpr uint32_t NCOUNTERS = 1052;
92 // v1
93 // static constexpr uint32_t NCOUNTERS = 1070;
94 // v2 - orbitid added at the end
95 static constexpr uint32_t NCOUNTERSv2 = 1071;
96 static constexpr uint32_t NCOUNTERS = 1085;
97 static std::vector<std::string> scalerNames;
98 CTPRunScalers() = default;
99 void printStream(std::ostream& stream) const;
100 void printO2(std::ostream& stream) const;
101 void printFromZero(std::ostream& stream) const;
102 void printClasses(std::ostream& stream) const;
103 std::vector<uint32_t> getClassIndexes() const;
104 uint32_t getRunNumber() { return mRunNumber; };
105 int getScalerIndexForClass(uint32_t cls) const;
106 std::vector<CTPScalerRecordO2>& getScalerRecordO2() { return mScalerRecordO2; };
107 std::vector<CTPScalerRecordRaw>& getScalerRecordRaw() { return mScalerRecordRaw; };
108 void setEpochTime(std::time_t tt, int index) { mScalerRecordRaw[index].epochTime = tt; };
109 int readScalers(const std::string& rawscalers);
110 int convertRawToO2();
111 int checkConsistency(const CTPScalerO2& scal0, const CTPScalerO2& scal1, errorCounters& eCnts) const;
112 int checkConsistency(const CTPScalerRecordO2& rec0, const CTPScalerRecordO2& rec1, errorCounters& eCnts) const;
113 void setClassMask(std::bitset<CTP_NCLASSES> classMask) { mClassMask = classMask; };
115 void setRunNumber(uint32_t rnumber) { mRunNumber = rnumber; };
116 void addScalerRacordRaw(CTPScalerRecordRaw& scalerrecordraw) { mScalerRecordRaw.push_back(scalerrecordraw); };
117 int printRates();
118 int printIntegrals();
119 int printInputRateAndIntegral(int inp);
120 int printClassBRateAndIntegralII(int icls);
121 int printClassBRateAndIntegral(int iclsinscalers);
122 //
123 int addOrbitOffset(uint32_t offset);
124 //
125 void printLMBRateVsT() const; // prints LMB interaction rate vs time for debugging
126 // returns the pair of global (levelled) interaction rate, as well as interpolated
127 // rate in Hz at a certain orbit number within the run
128 std::pair<double, double> getRate(uint32_t orbit, int classindex, int type, bool qc = 0) const;
129
131 std::pair<double, double> getRateGivenT(double timestamp, int classindex, int type, bool qc = 0) const;
132
134 std::array<uint64_t, 7> getIntegralForClass(int i) const
135 {
136 return {
137 mScalerRecordO2[0].scalers[i].classIndex,
138 mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].lmBefore - mScalerRecordO2[0].scalers[i].lmBefore,
139 mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].lmAfter - mScalerRecordO2[0].scalers[i].lmAfter,
140 mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l0Before - mScalerRecordO2[0].scalers[i].l0Before,
141 mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l0After - mScalerRecordO2[0].scalers[i].l0After,
142 mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l1Before - mScalerRecordO2[0].scalers[i].l1Before,
143 mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l1After - mScalerRecordO2[0].scalers[i].l1After,
144 };
145 }
147 uint64_t getLumiNoPuCorr(int classindex, int type) const;
149 std::vector<std::pair<double_t, double_t>> getRatesForIndex(int classindex, int type) const;
151 std::pair<unsigned long, unsigned long> getTimeLimit() const
152 {
153 return std::make_pair((unsigned long)mScalerRecordO2[0].epochTime * 1000, (unsigned long)mScalerRecordO2[mScalerRecordO2.size() - 1].epochTime * 1000);
154 }
156 std::pair<unsigned long, unsigned long> getTimeLimitFromRaw() const
157 {
158 return std::make_pair((unsigned long)mScalerRecordRaw[0].epochTime * 1000, (unsigned long)mScalerRecordRaw[mScalerRecordRaw.size() - 1].epochTime * 1000);
159 }
161 std::pair<unsigned long, unsigned long> getOrbitLimit() const
162 {
163 return std::make_pair((unsigned long)mScalerRecordO2[0].intRecord.orbit, (unsigned long)mScalerRecordO2[mScalerRecordO2.size() - 1].intRecord.orbit);
164 }
166 std::pair<unsigned long, unsigned long> getOrbitLimitFromRaw() const
167 {
168 return std::make_pair((unsigned long)mScalerRecordRaw[0].intRecord.orbit, (unsigned long)mScalerRecordRaw[mScalerRecordRaw.size() - 1].intRecord.orbit);
169 }
170
171 private:
172 // map from class index to overflow
173 // overflow counts how many time class scalerers overflowed
174 typedef std::map<uint32_t, std::array<uint32_t, 6>> overflows_t;
175 int mVersion = 0;
176 uint32_t mRunNumber = 0;
177 // using class mask for all class index related stuff
178 std::bitset<CTP_NCLASSES> mClassMask;
179 o2::detectors::DetID::mask_t mDetectorMask;
180 std::vector<CTPScalerRecordRaw> mScalerRecordRaw;
181 std::vector<CTPScalerRecordO2> mScalerRecordO2;
182 int processScalerLine(const std::string& line, int& level, uint32_t& nclasses);
183 int copyRawToO2ScalerRecord(const CTPScalerRecordRaw& rawrec, CTPScalerRecordO2& o2rec, overflows_t& classesoverflows, std::array<uint32_t, 48>& overflows);
184 int updateOverflows(const CTPScalerRecordRaw& rec0, const CTPScalerRecordRaw& rec1, overflows_t& classesoverflows) const;
185 int updateOverflows(const CTPScalerRaw& scal0, const CTPScalerRaw& scal1, std::array<uint32_t, 6>& overflow) const;
186 int updateOverflowsInps(const CTPScalerRecordRaw& rec0, const CTPScalerRecordRaw& rec1, std::array<uint32_t, 48>& overflow) const;
187 ClassDefNV(CTPRunScalers, 2);
188};
189} // namespace ctp
190} // namespace o2
191#endif //_CTP_SCALERS_H
definition of CTPDigit, CTPInputDigit
uint64_t orbit
Definition RawEventData.h:6
int32_t i
static constexpr uint32_t NCOUNTERS
Definition Scalers.h:96
int printClassBRateAndIntegral(int iclsinscalers)
Definition Scalers.cxx:626
std::vector< uint32_t > getClassIndexes() const
Definition Scalers.cxx:144
int printClassBRateAndIntegralII(int icls)
Definition Scalers.cxx:606
uint64_t getLumiNoPuCorr(int classindex, int type) const
retrieves integral - same interface as getRate, no pileup correction
Definition Scalers.cxx:661
int readScalers(const std::string &rawscalers)
Definition Scalers.cxx:172
uint32_t getRunNumber()
Definition Scalers.h:104
void setEpochTime(std::time_t tt, int index)
Definition Scalers.h:108
std::pair< unsigned long, unsigned long > getOrbitLimitFromRaw() const
retrieves orbit boundaries of this scaler object from Raw: should be same as from O2 and can be used ...
Definition Scalers.h:166
std::pair< unsigned long, unsigned long > getTimeLimitFromRaw() const
retrieves time boundaries of this scaler object from Raw: should be same as from O2 and can be used w...
Definition Scalers.h:156
void printClasses(std::ostream &stream) const
Definition Scalers.cxx:134
static constexpr uint32_t NCOUNTERSv2
Definition Scalers.h:95
void printLMBRateVsT() const
Definition Scalers.cxx:642
void setDetectorMask(o2::detectors::DetID::mask_t mask)
Definition Scalers.h:114
int printInputRateAndIntegral(int inp)
Definition Scalers.cxx:591
std::array< uint64_t, 7 > getIntegralForClass(int i) const
retrieves integral for class
Definition Scalers.h:134
static std::vector< std::string > scalerNames
Definition Scalers.h:97
std::pair< unsigned long, unsigned long > getTimeLimit() const
retrieves time boundaries of this scaler object from O2 scalers
Definition Scalers.h:151
std::pair< double, double > getRate(uint32_t orbit, int classindex, int type, bool qc=0) const
Definition Scalers.cxx:735
std::pair< double, double > getRateGivenT(double timestamp, int classindex, int type, bool qc=0) const
same with absolute timestamp (not orbit) as argument
Definition Scalers.cxx:809
void printO2(std::ostream &stream) const
Definition Scalers.cxx:117
int checkConsistency(const CTPScalerO2 &scal0, const CTPScalerO2 &scal1, errorCounters &eCnts) const
Definition Scalers.cxx:354
std::pair< unsigned long, unsigned long > getOrbitLimit() const
retrieves orbit boundaries of this scaler object from O2
Definition Scalers.h:161
void printStream(std::ostream &stream) const
Definition Scalers.cxx:104
void setRunNumber(uint32_t rnumber)
Definition Scalers.h:115
int addOrbitOffset(uint32_t offset)
Definition Scalers.cxx:885
int getScalerIndexForClass(uint32_t cls) const
Definition Scalers.cxx:155
std::vector< CTPScalerRecordRaw > & getScalerRecordRaw()
Definition Scalers.h:107
std::vector< CTPScalerRecordO2 > & getScalerRecordO2()
Definition Scalers.h:106
std::vector< std::pair< double_t, double_t > > getRatesForIndex(int classindex, int type) const
retrieves vector of counters - same interface as getRate, needed for
Definition Scalers.cxx:693
void addScalerRacordRaw(CTPScalerRecordRaw &scalerrecordraw)
Definition Scalers.h:116
void setClassMask(std::bitset< CTP_NCLASSES > classMask)
Definition Scalers.h:113
void printFromZero(std::ostream &stream) const
Definition Scalers.cxx:125
GLuint index
Definition glcorearb.h:781
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLintptr offset
Definition glcorearb.h:660
GLuint GLuint stream
Definition glcorearb.h:1806
GLint GLuint mask
Definition glcorearb.h:291
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Scalers produced from raw scalers corrected for overflow.
Definition Scalers.h:52
ClassDefNV(CTPScalerO2, 1)
uint64_t l0Before
Definition Scalers.h:58
void printFromZero(std::ostream &stream, CTPScalerO2 &scaler0) const
Definition Scalers.cxx:58
uint64_t lmBefore
Definition Scalers.h:56
uint64_t l1Before
Definition Scalers.h:60
void createCTPScalerO2FromRaw(const CTPScalerRaw &raw, const std::array< uint32_t, 6 > &overfow)
Definition Scalers.cxx:40
void printStream(std::ostream &stream) const
Definition Scalers.cxx:51
uint32_t classIndex
Definition Scalers.h:55
ClassDefNV(CTPScalerRaw, 1)
uint32_t classIndex
Definition Scalers.h:41
void printStream(std::ostream &stream) const
Definition Scalers.cxx:32
o2::InteractionRecord intRecord
Definition Scalers.h:78
ClassDefNV(CTPScalerRecordO2, 4)
std::vector< uint64_t > scalersInps
Definition Scalers.h:82
std::vector< CTPScalerO2 > scalers
Definition Scalers.h:80
void printFromZero(std::ostream &stream, CTPScalerRecordO2 &record0) const
Definition Scalers.cxx:91
void printStream(std::ostream &stream) const
Definition Scalers.cxx:78
std::vector< CTPScalerRaw > scalers
Definition Scalers.h:70
void printStream(std::ostream &stream) const
Definition Scalers.cxx:65
ClassDefNV(CTPScalerRecordRaw, 4)
o2::InteractionRecord intRecord
Definition Scalers.h:68
std::vector< uint32_t > scalersInps
Definition Scalers.h:72
void printStream(std::ostream &stream) const
Definition Scalers.cxx:22