You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DataFormats/Detectors/CTP/src/Scalers.cxx
+28-28Lines changed: 28 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -674,35 +674,35 @@ std::pair<double, double> CTPRunScalers::getRate(uint32_t orbit, int classindex,
674
674
675
675
// then we can use binary search to find the right entries
676
676
auto iter = std::lower_bound(mScalerRecordO2.begin(), mScalerRecordO2.end(), orbit, [&](CTPScalerRecordO2 const& a, uint32_t value) { return a.intRecord.orbit <= value; });
677
-
auto nextindex = iter - mScalerRecordO2.begin(); // this points to the first index that has orbit greater or equal to given orbit
677
+
auto nextindex = std::distance(mScalerRecordO2.begin(), iter); // this points to the first index that has orbit greater or equal to given orbit
678
678
679
679
auto calcRate = [&](auto index1, auto index2) -> double {
680
-
auto next = &mScalerRecordO2[index2];
681
-
auto prev = &mScalerRecordO2[index1];
682
-
auto timedelta = (next->intRecord.orbit - prev->intRecord.orbit) * 88.e-6; // converts orbits into time
680
+
constauto& snext = mScalerRecordO2[index2];
681
+
constauto& sprev = mScalerRecordO2[index1];
682
+
auto timedelta = (snext.intRecord.orbit - sprev.intRecord.orbit) * 88.e-6; // converts orbits into time
683
683
if (type < 7) {
684
-
auto s0 = &(prev->scalers[classindex]); // type CTPScalerO2*
685
-
auto s1 = &(next->scalers[classindex]);
684
+
constauto& s0 = sprev.scalers[classindex]; // type CTPScalerO2*
685
+
constauto& s1 = snext.scalers[classindex];
686
686
switch (type) {
687
687
case1:
688
-
return (s1->lmBefore - s0->lmBefore) / timedelta;
688
+
return (s1.lmBefore - s0.lmBefore) / timedelta;
689
689
case2:
690
-
return (s1->lmAfter - s0->lmAfter) / timedelta;
690
+
return (s1.lmAfter - s0.lmAfter) / timedelta;
691
691
case3:
692
-
return (s1->l0Before - s0->l0Before) / timedelta;
692
+
return (s1.l0Before - s0.l0Before) / timedelta;
693
693
case4:
694
-
return (s1->l0After - s0->l0After) / timedelta;
694
+
return (s1.l0After - s0.l0After) / timedelta;
695
695
case5:
696
-
return (s1->l1Before - s0->l1Before) / timedelta;
696
+
return (s1.l1Before - s0.l1Before) / timedelta;
697
697
case6:
698
-
return (s1->l1After - s0->l1After) / timedelta;
698
+
return (s1.l1After - s0.l1After) / timedelta;
699
699
default:
700
700
LOG(error) << "Wrong type:" << type;
701
701
return -1; // wrong type
702
702
}
703
703
} elseif (type == 7) {
704
-
auto s0 = &(prev->scalersInps[classindex]); // type CTPScalerO2*
705
-
auto s1 = &(next->scalersInps[classindex]);
704
+
auto s0 = sprev.scalersInps[classindex]; // type CTPScalerO2*
705
+
auto s1 = snext.scalersInps[classindex];
706
706
return (s1 - s0) / timedelta;
707
707
} else {
708
708
LOG(error) << "Wrong type:" << type;
@@ -738,37 +738,37 @@ std::pair<double, double> CTPRunScalers::getRateGivenT(double timestamp, int cla
738
738
// this points to the first index that has orbit greater to given orbit;
739
739
// 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.
740
740
// 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.
741
-
auto nextindex = iter - mScalerRecordO2.begin();
741
+
auto nextindex = std::distance(mScalerRecordO2.begin(), iter);
742
742
743
743
auto calcRate = [&](auto index1, auto index2) -> double {
744
-
auto next = &mScalerRecordO2[index2];
745
-
auto prev = &mScalerRecordO2[index1];
746
-
auto timedelta = (next->intRecord.orbit - prev->intRecord.orbit) * 88.e-6; // converts orbits into time
744
+
constauto& snext = mScalerRecordO2[index2];
745
+
constauto& sprev = mScalerRecordO2[index1];
746
+
auto timedelta = (snext.intRecord.orbit - sprev.intRecord.orbit) * 88.e-6; // converts orbits into time
0 commit comments