Skip to content

Commit

Permalink
fixing rare condition when reading tof calib correction
Browse files Browse the repository at this point in the history
  • Loading branch information
noferini authored and sawenzel committed Nov 29, 2023
1 parent b48ea64 commit 4c506b1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion DataFormats/Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ float CalibTimeSlewingParamTOF::evalTimeSlewing(int channel, float totIn) const
}

int n = (*(mChannelStart[sector]))[channel];
int nFirst = n;

if (n < 0) {
return (*(mGlobalOffset[sector]))[channel];
}
Expand Down Expand Up @@ -197,10 +199,14 @@ float CalibTimeSlewingParamTOF::evalTimeSlewing(int channel, float totIn) const
return (float)((*(mTimeSlewing[sector]))[n].second + (*(mGlobalOffset[sector]))[channel]); // use the last value stored for that channel
}

if (n < nFirst) { // this is before the first point (probably tot = 0 calibration is missing)
return (*(mGlobalOffset[sector]))[channel];
}

float w1 = (float)(tot - (*(mTimeSlewing[sector]))[n].first);
float w2 = (float)((*(mTimeSlewing[sector]))[n + 1].first - tot);

return (float)((*(mGlobalOffset[sector]))[channel] + (((*(mTimeSlewing[sector]))[n].second * w2 + (*(mTimeSlewing[sector]))[n + 1].second * w1) / ((*(mTimeSlewing[sector]))[n + 1].first - (*(mTimeSlewing[sector]))[n].first)));
return (float)((*(mGlobalOffset[sector]))[channel] + (((*(mTimeSlewing[sector]))[n].second * w2 + (*(mTimeSlewing[sector]))[n + 1].second * w1) / (w1 + w2)));
}
//______________________________________________
void CalibTimeSlewingParamTOF::setTimeSlewingInfo(int channel, float offsetold, int nold, const unsigned short* oldtot, const short* olddt, int nnew, const unsigned short* newtot, const short* newdt)
Expand Down

0 comments on commit 4c506b1

Please sign in to comment.