Skip to content

Commit

Permalink
Update ZdcSimpleRecAlgo_Run3.cc
Browse files Browse the repository at this point in the history
Update ZdcSimpleRecAlgo_Run3.cc

Fixed an issue where if statement checking wrong variable to guard against seg fault. Fixed issue by updating associated for loop condition to be less than digi_size. I also updated the chargedweightedtime to check for potential NAN which will now be set to -99.0
  • Loading branch information
matt2275 committed Oct 8, 2024
1 parent 4bc3e62 commit f787df2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions RecoLocalCalo/HcalRecAlgos/src/ZdcSimpleRecAlgo_Run3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ ZDCRecHit ZdcSimpleRecAlgo_Run3::reco0(const QIE10DataFrame& digi,
double ta = 0;
double energySOIp1 = 0;
double ratioSOIp1 = -1.0;
double chargeWeightedTime = 0;
double chargeWeightedTime = -99.0;

double Allnoise = 0;
int noiseslices = 0;
Expand Down Expand Up @@ -223,9 +223,7 @@ ZDCRecHit ZdcSimpleRecAlgo_Run3::reco0(const QIE10DataFrame& digi,

double tmp_energy = 0;
double tmp_TSWeightedEnergy = 0;
for (int ts = 0; ts < nTs_; ++ts) {
if (CurrentTS >= digi_size)
continue;
for (int ts = 0; ts < digi_size; ++ts) {
int capid = digi[ts].capid();

// max sure there are no negative values in time calculation
Expand All @@ -237,7 +235,8 @@ ZDCRecHit ZdcSimpleRecAlgo_Run3::reco0(const QIE10DataFrame& digi,
}
}

chargeWeightedTime = (tmp_TSWeightedEnergy / tmp_energy - 1) * 25.0;
if (tmp_energy > 0)
chargeWeightedTime = (tmp_TSWeightedEnergy / tmp_energy - 1) * 25.0;
auto rh = ZDCRecHit(digi.id(), ampl, time, -99);
rh.setEnergySOIp1(energySOIp1);

Expand Down

0 comments on commit f787df2

Please sign in to comment.