Skip to content

Commit f965e3f

Browse files
sevdokimshahor02
authored andcommitted
Fix CPV calibration objects
1 parent aacf2cb commit f965e3f

7 files changed

Lines changed: 59 additions & 34 deletions

File tree

DataFormats/Detectors/CPV/include/DataFormatsCPV/BadChannelMap.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,28 @@ class BadChannelMap
9494
/// Only bad or warm cells are added to the container. In case
9595
/// the mask type is GOOD_CELL, the entry is removed from the
9696
/// container if present before, otherwise the cell is ignored.
97-
void addBadChannel(unsigned short channelID) { mBadCells.set(channelID); } //set bit to true
97+
void addBadChannel(unsigned short channelID)
98+
{
99+
if (channelID < NCHANNELS)
100+
mBadCells.set(channelID);
101+
} //set bit to true
98102

99103
/// \brief Mark channel as good
100104
/// \param channelID Absolute ID of the channel
101105
///
102106
/// Setting channel as good.
103-
void setChannelGood(unsigned short channelID) { mBadCells.set(channelID, false); }
107+
void setChannelGood(unsigned short channelID)
108+
{
109+
if (channelID < NCHANNELS)
110+
mBadCells.set(channelID, false);
111+
}
104112

105113
/// \brief Get the status of a certain cell
106114
/// \param channelID channel for which to obtain the channel status
107115
/// \return true if good channel
108116
///
109117
/// Provide the mask status of a cell.
110-
bool isChannelGood(unsigned short channelID) const { return !mBadCells.test(channelID); }
118+
bool isChannelGood(unsigned short channelID) const { return channelID < NCHANNELS ? !mBadCells.test(channelID) : false; }
111119

112120
/// \brief Convert map into 2D histogram representation
113121
/// \param mod Module number

DataFormats/Detectors/CPV/include/DataFormatsCPV/CalibParams.h

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

2222
#include <array>
2323
#include "TObject.h"
24+
#include "CPVBase/Geometry.h"
2425

2526
class TH2;
2627

@@ -45,12 +46,16 @@ class CalibParams
4546
/// \brief Get High Gain energy calibration coefficients
4647
/// \param cellID Absolute ID of cell
4748
/// \return high gain energy calibration coefficient of the cell
48-
float getGain(unsigned short cellID) const { return mGainCalib[cellID]; }
49+
float getGain(unsigned short cellID) const { return cellID < o2::cpv::Geometry::kNCHANNELS ? mGainCalib[cellID] : 0.0; }
4950

5051
/// \brief Set High Gain energy calibration coefficient
5152
/// \param cellID Absolute ID of cell
5253
/// \param c is the calibration coefficient
53-
void setGain(unsigned short cellID, float c) { mGainCalib[cellID] = c; }
54+
void setGain(unsigned short cellID, float c)
55+
{
56+
if (cellID < o2::cpv::Geometry::kNCHANNELS)
57+
mGainCalib[cellID] = c;
58+
}
5459

5560
/// \brief Set High Gain energy calibration coefficients for one module in the form of 2D histogram
5661
/// \param 2D(64,56) histogram with calibration coefficients

DataFormats/Detectors/CPV/include/DataFormatsCPV/Pedestals.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,22 @@ class Pedestals
4646
/// \brief Get pedestal
4747
/// \param cellID Absolute ID of cell
4848
/// \return pedestal for the cell
49-
short getPedestal(short cellID) const { return short(mPedestals.at(cellID)); }
50-
float getPedSigma(short cellID) const { return mPedSigmas.at(cellID); }
49+
short getPedestal(short cellID) const { return ((cellID >= 0) && (cellID < NCHANNELS)) ? short(mPedestals.at(cellID)) : 0; }
50+
float getPedSigma(short cellID) const { return ((cellID >= 0) && (cellID < NCHANNELS)) ? mPedSigmas.at(cellID) : 0.0; }
5151

5252
/// \brief Set pedestal
5353
/// \param cellID Absolute ID of cell
5454
/// \param c is the pedestal (expected to be in range <254)
55-
void setPedestal(short cellID, short c) { mPedestals[cellID] = (c > 0 && c < 511) ? c : mPedestals[cellID]; }
56-
void setPedSigma(short cellID, float c) { mPedSigmas[cellID] = (c > 0) ? c : mPedSigmas[cellID]; }
55+
void setPedestal(short cellID, short c)
56+
{
57+
if ((cellID >= 0) && (cellID < NCHANNELS))
58+
mPedestals[cellID] = (c > 0 && c < 511) ? c : mPedestals[cellID];
59+
}
60+
void setPedSigma(short cellID, float c)
61+
{
62+
if ((cellID >= 0) && (cellID < NCHANNELS))
63+
mPedSigmas[cellID] = (c > 0) ? c : mPedSigmas[cellID];
64+
}
5765

