@@ -65,7 +65,8 @@ void CTPScalerRecordRaw::printStream(std::ostream& stream) const
6565 for (auto const & cnts : scalers) {
6666 cnts.printStream (stream);
6767 }
68- for (auto const & dets : scalersDets) {
68+ std::cout << " Inputs:" << scalersInps.size () << std::endl;
69+ for (auto const & dets : scalersInps) {
6970 stream << dets << " " ;
7071 }
7172 stream << std::endl;
@@ -77,7 +78,8 @@ void CTPScalerRecordO2::printStream(std::ostream& stream) const
7778 for (auto const & cnts : scalers) {
7879 cnts.printStream (stream);
7980 }
80- for (auto const & dets : scalersDets) {
81+ std::cout << " Inputs:" << scalersInps.size () << std::endl;
82+ for (auto const & dets : scalersInps) {
8183 stream << dets << " " ;
8284 }
8385 stream << std::endl;
@@ -273,10 +275,12 @@ int CTPRunScalers::convertRawToO2()
273275 overflows[i] = {0 , 0 , 0 , 0 , 0 , 0 };
274276 }
275277 }
278+ // Input overflows
279+ std::array<uint32_t , 48 > overflowsInputs = {48 * 0 };
276280 errorCounters eCnts;
277281 // 1st o2 rec is just copy
278282 CTPScalerRecordO2 o2rec;
279- copyRawToO2ScalerRecord (mScalerRecordRaw [0 ], o2rec, overflows);
283+ copyRawToO2ScalerRecord (mScalerRecordRaw [0 ], o2rec, overflows, overflowsInputs );
280284 mScalerRecordO2 .push_back (o2rec);
281285 int j = 1 ;
282286 for (uint32_t i = 1 ; i < mScalerRecordRaw .size (); i++) {
@@ -285,7 +289,8 @@ int CTPRunScalers::convertRawToO2()
285289 //
286290 if (ret == 0 ) {
287291 CTPScalerRecordO2 o2rec;
288- copyRawToO2ScalerRecord (mScalerRecordRaw [i], o2rec, overflows);
292+ ret = updateOverflowsInps (mScalerRecordRaw [i - 1 ], mScalerRecordRaw [i], overflowsInputs);
293+ copyRawToO2ScalerRecord (mScalerRecordRaw [i], o2rec, overflows, overflowsInputs);
289294 mScalerRecordO2 .push_back (o2rec);
290295 // Check consistency
291296 checkConsistency (mScalerRecordO2 [j - 1 ], mScalerRecordO2 [j], eCnts);
@@ -295,7 +300,7 @@ int CTPRunScalers::convertRawToO2()
295300 eCnts.printStream (std::cout);
296301 return 0 ;
297302}
298- int CTPRunScalers::copyRawToO2ScalerRecord (const CTPScalerRecordRaw& rawrec, CTPScalerRecordO2& o2rec, overflows_t & classesoverflows)
303+ int CTPRunScalers::copyRawToO2ScalerRecord (const CTPScalerRecordRaw& rawrec, CTPScalerRecordO2& o2rec, overflows_t & classesoverflows, std::array< uint32_t , 48 >& overflows )
299304{
300305 if (rawrec.scalers .size () != (mClassMask .count ())) {
301306 LOG (error) << " Inconsistent scaler record size:" << rawrec.scalers .size () << " Expected:" << mClassMask .count ();
@@ -313,6 +318,10 @@ int CTPRunScalers::copyRawToO2ScalerRecord(const CTPScalerRecordRaw& rawrec, CTP
313318 o2scal.createCTPScalerO2FromRaw (rawscal, classesoverflows[k]);
314319 o2rec.scalers .push_back (o2scal);
315320 }
321+ for (int i = 0 ; i < rawrec.scalersInps .size (); i++) {
322+ uint64_t inpo2 = (uint64_t )(rawrec.scalersInps [i]) + 0xffffffffull * (uint64_t )(overflows[i]);
323+ o2rec.scalersInps .push_back (inpo2);
324+ }
316325 return 0 ;
317326}
318327int CTPRunScalers::checkConsistency (const CTPScalerO2& scal0, const CTPScalerO2& scal1, errorCounters& eCnts) const
@@ -452,6 +461,26 @@ int CTPRunScalers::updateOverflows(const CTPScalerRaw& scal0, const CTPScalerRaw
452461 // std::cout << std::endl;
453462 return 0 ;
454463}
464+ //
465+ int CTPRunScalers::updateOverflowsInps (const CTPScalerRecordRaw& rec0, const CTPScalerRecordRaw& rec1, std::array<uint32_t , 48 >& overflow) const
466+ {
467+ int NINPS = 48 ;
468+ if (rec0.scalersInps .size () < NINPS) {
469+ LOG (error) << " updateOverflowsInps.size < 48:" << rec0.scalersInps .size ();
470+ return 1 ;
471+ }
472+ if (rec1.scalersInps .size () < NINPS) {
473+ LOG (error) << " updateOverflowsInps.size < 48:" << rec1.scalersInps .size ();
474+ return 2 ;
475+ }
476+ for (int i = 0 ; i < NINPS; i++) {
477+ if (rec0.scalersInps [i] > rec1.scalersInps [i]) {
478+ overflow[i] += 1 ;
479+ }
480+ }
481+ return 0 ;
482+ }
483+ //
455484int CTPRunScalers::printRates ()
456485{
457486 if (mScalerRecordO2 .size () == 0 ) {
@@ -507,7 +536,42 @@ int CTPRunScalers::printIntegrals()
507536 }
508537 return 0 ;
509538}
510-
539+ //
540+ // Input counting 1..48
541+ int CTPRunScalers::printInputRateAndIntegral (int inp)
542+ {
543+ if (mScalerRecordO2 .size () == 0 ) {
544+ LOG (info) << " ScalerRecord is empty, doing nothing" ;
545+ return 1 ;
546+ }
547+ double_t time0 = mScalerRecordO2 [0 ].epochTime ;
548+ double_t timeL = mScalerRecordO2 [mScalerRecordO2 .size () - 1 ].epochTime ;
549+ int integral = mScalerRecordO2 [mScalerRecordO2 .size () - 1 ].scalersInps [inp - 1 ] - mScalerRecordO2 [0 ].scalersInps [inp - 1 ];
550+ std::cout << " Scaler Integrals for run:" << mRunNumber << " duration:" << timeL - time0;
551+ std::cout << " Input " << inp << " integral:" << integral << " rate:" << integral / (timeL - time0) << std::endl;
552+ return 0 ;
553+ }
554+ // Prints class before counters for lumi
555+ // Class counting 1..64
556+ int CTPRunScalers::printClassBRateAndIntegral (int icls)
557+ {
558+ if (mScalerRecordO2 .size () == 0 ) {
559+ LOG (info) << " ScalerRecord is empty, doing nothing" ;
560+ return 1 ;
561+ }
562+ double_t time0 = mScalerRecordO2 [0 ].epochTime ;
563+ double_t timeL = mScalerRecordO2 [mScalerRecordO2 .size () - 1 ].epochTime ;
564+ if (mScalerRecordO2 [0 ].scalers .size () < icls) {
565+ LOG (error) << " class number bigger than expected for this run:" << icls << " expexted smaller than:" << mScalerRecordO2 [0 ].scalers .size ();
566+ return 1 ;
567+ } else {
568+ int integral = mScalerRecordO2 [mScalerRecordO2 .size () - 1 ].scalers [icls - 1 ].lmBefore - mScalerRecordO2 [0 ].scalers [icls - 1 ].lmBefore ;
569+ std::cout << " Scaler Integrals for run:" << mRunNumber << " duration:" << timeL - time0;
570+ std::cout << " Class " << icls << " integral:" << integral << " rate:" << integral / (timeL - time0) << std::endl;
571+ }
572+ return 0 ;
573+ }
574+ //
511575void CTPRunScalers::printLMBRateVsT () const
512576{
513577 for (int i = 1 ; i < mScalerRecordO2 .size (); i++) { // loop over time
0 commit comments