@@ -723,7 +723,7 @@ std::pair<double, double> CTPRunScalers::getRate(uint32_t orbit, int classindex,
723723// rate in Hz at a certain orbit number within the run
724724// type - 7 : inputs
725725// type - 1..6 : lmb,lma,l0b,l0a,l1b,l1a
726- std::pair<double , double > CTPRunScalers::getRateGivenT (double timestamp, int classindex, int type) const
726+ std::pair<double , double > CTPRunScalers::getRateGivenT (double timestamp, int classindex, int type, bool qc ) const
727727{
728728 if (mScalerRecordO2 .size () <= 1 ) {
729729 LOG (error) << " not enough data" ;
@@ -775,12 +775,24 @@ std::pair<double, double> CTPRunScalers::getRateGivenT(double timestamp, int cla
775775 return -1 ; // wrong type
776776 }
777777 };
778- if (nextindex == 0 || nextindex == mScalerRecordO2 . size () ) {
778+ if (nextindex == 0 ) {
779779 // orbit is out of bounds
780- LOG (info) << " query timestamp " << (long )timestamp << " out of bounds; Just returning the global rate" ;
781- return std::make_pair (/* global mean rate*/ calcRate (0 , mScalerRecordO2 .size () - 1 ), /* current rate */ -1 );
780+ if (qc == 0 ) {
781+ LOG (info) << " query timestamp " << (long )timestamp << " before first record; Just returning the global rate" ;
782+ return std::make_pair (/* global mean rate*/ calcRate (0 , mScalerRecordO2 .size () - 1 ), /* current rate */ -1 );
783+ } else {
784+ LOG (info) << " query timestamp " << (long )timestamp << " before first record; Returning the first rate" ;
785+ return std::make_pair (/* global mean rate*/ calcRate (0 , mScalerRecordO2 .size () - 1 ), /* first rate */ calcRate (0 ,1 ) );
786+ }
787+ } else if (nextindex == mScalerRecordO2 .size ()){
788+ if (qc == 0 ) {
789+ LOG (info) << " query timestamp " << (long )timestamp << " after last record; Just returning the global rate" ;
790+ return std::make_pair (/* global mean rate*/ calcRate (0 , mScalerRecordO2 .size () - 1 ), /* current rate */ -1 );
791+ } else {
792+ LOG (info) << " query timestamp " << (long )timestamp << " after last record; Returning the last rate" ;
793+ return std::make_pair (/* global mean rate*/ calcRate (0 , mScalerRecordO2 .size () - 1 ), /* last rate */ calcRate (mScalerRecordO2 .size () - 2 , mScalerRecordO2 .size () - 1 ) );
794+ }
782795 } else {
783-
784796 return std::make_pair (/* global mean rate*/ calcRate (0 , mScalerRecordO2 .size () - 1 ), /* current rate */ calcRate (nextindex - 1 , nextindex));
785797 }
786798 return std::make_pair (-1 ., -1 .);
0 commit comments