5866
/// \brief Set pedestals from 1D histogram with cell absId in x axis
5967
/// \param 1D(NCHANNELS) histogram with calibration coefficients

DataFormats/Detectors/CPV/src/BadChannelMap.cxx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,32 @@
2020

2121
using namespace o2::cpv;
2222

23-
BadChannelMap::BadChannelMap(short /*dummy*/)
23+
BadChannelMap::BadChannelMap(short test)
2424
{
25+
//reset all channels to be good
26+
mBadCells.reset();
2527

26-
//Mark few channels as bad for test peurposes
27-
for (short i = 0; i < 60; i++) {
28-
//module 2
29-
unsigned short channelID = 3584 + i * 57;
30-
mBadCells.set(channelID);
31-
channelID = 3640 + i * 55;
32-
mBadCells.set(channelID);
33-
}
28+
if (test == 2) {
29+
//Mark few channels as bad for test peurposes
30+
for (short i = 0; i < 60; i++) {
31+
//module 2
32+
unsigned short channelID = 3584 + i * 57;
33+
mBadCells.set(channelID);
34+
channelID = 3640 + i * 55;
35+
mBadCells.set(channelID);
36+
}
3437

35-
for (short i = 0; i < 16; i++) {
36-
//module 3
37-
unsigned short channelID = 8972 + i * 57;
38-
mBadCells.set(channelID);
39-
channelID = 8092 + i * 57;
40-
mBadCells.set(channelID);
41-
channelID = 8147 + i * 55;
42-
mBadCells.set(channelID);
43-
channelID = 9059 + i * 55;
44-
mBadCells.set(channelID);
38+
for (short i = 0; i < 16; i++) {
39+
//module 3
40+
unsigned short channelID = 8972 + i * 57;
41+
mBadCells.set(channelID);
42+
channelID = 8092 + i * 57;
43+
mBadCells.set(channelID);
44+
channelID = 8147 + i * 55;
45+
mBadCells.set(channelID);
46+
channelID = 9059 + i * 55;
47+
mBadCells.set(channelID);
48+
}
4549
}
4650
}
4751

DataFormats/Detectors/CPV/src/CalibParams.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ bool CalibParams::setGain(TH2* h, short module)
4040
return false;
4141
}
4242

43-
short relid[3] = {module, 1, 1};
43+
short relid[3] = {module, 0, 0};
4444
unsigned short absId;
4545
for (short ix = 1; ix <= MAXX; ix++) {
46-
relid[1] = ix;
46+
relid[1] = ix - 1;
4747
for (short iz = 1; iz <= MAXZ; iz++) {
48-
relid[2] = iz;
48+
relid[2] = iz - 1;
4949

5050
if (Geometry::relToAbsNumbering(relid, absId)) {
5151
mGainCalib[absId] = h->GetBinContent(ix, iz);

DataFormats/Detectors/CPV/src/Pedestals.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool Pedestals::setPedestals(TH1* h)
4242
<< " exceeds max possible value 511 (limited by CPV electronics)";
4343
continue;
4444
}
45-
mPedestals[i] = short(h->GetBinContent(i));
45+
mPedestals[i - 1] = short(h->GetBinContent(i));
4646
}
4747
return true;
4848
}
@@ -66,7 +66,7 @@ bool Pedestals::setPedSigmas(TH1F* h)
6666
<< " cannot be less than 0";
6767
continue;
6868
}
69-
mPedSigmas[i] = float(h->GetBinContent(i));
69+
mPedSigmas[i - 1] = float(h->GetBinContent(i));
7070
}
7171
return true;
7272
}

Detectors/CPV/workflow/src/RawToDigitConverterSpec.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void RawToDigitConverterSpec::run(framework::ProcessingContext& ctx)
224224
}
225225
digitBuffer.clear();
226226

227-
LOG(INFO) << "[CPVRawToDigitConverter - run] Writing " << mOutputDigits.size() << " digits ...";
227+
LOG(DEBUG) << "[CPVRawToDigitConverter - run] Writing " << mOutputDigits.size() << " digits ...";
228228
ctx.outputs().snapshot(o2::framework::Output{"CPV", "DIGITS", 0, o2::framework::Lifetime::Timeframe}, mOutputDigits);
229229
ctx.outputs().snapshot(o2::framework::Output{"CPV", "DIGITTRIGREC", 0, o2::framework::Lifetime::Timeframe}, mOutputTriggerRecords);
230230
ctx.outputs().snapshot(o2::framework::Output{"CPV", "RAWHWERRORS", 0, o2::framework::Lifetime::Timeframe}, mOutputHWErrors);

0 commit comments

Comments
 (0)