Project
Loading...
Searching...
No Matches
Scalers.cxx
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
14
16#include <iostream>
17#include <iomanip>
19#include <fairlogger/Logger.h>
20
21using namespace o2::ctp;
22void errorCounters::printStream(std::ostream& stream) const
23{
24 // stream << "Counter warnings diff 1 lmBlmA:" << lmBlmAd1 << " lmAl0B:" << lmAl0Bd1 << " l0Bl0A:" << l0Bl0Ad1 << " l0Al1B: " << l0Al1Bd1 << " l1Bl1A:" << l1Bl1Ad1;
25 // stream << std::endl;
26 if (lmB + l0B + l1B + lmA + l0A + l1A + lmBlmA + lmAl0B + l0Bl0A + l0Al1B + l1Bl1A) {
27 stream << "Counter errorrs: lmB:" << lmB << " l0B:" << l0B << " l1B:" << l1B << " lmA:" << lmA << " l0A:" << l0A << " l1A:" << l1A;
28 stream << " lmBlmA:" << lmBlmA << " lmAl0B:" << lmAl0B << " l0Bl0A:" << l0Bl0A << " l0Al1B: " << l0Al1B << " l1Bl1A:" << l1Bl1A;
29 stream << std::endl;
30 }
31}
32void CTPScalerRaw::printStream(std::ostream& stream) const
33{
34 stream << "Class:" << std::setw(2) << classIndex << " RAW";
35 stream << " LMB:" << std::setw(10) << lmBefore << " LMA:" << std::setw(10) << lmAfter;
36 stream << " L0B:" << std::setw(10) << l0Before << " L0A:" << std::setw(10) << l0After;
37 stream << " L1B:" << std::setw(10) << l1Before << " L1A:" << std::setw(10) << l1After << std::endl;
38}
39//
40void CTPScalerO2::createCTPScalerO2FromRaw(const CTPScalerRaw& raw, const std::array<uint32_t, 6>& overflow)
41{
43 lmBefore = (uint64_t)(raw.lmBefore) + 0xffffffffull * (uint64_t)(overflow[0]);
44 lmAfter = (uint64_t)(raw.lmAfter) + 0xffffffffull * (uint64_t)(overflow[1]);
45 l0Before = (uint64_t)(raw.l0Before) + 0xffffffffull * (uint64_t)(overflow[2]);
46 l0After = (uint64_t)(raw.l0After) + 0xffffffffull * (uint64_t)(overflow[3]);
47 l1Before = (uint64_t)(raw.l1Before) + 0xffffffffull * (uint64_t)(overflow[4]);
48 l1After = (uint64_t)(raw.l1After) + 0xffffffffull * (uint64_t)(overflow[5]);
49 //std::cout << "lmb overflow:" << overflow[0] << " lmb:" << lmBefore << " raw:" << raw.lmBefore << std::endl;
50}
51void CTPScalerO2::printStream(std::ostream& stream) const
52{
53 stream << "Class:" << std::setw(2) << classIndex << " O2";
54 stream << " LMB:" << std::setw(10) << lmBefore << " LMA:" << std::setw(10) << lmAfter;
55 stream << " L0B:" << std::setw(10) << l0Before << " L0A:" << std::setw(10) << l0After;
56 stream << " L1B:" << std::setw(10) << l1Before << " L1A:" << std::setw(10) << l1After << std::endl;
57}
58void CTPScalerO2::printFromZero(std::ostream& stream, CTPScalerO2& scaler0) const
59{
60 stream << "Class:" << std::setw(2) << classIndex << " O2";
61 stream << " LMB:" << std::setw(10) << lmBefore - scaler0.lmBefore << " LMA:" << std::setw(10) << lmAfter - scaler0.lmAfter;
62 stream << " LOB:" << std::setw(10) << l0Before - scaler0.l0Before << " L0A:" << std::setw(10) << l0After - scaler0.l0After;
63 stream << " L1B:" << std::setw(10) << l1Before - scaler0.l1Before << " L1A:" << std::setw(10) << l1After - scaler0.l1After << std::endl;
64}
65void CTPScalerRecordRaw::printStream(std::ostream& stream) const
66{
67 stream << "Orbit:" << intRecord.orbit << " BC:" << intRecord.bc;
68 stream << " miliSeconds:" << epochTime << std::endl;
69 for (auto const& cnts : scalers) {
70 cnts.printStream(stream);
71 }
72 std::cout << "Inputs:" << scalersInps.size() << std::endl;
73 for (auto const& dets : scalersInps) {
74 stream << dets << " ";
75 }
76 stream << std::endl;
77}
78void CTPScalerRecordO2::printStream(std::ostream& stream) const
79{
80 stream << "Orbit:" << intRecord.orbit << " BC:" << intRecord.bc;
81 stream << " miliSeconds:" << epochTime << std::endl;
82 for (auto const& cnts : scalers) {
83 cnts.printStream(stream);
84 }
85 std::cout << "Inputs:" << scalersInps.size() << std::endl;
86 for (auto const& dets : scalersInps) {
87 stream << dets << " ";
88 }
89 stream << std::endl;
90}
92{
93 stream << "printFromZero Orbit:" << intRecord.orbit - record0.intRecord.orbit << " BC:" << intRecord.bc;
94 stream << " miliSeconds:" << std::setprecision(20) << epochTime - record0.epochTime << std::endl;
95 // this-record0
96 for (uint32_t i = 0; i < scalers.size(); i++) {
97 scalers[i].printFromZero(stream, record0.scalers[i]);
98 }
99 stream << std::endl;
100}
101//
102// CTPRunScalers
103//
104void CTPRunScalers::printStream(std::ostream& stream) const
105{
106 stream << "CTP Scalers (version:" << mVersion << ") Run:" << mRunNumber << std::endl;
108 stream << "Detector mask:" << mDetectorMask << std::endl;
109 for (auto const& rec : mScalerRecordRaw) {
110 rec.printStream(stream);
111 }
112 stream << "O2 Counters:" << std::endl;
113 for (auto const& rec : mScalerRecordO2) {
114 rec.printStream(stream);
115 }
116}
117void CTPRunScalers::printO2(std::ostream& stream) const
118{
119 stream << "CTP Scalers (version:" << mVersion << ") Run:" << mRunNumber << std::endl;
120 stream << "O2 Counters:" << std::endl;
121 for (auto const& rec : mScalerRecordO2) {
122 rec.printStream(stream);
123 }
124}
125void CTPRunScalers::printFromZero(std::ostream& stream) const
126{
127 stream << "CTP Scalers (version:" << mVersion << ") Run:" << mRunNumber << std::endl;
128 stream << "O2 Counters:" << std::endl;
129 CTPScalerRecordO2 record0 = mScalerRecordO2[0];
130 for (auto const& rec : mScalerRecordO2) {
131 rec.printFromZero(stream, record0);
132 }
133}
134void CTPRunScalers::printClasses(std::ostream& stream) const
135{
136 stream << "CTP classes:";
137 for (uint32_t i = 0; i < mClassMask.size(); i++) {
138 if (mClassMask[i]) {
139 stream << " " << i;
140 }
141 }
142 stream << std::endl;
143}
144std::vector<uint32_t> CTPRunScalers::getClassIndexes() const
145{
146 std::vector<uint32_t> indexes;
147 for (uint32_t i = 0; i < CTP_NCLASSES; i++) {
148 if (mClassMask[i]) {
149 indexes.push_back(i);
150 }
151 }
152 return indexes;
153}
154// cls counted from 0
156{
157 if (cls >= 64) {
158 LOG(error) << "Class index out of range:" << cls;
159 return 255;
160 }
161 std::vector<uint32_t> clslist = getClassIndexes();
162 int i = 0;
163 for (auto const& clsl : clslist) {
164 if (cls == clsl) {
165 return i;
166 }
167 i++;
168 }
169 LOG(error) << " Class not found:" << cls;
170 return 255;
171}
172int CTPRunScalers::readScalers(const std::string& rawscalers)
173{
174 LOG(info) << "Loading CTP scalers.";
175 std::istringstream iss(rawscalers);
176 int ret = 0;
177 int level = 0;
178 std::string line;
179 uint32_t nclasses = 0;
180 int nlines = 0;
181 while (std::getline(iss, line)) {
183 if ((ret = processScalerLine(line, level, nclasses)) != 0) {
184 return ret;
185 }
186 nlines++;
187 }
188 if (nlines < 4) {
189 LOG(error) << "Input string seems too small:\n"
190 << rawscalers;
191 return 6;
192 }
193 if (nclasses != 0) {
194 LOG(error) << "Wrong number of classes in final record";
195 return 6;
196 }
197 return 0;
198}
199int CTPRunScalers::processScalerLine(const std::string& line, int& level, uint32_t& nclasses)
200{
201 //std::cout << "Processing line" << std::endl;
202 if (line.size() == 0) {
203 return 0;
204 }
205 if (line.at(0) == '#') {
206 return 0;
207 }
208 std::vector<std::string> tokens = o2::utils::Str::tokenize(line, ' ');
209 size_t ntokens = tokens.size();
210 if (ntokens == 0) {
211 return 0;
212 }
213 //std::cout << line << " level in::" << level << std::endl;
214 // Version
215 if (level == 0) {
216 if (ntokens != 1) {
217 LOG(error) << "Expected version in the first line";
218 return 1;
219 } else {
220 mVersion = std::stoi(tokens[0]);
221 level = 1;
222 return 0;
223 }
224 }
225 // Run Number N Classes [class indexes]
226 if (level == 1) {
227 if (ntokens < 3) {
228 LOG(error) << "Wrong syntax of second line in CTP scalers";
229 return 2;
230 } else {
231 mRunNumber = std::stol(tokens[0]);
232 uint32_t numofclasses = std::stoi(tokens[1]);
233 if ((numofclasses + 2) != ntokens) {
234 LOG(error) << "Wrong syntax of second line in CTP scalers";
235 return 3;
236 }
237 mClassMask.reset();
238 for (uint32_t i = 0; i < numofclasses; i++) {
239 int index = std::stoi(tokens[i + 2]);
240 mClassMask[index] = 1;
241 }
242 level = 2;
243 nclasses = 0;
244 return 0;
245 }
246 }
247 // Time stamp: orbit bcid linuxtime
248 if (level == 2) {
249 if (ntokens != 4) {
250 LOG(error) << "Wrong syntax of time stamp line in CTP scalers";
251 return 4;
252 } else {
254 rec.intRecord.orbit = std::stol(tokens[0]);
255 rec.intRecord.bc = std::stol(tokens[1]);
256 // rec.seconds = std::stol(tokens[2]);
257 rec.epochTime = std::stoll(tokens[2]);
258 // rec.microSeconds = std::stol(tokens[3]);
259 mScalerRecordRaw.push_back(rec);
260 level = 3;
261 return 0;
262 }
263 }
264 if (level == 3) {
265 if (ntokens != 6) {
266 LOG(error) << "Wrong syntax of counters line in CTP scalers";
267 return 5;
268 } else {
269 //std::cout << "nclasses:" << nclasses << std::endl;
270 CTPScalerRaw scaler;
271 scaler.classIndex = getClassIndexes()[nclasses];
272 scaler.lmBefore = std::stol(tokens[0]);
273 scaler.lmAfter = std::stol(tokens[1]);
274 scaler.l0Before = std::stol(tokens[2]);
275 scaler.l0After = std::stol(tokens[3]);
276 scaler.l1Before = std::stol(tokens[4]);
277 scaler.l1After = std::stol(tokens[5]);
278 (mScalerRecordRaw.back()).scalers.push_back(scaler);
279 nclasses++;
280 if (nclasses >= mClassMask.count()) {
281 level = 2;
282 nclasses = 0;
283 }
284 return 0;
285 }
286 }
287 return 0;
288}
292{
293 //struct classScalersOverflows {uint32_t overflows[6];};
294 overflows_t overflows;
295 for (uint32_t i = 0; i < mClassMask.size(); i++) {
296 if (mClassMask[i]) {
297 overflows[i] = {0, 0, 0, 0, 0, 0};
298 }
299 }
300 // Input overflows
301 std::array<uint32_t, 48> overflowsInputs = {48 * 0};
302 errorCounters eCnts;
303 // 1st o2 rec is just copy
304 CTPScalerRecordO2 o2rec;
305 copyRawToO2ScalerRecord(mScalerRecordRaw[0], o2rec, overflows, overflowsInputs);
306 mScalerRecordO2.push_back(o2rec);
307 int j = 1;
308 for (uint32_t i = 1; i < mScalerRecordRaw.size(); i++) {
309 //update overflows
310 int ret = updateOverflows(mScalerRecordRaw[i - 1], mScalerRecordRaw[i], overflows);
311 // for(int k = 0; k < mClassMask.size(); k++) {
312 // if(mClassMask[k]) {
313 // LOG(info) << i << " " << k << " " << overflows[k][0] << " " << overflows[k][1] << " " << overflows[k][2] << " " << overflows[k][3] << " " << overflows[k][4] << " " << overflows[k][5];
314 // }
315 // }
316 //
317 if (ret == 0) {
318 CTPScalerRecordO2 o2rec;
319 ret = updateOverflowsInps(mScalerRecordRaw[i - 1], mScalerRecordRaw[i], overflowsInputs);
320 copyRawToO2ScalerRecord(mScalerRecordRaw[i], o2rec, overflows, overflowsInputs);
321 mScalerRecordO2.push_back(o2rec);
322 // Check consistency
323 checkConsistency(mScalerRecordO2[j - 1], mScalerRecordO2[j], eCnts);
324 j++;
325 }
326 }
327 eCnts.printStream(std::cout);
328 return 0;
329}
330int CTPRunScalers::copyRawToO2ScalerRecord(const CTPScalerRecordRaw& rawrec, CTPScalerRecordO2& o2rec, overflows_t& classesoverflows, std::array<uint32_t, 48>& overflows)
331{
332 if (rawrec.scalers.size() != (mClassMask.count())) {
333 LOG(error) << "Inconsistent scaler record size:" << rawrec.scalers.size() << " Expected:" << mClassMask.count();
334 return 1;
335 }
336 o2rec.scalers.clear();
337 o2rec.intRecord = rawrec.intRecord;
338 // o2rec.seconds = rawrec.seconds;
339 // o2rec.microSeconds = rawrec.microSeconds;
340 o2rec.epochTime = rawrec.epochTime;
341 for (uint32_t i = 0; i < rawrec.scalers.size(); i++) {
342 CTPScalerRaw rawscal = rawrec.scalers[i];
343 CTPScalerO2 o2scal;
344 int k = (getClassIndexes())[i];
345 o2scal.createCTPScalerO2FromRaw(rawscal, classesoverflows[k]);
346 o2rec.scalers.push_back(o2scal);
347 }
348 for (uint32_t i = 0; i < rawrec.scalersInps.size(); i++) {
349 uint64_t inpo2 = (uint64_t)(rawrec.scalersInps[i]) + 0xffffffffull * (uint64_t)(overflows[i]);
350 o2rec.scalersInps.push_back(inpo2);
351 }
352 return 0;
353}
354int CTPRunScalers::checkConsistency(const CTPScalerO2& scal0, const CTPScalerO2& scal1, errorCounters& eCnts) const
355{
356 int ret = 0;
357 // Scaler should never decrease
358 if (scal0.lmBefore > scal1.lmBefore) {
359 eCnts.lmB++;
360 if (eCnts.lmB < eCnts.MAXPRINT) {
361 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmBefore 0:" << scal0.lmBefore << " lmBefore :" << scal1.lmBefore;
362 }
363 ret++;
364 }
365 if (scal0.l0Before > scal1.l0Before) {
366 eCnts.l0B++;
367 if (eCnts.l0B < eCnts.MAXPRINT) {
368 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmBefore 0:" << scal0.l0Before << " lmBefore :" << scal1.l0Before;
369 }
370 ret++;
371 }
372 if (scal0.l1Before > scal1.l1Before) {
373 eCnts.l1B++;
374 if (eCnts.l1B < eCnts.MAXPRINT) {
375 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmBefore 0:" << scal0.l1Before << " lmBefore :" << scal1.l1Before;
376 }
377 ret++;
378 }
379 if (scal0.lmAfter > scal1.lmAfter) {
380 eCnts.lmA++;
381 if (eCnts.lmA < eCnts.MAXPRINT) {
382 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmAfter 0:" << scal0.lmAfter << " lmAfter :" << scal1.lmAfter;
383 }
384 ret++;
385 }
386 if (scal0.l0After > scal1.l0After) {
387 eCnts.l0A++;
388 if (eCnts.l0A < eCnts.MAXPRINT) {
389 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmAfter 0:" << scal0.l0After << " lmAfter :" << scal1.l0After;
390 }
391 ret++;
392 }
393 if (scal0.l1After > scal1.l1After) {
394 eCnts.l1A++;
395 if (eCnts.l1A < eCnts.MAXPRINT) {
396 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmAfter 0:" << scal0.l1After << " lmAfter :" << scal1.l1After;
397 }
398 ret++;
399 }
400 //
401 // LMB >= LMA >= L0B >= L0A >= L1B >= L1A: 5 relations
402 // broken for classes started at L0
403 //
404 int64_t difThres = 6;
405 int64_t dif = (scal1.lmAfter - scal0.lmAfter) - (scal1.lmBefore - scal0.lmBefore);
406 if (dif <= difThres) {
407 eCnts.lmBlmAd1++;
408 } else if (dif > difThres) {
409 eCnts.lmBlmA++;
410 if (eCnts.lmBlmA < eCnts.MAXPRINT) {
411 LOG(error) << "LMA > LMB error:" << dif;
412 }
413 ret++;
414 }
415 dif = (scal1.l0After - scal0.l0After) - (scal1.l0Before - scal0.l0Before);
416 if (dif <= difThres) {
417 eCnts.l0Bl0Ad1++;
418 } else if (dif > difThres) {
419 eCnts.l0Bl0A++;
420 if (eCnts.l0Bl0A < eCnts.MAXPRINT) {
421 LOG(error) << "L0A > L0B error:" << dif;
422 }
423 ret++;
424 }
425 dif = (scal1.l0After - scal0.l0After) - (scal1.l0Before - scal0.l0Before);
426 if (dif <= difThres) {
427 eCnts.l1Bl1Ad1++;
428 } else if (dif > difThres) {
429 eCnts.l1Bl1A++;
430 if (eCnts.l1Bl1A < eCnts.MAXPRINT) {
431 LOG(error) << "L1A > L1B error:" << dif;
432 }
433 ret++;
434 }
435 if ((scal1.l0Before - scal0.l0Before) > (scal1.lmAfter - scal0.lmAfter)) {
436 // LOG(warning) << "L0B > LMA ok if L0 class.";
437 // ret++;
438 }
439 dif = (scal1.l1Before - scal0.l1Before) - (scal1.l0After - scal0.l0After);
440 // LOG(info) << "L1B L0A " << dif << " " << scal1.l1Before << " " << scal1.l0After << " " << scal0.l1Before << " " << scal0.l0After;
441 if (dif <= difThres) {
442 eCnts.l0Al1Bd1++;
443 } else if (dif > difThres) {
444 eCnts.l0Al1B++;
445 if (eCnts.l0Al1B < eCnts.MAXPRINT) {
446 // LOG(error) << "L1B > L0A Before error:" << dif << " " << scal1.l1Before << " " << scal1.l0After << " " << scal0.l1Before << " " << scal0.l0After;
447 LOG(warning) << "L1B > L0A Before error:" << dif;
448 }
449 ret++;
450 }
451 //
452 if (ret < 0) {
453 scal0.printStream(std::cout);
454 scal1.printStream(std::cout);
455 }
456 return ret;
457}
458int CTPRunScalers::updateOverflows(const CTPScalerRecordRaw& rec0, const CTPScalerRecordRaw& rec1, overflows_t& classesoverflows) const
459{
460 if (rec1.scalers.size() != mClassMask.count()) {
461 LOG(error) << "Inconsistent scaler record size:" << rec1.scalers.size() << " Expected:" << mClassMask.count();
462 return 1;
463 }
464 if (rec0.intRecord.orbit > rec1.intRecord.orbit) {
465 LOG(warning) << "rec0 orbit:" << rec0.intRecord.orbit << "> rec1 orbit:" << rec1.intRecord.orbit << " skipping this record";
466 return 1;
467 }
468 for (uint32_t i = 0; i < rec0.scalers.size(); i++) {
469 int k = (getClassIndexes())[i];
470 updateOverflows(rec0.scalers[i], rec1.scalers[i], classesoverflows[k]);
471 }
472 return 0;
473}
475{
476 int ret = 0;
477 for (uint32_t i = 0; i < rec0.scalers.size(); i++) {
478 ret += checkConsistency(rec0.scalers[i], rec1.scalers[i], eCnts);
479 }
480 return ret;
481}
482int CTPRunScalers::updateOverflows(const CTPScalerRaw& scal0, const CTPScalerRaw& scal1, std::array<uint32_t, 6>& overflow) const
483{
484 if (scal0.lmBefore > scal1.lmBefore) {
485 overflow[0] += 1;
486 }
487 if (scal0.lmAfter > scal1.lmAfter) {
488 overflow[1] += 1;
489 }
490 if (scal0.l0Before > scal1.l0Before) {
491 overflow[2] += 1;
492 }
493 if (scal0.l0After > scal1.l0After) {
494 overflow[3] += 1;
495 }
496 if (scal0.l1Before > scal1.l1Before) {
497 overflow[4] += 1;
498 }
499 if (scal0.l1After > scal1.l1After) {
500 overflow[5] += 1;
501 }
502 //std::cout << "lmB0:" << scal0.lmBefore << " lmB1:" << scal1.lmBefore << " over:" << overflow[0] << std::endl;
503 //for(int i = 0; i < 6; i++)std::cout << overflow[i] << " ";
504 //std::cout << std::endl;
505 return 0;
506}
507//
508int CTPRunScalers::updateOverflowsInps(const CTPScalerRecordRaw& rec0, const CTPScalerRecordRaw& rec1, std::array<uint32_t, 48>& overflow) const
509{
510 static int iPrint = 0;
511 uint32_t NINPS = 48;
512 if (rec0.scalersInps.size() < NINPS) {
513 if (iPrint < 1) {
514 LOG(warning) << "Input scalers not available. Size:" << rec0.scalersInps.size();
515 iPrint++;
516 }
517 return 1;
518 }
519 if (rec1.scalersInps.size() < NINPS) {
520 if (iPrint < 1) {
521 LOG(warning) << "Input scalers not available. Size:" << rec0.scalersInps.size();
522 iPrint++;
523 }
524 return 2;
525 }
526 for (uint32_t i = 0; i < NINPS; i++) {
527 if (rec0.scalersInps[i] > rec1.scalersInps[i]) {
528 overflow[i] += 1;
529 }
530 }
531 return 0;
532}
533//
535{
536 if (mScalerRecordO2.size() == 0) {
537 LOG(info) << "ScalerRecord is empty, doing nothing";
538 return 0;
539 }
540 LOG(info) << "Scaler rates for run:" << mRunNumber;
541 CTPScalerRecordO2* scalrec0 = &mScalerRecordO2[0];
542 uint32_t orbit0 = scalrec0->intRecord.orbit;
543 for (uint32_t i = 1; i < mScalerRecordO2.size(); i++) {
544 CTPScalerRecordO2* scalrec1 = &mScalerRecordO2[i];
545 double_t tt = (double_t)(scalrec1->intRecord.orbit - scalrec0->intRecord.orbit);
546 double_t tinrun = (double_t)(scalrec1->intRecord.orbit - orbit0);
547 tt = tt * 88e-6;
548 tinrun = tinrun * 88e-6;
549 std::cout << "==> Time wrt to SOR [s]:" << tinrun << " time intervale[s]:" << tt << std::endl;
550 for (uint32_t j = 0; j < scalrec1->scalers.size(); j++) {
551 CTPScalerO2* s0 = &(scalrec0->scalers[j]);
552 CTPScalerO2* s1 = &(scalrec1->scalers[j]);
553 double_t rMB = (s1->lmBefore - s0->lmBefore) / tt;
554 double_t rMA = (s1->lmAfter - s0->lmAfter) / tt;
555 double_t r0B = (s1->l0Before - s0->l0Before) / tt;
556 double_t r0A = (s1->l0After - s0->l0After) / tt;
557 double_t r1B = (s1->l1Before - s0->l1Before) / tt;
558 double_t r1A = (s1->l1After - s0->l1After) / tt;
559 std::cout << "Class:" << s0->classIndex << ": ";
560 std::cout << rMB << " " << rMA << " ";
561 std::cout << r0B << " " << r0A << " ";
562 std::cout << r1B << " " << r1A;
563 std::cout << std::endl;
564 }
565 scalrec0 = scalrec1;
566 }
567 return 0;
568}
570{
571 if (mScalerRecordO2.size() == 0) {
572 LOG(info) << "ScalerRecord is empty, doing nothing";
573 return 0;
574 }
575 double_t time0 = mScalerRecordO2[0].epochTime;
576 double_t timeL = mScalerRecordO2[mScalerRecordO2.size() - 1].epochTime;
577 LOG(info) << "Scaler Integrals for run:" << mRunNumber << " duration:" << timeL - time0;
578
579 for (uint32_t i = 0; i < mScalerRecordO2[0].scalers.size(); i++) {
580 std::cout << i << " LMB " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].lmBefore - mScalerRecordO2[0].scalers[i].lmBefore << std::endl;
581 std::cout << i << " LMA " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].lmAfter - mScalerRecordO2[0].scalers[i].lmAfter << std::endl;
582 std::cout << i << " L0B " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l0Before - mScalerRecordO2[0].scalers[i].l0Before << std::endl;
583 std::cout << i << " L0A " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l0After - mScalerRecordO2[0].scalers[i].l0After << std::endl;
584 std::cout << i << " L1B " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l1Before - mScalerRecordO2[0].scalers[i].l1Before << std::endl;
585 std::cout << i << " L1A " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l1After - mScalerRecordO2[0].scalers[i].l1After << std::endl;
586 }
587 return 0;
588}
589//
590// Input counting 1..48
592{
593 if (mScalerRecordO2.size() == 0) {
594 LOG(info) << "ScalerRecord is empty, doing nothing";
595 return 1;
596 }
597 double_t time0 = mScalerRecordO2[0].epochTime;
598 double_t timeL = mScalerRecordO2[mScalerRecordO2.size() - 1].epochTime;
599 int integral = mScalerRecordO2[mScalerRecordO2.size() - 1].scalersInps[inp - 1] - mScalerRecordO2[0].scalersInps[inp - 1];
600 std::cout << "Scaler Integrals for run:" << mRunNumber << " duration:" << timeL - time0;
601 std::cout << " Input " << inp << " integral:" << integral << " rate:" << integral / (timeL - time0) << std::endl;
602 return 0;
603}
604// Prints class before counters for lumi
605// Class counting 1..64
607{
608 if (mScalerRecordO2.size() == 0) {
609 LOG(info) << "ScalerRecord is empty, doing nothing";
610 return 1;
611 }
612 double_t time0 = mScalerRecordO2[0].epochTime;
613 double_t timeL = mScalerRecordO2[mScalerRecordO2.size() - 1].epochTime;
614 int iscalerindex = getScalerIndexForClass(iclsindex);
615 if (iscalerindex != 255) {
616 int integral = mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[iscalerindex].lmBefore - mScalerRecordO2[0].scalers[iscalerindex].lmBefore;
617 std::cout << "Scaler Integrals for run:" << mRunNumber << " duration:" << timeL - time0;
618 std::cout << " Class index" << iclsindex << " integral:" << integral << " rate:" << integral / (timeL - time0) << std::endl;
619 return 0;
620 }
621 return 1;
622}
623// Prints class before counters for lumi
624// Scaler Index Class counting 1..64
625// getScalerIndexForClass(int cls) shpild be called before to convert class index to scaler class index
627{
628 if (mScalerRecordO2.size() == 0) {
629 LOG(info) << "ScalerRecord is empty, doing nothing";
630 return 1;
631 }
632 double_t time0 = mScalerRecordO2[0].epochTime;
633 double_t timeL = mScalerRecordO2[mScalerRecordO2.size() - 1].epochTime;
634 {
635 int integral = mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[iclsscalerindex - 1].lmBefore - mScalerRecordO2[0].scalers[iclsscalerindex - 1].lmBefore;
636 std::cout << "Scaler Integrals for run:" << mRunNumber << " duration:" << timeL - time0;
637 std::cout << " Class scaler index:" << iclsscalerindex << " integral:" << integral << " rate:" << integral / (timeL - time0) << std::endl;
638 }
639 return 0;
640}
641//
643{
644 for (uint32_t i = 1; i < mScalerRecordO2.size(); i++) { // loop over time
645 auto prev = &mScalerRecordO2[i - 1];
646 auto curr = &mScalerRecordO2[i];
647 double_t tt = (double_t)(curr->intRecord.orbit - prev->intRecord.orbit);
648 tt = tt * 88e-6;
649
650 for (int j = 0; j < 1; j++) { // loop over classes
651 auto s0 = &(prev->scalers[j]); // type CTPScalerO2*
652 auto s1 = &(curr->scalers[j]);
653 double_t rMB = (s1->lmBefore - s0->lmBefore) / tt; // rate
654 auto delta = curr->epochTime - prev->epochTime;
655 double rMB2 = (s1->lmBefore - s0->lmBefore) / delta;
656 std::cout << "Class " << j << " " << (unsigned long long)(prev->epochTime) << " " << (unsigned long long)(curr->epochTime) << " DeltaTime " << delta << " tt " << tt << " interactions / s " << rMB << " in Hz " << rMB2 << "\n";
657 }
658 }
659}
660//
661uint64_t CTPRunScalers::getLumiNoPuCorr(int classindex, int type) const
662{
663 if (type < 7) {
664 const auto s0 = mScalerRecordO2[0].scalers[classindex];
665 const auto s1 = mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[classindex];
666 switch (type) {
667 case 1:
668 return (s1.lmBefore - s0.lmBefore);
669 case 2:
670 return (s1.lmAfter - s0.lmAfter);
671 case 3:
672 return (s1.l0Before - s0.l0Before);
673 case 4:
674 return (s1.l0After - s0.l0After);
675 case 5:
676 return (s1.l1Before - s0.l1Before);
677 case 6:
678 return (s1.l1After - s0.l1After);
679 default:
680 LOG(error) << "Wrong type:" << type;
681 return -1; // wrong type
682 }
683 } else if (type == 7) {
684 auto s0 = mScalerRecordO2[0].scalersInps[classindex]; // type CTPScalerO2*
685 auto s1 = mScalerRecordO2[mScalerRecordO2.size() - 1].scalersInps[classindex];
686 return (s1 - s0);
687 } else {
688 LOG(error) << "Wrong type:" << type;
689 return -1; // wrong type
690 }
691};
692//
693std::vector<std::pair<double_t, double_t>> CTPRunScalers::getRatesForIndex(int classindex, int type) const
694{
695 std::vector<std::pair<double_t, double_t>> scals;
696 for (int i = 0; i < mScalerRecordO2.size() - 1; i++) {
697 double_t diff = 0;
698 // double_t timeDiff = mScalerRecordO2[i + 1].epochTime - mScalerRecordO2[i].epochTime;
699 double_t timeDiff = (mScalerRecordO2[i + 1].intRecord.orbit - mScalerRecordO2[i].intRecord.orbit) * o2::constants::lhc::LHCOrbitMUS / 1.e6;
700 if (type < 7) {
701 const auto s0 = mScalerRecordO2[i].scalers[classindex];
702 const auto s1 = mScalerRecordO2[i + 1].scalers[classindex];
703 if (type == 1) {
704 diff = s1.lmBefore - s0.lmBefore;
705 } else if (type == 2) {
706 diff = s1.lmAfter - s0.lmAfter;
707 } else if (type == 3) {
708 diff = s1.l0Before - s0.l0Before;
709 } else if (type == 4) {
710 diff = s1.l0After - s0.l0After;
711 } else if (type == 5) {
712 diff = s1.l1Before - s0.l1Before;
713 } else if (type == 6) {
714 diff = s1.l1After - s0.l1After;
715 } else {
716 LOG(error) << "Wrong type:" << type;
717 return scals; // wrong type
718 }
719 } else if (type == 7) {
720 auto s0 = mScalerRecordO2[i].scalersInps[classindex]; // type CTPScalerO2*
721 auto s1 = mScalerRecordO2[i + 1].scalersInps[classindex];
722 diff = s1 - s0;
723 } else {
724 LOG(error) << "Wrong type:" << type;
725 return scals; // wrong type
726 }
727 scals.emplace_back(std::pair<double_t, double_t>{diff, timeDiff});
728 }
729 return scals;
730};
731// returns the pair of global (levelled) interaction rate, as well as instantaneous interpolated
732// rate in Hz at a certain orbit number within the run
733// type - 7 : inputs
734// type - 1..6 : lmb,lma,l0b,l0a,l1b,l1a
735std::pair<double, double> CTPRunScalers::getRate(uint32_t orbit, int classindex, int type, bool qc) const
736{
737 if (mScalerRecordO2.size() <= 1) {
738 LOG(error) << "not enough data";
739 return std::make_pair(-1., -1.);
740 }
741
742 // assumption: mScalerRecordO2 is arranged in increasing
743 // orbit numbers
744
745 // then we can use binary search to find the right entries
746 auto iter = std::lower_bound(mScalerRecordO2.begin(), mScalerRecordO2.end(), orbit, [&](CTPScalerRecordO2 const& a, uint32_t value) { return a.intRecord.orbit <= value; });
747 auto nextindex = std::distance(mScalerRecordO2.begin(), iter); // this points to the first index that has orbit greater or equal to given orbit
748
749 auto calcRate = [&](auto index1, auto index2) -> double {
750 const auto& snext = mScalerRecordO2[index2];
751 const auto& sprev = mScalerRecordO2[index1];
752 auto timedelta = (snext.intRecord.orbit - sprev.intRecord.orbit) * 88.e-6; // converts orbits into time
753 if (type < 7) {
754 const auto& s0 = sprev.scalers[classindex]; // type CTPScalerO2*
755 const auto& s1 = snext.scalers[classindex];
756 switch (type) {
757 case 1:
758 return (s1.lmBefore - s0.lmBefore) / timedelta;
759 case 2:
760 return (s1.lmAfter - s0.lmAfter) / timedelta;
761 case 3:
762 return (s1.l0Before - s0.l0Before) / timedelta;
763 case 4:
764 return (s1.l0After - s0.l0After) / timedelta;
765 case 5:
766 return (s1.l1Before - s0.l1Before) / timedelta;
767 case 6:
768 return (s1.l1After - s0.l1After) / timedelta;
769 default:
770 LOG(error) << "Wrong type:" << type;
771 return -1; // wrong type
772 }
773 } else if (type == 7) {
774 auto s0 = sprev.scalersInps[classindex]; // type CTPScalerO2*
775 auto s1 = snext.scalersInps[classindex];
776 return (s1 - s0) / timedelta;
777 } else {
778 LOG(error) << "Wrong type:" << type;
779 return -1; // wrong type
780 }
781 };
782 // qc flag decides what to return if time outside run
783 if (nextindex == 0) {
784 // orbit is out of bounds
785 if (qc == 0) {
786 LOG(info) << "query orbit " << orbit << " before first record; Just returning the global rate";
787 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
788 } else {
789 LOG(info) << "query orbit " << orbit << " before first record; Returning the first rate";
790 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* first rate */ calcRate(0, 1));
791 }
792 } else if (nextindex == mScalerRecordO2.size()) {
793 if (qc == 0) {
794 LOG(info) << "query orbit " << orbit << " after last record; Just returning the global rate";
795 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
796 } else {
797 LOG(info) << "query orbit " << orbit << " after last record; Returning the last rate";
798 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* last rate */ calcRate(mScalerRecordO2.size() - 2, mScalerRecordO2.size() - 1));
799 }
800 } else {
801 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ calcRate(nextindex - 1, nextindex));
802 }
803 return std::make_pair(-1., -1.);
804}
805// returns the pair of global (levelled) interaction rate, as well as instantaneous interpolated
806// rate in Hz at a certain orbit number within the run
807// type - 7 : inputs
808// type - 1..6 : lmb,lma,l0b,l0a,l1b,l1a
809std::pair<double, double> CTPRunScalers::getRateGivenT(double timestamp, int classindex, int type, bool qc) const
810{
811 if (mScalerRecordO2.size() <= 1) {
812 LOG(error) << "not enough data";
813 return std::make_pair(-1., -1.);
814 }
815
816 // assumption: mScalerRecordO2 is arranged in increasing
817 // orbit numbers
818
819 // then we can use binary search to find the right entries
820 auto iter = std::lower_bound(mScalerRecordO2.begin(), mScalerRecordO2.end(), timestamp, [&](CTPScalerRecordO2 const& a, double value) { return a.epochTime <= value; });
821 // this points to the first index that has orbit greater to given orbit;
822 // If this is 0, it means that the above condition was false from the beginning, basically saying that the timestamp is below any of the ScalerRecords' orbits.
823 // If this is mScalerRecordO2.size(), it means mScalerRecordO2.end() was returned, condition was met throughout all ScalerRecords, basically saying the timestamp is above any of the ScalarRecordss orbits.
824 auto nextindex = std::distance(mScalerRecordO2.begin(), iter);
825
826 auto calcRate = [&](auto index1, auto index2) -> double {
827 const auto& snext = mScalerRecordO2[index2];
828 const auto& sprev = mScalerRecordO2[index1];
829 auto timedelta = (snext.intRecord.orbit - sprev.intRecord.orbit) * 88.e-6; // converts orbits into time
830 // std::cout << "timedelta:" << timedelta << std::endl;
831 if (type < 7) {
832 const auto& s0 = sprev.scalers[classindex]; // type CTPScalerO2*
833 const auto& s1 = snext.scalers[classindex];
834 switch (type) {
835 case 1:
836 return (s1.lmBefore - s0.lmBefore) / timedelta;
837 case 2:
838 return (s1.lmAfter - s0.lmAfter) / timedelta;
839 case 3:
840 return (s1.l0Before - s0.l0Before) / timedelta;
841 case 4:
842 return (s1.l0After - s0.l0After) / timedelta;
843 case 5:
844 return (s1.l1Before - s0.l1Before) / timedelta;
845 case 6:
846 return (s1.l1After - s0.l1After) / timedelta;
847 default:
848 LOG(error) << "Wrong type:" << type;
849 return -1; // wrong type
850 }
851 } else if (type == 7) {
852 // LOG(info) << "doing input:";
853 auto s0 = sprev.scalersInps[classindex]; // type CTPScalerO2*
854 auto s1 = snext.scalersInps[classindex];
855 return (s1 - s0) / timedelta;
856 } else {
857 LOG(error) << "Wrong type:" << type;
858 return -1; // wrong type
859 }
860 };
861 if (nextindex == 0) {
862 // orbit is out of bounds
863 if (qc == 0) {
864 LOG(info) << "query timestamp " << (long)timestamp << " before first record; Just returning the global rate";
865 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
866 } else {
867 LOG(info) << "query timestamp " << (long)timestamp << " before first record; Returning the first rate";
868 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* first rate */ calcRate(0, 1));
869 }
870 } else if (nextindex == mScalerRecordO2.size()) {
871 if (qc == 0) {
872 LOG(info) << "query timestamp " << (long)timestamp << " after last record; Just returning the global rate";
873 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
874 } else {
875 LOG(info) << "query timestamp " << (long)timestamp << " after last record; Returning the last rate";
876 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* last rate */ calcRate(mScalerRecordO2.size() - 2, mScalerRecordO2.size() - 1));
877 }
878 } else {
879 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ calcRate(nextindex - 1, nextindex));
880 }
881 return std::make_pair(-1., -1.);
882}
883// Offset orbit of all records
884//
886{
887 int over = 0;
888 LOG(info) << "Subtracting from orbit " << offset;
889 for (auto& screc : mScalerRecordRaw) {
890 uint32_t orbit = screc.intRecord.orbit;
891 uint32_t orbitnew = 0;
892 orbitnew = orbit - offset;
893 if (orbit < offset) {
894 over++;
895 }
896 screc.intRecord.orbit = orbitnew;
897 }
898 if (over != 0 && over != mScalerRecordRaw.size()) {
899 LOG(warning) << "Orbit overflow inside run. Run:" << mRunNumber;
900 }
901 return 0;
902}
903std::vector<std::string> CTPRunScalers::scalerNames =
904 {
905 "runn0", "runn1", "runn2", "runn3", "runn4", "runn5", "runn6", "runn7", "runn8", "runn9", "runn10", "runn11", "runn12", "runn13", "runn14", "runn15", "ltg1_ORB", "ltg1_HB", "ltg1_HBr", "ltg1_HC", "ltg1_PH", "ltg1_PP", "ltg1_CAL", "ltg1_SOT", "ltg1_EOT", "ltg1_SOC", "ltg1_EOC", "ltg1_TF", "ltg1_FERST", "ltg1_RT", "ltg1_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg1_GAP1", "ltg1_GAP2", "ltg1_TPC_sync", "ltg1_TPC_rst", "ltg1_TOF", "ltg2_ORB", "ltg2_HB", "ltg2_HBr", "ltg2_HC", "ltg2_PH", "ltg2_PP", "ltg2_CAL", "ltg2_SOT", "ltg2_EOT", "ltg2_SOC", "ltg2_EOC", "ltg2_TF", "ltg2_FERST", "ltg2_RT", "ltg2_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg2_GAP1", "ltg2_GAP2", "ltg2_TPC_sync", "ltg2_TPC_rst", "ltg2_TOF", "ltg3_ORB", "ltg3_HB", "ltg3_HBr", "ltg3_HC", "ltg3_PH", "ltg3_PP", "ltg3_CAL", "ltg3_SOT", "ltg3_EOT", "ltg3_SOC", "ltg3_EOC", "ltg3_TF", "ltg3_FERST", "ltg3_RT", "ltg3_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg3_GAP1", "ltg3_GAP2", "ltg3_TPC_sync", "ltg3_TPC_rst", "ltg3_TOF", "ltg4_ORB", "ltg4_HB", "ltg4_HBr", "ltg4_HC", "ltg4_PH", "ltg4_PP", "ltg4_CAL", "ltg4_SOT", "ltg4_EOT", "ltg4_SOC", "ltg4_EOC", "ltg4_TF", "ltg4_FERST", "ltg4_RT", "ltg4_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg4_GAP1", "ltg4_GAP2", "ltg4_TPC_sync", "ltg4_TPC_rst", "ltg4_TOF", "ltg5_ORB", "ltg5_HB", "ltg5_HBr", "ltg5_HC", "ltg5_PH", "ltg5_PP", "ltg5_CAL", "ltg5_SOT", "ltg5_EOT", "ltg5_SOC", "ltg5_EOC", "ltg5_TF", "ltg5_FERST", "ltg5_RT", "ltg5_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg5_GAP1", "ltg5_GAP2", "ltg5_TPC_sync", "ltg5_TPC_rst", "ltg5_TOF", "ltg6_ORB", "ltg6_HB", "ltg6_HBr", "ltg6_HC", "ltg6_PH", "ltg6_PP", "ltg6_CAL", "ltg6_SOT", "ltg6_EOT", "ltg6_SOC", "ltg6_EOC", "ltg6_TF", "ltg6_FERST", "ltg6_RT", "ltg6_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg6_GAP1", "ltg6_GAP2", "ltg6_TPC_sync", "ltg6_TPC_rst", "ltg6_TOF", "ltg7_ORB", "ltg7_HB", "ltg7_HBr", "ltg7_HC", "ltg7_PH", "ltg7_PP", "ltg7_CAL", "ltg7_SOT", "ltg7_EOT", "ltg7_SOC", "ltg7_EOC", "ltg7_TF", "ltg7_FERST", "ltg7_RT", "ltg7_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg7_GAP1", "ltg7_GAP2", "ltg7_TPC_sync", "ltg7_TPC_rst", "ltg7_TOF", "ltg8_ORB", "ltg8_HB", "ltg8_HBr", "ltg8_HC", "ltg8_PH", "ltg8_PP", "ltg8_CAL", "ltg8_SOT", "ltg8_EOT", "ltg8_SOC", "ltg8_EOC", "ltg8_TF", "ltg8_FERST", "ltg8_RT", "ltg8_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg8_GAP1", "ltg8_GAP2", "ltg8_TPC_sync", "ltg8_TPC_rst", "ltg8_TOF", "ltg9_ORB", "ltg9_HB", "ltg9_HBr", "ltg9_HC", "ltg9_PH", "ltg9_PP", "ltg9_CAL", "ltg9_SOT", "ltg9_EOT", "ltg9_SOC", "ltg9_EOC", "ltg9_TF", "ltg9_FERST", "ltg9_RT", "ltg9_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg9_GAP1", "ltg9_GAP2", "ltg9_TPC_sync", "ltg9_TPC_rst", "ltg9_TOF", "ltg10_ORB", "ltg10_HB", "ltg10_HBr", "ltg10_HC", "ltg10_PH", "ltg10_PP", "ltg10_CAL", "ltg10_SOT", "ltg10_EOT", "ltg10_SOC", "ltg10_EOC", "ltg10_TF", "ltg10_FERST", "ltg10_RT", "ltg10_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg10_GAP1", "ltg10_GAP2", "ltg10_TPC_sync", "ltg10_TPC_rst", "ltg10_TOF", "ltg11_ORB", "ltg11_HB", "ltg11_HBr", "ltg11_HC", "ltg11_PH", "ltg11_PP", "ltg11_CAL", "ltg11_SOT", "ltg11_EOT", "ltg11_SOC", "ltg11_EOC", "ltg11_TF", "ltg11_FERST", "ltg11_RT", "ltg11_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg11_GAP1", "ltg11_GAP2", "ltg11_TPC_sync", "ltg11_TPC_rst", "ltg11_TOF", "ltg12_ORB", "ltg12_HB", "ltg12_HBr", "ltg12_HC", "ltg12_PH", "ltg12_PP", "ltg12_CAL", "ltg12_SOT", "ltg12_EOT", "ltg12_SOC", "ltg12_EOC", "ltg12_TF", "ltg12_FERST", "ltg12_RT", "ltg12_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg12_GAP1", "ltg12_GAP2", "ltg12_TPC_sync", "ltg12_TPC_rst", "ltg12_TOF", "ltg13_ORB", "ltg13_HB", "ltg13_HBr", "ltg13_HC", "ltg13_PH", "ltg13_PP", "ltg13_CAL", "ltg13_SOT", "ltg13_EOT", "ltg13_SOC", "ltg13_EOC", "ltg13_TF", "ltg13_FERST", "ltg13_RT", "ltg13_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg13_GAP1", "ltg13_GAP2", "ltg13_TPC_sync", "ltg13_TPC_rst", "ltg13_TOF", "ltg14_ORB", "ltg14_HB", "ltg14_HBr", "ltg14_HC", "ltg14_PH", "ltg14_PP", "ltg14_CAL", "ltg14_SOT", "ltg14_EOT", "ltg14_SOC", "ltg14_EOC", "ltg14_TF", "ltg14_FERST", "ltg14_RT", "ltg14_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg14_GAP1", "ltg14_GAP2", "ltg14_TPC_sync", "ltg14_TPC_rst", "ltg14_TOF", "ltg15_ORB", "ltg15_HB", "ltg15_HBr", "ltg15_HC", "ltg15_PH", "ltg15_PP", "ltg15_CAL", "ltg15_SOT", "ltg15_EOT", "ltg15_SOC", "ltg15_EOC", "ltg15_TF", "ltg15_FERST", "ltg15_RT", "ltg15_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg15_GAP1", "ltg15_GAP2", "ltg15_TPC_sync", "ltg15_TPC_rst", "ltg15_TOF", "ltg16_ORB", "ltg16_HB", "ltg16_HBr", "ltg16_HC", "ltg16_PH", "ltg16_PP", "ltg16_CAL", "ltg16_SOT", "ltg16_EOT", "ltg16_SOC", "ltg16_EOC", "ltg16_TF", "ltg16_FERST", "ltg16_RT", "ltg16_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg16_GAP1", "ltg16_GAP2", "ltg16_TPC_sync", "ltg16_TPC_rst", "ltg16_TOF", "ltg17_ORB", "ltg17_HB", "ltg17_HBr", "ltg17_HC", "ltg17_PH", "ltg17_PP", "ltg17_CAL", "ltg17_SOT", "ltg17_EOT", "ltg17_SOC", "ltg17_EOC", "ltg17_TF", "ltg17_FERST", "ltg17_RT", "ltg17_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg17_GAP1", "ltg17_GAP2", "ltg17_TPC_sync", "ltg17_TPC_rst", "ltg17_TOF", "ltg18_ORB", "ltg18_HB", "ltg18_HBr", "ltg18_HC", "ltg18_PH", "ltg18_PP", "ltg18_CAL", "ltg18_SOT", "ltg18_EOT", "ltg18_SOC", "ltg18_EOC", "ltg18_TF", "ltg18_FERST", "ltg18_RT", "ltg18_RS", "", "", "", "", "", "", "", "", "", "", "", "", "ltg18_GAP1", "ltg18_GAP2", "ltg18_TPC_sync", "ltg18_TPC_rst", "ltg18_TOF", "bc40", "clk240", "extorb", "PLSRin", "FastLMin", "BUSYin", "SPAREin", "inp1", "inp2", "inp3", "inp4", "inp5", "inp6", "inp7", "inp8", "inp9", "inp10", "inp11", "inp12", "inp13", "inp14", "inp15", "inp16", "inp17", "inp18", "inp19", "inp20", "inp21", "inp22", "inp23", "inp24", "inp25", "inp26", "inp27", "inp28", "inp29", "inp30", "inp31", "inp32", "inp33", "inp34", "inp35", "inp36", "inp37", "inp38", "inp39", "inp40", "inp41", "inp42", "inp43", "inp44", "inp45", "inp46", "inp47", "inp48", "clamb1", "clamb2", "clamb3", "clamb4", "clamb5", "clamb6", "clamb7", "clamb8", "clamb9", "clamb10", "clamb11", "clamb12", "clamb13", "clamb14", "clamb15", "clamb16", "clamb17", "clamb18", "clamb19", "clamb20", "clamb21", "clamb22", "clamb23", "clamb24", "clamb25", "clamb26", "clamb27", "clamb28", "clamb29", "clamb30", "clamb31", "clamb32", "clamb33", "clamb34", "clamb35", "clamb36", "clamb37", "clamb38", "clamb39", "clamb40", "clamb41", "clamb42", "clamb43", "clamb44", "clamb45", "clamb46", "clamb47", "clamb48", "clamb49", "clamb50", "clamb51", "clamb52", "clamb53", "clamb54", "clamb55", "clamb56", "clamb57", "clamb58", "clamb59", "clamb60", "clamb61", "clamb62", "clamb63", "clamb64", "clama1", "clama2", "clama3", "clama4", "clama5", "clama6", "clama7", "clama8", "clama9", "clama10", "clama11", "clama12", "clama13", "clama14", "clama15", "clama16", "clama17", "clama18", "clama19", "clama20", "clama21", "clama22", "clama23", "clama24", "clama25", "clama26", "clama27", "clama28", "clama29", "clama30", "clama31", "clama32", "clama33", "clama34", "clama35", "clama36", "clama37", "clama38", "clama39", "clama40", "clama41", "clama42", "clama43", "clama44", "clama45", "clama46", "clama47", "clama48", "clama49", "clama50", "clama51", "clama52", "clama53", "clama54", "clama55", "clama56", "clama57", "clama58", "clama59", "clama60", "clama61", "clama62", "clama63", "clama64", "cla0b1", "cla0b2", "cla0b3", "cla0b4", "cla0b5", "cla0b6", "cla0b7", "cla0b8", "cla0b9", "cla0b10", "cla0b11", "cla0b12", "cla0b13", "cla0b14", "cla0b15", "cla0b16", "cla0b17", "cla0b18", "cla0b19", "cla0b20", "cla0b21", "cla0b22", "cla0b23", "cla0b24", "cla0b25", "cla0b26", "cla0b27", "cla0b28", "cla0b29", "cla0b30", "cla0b31", "cla0b32", "cla0b33", "cla0b34", "cla0b35", "cla0b36", "cla0b37", "cla0b38", "cla0b39", "cla0b40", "cla0b41", "cla0b42", "cla0b43", "cla0b44", "cla0b45", "cla0b46", "cla0b47", "cla0b48", "cla0b49", "cla0b50", "cla0b51", "cla0b52", "cla0b53", "cla0b54", "cla0b55", "cla0b56", "cla0b57", "cla0b58", "cla0b59", "cla0b60", "cla0b61", "cla0b62", "cla0b63", "cla0b64", "cla0a1", "cla0a2", "cla0a3", "cla0a4", "cla0a5", "cla0a6", "cla0a7", "cla0a8", "cla0a9", "cla0a10", "cla0a11", "cla0a12", "cla0a13", "cla0a14", "cla0a15", "cla0a16", "cla0a17", "cla0a18", "cla0a19", "cla0a20", "cla0a21", "cla0a22", "cla0a23", "cla0a24", "cla0a25", "cla0a26", "cla0a27", "cla0a28", "cla0a29", "cla0a30", "cla0a31", "cla0a32", "cla0a33", "cla0a34", "cla0a35", "cla0a36", "cla0a37", "cla0a38", "cla0a39", "cla0a40", "cla0a41", "cla0a42", "cla0a43", "cla0a44", "cla0a45", "cla0a46", "cla0a47", "cla0a48", "cla0a49", "cla0a50", "cla0a51", "cla0a52", "cla0a53", "cla0a54", "cla0a55", "cla0a56", "cla0a57", "cla0a58", "cla0a59", "cla0a60", "cla0a61", "cla0a62", "cla0a63", "cla0a64", "cla1b1", "cla1b2", "cla1b3", "cla1b4", "cla1b5", "cla1b6", "cla1b7", "cla1b8", "cla1b9", "cla1b10", "cla1b11", "cla1b12", "cla1b13", "cla1b14", "cla1b15", "cla1b16", "cla1b17", "cla1b18", "cla1b19", "cla1b20", "cla1b21", "cla1b22", "cla1b23", "cla1b24", "cla1b25", "cla1b26", "cla1b27", "cla1b28", "cla1b29", "cla1b30", "cla1b31", "cla1b32", "cla1b33", "cla1b34", "cla1b35", "cla1b36", "cla1b37", "cla1b38", "cla1b39", "cla1b40", "cla1b41", "cla1b42", "cla1b43", "cla1b44", "cla1b45", "cla1b46", "cla1b47", "cla1b48", "cla1b49", "cla1b50", "cla1b51", "cla1b52", "cla1b53", "cla1b54", "cla1b55", "cla1b56", "cla1b57", "cla1b58", "cla1b59", "cla1b60", "cla1b61", "cla1b62", "cla1b63", "cla1b64", "cla1a1", "cla1a2", "cla1a3", "cla1a4", "cla1a5", "cla1a6", "cla1a7", "cla1a8", "cla1a9", "cla1a10", "cla1a11", "cla1a12", "cla1a13", "cla1a14", "cla1a15", "cla1a16", "cla1a17", "cla1a18", "cla1a19", "cla1a20", "cla1a21", "cla1a22", "cla1a23", "cla1a24", "cla1a25", "cla1a26", "cla1a27", "cla1a28", "cla1a29", "cla1a30", "cla1a31", "cla1a32", "cla1a33", "cla1a34", "cla1a35", "cla1a36", "cla1a37", "cla1a38", "cla1a39", "cla1a40", "cla1a41", "cla1a42", "cla1a43", "cla1a44", "cla1a45", "cla1a46", "cla1a47", "cla1a48", "cla1a49", "cla1a50", "cla1a51", "cla1a52", "cla1a53", "cla1a54", "cla1a55", "cla1a56", "cla1a57", "cla1a58", "cla1a59", "cla1a60", "cla1a61", "cla1a62", "cla1a63", "cla1a64", "l0_trigger", "l1_trigger", "l2_trigger", "clum1", "clum2", "clum3", "clum4", "clum5", "clum6", "clu01", "clu02", "clu03", "clu04", "clu05", "clu06", "clu11", "clu12", "clu13", "clu14", "clu15", "clu16",
906 "ltg1_busy", "ltg2_busy", "ltg3_busy", "ltg4_busy", "ltg5_busy", "ltg6_busy", "ltg7_busy", "ltg8_busy", "ltg9_busy",
907 "ltg10_busy", "ltg11_busy", "ltg12_busy", "ltg13_busy", "ltg14_busy", "ltg15_busy", "ltg16_busy", "ltg17_busy", "ltg18_busy", "orbitid", "clum7", "clum8", "clu07", "clu08", "clu17", "clu18", "clu_busy1", "clu_busy2", "clu_busy3", "clu_busy4", "clu_busy5", "clu_busy6", "clu_busy7", "clu_busy8"};
uint64_t orbit
Definition RawEventData.h:6
int32_t i
uint32_t j
Definition RawData.h:0
definition of CTPScalerRaw, CTPScalerO2
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
void printClasses(std::ostream &stream) const
Definition Scalers.cxx:134
void printLMBRateVsT() const
Definition Scalers.cxx:642
int printInputRateAndIntegral(int inp)
Definition Scalers.cxx:591
static std::vector< std::string > scalerNames
Definition Scalers.h:97
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
void printStream(std::ostream &stream) const
Definition Scalers.cxx:104
int addOrbitOffset(uint32_t offset)
Definition Scalers.cxx:885
int getScalerIndexForClass(uint32_t cls) const
Definition Scalers.cxx:155
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 printFromZero(std::ostream &stream) const
Definition Scalers.cxx:125
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
Definition glcorearb.h:5034
GLuint index
Definition glcorearb.h:781
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLintptr offset
Definition glcorearb.h:660
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLuint GLuint stream
Definition glcorearb.h:1806
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s0
Definition glcorearb.h:5034
constexpr double LHCOrbitMUS
GPUReconstruction * rec
uint32_t orbit
LHC orbit.
uint16_t bc
bunch crossing ID of interaction
Scalers produced from raw scalers corrected for overflow.
Definition Scalers.h:52
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
uint32_t classIndex
Definition Scalers.h:41
void printStream(std::ostream &stream) const
Definition Scalers.cxx:32
o2::InteractionRecord intRecord
Definition Scalers.h:78
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
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
static void trim(std::string &s)
Definition StringUtils.h:71
static std::vector< std::string > tokenize(const std::string &src, char delim, bool trimToken=true, bool skipEmpty=true)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"