Skip to content

Commit 70df0cd

Browse files
committed
Several bug fixes in PHOS calibrator
* avoid integer overflow * initialize variables * fix other evident logic bugs Hopefully fixes a Exception while running: bitset::test: __position (which is 18446744073709548060) >= _Nb (which is 14337) observed in the ARM CI.
1 parent 6db969d commit 70df0cd

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Detectors/PHOS/calib/include/PHOSCalibWorkflow/TurnOnHistos.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include <bitset>
2323
#include <array>
24-
#include "TObject.h"
24+
#include "TObject.h" // # RTYpe ?
2525

2626
namespace o2
2727
{
@@ -76,7 +76,7 @@ class TurnOnHistos
7676
/// \param bitset with channels fired in event
7777
void fillFiredMap(const std::bitset<NCHANNELS>& bs)
7878
{
79-
for (short i = NCHANNELS; --i;) {
79+
for (size_t i = 0; i < NCHANNELS; ++i) {
8080
if (bs[i]) {
8181
mGoodMap[i]++;
8282
}
@@ -87,7 +87,7 @@ class TurnOnHistos
8787
/// \param bitset with channels fired in event
8888
void fillNoisyMap(const std::bitset<NCHANNELS>& bs)
8989
{
90-
for (short i = NCHANNELS; --i;) {
90+
for (size_t i = 0; i < NCHANNELS; ++i) {
9191
if (bs[i]) {
9292
mNoisyMap[i]++;
9393
}

Detectors/PHOS/calib/src/PHOSTurnonCalibrator.cxx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PHOSTurnonSlot::PHOSTurnonSlot(bool useCCDB) : mUseCCDB(useCCDB)
3636
PHOSTurnonSlot::PHOSTurnonSlot(const PHOSTurnonSlot& other)
3737
{
3838
mUseCCDB = other.mUseCCDB;
39-
mRunStartTime = other.mUseCCDB;
39+
mRunStartTime = other.mRunStartTime;
4040
mFiredTiles.reset();
4141
mNoisyTiles.reset();
4242
mTurnOnHistos = std::make_unique<TurnOnHistos>();
@@ -91,23 +91,25 @@ void PHOSTurnonSlot::scanClusters(const gsl::span<const Cell>& cells, const Trig
9191
for (int i = firstCellInEvent; i < lastCellInEvent; i++) {
9292
const Cell& c = cells[i];
9393
if (c.getTRU()) {
94-
mNoisyTiles.set(c.getTRUId() - Geometry::getTotalNCells() - 1);
94+
auto channel = c.getTRUId() - Geometry::getTotalNCells() - 1;
95+
if (channel >= 0) {
96+
mNoisyTiles.set(channel);
97+
}
9598
}
9699
}
97100

98101
// Copy to have good and noisy map
99102
mFiredTiles.reset();
100-
char mod;
101-
float x, z;
102-
short ddl;
103+
float x{0}, z{0};
104+
short ddl{0};
103105
int firstCluInEvent = clutr.getFirstEntry();
104106
int lastCluInEvent = firstCluInEvent + clutr.getNumberOfObjects();
105107
for (int i = firstCluInEvent; i < lastCluInEvent; i++) {
106108
const Cluster& clu = clusters[i];
107109
if (clu.getEnergy() < 1.e-4) {
108110
continue;
109111
}
110-
mod = clu.module();
112+
char mod = clu.module();
111113
clu.getLocalPosition(x, z);
112114
// TODO: do we need separate 2x2 and 4x4 spectra? Switch?
113115
// short truId2x2 = Geometry::relPosToTruId(mod, x, z, 0);
@@ -123,7 +125,7 @@ void PHOSTurnonSlot::scanClusters(const gsl::span<const Cell>& cells, const Trig
123125
// Fill final good and noisy maps
124126
mTurnOnHistos->fillFiredMap(mFiredTiles);
125127
mNoisyTiles ^= mFiredTiles;
126-
mTurnOnHistos->fillNoisyMap(mFiredTiles);
128+
mTurnOnHistos->fillNoisyMap(mNoisyTiles);
127129
}
128130
//==============================================
129131

0 commit comments

Comments
 (0)