Skip to content

Commit 157977f

Browse files
Dmitri Peresunkoshahor02
authored andcommitted
Fixing module numbering; adjust cell address; handling pedestal runs
1 parent 80003af commit 157977f

File tree

17 files changed

+99
-191
lines changed

17 files changed

+99
-191
lines changed

DataFormats/Detectors/PHOS/include/DataFormatsPHOS/Cell.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ namespace o2
2525
namespace phos
2626
{
2727

28-
constexpr int kNmaxCell = 12545; //56*64*3.5 + 1
28+
constexpr int kOffset = 1792; // offset due to missing half of module 1: 56*32
29+
constexpr int kNmaxCell = 14337; //56*64*4 + 1 - kOffset
2930
constexpr float kEnergyConv = 0.005; //Energy digitization step
3031
constexpr float kTimeAccuracy = 0.3e-9; //Time digitization step
3132
constexpr float kTime0 = 150.e-9; //-Minimal time to be digitized

DataFormats/Detectors/PHOS/src/Cell.cxx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
using namespace o2::phos;
1616

1717
// split 40 bits as following:
18-
// 14 bits: address, normal cells. starting from NmaxCell=3.5*56*64+1=12 544 will be TRU cells (3 136 addresses)
18+
// 14 bits: address, normal cells. starting from NmaxCell=3.5*56*64+1=14 337 will be TRU cells (3 136 addresses)
1919
// 10 bits: time
2020
// 15 bits: Energy
2121
// 1 bit: High/low gain
@@ -35,20 +35,18 @@ Cell::Cell(short absId, float energy, float time, ChannelType_t ctype)
3535
void Cell::setAbsId(short absId)
3636
{
3737
//14 bits available
38-
if (absId > kNmaxCell || absId < 0) {
38+
if (absId > kNmaxCell || absId < kOffset) {
3939
absId = kNmaxCell;
4040
}
41-
ULong_t t = (ULong_t)absId;
41+
ULong_t t = (ULong_t)(absId - kOffset);
4242

4343
ULong_t b = getLong() & 0xffffffc000; // 1111 1111 1111 1111 1111 1111 1100 0000 0000 0000
4444
mBits = b + t;
4545
}
4646
void Cell::setTRUId(short absId)
4747
{
4848
//14 bits available
49-
absId += kNmaxCell + 1;
50-
// if (absId > kNmaxCell || absId < 0)
51-
// absId = kNmaxCell;
49+
absId += kNmaxCell - kOffset + 1;
5250
ULong_t t = (ULong_t)absId;
5351

5452
ULong_t b = getLong() & 0xffffffc000; // 1111 1111 1111 1111 1111 1111 1100 0000 0000 0000
@@ -58,7 +56,7 @@ void Cell::setTRUId(short absId)
5856
short Cell::getAbsId() const
5957
{
6058
ULong_t t = getLong() & 0x3fff; //14 bits
61-
short a = (short)t;
59+
short a = kOffset + (short)t;
6260
if (a <= kNmaxCell) {
6361
return a;
6462
} else {
@@ -69,7 +67,7 @@ short Cell::getAbsId() const
6967
short Cell::getTRUId() const
7068
{
7169
ULong_t t = getLong() & 0x3fff; //14 bits
72-
short a = (short)t;
70+
short a = kOffset + (short)t;
7371
if (a > kNmaxCell) {
7472
return a - kNmaxCell - 1;
7573
} else {
@@ -182,7 +180,7 @@ Bool_t Cell::getTRU() const
182180
{
183181
ULong_t t = getLong();
184182
t &= 0x3fff; //14 bits
185-
int a = (int)t;
183+
int a = kOffset + (int)t;
186184
return (a > kNmaxCell); //TRU addresses
187185
}
188186

DataFormats/Detectors/PHOS/test/testCell.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(Cell_test)
2929
{
3030
Cell c;
3131
c.setTime(0.);
32-
for (short j = 0; j < 12544; j++) {
32+
for (short j = 1793; j < 14337; j++) {
3333
c.setAbsId(j);
3434
BOOST_CHECK_EQUAL(c.getAbsId(), j);
3535
BOOST_CHECK_EQUAL(c.getTRUId(), 0);
@@ -47,12 +47,12 @@ BOOST_AUTO_TEST_CASE(Cell_test)
4747
BOOST_CHECK_EQUAL(c.getTRU(), true);
4848
}
4949

50-
c.setAbsId(0);
50+
c.setAbsId(1793);
5151
std::vector<float> times = {-150.e-9, -10.5e-9, -0.55e-9, 0.35e-9, 2.1e-9, 3.2e-9, 4.e-9, 5.e-9, 6.e-9, 7.e-9, 8.e-9, 9.e-9, 10.e-9, 20.e-9, 50.e-9, 100.e-9, 150.e-9};
5252

5353
for (float t : times) {
5454
c.setTime(t);
55-
BOOST_CHECK_EQUAL(c.getAbsId(), 0);
55+
BOOST_CHECK_EQUAL(c.getAbsId(), 1793);
5656
BOOST_CHECK_SMALL(c.getTime() - t, kTimeAccuracy);
5757
BOOST_CHECK_SMALL(c.getEnergy() - float(0), kEnergyConv);
5858
BOOST_CHECK_EQUAL(c.getLowGain(), true);
@@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(Cell_test)
6363

6464
for (float e : energies) {
6565
c.setEnergy(e);
66-
BOOST_CHECK_EQUAL(c.getAbsId(), 0);
66+
BOOST_CHECK_EQUAL(c.getAbsId(), 1793);
6767
BOOST_CHECK_SMALL(c.getTime() - float(0.), kTimeAccuracy);
6868
BOOST_CHECK_SMALL(e - c.getEnergy(), kEnergyConv); // Require 5 MeV resolution
6969
BOOST_CHECK_EQUAL(c.getLowGain(), true);
@@ -72,15 +72,15 @@ BOOST_AUTO_TEST_CASE(Cell_test)
7272
c.setEnergy(0);
7373

7474
c.setLowGain();
75-
BOOST_CHECK_EQUAL(c.getAbsId(), 0);
75+
BOOST_CHECK_EQUAL(c.getAbsId(), 1793);
7676
BOOST_CHECK_SMALL(c.getTime() - float(0.), kTimeAccuracy);
7777
BOOST_CHECK_SMALL(c.getEnergy() - float(0), kEnergyConv);
7878
BOOST_CHECK_EQUAL(c.getLowGain(), true);
7979
BOOST_CHECK_EQUAL(c.getHighGain(), false);
8080
BOOST_CHECK_EQUAL(c.getTRU(), false);
8181

8282
c.setHighGain();
83-
BOOST_CHECK_EQUAL(c.getAbsId(), 0);
83+
BOOST_CHECK_EQUAL(c.getAbsId(), 1793);
8484
BOOST_CHECK_SMALL(c.getTime() - float(0.), kTimeAccuracy);
8585
BOOST_CHECK_SMALL(c.getEnergy() - float(0), kEnergyConv);
8686
BOOST_CHECK_EQUAL(c.getLowGain(), false);
1.96 KB
Binary file not shown.

Detectors/PHOS/base/src/Geometry.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ ClassImp(Geometry);
2020
// module numbering:
2121
// start from module 0 (non-existing), 1 (half-module), 2 (bottom),... 4(highest)
2222
// absId:
23-
// start from 1 till 5*64*56. Numbering in each module starts at bottom left and first go in z direction:
23+
// start from 1 till 4*64*56. Numbering in each module starts at bottom left and first go in z direction:
2424
// 56 112 3584
2525
// ... ... ...
2626
// 1 57 ...3529
27-
// relid[3]: (module number[0...4], iphi[1...64], iz[1...56])
27+
// relid[3]: (module number[0...3], iphi[1...64], iz[1...56])
2828

2929
// these initialisations are needed for a singleton
3030
Geometry* Geometry::sGeom = nullptr;
@@ -131,8 +131,8 @@ void Geometry::absIdToRelPosInModule(short absId, float& x, float& z)
131131
char relid[3];
132132
absToRelNumbering(absId, relid);
133133

134-
x = (relid[1] - 28 - 0.5) * cellStep;
135-
z = (relid[2] - 32 - 0.5) * cellStep;
134+
x = (relid[1] - 32 - 0.5) * cellStep;
135+
z = (relid[2] - 28 - 0.5) * cellStep;
136136
}
137137
bool Geometry::relToAbsNumbering(const char* relId, short& absId)
138138
{
@@ -151,7 +151,7 @@ void Geometry::relPosToAbsId(char module, float x, float z, short& absId)
151151
{
152152
const float cellStep = 2.25;
153153

154-
char relid[3] = {module, char(x / cellStep + 28.5), char(z / cellStep + 32.5)};
154+
char relid[3] = {module, static_cast<char>(ceil(x / cellStep + 32.5)), static_cast<char>(ceil(z / cellStep + 28.5))};
155155
relToAbsNumbering(relid, absId);
156156
}
157157

Detectors/PHOS/base/src/Mapping.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ Mapping::ErrorStatus Mapping::setMapping()
119119
LOG(FATAL) << "Maximal HW address in file " << maxHWAddress << "larger than array size " << NMaxHWAddress << "for /Mod" << m << "RCU" << i << ".data is wrong: no maxHWAddress";
120120
return kNotInitialized;
121121
}
122-
123122
for (short ich = 0; ich < numberOfChannels; ich++) { // 1792 = 2*896 channels connected to each RCU
124123
int hwAddress;
125124
if (!(*fIn >> hwAddress)) {
@@ -152,7 +151,7 @@ Mapping::ErrorStatus Mapping::setMapping()
152151
// relid[2] = Column number inside a PHOS module (Z coordinate)
153152
short ddl = 4 * m + i - 2;
154153

155-
char relid[3] = {(char)m, (char)row, (char)col};
154+
char relid[3] = {static_cast<char>(m), static_cast<char>(row + 1), static_cast<char>(col + 1)};
156155
short absId;
157156
geom->relToAbsNumbering(relid, absId);
158157

@@ -163,7 +162,6 @@ Mapping::ErrorStatus Mapping::setMapping()
163162

164163
mAbsId[ddl][hwAddress] = absId;
165164
mCaloFlag[ddl][hwAddress] = (CaloFlag)caloFlag;
166-
167165
mAbsToHW[absId][caloFlag][0] = ddl;
168166
mAbsToHW[absId][caloFlag][1] = hwAddress;
169167
}

Detectors/PHOS/calib/include/PHOSCalib/BadChannelMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class BadChannelMap
132132

133133
private:
134134
static constexpr short NCHANNELS = 14337; ///< Number of channels starting from 1 (4*64*56+1
135-
static constexpr short OFFSET = 5377; ///< Non-existing channels 56*64*1.5+1
135+
static constexpr short OFFSET = 1793; ///< Non-existing channels 56*64*0.5+1
136136
std::bitset<NCHANNELS> mBadCells; ///< Container for bad cells, 1 means bad sell
137137

138138
ClassDefNV(BadChannelMap, 1);

Detectors/PHOS/calib/include/PHOSCalib/CalibParams.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class CalibParams
107107

108108
private:
109109
static constexpr short NCHANNELS = 14337; ///< Number of channels starting from 1
110-
static constexpr short OFFSET = 5377; ///< Non-existing channels 56*64*1.5+1
110+
static constexpr short OFFSET = 1793; ///< Non-existing channels 56*64*0.5+1
111111
std::array<float, NCHANNELS> mGainCalib; ///< Container for the gain calibration coefficients
112112
std::array<float, NCHANNELS> mHGLGRatio; ///< Container for the High Gain to Low Gain ratios
113113
std::array<float, NCHANNELS> mHGTimeCalib; ///< Container for the High Gain time calibration coefficients

Detectors/PHOS/calib/include/PHOSCalib/Pedestals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Pedestals
8383

8484
private:
8585
static constexpr short NCHANNELS = 14337; ///< Number of channels starting from 1
86-
static constexpr short OFFSET = 5377; ///< Non-existing channels 56*64*1.5+1
86+
static constexpr short OFFSET = 1793; ///< Non-existing channels 56*64*1.5+1
8787
std::array<unsigned char, NCHANNELS> mHGPedestals; ///< Container for pedestals
8888
std::array<unsigned char, NCHANNELS> mLGPedestals; ///< Container for pedestals
8989

Detectors/PHOS/reconstruction/include/PHOSReconstruction/Clusterer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class Clusterer
7474

7575
protected:
7676
Geometry* mPHOSGeom = nullptr; ///< PHOS geometry
77-
const CalibParams* mCalibParams = nullptr; //! Calibration coefficients
78-
const BadChannelMap* mBadMap = nullptr; //! Calibration coefficients
77+
std::unique_ptr<CalibParams> mCalibParams; ///! Calibration coefficients
78+
std::unique_ptr<BadChannelMap> mBadMap; ///! Bad map
7979

8080
std::vector<FullCluster> mClusters; ///< internal vector of clusters
8181
int mFirstDigitInEvent; ///< Range of digits from one event

0 commit comments

Comments
 (0)