Skip to content

Commit

Permalink
Correction to TOA calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
horohoo committed Oct 31, 2024
1 parent 96f6980 commit 6011bf0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Hcal/src/Hcal/HcalRecProducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ double HcalRecProducer::getTOA(
// get toa relative to the startBX
double toaRelStartBX(0.), maxMeas{0.};
int toaSample(0), maxSample(0), iADC(0);
bool noTOA = true;
for (int i_sample{0}; i_sample < digi.size(); i_sample++) {
auto sample{digi.at(i_sample)};
if (sample.toa() > 0) {
noTOA = false;
toaRelStartBX = sample.toa() * (clock_cycle_ / 1024); // ns
// find in which ADC sample the TOA was taken
toaSample = iADC;
Expand All @@ -103,11 +105,20 @@ double HcalRecProducer::getTOA(
iADC++;
}

int sign = 1;
if ((maxSample - toaSample) <= 0) {
sign = -1;
}

// time w.r.t to the peak
double toa = (maxSample - toaSample) * clock_cycle_ - toaRelStartBX;
double toa = (abs(maxSample - toaSample) * clock_cycle_ - toaRelStartBX)*sign;

// time w.r.t to the SOI
toa += ((int)iSOI - maxSample) * clock_cycle_;
//toa += ((int)iSOI - maxSample) * clock_cycle_;

if (noTOA) {
toa = 0.;
}

return toa;
}
Expand Down

0 comments on commit 6011bf0

Please sign in to comment.