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>
20#include <fairlogger/Logger.h>
21
22using namespace o2::ctp;
23void errorCounters::printStream(std::ostream& stream) const
24{
25 // stream << "Counter warnings diff 1 lmBlmA:" << lmBlmAd1 << " lmAl0B:" << lmAl0Bd1 << " l0Bl0A:" << l0Bl0Ad1 << " l0Al1B: " << l0Al1Bd1 << " l1Bl1A:" << l1Bl1Ad1;
26 // stream << std::endl;
27 if (lmB + l0B + l1B + lmA + l0A + l1A + lmBlmA + lmAl0B + l0Bl0A + l0Al1B + l1Bl1A) {
28 stream << "Counter errorrs: lmB:" << lmB << " l0B:" << l0B << " l1B:" << l1B << " lmA:" << lmA << " l0A:" << l0A << " l1A:" << l1A;
29 stream << " lmBlmA:" << lmBlmA << " lmAl0B:" << lmAl0B << " l0Bl0A:" << l0Bl0A << " l0Al1B: " << l0Al1B << " l1Bl1A:" << l1Bl1A;
30 stream << std::endl;
31 }
32}
33void CTPScalerRaw::printStream(std::ostream& stream) const
34{
35 stream << "Class:" << std::setw(2) << classIndex << " RAW";
36 stream << " LMB:" << std::setw(10) << lmBefore << " LMA:" << std::setw(10) << lmAfter;
37 stream << " L0B:" << std::setw(10) << l0Before << " L0A:" << std::setw(10) << l0After;
38 stream << " L1B:" << std::setw(10) << l1Before << " L1A:" << std::setw(10) << l1After << std::endl;
39}
40//
41void CTPScalerO2::createCTPScalerO2FromRaw(const CTPScalerRaw& raw, const std::array<uint32_t, 6>& overflow)
42{
43 classIndex = raw.classIndex;
44 lmBefore = (uint64_t)(raw.lmBefore) + 0xffffffffull * (uint64_t)(overflow[0]);
45 lmAfter = (uint64_t)(raw.lmAfter) + 0xffffffffull * (uint64_t)(overflow[1]);
46 l0Before = (uint64_t)(raw.l0Before) + 0xffffffffull * (uint64_t)(overflow[2]);
47 l0After = (uint64_t)(raw.l0After) + 0xffffffffull * (uint64_t)(overflow[3]);
48 l1Before = (uint64_t)(raw.l1Before) + 0xffffffffull * (uint64_t)(overflow[4]);
49 l1After = (uint64_t)(raw.l1After) + 0xffffffffull * (uint64_t)(overflow[5]);
50 //std::cout << "lmb overflow:" << overflow[0] << " lmb:" << lmBefore << " raw:" << raw.lmBefore << std::endl;
51}
52void CTPScalerO2::printStream(std::ostream& stream) const
53{
54 stream << "Class:" << std::setw(2) << classIndex << " O2";
55 stream << " LMB:" << std::setw(10) << lmBefore << " LMA:" << std::setw(10) << lmAfter;
56 stream << " L0B:" << std::setw(10) << l0Before << " L0A:" << std::setw(10) << l0After;
57 stream << " L1B:" << std::setw(10) << l1Before << " L1A:" << std::setw(10) << l1After << std::endl;
58}
59void CTPScalerO2::printFromZero(std::ostream& stream, CTPScalerO2& scaler0) const
60{
61 stream << "Class:" << std::setw(2) << classIndex << " O2";
62 stream << " LMB:" << std::setw(10) << lmBefore - scaler0.lmBefore << " LMA:" << std::setw(10) << lmAfter - scaler0.lmAfter;
63 stream << " LOB:" << std::setw(10) << l0Before - scaler0.l0Before << " L0A:" << std::setw(10) << l0After - scaler0.l0After;
64 stream << " L1B:" << std::setw(10) << l1Before - scaler0.l1Before << " L1A:" << std::setw(10) << l1After - scaler0.l1After << std::endl;
65}
66void CTPScalerRecordRaw::printStream(std::ostream& stream) const
67{
68 stream << "Orbit:" << intRecord.orbit << " BC:" << intRecord.bc;
69 stream << " miliSeconds:" << epochTime << std::endl;
70 for (auto const& cnts : scalers) {
71 cnts.printStream(stream);
72 }
73 std::cout << "Inputs:" << scalersInps.size() << std::endl;
74 for (auto const& dets : scalersInps) {
75 stream << dets << " ";
76 }
77 stream << std::endl;
78}
79void CTPScalerRecordO2::printStream(std::ostream& stream) const
80{
81 stream << "Orbit:" << intRecord.orbit << " BC:" << intRecord.bc;
82 stream << " miliSeconds:" << epochTime << std::endl;
83 for (auto const& cnts : scalers) {
84 cnts.printStream(stream);
85 }
86 std::cout << "Inputs:" << scalersInps.size() << std::endl;
87 for (auto const& dets : scalersInps) {
88 stream << dets << " ";
89 }
90 stream << std::endl;
91}
93{
94 stream << "printFromZero Orbit:" << intRecord.orbit - record0.intRecord.orbit << " BC:" << intRecord.bc;
95 stream << " miliSeconds:" << std::setprecision(20) << epochTime - record0.epochTime << std::endl;
96 // this-record0
97 for (uint32_t i = 0; i < scalers.size(); i++) {
98 scalers[i].printFromZero(stream, record0.scalers[i]);
99 }
100 stream << std::endl;
101}
102//
103// CTPRunScalers
104//
105void CTPRunScalers::printStream(std::ostream& stream) const
106{
107 stream << "CTP Scalers (version:" << mVersion << ") Run:" << mRunNumber << std::endl;
109 stream << "Detector mask:" << mDetectorMask << std::endl;
110 for (auto const& rec : mScalerRecordRaw) {
111 rec.printStream(stream);
112 }
113 stream << "O2 Counters:" << std::endl;
114 for (auto const& rec : mScalerRecordO2) {
115 rec.printStream(stream);
116 }
117}
118void CTPRunScalers::printO2(std::ostream& stream) const
119{
120 stream << "CTP Scalers (version:" << mVersion << ") Run:" << mRunNumber << std::endl;
121 stream << "O2 Counters:" << std::endl;
122 for (auto const& rec : mScalerRecordO2) {
123 rec.printStream(stream);
124 }
125}
126void CTPRunScalers::printFromZero(std::ostream& stream) const
127{
128 stream << "CTP Scalers (version:" << mVersion << ") Run:" << mRunNumber << std::endl;
129 stream << "O2 Counters:" << std::endl;
130 CTPScalerRecordO2 record0 = mScalerRecordO2[0];
131 for (auto const& rec : mScalerRecordO2) {
132 rec.printFromZero(stream, record0);
133 }
134}
135void CTPRunScalers::printClasses(std::ostream& stream) const
136{
137 stream << "CTP classes:";
138 for (uint32_t i = 0; i < mClassMask.size(); i++) {
139 if (mClassMask[i]) {
140 stream << " " << i;
141 }
142 }
143 stream << std::endl;
144}
145std::vector<uint32_t> CTPRunScalers::getClassIndexes() const
146{
147 std::vector<uint32_t> indexes;
148 for (uint32_t i = 0; i < CTP_NCLASSES; i++) {
149 if (mClassMask[i]) {
150 indexes.push_back(i);
151 }
152 }
153 return indexes;
154}
155// cls counted from 0
157{
158 if (cls >= 64) {
159 LOG(error) << "Class index out of range:" << cls;
160 return 255;
161 }
162 std::vector<uint32_t> clslist = getClassIndexes();
163 int i = 0;
164 for (auto const& clsl : clslist) {
165 if (cls == clsl) {
166 return i;
167 }
168 i++;
169 }
170 LOG(error) << " Class not found:" << cls;
171 return 255;
172}
173int CTPRunScalers::readScalers(const std::string& rawscalers)
174{
175 LOG(info) << "Loading CTP scalers.";
176 std::istringstream iss(rawscalers);
177 int ret = 0;
178 int level = 0;
179 std::string line;
180 uint32_t nclasses = 0;
181 int nlines = 0;
182 while (std::getline(iss, line)) {
184 if ((ret = processScalerLine(line, level, nclasses)) != 0) {
185 return ret;
186 }
187 nlines++;
188 }
189 if (nlines < 4) {
190 LOG(error) << "Input string seems too small:\n"
191 << rawscalers;
192 return 6;
193 }
194 if (nclasses != 0) {
195 LOG(error) << "Wrong number of classes in final record";
196 return 6;
197 }
198 return 0;
199}
200int CTPRunScalers::processScalerLine(const std::string& line, int& level, uint32_t& nclasses)
201{
202 //std::cout << "Processing line" << std::endl;
203 if (line.size() == 0) {
204 return 0;
205 }
206 if (line.at(0) == '#') {
207 return 0;
208 }
209 std::vector<std::string> tokens = o2::utils::Str::tokenize(line, ' ');
210 size_t ntokens = tokens.size();
211 if (ntokens == 0) {
212 return 0;
213 }
214 //std::cout << line << " level in::" << level << std::endl;
215 // Version
216 if (level == 0) {
217 if (ntokens != 1) {
218 LOG(error) << "Expected version in the first line";
219 return 1;
220 } else {
221 mVersion = std::stoi(tokens[0]);
222 level = 1;
223 return 0;
224 }
225 }
226 // Run Number N Classes [class indexes]
227 if (level == 1) {
228 if (ntokens < 3) {
229 LOG(error) << "Wrong syntax of second line in CTP scalers";
230 return 2;
231 } else {
232 mRunNumber = std::stol(tokens[0]);
233 uint32_t numofclasses = std::stoi(tokens[1]);
234 if ((numofclasses + 2) != ntokens) {
235 LOG(error) << "Wrong syntax of second line in CTP scalers";
236 return 3;
237 }
238 mClassMask.reset();
239 for (uint32_t i = 0; i < numofclasses; i++) {
240 int index = std::stoi(tokens[i + 2]);
241 mClassMask[index] = 1;
242 }
243 level = 2;
244 nclasses = 0;
245 return 0;
246 }
247 }
248 // Time stamp: orbit bcid linuxtime
249 if (level == 2) {
250 if (ntokens != 4) {
251 LOG(error) << "Wrong syntax of time stamp line in CTP scalers";
252 return 4;
253 } else {
255 rec.intRecord.orbit = std::stol(tokens[0]);
256 rec.intRecord.bc = std::stol(tokens[1]);
257 // rec.seconds = std::stol(tokens[2]);
258 rec.epochTime = std::stoll(tokens[2]);
259 // rec.microSeconds = std::stol(tokens[3]);
260 mScalerRecordRaw.push_back(rec);
261 level = 3;
262 return 0;
263 }
264 }
265 if (level == 3) {
266 if (ntokens != 6) {
267 LOG(error) << "Wrong syntax of counters line in CTP scalers";
268 return 5;
269 } else {
270 //std::cout << "nclasses:" << nclasses << std::endl;
271 CTPScalerRaw scaler;
272 scaler.classIndex = getClassIndexes()[nclasses];
273 scaler.lmBefore = std::stol(tokens[0]);
274 scaler.lmAfter = std::stol(tokens[1]);
275 scaler.l0Before = std::stol(tokens[2]);
276 scaler.l0After = std::stol(tokens[3]);
277 scaler.l1Before = std::stol(tokens[4]);
278 scaler.l1After = std::stol(tokens[5]);
279 (mScalerRecordRaw.back()).scalers.push_back(scaler);
280 nclasses++;
281 if (nclasses >= mClassMask.count()) {
282 level = 2;
283 nclasses = 0;
284 }
285 return 0;
286 }
287 }
288 return 0;
289}
293{
294 //struct classScalersOverflows {uint32_t overflows[6];};
295 overflows_t overflows;
296 for (uint32_t i = 0; i < mClassMask.size(); i++) {
297 if (mClassMask[i]) {
298 overflows[i] = {0, 0, 0, 0, 0, 0};
299 }
300 }
301 // Input overflows
302 std::array<uint32_t, 48> overflowsInputs = {48 * 0};
303 errorCounters eCnts;
304 // 1st o2 rec is just copy
305 CTPScalerRecordO2 o2rec;
306 copyRawToO2ScalerRecord(mScalerRecordRaw[0], o2rec, overflows, overflowsInputs);
307 mScalerRecordO2.push_back(o2rec);
308 int j = 1;
309 for (uint32_t i = 1; i < mScalerRecordRaw.size(); i++) {
310 //update overflows
311 int ret = updateOverflows(mScalerRecordRaw[i - 1], mScalerRecordRaw[i], overflows);
312 // for(int k = 0; k < mClassMask.size(); k++) {
313 // if(mClassMask[k]) {
314 // LOG(info) << i << " " << k << " " << overflows[k][0] << " " << overflows[k][1] << " " << overflows[k][2] << " " << overflows[k][3] << " " << overflows[k][4] << " " << overflows[k][5];
315 // }
316 // }
317 //
318 if (ret == 0) {
319 CTPScalerRecordO2 o2rec;
320 ret = updateOverflowsInps(mScalerRecordRaw[i - 1], mScalerRecordRaw[i], overflowsInputs);
321 copyRawToO2ScalerRecord(mScalerRecordRaw[i], o2rec, overflows, overflowsInputs);
322 mScalerRecordO2.push_back(o2rec);
323 // Check consistency
324 checkConsistency(mScalerRecordO2[j - 1], mScalerRecordO2[j], eCnts);
325 j++;
326 }
327 }
328 eCnts.printStream(std::cout);
329 return 0;
330}
331int CTPRunScalers::copyRawToO2ScalerRecord(const CTPScalerRecordRaw& rawrec, CTPScalerRecordO2& o2rec, overflows_t& classesoverflows, std::array<uint32_t, 48>& overflows)
332{
333 if (rawrec.scalers.size() != (mClassMask.count())) {
334 LOG(error) << "Inconsistent scaler record size:" << rawrec.scalers.size() << " Expected:" << mClassMask.count();
335 return 1;
336 }
337 o2rec.scalers.clear();
338 o2rec.intRecord = rawrec.intRecord;
339 // o2rec.seconds = rawrec.seconds;
340 // o2rec.microSeconds = rawrec.microSeconds;
341 o2rec.epochTime = rawrec.epochTime;
342 for (uint32_t i = 0; i < rawrec.scalers.size(); i++) {
343 CTPScalerRaw rawscal = rawrec.scalers[i];
344 CTPScalerO2 o2scal;
345 int k = (getClassIndexes())[i];
346 o2scal.createCTPScalerO2FromRaw(rawscal, classesoverflows[k]);
347 o2rec.scalers.push_back(o2scal);
348 }
349 for (uint32_t i = 0; i < rawrec.scalersInps.size(); i++) {
350 uint64_t inpo2 = (uint64_t)(rawrec.scalersInps[i]) + 0xffffffffull * (uint64_t)(overflows[i]);
351 o2rec.scalersInps.push_back(inpo2);
352 }
353 return 0;
354}
355int CTPRunScalers::checkConsistency(const CTPScalerO2& scal0, const CTPScalerO2& scal1, errorCounters& eCnts) const
356{
357 int ret = 0;
358 // Scaler should never decrease
359 if (scal0.lmBefore > scal1.lmBefore) {
360 eCnts.lmB++;
361 if (eCnts.lmB < eCnts.MAXPRINT) {
362 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmBefore 0:" << scal0.lmBefore << " lmBefore :" << scal1.lmBefore;
363 }
364 ret++;
365 }
366 if (scal0.l0Before > scal1.l0Before) {
367 eCnts.l0B++;
368 if (eCnts.l0B < eCnts.MAXPRINT) {
369 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmBefore 0:" << scal0.l0Before << " lmBefore :" << scal1.l0Before;
370 }
371 ret++;
372 }
373 if (scal0.l1Before > scal1.l1Before) {
374 eCnts.l1B++;
375 if (eCnts.l1B < eCnts.MAXPRINT) {
376 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmBefore 0:" << scal0.l1Before << " lmBefore :" << scal1.l1Before;
377 }
378 ret++;
379 }
380 if (scal0.lmAfter > scal1.lmAfter) {
381 eCnts.lmA++;
382 if (eCnts.lmA < eCnts.MAXPRINT) {
383 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmAfter 0:" << scal0.lmAfter << " lmAfter :" << scal1.lmAfter;
384 }
385 ret++;
386 }
387 if (scal0.l0After > scal1.l0After) {
388 eCnts.l0A++;
389 if (eCnts.l0A < eCnts.MAXPRINT) {
390 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmAfter 0:" << scal0.l0After << " lmAfter :" << scal1.l0After;
391 }
392 ret++;
393 }
394 if (scal0.l1After > scal1.l1After) {
395 eCnts.l1A++;
396 if (eCnts.l1A < eCnts.MAXPRINT) {
397 LOG(error) << "Scaler decreasing: Class:" << scal0.classIndex << " lmAfter 0:" << scal0.l1After << " lmAfter :" << scal1.l1After;
398 }
399 ret++;
400 }
401 //
402 // LMB >= LMA >= L0B >= L0A >= L1B >= L1A: 5 relations
403 // broken for classes started at L0
404 //
405 int64_t difThres = 6;
406 int64_t dif = (scal1.lmAfter - scal0.lmAfter) - (scal1.lmBefore - scal0.lmBefore);
407 if (dif <= difThres) {
408 eCnts.lmBlmAd1++;
409 } else if (dif > difThres) {
410 eCnts.lmBlmA++;
411 if (eCnts.lmBlmA < eCnts.MAXPRINT) {
412 LOG(error) << "LMA > LMB error:" << dif;
413 }
414 ret++;
415 }
416 dif = (scal1.l0After - scal0.l0After) - (scal1.l0Before - scal0.l0Before);
417 if (dif <= difThres) {
418 eCnts.l0Bl0Ad1++;
419 } else if (dif > difThres) {
420 eCnts.l0Bl0A++;
421 if (eCnts.l0Bl0A < eCnts.MAXPRINT) {
422 LOG(error) << "L0A > L0B error:" << dif;
423 }
424 ret++;
425 }
426 dif = (scal1.l0After - scal0.l0After) - (scal1.l0Before - scal0.l0Before);
427 if (dif <= difThres) {
428 eCnts.l1Bl1Ad1++;
429 } else if (dif > difThres) {
430 eCnts.l1Bl1A++;
431 if (eCnts.l1Bl1A < eCnts.MAXPRINT) {
432 LOG(error) << "L1A > L1B error:" << dif;
433 }
434 ret++;
435 }
436 if ((scal1.l0Before - scal0.l0Before) > (scal1.lmAfter - scal0.lmAfter)) {
437 // LOG(warning) << "L0B > LMA ok if L0 class.";
438 // ret++;
439 }
440 dif = (scal1.l1Before - scal0.l1Before) - (scal1.l0After - scal0.l0After);
441 // LOG(info) << "L1B L0A " << dif << " " << scal1.l1Before << " " << scal1.l0After << " " << scal0.l1Before << " " << scal0.l0After;
442 if (dif <= difThres) {
443 eCnts.l0Al1Bd1++;
444 } else if (dif > difThres) {
445 eCnts.l0Al1B++;
446 if (eCnts.l0Al1B < eCnts.MAXPRINT) {
447 // LOG(error) << "L1B > L0A Before error:" << dif << " " << scal1.l1Before << " " << scal1.l0After << " " << scal0.l1Before << " " << scal0.l0After;
448 LOG(warning) << "L1B > L0A Before error:" << dif;
449 }
450 ret++;
451 }
452 //
453 if (ret < 0) {
454 scal0.printStream(std::cout);
455 scal1.printStream(std::cout);
456 }
457 return ret;
458}
459int CTPRunScalers::updateOverflows(const CTPScalerRecordRaw& rec0, const CTPScalerRecordRaw& rec1, overflows_t& classesoverflows) const
460{
461 if (rec1.scalers.size() != mClassMask.count()) {
462 LOG(error) << "Inconsistent scaler record size:" << rec1.scalers.size() << " Expected:" << mClassMask.count();
463 return 1;
464 }
465 if (rec0.intRecord.orbit > rec1.intRecord.orbit) {
466 LOG(warning) << "rec0 orbit:" << rec0.intRecord.orbit << "> rec1 orbit:" << rec1.intRecord.orbit << " skipping this record";
467 return 1;
468 }
469 for (uint32_t i = 0; i < rec0.scalers.size(); i++) {
470 int k = (getClassIndexes())[i];
471 updateOverflows(rec0.scalers[i], rec1.scalers[i], classesoverflows[k]);
472 }
473 return 0;
474}
476{
477 int ret = 0;
478 for (uint32_t i = 0; i < rec0.scalers.size(); i++) {
479 ret += checkConsistency(rec0.scalers[i], rec1.scalers[i], eCnts);
480 }
481 return ret;
482}
483int CTPRunScalers::updateOverflows(const CTPScalerRaw& scal0, const CTPScalerRaw& scal1, std::array<uint32_t, 6>& overflow) const
484{
485 if (scal0.lmBefore > scal1.lmBefore) {
486 overflow[0] += 1;
487 }
488 if (scal0.lmAfter > scal1.lmAfter) {
489 overflow[1] += 1;
490 }
491 if (scal0.l0Before > scal1.l0Before) {
492 overflow[2] += 1;
493 }
494 if (scal0.l0After > scal1.l0After) {
495 overflow[3] += 1;
496 }
497 if (scal0.l1Before > scal1.l1Before) {
498 overflow[4] += 1;
499 }
500 if (scal0.l1After > scal1.l1After) {
501 overflow[5] += 1;
502 }
503 //std::cout << "lmB0:" << scal0.lmBefore << " lmB1:" << scal1.lmBefore << " over:" << overflow[0] << std::endl;
504 //for(int i = 0; i < 6; i++)std::cout << overflow[i] << " ";
505 //std::cout << std::endl;
506 return 0;
507}
508//
509int CTPRunScalers::updateOverflowsInps(const CTPScalerRecordRaw& rec0, const CTPScalerRecordRaw& rec1, std::array<uint32_t, 48>& overflow) const
510{
511 static int iPrint = 0;
512 uint32_t NINPS = 48;
513 if (rec0.scalersInps.size() < NINPS) {
514 if (iPrint < 1) {
515 LOG(warning) << "Input scalers not available. Size:" << rec0.scalersInps.size();
516 iPrint++;
517 }
518 return 1;
519 }
520 if (rec1.scalersInps.size() < NINPS) {
521 if (iPrint < 1) {
522 LOG(warning) << "Input scalers not available. Size:" << rec0.scalersInps.size();
523 iPrint++;
524 }
525 return 2;
526 }
527 for (uint32_t i = 0; i < NINPS; i++) {
528 if (rec0.scalersInps[i] > rec1.scalersInps[i]) {
529 overflow[i] += 1;
530 }
531 }
532 return 0;
533}
534//
536{
537 if (mScalerRecordO2.size() == 0) {
538 LOG(info) << "ScalerRecord is empty, doing nothing";
539 return 0;
540 }
541 LOG(info) << "Scaler rates for run:" << mRunNumber;
542 CTPScalerRecordO2* scalrec0 = &mScalerRecordO2[0];
543 uint32_t orbit0 = scalrec0->intRecord.orbit;
544 for (uint32_t i = 1; i < mScalerRecordO2.size(); i++) {
545 CTPScalerRecordO2* scalrec1 = &mScalerRecordO2[i];
546 double_t tt = (double_t)(scalrec1->intRecord.orbit - scalrec0->intRecord.orbit);
547 double_t tinrun = (double_t)(scalrec1->intRecord.orbit - orbit0);
548 tt = tt * o2::constants::lhc::LHCOrbitMUS * 1.e-6;
549 tinrun = tinrun * o2::constants::lhc::LHCOrbitMUS * 1.e-6;
550 std::cout << "==> Time wrt to SOR [s]:" << tinrun << " time intervale[s]:" << tt << std::endl;
551 for (uint32_t j = 0; j < scalrec1->scalers.size(); j++) {
552 CTPScalerO2* s0 = &(scalrec0->scalers[j]);
553 CTPScalerO2* s1 = &(scalrec1->scalers[j]);
554 double_t rMB = (s1->lmBefore - s0->lmBefore) / tt;
555 double_t rMA = (s1->lmAfter - s0->lmAfter) / tt;
556 double_t r0B = (s1->l0Before - s0->l0Before) / tt;
557 double_t r0A = (s1->l0After - s0->l0After) / tt;
558 double_t r1B = (s1->l1Before - s0->l1Before) / tt;
559 double_t r1A = (s1->l1After - s0->l1After) / tt;
560 std::cout << "Class:" << s0->classIndex << ": ";
561 std::cout << rMB << " " << rMA << " ";
562 std::cout << r0B << " " << r0A << " ";
563 std::cout << r1B << " " << r1A;
564 std::cout << std::endl;
565 }
566 scalrec0 = scalrec1;
567 }
568 return 0;
569}
571{
572 if (mScalerRecordO2.size() == 0) {
573 LOG(info) << "ScalerRecord is empty, doing nothing";
574 return 0;
575 }
576 double_t time0 = mScalerRecordO2[0].epochTime;
577 double_t timeL = mScalerRecordO2[mScalerRecordO2.size() - 1].epochTime;
578 LOG(info) << "Scaler Integrals for run:" << mRunNumber << " duration:" << timeL - time0;
579
580 for (uint32_t i = 0; i < mScalerRecordO2[0].scalers.size(); i++) {
581 std::cout << i << " LMB " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].lmBefore - mScalerRecordO2[0].scalers[i].lmBefore << std::endl;
582 std::cout << i << " LMA " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].lmAfter - mScalerRecordO2[0].scalers[i].lmAfter << std::endl;
583 std::cout << i << " L0B " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l0Before - mScalerRecordO2[0].scalers[i].l0Before << std::endl;
584 std::cout << i << " L0A " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l0After - mScalerRecordO2[0].scalers[i].l0After << std::endl;
585 std::cout << i << " L1B " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l1Before - mScalerRecordO2[0].scalers[i].l1Before << std::endl;
586 std::cout << i << " L1A " << mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[i].l1After - mScalerRecordO2[0].scalers[i].l1After << std::endl;
587 }
588 return 0;
589}
590//
591// Input counting 1..48
593{
594 if (mScalerRecordO2.size() == 0) {
595 LOG(info) << "ScalerRecord is empty, doing nothing";
596 return 1;
597 }
598 double_t time0 = mScalerRecordO2[0].epochTime;
599 double_t timeL = mScalerRecordO2[mScalerRecordO2.size() - 1].epochTime;
600 int integral = mScalerRecordO2[mScalerRecordO2.size() - 1].scalersInps[inp - 1] - mScalerRecordO2[0].scalersInps[inp - 1];
601 std::cout << "Scaler Integrals for run:" << mRunNumber << " duration:" << timeL - time0;
602 std::cout << " Input " << inp << " integral:" << integral << " rate:" << integral / (timeL - time0) << std::endl;
603 return 0;
604}
605// Prints class before counters for lumi
606// Class counting 1..64
608{
609 if (mScalerRecordO2.size() == 0) {
610 LOG(info) << "ScalerRecord is empty, doing nothing";
611 return 1;
612 }
613 double_t time0 = mScalerRecordO2[0].epochTime;
614 double_t timeL = mScalerRecordO2[mScalerRecordO2.size() - 1].epochTime;
615 int iscalerindex = getScalerIndexForClass(iclsindex);
616 if (iscalerindex != 255) {
617 int integral = mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[iscalerindex].lmBefore - mScalerRecordO2[0].scalers[iscalerindex].lmBefore;
618 std::cout << "Scaler Integrals for run:" << mRunNumber << " duration:" << timeL - time0;
619 std::cout << " Class index" << iclsindex << " integral:" << integral << " rate:" << integral / (timeL - time0) << std::endl;
620 return 0;
621 }
622 return 1;
623}
624// Prints class before counters for lumi
625// Scaler Index Class counting 1..64
626// getScalerIndexForClass(int cls) shpild be called before to convert class index to scaler class index
628{
629 if (mScalerRecordO2.size() == 0) {
630 LOG(info) << "ScalerRecord is empty, doing nothing";
631 return 1;
632 }
633 double_t time0 = mScalerRecordO2[0].epochTime;
634 double_t timeL = mScalerRecordO2[mScalerRecordO2.size() - 1].epochTime;
635 {
636 int integral = mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[iclsscalerindex - 1].lmBefore - mScalerRecordO2[0].scalers[iclsscalerindex - 1].lmBefore;
637 std::cout << "Scaler Integrals for run:" << mRunNumber << " duration:" << timeL - time0;
638 std::cout << " Class scaler index:" << iclsscalerindex << " integral:" << integral << " rate:" << integral / (timeL - time0) << std::endl;
639 }
640 return 0;
641}
642//
644{
645 for (uint32_t i = 1; i < mScalerRecordO2.size(); i++) { // loop over time
646 auto prev = &mScalerRecordO2[i - 1];
647 auto curr = &mScalerRecordO2[i];
648 double_t tt = (double_t)(curr->intRecord.orbit - prev->intRecord.orbit);
649 tt = tt * o2::constants::lhc::LHCOrbitMUS * 1.e-6;
650
651 for (int j = 0; j < 1; j++) { // loop over classes
652 auto s0 = &(prev->scalers[j]); // type CTPScalerO2*
653 auto s1 = &(curr->scalers[j]);
654 double_t rMB = (s1->lmBefore - s0->lmBefore) / tt; // rate
655 auto delta = curr->epochTime - prev->epochTime;
656 double rMB2 = (s1->lmBefore - s0->lmBefore) / delta;
657 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";
658 }
659 }
660}
661//
663{
664 if (type < 7) {
665 const auto s0 = mScalerRecordO2[0].scalers[classindex];
666 const auto s1 = mScalerRecordO2[mScalerRecordO2.size() - 1].scalers[classindex];
667 switch (type) {
668 case 1:
669 return (s1.lmBefore - s0.lmBefore);
670 case 2:
671 return (s1.lmAfter - s0.lmAfter);
672 case 3:
673 return (s1.l0Before - s0.l0Before);
674 case 4:
675 return (s1.l0After - s0.l0After);
676 case 5:
677 return (s1.l1Before - s0.l1Before);
678 case 6:
679 return (s1.l1After - s0.l1After);
680 default:
681 LOG(error) << "Wrong type:" << type;
682 return -1; // wrong type
683 }
684 } else if (type == 7) {
685 auto s0 = mScalerRecordO2[0].scalersInps[classindex]; // type CTPScalerO2*
686 auto s1 = mScalerRecordO2[mScalerRecordO2.size() - 1].scalersInps[classindex];
687 return (s1 - s0);
688 } else {
689 LOG(error) << "Wrong type:" << type;
690 return -1; // wrong type
691 }
692};
693//
694std::vector<std::pair<double_t, double_t>> CTPRunScalers::getRatesForIndex(int classindex, int type) const
695{
696 std::vector<std::pair<double_t, double_t>> scals;
697 for (int i = 0; i < mScalerRecordO2.size() - 1; i++) {
698 double_t diff = 0;
699 // double_t timeDiff = mScalerRecordO2[i + 1].epochTime - mScalerRecordO2[i].epochTime;
700 double_t timeDiff = (mScalerRecordO2[i + 1].intRecord.orbit - mScalerRecordO2[i].intRecord.orbit) * o2::constants::lhc::LHCOrbitMUS / 1.e6;
701 if (type < 7) {
702 const auto s0 = mScalerRecordO2[i].scalers[classindex];
703 const auto s1 = mScalerRecordO2[i + 1].scalers[classindex];
704 if (type == 1) {
705 diff = s1.lmBefore - s0.lmBefore;
706 } else if (type == 2) {
707 diff = s1.lmAfter - s0.lmAfter;
708 } else if (type == 3) {
709 diff = s1.l0Before - s0.l0Before;
710 } else if (type == 4) {
711 diff = s1.l0After - s0.l0After;
712 } else if (type == 5) {
713 diff = s1.l1Before - s0.l1Before;
714 } else if (type == 6) {
715 diff = s1.l1After - s0.l1After;
716 } else {
717 LOG(error) << "Wrong type:" << type;
718 return scals; // wrong type
719 }
720 } else if (type == 7) {
721 auto s0 = mScalerRecordO2[i].scalersInps[classindex]; // type CTPScalerO2*
722 auto s1 = mScalerRecordO2[i + 1].scalersInps[classindex];
723 diff = s1 - s0;
724 } else {
725 LOG(error) << "Wrong type:" << type;
726 return scals; // wrong type
727 }
728 scals.emplace_back(std::pair<double_t, double_t>{diff, timeDiff});
729 }
730 return scals;
731};
732// returns the pair of global (levelled) interaction rate, as well as instantaneous interpolated
733// rate in Hz at a certain orbit number within the run
734// type - 7 : inputs
735// type - 1..6 : lmb,lma,l0b,l0a,l1b,l1a
736std::pair<double, double> CTPRunScalers::getRate(uint32_t orbit, int classindex, int type, bool qc) const
737{
738 if (mScalerRecordO2.size() <= 1) {
739 LOG(error) << "not enough data";
740 return std::make_pair(-1., -1.);
741 }
742
743 // assumption: mScalerRecordO2 is arranged in increasing
744 // orbit numbers
745
746 // then we can use binary search to find the right entries
747 auto iter = std::lower_bound(mScalerRecordO2.begin(), mScalerRecordO2.end(), orbit, [&](CTPScalerRecordO2 const& a, uint32_t value) { return a.intRecord.orbit <= value; });
748 auto nextindex = std::distance(mScalerRecordO2.begin(), iter); // this points to the first index that has orbit greater or equal to given orbit
749
750 auto calcRate = [&](auto index1, auto index2) -> double {
751 const auto& snext = mScalerRecordO2[index2];
752 const auto& sprev = mScalerRecordO2[index1];
753 auto timedelta = (snext.intRecord.orbit - sprev.intRecord.orbit) * o2::constants::lhc::LHCOrbitMUS * 1.e-6; // converts orbits into time
754 if (type < 7) {
755 const auto& s0 = sprev.scalers[classindex]; // type CTPScalerO2*
756 const auto& s1 = snext.scalers[classindex];
757 switch (type) {
758 case 1:
759 return (s1.lmBefore - s0.lmBefore) / timedelta;
760 case 2:
761 return (s1.lmAfter - s0.lmAfter) / timedelta;
762 case 3:
763 return (s1.l0Before - s0.l0Before) / timedelta;
764 case 4:
765 return (s1.l0After - s0.l0After) / timedelta;
766 case 5:
767 return (s1.l1Before - s0.l1Before) / timedelta;
768 case 6:
769 return (s1.l1After - s0.l1After) / timedelta;
770 default:
771 LOG(error) << "Wrong type:" << type;
772 return -1; // wrong type
773 }
774 } else if (type == 7) {
775 auto s0 = sprev.scalersInps[classindex]; // type CTPScalerO2*
776 auto s1 = snext.scalersInps[classindex];
777 return (s1 - s0) / timedelta;
778 } else {
779 LOG(error) << "Wrong type:" << type;
780 return -1; // wrong type
781 }
782 };
783 // qc flag decides what to return if time outside run
784 if (nextindex == 0) {
785 // orbit is out of bounds
786 if (qc == 0) {
787 LOG(info) << "query orbit " << orbit << " before first record; Just returning the global rate";
788 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
789 } else {
790 LOG(info) << "query orbit " << orbit << " before first record; Returning the first rate";
791 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* first rate */ calcRate(0, 1));
792 }
793 } else if (nextindex == mScalerRecordO2.size()) {
794 if (qc == 0) {
795 LOG(info) << "query orbit " << orbit << " after last record; Just returning the global rate";
796 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
797 } else {
798 LOG(info) << "query orbit " << orbit << " after last record; Returning the last rate";
799 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* last rate */ calcRate(mScalerRecordO2.size() - 2, mScalerRecordO2.size() - 1));
800 }
801 } else {
802 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ calcRate(nextindex - 1, nextindex));
803 }
804 return std::make_pair(-1., -1.);
805}
806// returns the pair of global (levelled) interaction rate, as well as instantaneous interpolated
807// rate in Hz at a certain orbit number within the run
808// type - 7 : inputs
809// type - 1..6 : lmb,lma,l0b,l0a,l1b,l1a
810std::pair<double, double> CTPRunScalers::getRateGivenT(double timestamp, int classindex, int type, bool qc) const
811{
812 if (mScalerRecordO2.size() <= 1) {
813 LOG(error) << "not enough data";
814 return std::make_pair(-1., -1.);
815 }
816
817 // assumption: mScalerRecordO2 is arranged in increasing
818 // orbit numbers
819
820 // then we can use binary search to find the right entries
821 auto iter = std::lower_bound(mScalerRecordO2.begin(), mScalerRecordO2.end(), timestamp, [&](CTPScalerRecordO2 const& a, double value) { return a.epochTime <= value; });
822 // this points to the first index that has orbit greater to given orbit;
823 // 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.
824 // 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.
825 auto nextindex = std::distance(mScalerRecordO2.begin(), iter);
826
827 auto calcRate = [&](auto index1, auto index2) -> double {
828 const auto& snext = mScalerRecordO2[index2];
829 const auto& sprev = mScalerRecordO2[index1];
830 auto timedelta = (snext.intRecord.orbit - sprev.intRecord.orbit) * o2::constants::lhc::LHCOrbitMUS * 1.e-6; // converts orbits into time
831 // std::cout << "timedelta:" << timedelta << std::endl;
832 if (type < 7) {
833 const auto& s0 = sprev.scalers[classindex]; // type CTPScalerO2*
834 const auto& s1 = snext.scalers[classindex];
835 switch (type) {
836 case 1:
837 return (s1.lmBefore - s0.lmBefore) / timedelta;
838 case 2:
839 return (s1.lmAfter - s0.lmAfter) / timedelta;
840 case 3:
841 return (s1.l0Before - s0.l0Before) / timedelta;
842 case 4:
843 return (s1.l0After - s0.l0After) / timedelta;
844 case 5:
845 return (s1.l1Before - s0.l1Before) / timedelta;
846 case 6:
847 return (s1.l1After - s0.l1After) / timedelta;
848 default:
849 LOG(error) << "Wrong type:" << type;
850 return -1; // wrong type
851 }
852 } else if (type == 7) {
853 // LOG(info) << "doing input:";
854 auto s0 = sprev.scalersInps[classindex]; // type CTPScalerO2*
855 auto s1 = snext.scalersInps[classindex];
856 return (s1 - s0) / timedelta;
857 } else {
858 LOG(error) << "Wrong type:" << type;
859 return -1; // wrong type
860 }
861 };
862 if (nextindex == 0) {
863 // orbit is out of bounds
864 if (qc == 0) {
865 LOG(info) << "query timestamp " << (long)timestamp << " before first record; Just returning the global rate";
866 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
867 } else {
868 LOG(info) << "query timestamp " << (long)timestamp << " before first record; Returning the first rate";
869 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* first rate */ calcRate(0, 1));
870 }
871 } else if (nextindex == mScalerRecordO2.size()) {
872 if (qc == 0) {
873 LOG(info) << "query timestamp " << (long)timestamp << " after last record; Just returning the global rate";
874 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ -1);
875 } else {
876 LOG(info) << "query timestamp " << (long)timestamp << " after last record; Returning the last rate";
877 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* last rate */ calcRate(mScalerRecordO2.size() - 2, mScalerRecordO2.size() - 1));
878 }
879 } else {
880 return std::make_pair(/*global mean rate*/ calcRate(0, mScalerRecordO2.size() - 1), /* current rate */ calcRate(nextindex - 1, nextindex));
881 }
882 return std::make_pair(-1., -1.);
883}
884// Offset orbit of all records
885//
887{
888 int over = 0;
889 LOG(info) << "Subtracting from orbit " << offset;
890 for (auto& screc : mScalerRecordRaw) {
891 uint32_t orbit = screc.intRecord.orbit;
892 uint32_t orbitnew = 0;
893 orbitnew = orbit - offset;
894 if (orbit < offset) {
895 over++;
896 }
897 screc.intRecord.orbit = orbitnew;
898 }
899 if (over != 0 && over != mScalerRecordRaw.size()) {
900 LOG(warning) << "Orbit overflow inside run. Run:" << mRunNumber;
901 }
902 return 0;
903}
904std::vector<std::string> CTPRunScalers::scalerNames =
905 {
906 "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",
907 "ltg1_busy", "ltg2_busy", "ltg3_busy", "ltg4_busy", "ltg5_busy", "ltg6_busy", "ltg7_busy", "ltg8_busy", "ltg9_busy",
908 "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
unsigned int uint32_t
int32_t i
o2::raw::RawFileWriter * raw
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
configStandalone rec
bool overflow
char error[CURL_ERROR_SIZE]
Header to collect LHC related constants.
uint32_t j
Definition RawData.h:0
definition of CTPScalerRaw, CTPScalerO2
int printClassBRateAndIntegral(int iclsinscalers)
Definition Scalers.cxx:627
std::vector< uint32_t > getClassIndexes() const
Definition Scalers.cxx:145
int printClassBRateAndIntegralII(int icls)
Definition Scalers.cxx:607
uint64_t getLumiNoPuCorr(int classindex, int type) const
retrieves integral - same interface as getRate, no pileup correction
Definition Scalers.cxx:662
int readScalers(const std::string &rawscalers)
Definition Scalers.cxx:173
void printClasses(std::ostream &stream) const
Definition Scalers.cxx:135
void printLMBRateVsT() const
Definition Scalers.cxx:643
int printInputRateAndIntegral(int inp)
Definition Scalers.cxx:592
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:736
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:810
void printO2(std::ostream &stream) const
Definition Scalers.cxx:118
int checkConsistency(const CTPScalerO2 &scal0, const CTPScalerO2 &scal1, errorCounters &eCnts) const
Definition Scalers.cxx:355
void printStream(std::ostream &stream) const
Definition Scalers.cxx:105
int addOrbitOffset(uint32_t offset)
Definition Scalers.cxx:886
int getScalerIndexForClass(uint32_t cls) const
Definition Scalers.cxx:156
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:694
void printFromZero(std::ostream &stream) const
Definition Scalers.cxx:126
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
GLint level
Definition glcorearb.h:275
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
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:59
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:41
void printStream(std::ostream &stream) const
Definition Scalers.cxx:52
uint32_t classIndex
Definition Scalers.h:55
uint32_t classIndex
Definition Scalers.h:41
void printStream(std::ostream &stream) const
Definition Scalers.cxx:33
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:92
void printStream(std::ostream &stream) const
Definition Scalers.cxx:79
std::vector< CTPScalerRaw > scalers
Definition Scalers.h:70
void printStream(std::ostream &stream) const
Definition Scalers.cxx:66
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:23
static void trim(std::string &s)
Definition StringUtils.h:70
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"