Skip to content

Commit e235636

Browse files
mfasDashahor02
authored andcommitted
[EMCAL-1046] Swap HG and LG at overflow cut
The reconstruction swap HG and LG at 950 ADC counts in order to avoid saturation of the HG (i.e. due to pedestals). The compression instead used the 10 bit ADC range (1024). In the encoding LG cells in that energy range are encoded with negative values and therefore are out-of-range. In addition introduce a 200 MeV safety margin for the LG in order to not truncate for cells which are slightly below the saturation offset due to floating point imprecision.
1 parent 87edefe commit e235636

File tree

4 files changed

+101
-3
lines changed

4 files changed

+101
-3
lines changed

DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/Cell.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class Cell
6060
public:
6161
enum class EncoderVersion {
6262
EncodingV0,
63-
EncodingV1
63+
EncodingV1,
64+
EncodingV2
6465
};
6566
/// \brief Default constructor
6667
Cell() = default;
@@ -202,7 +203,7 @@ class Cell
202203
/// the limits is provided the energy is
203204
/// set to the limits (0 in case of negative
204205
/// energy, 250. in case of energies > 250 GeV)
205-
uint16_t getEnergyEncoded(EncoderVersion version = EncoderVersion::EncodingV1) const;
206+
uint16_t getEnergyEncoded(EncoderVersion version = EncoderVersion::EncodingV2) const;
206207

207208
/// \brief Get encoded bit representation of cell type (for CTF)
208209
/// \return Encoded bit representation
@@ -218,10 +219,14 @@ class Cell
218219
static uint16_t encodeTime(float timestamp);
219220
static uint16_t encodeEnergyV0(float energy);
220221
static uint16_t encodeEnergyV1(float energy, ChannelType_t celltype);
222+
static uint16_t encodeEnergyV2(float energy, ChannelType_t celltype);
221223
static uint16_t V0toV1(uint16_t energybits, ChannelType_t celltype);
224+
static uint16_t V0toV2(uint16_t energybits, ChannelType_t celltype);
225+
static uint16_t V1toV2(uint16_t energybits, ChannelType_t celltype);
222226
static float decodeTime(uint16_t timestampBits);
223227
static float decodeEnergyV0(uint16_t energybits);
224228
static float decodeEnergyV1(uint16_t energybits, ChannelType_t celltype);
229+
static float decodeEnergyV2(uint16_t energybits, ChannelType_t celltype);
225230

226231
private:
227232
/// \brief Set cell energy from encoded bit representation (from CTF)

DataFormats/Detectors/EMCAL/src/Cell.cxx

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ const float
4444
ENERGY_RESOLUTION_TRU = ENERGY_TRUNCATION / ENERGY_BITS,
4545
ENERGY_RESOLUTION_LEDMON = ENERGY_TRUNCATION / ENERGY_BITS;
4646
}
47+
48+
namespace v2
49+
{
50+
const float
51+
ENERGY_BITS = static_cast<float>(0x3FFF),
52+
SAFETYMARGIN = 0.2,
53+
HGLGTRANSITION = o2::emcal::constants::OVERFLOWCUT * o2::emcal::constants::EMCAL_ADCENERGY,
54+
OFFSET_LG = HGLGTRANSITION - SAFETYMARGIN,
55+
ENERGY_TRUNCATION = 250.,
56+
ENERGY_RESOLUTION_LG = (ENERGY_TRUNCATION - OFFSET_LG) / ENERGY_BITS,
57+
ENERGY_RESOLUTION_HG = HGLGTRANSITION / ENERGY_BITS,
58+
ENERGY_RESOLUTION_TRU = ENERGY_TRUNCATION / ENERGY_BITS,
59+
ENERGY_RESOLUTION_LEDMON = ENERGY_TRUNCATION / ENERGY_BITS;
60+
61+
}
4762
} // namespace EnergyEncoding
4863

4964
namespace DecodingV0
@@ -87,6 +102,10 @@ uint16_t Cell::getEnergyEncoded(EncoderVersion version) const
87102
case EncoderVersion::EncodingV1:
88103
energyBits = encodeEnergyV1(mEnergy, mChannelType);
89104
break;
105+
106+
case EncoderVersion::EncodingV2:
107+
energyBits = encodeEnergyV2(mEnergy, mChannelType);
108+
break;
90109
}
91110
return energyBits;
92111
}
@@ -105,6 +124,9 @@ void Cell::setEnergyEncoded(uint16_t energyBits, uint16_t channelTypeBits, Encod
105124
case EncoderVersion::EncodingV1:
106125
mEnergy = decodeEnergyV1(energyBits, static_cast<ChannelType_t>(channelTypeBits));
107126
break;
127+
case EncoderVersion::EncodingV2:
128+
mEnergy = decodeEnergyV2(energyBits, static_cast<ChannelType_t>(channelTypeBits));
129+
break;
108130
}
109131
}
110132

@@ -214,12 +236,55 @@ uint16_t Cell::encodeEnergyV1(float energy, ChannelType_t celltype)
214236
return static_cast<uint16_t>(std::round((truncatedEnergy - energyOffset) / resolutionApplied));
215237
};
216238

239+
uint16_t Cell::encodeEnergyV2(float energy, ChannelType_t celltype)
240+
{
241+
double truncatedEnergy = energy;
242+
if (truncatedEnergy < 0.) {
243+
truncatedEnergy = 0.;
244+
} else if (truncatedEnergy > EnergyEncoding::v2::ENERGY_TRUNCATION) {
245+
truncatedEnergy = EnergyEncoding::v2::ENERGY_TRUNCATION;
246+
}
247+
float resolutionApplied = 0., energyOffset = 0.;
248+
switch (celltype) {
249+
case ChannelType_t::HIGH_GAIN: {
250+
resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_HG;
251+
break;
252+
}
253+
case ChannelType_t::LOW_GAIN: {
254+
resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LG;
255+
energyOffset = EnergyEncoding::v2::OFFSET_LG;
256+
break;
257+
}
258+
case ChannelType_t::TRU: {
259+
resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_TRU;
260+
break;
261+
}
262+
case ChannelType_t::LEDMON: {
263+
resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LEDMON;
264+
break;
265+
}
266+
}
267+
return static_cast<uint16_t>(std::round((truncatedEnergy - energyOffset) / resolutionApplied));
268+
};
269+
217270
uint16_t Cell::V0toV1(uint16_t energyBits, ChannelType_t celltype)
218271
{
219272
auto decodedEnergy = decodeEnergyV0(energyBits);
220273
return encodeEnergyV1(decodedEnergy, celltype);
221274
}
222275

276+
uint16_t Cell::V0toV2(uint16_t energyBits, ChannelType_t celltype)
277+
{
278+
auto decodedEnergy = decodeEnergyV0(energyBits);
279+
return encodeEnergyV2(decodedEnergy, celltype);
280+
}
281+
282+
uint16_t Cell::V1toV2(uint16_t energyBits, ChannelType_t celltype)
283+
{
284+
auto decodedEnergy = decodeEnergyV1(energyBits, celltype);
285+
return encodeEnergyV2(decodedEnergy, celltype);
286+
}
287+
223288
float Cell::decodeTime(uint16_t timestampBits)
224289
{
225290
return (static_cast<float>(timestampBits) * TimeEncoding::TIME_RESOLUTION) - TimeEncoding::TIME_SHIFT;
@@ -256,6 +321,32 @@ float Cell::decodeEnergyV1(uint16_t energyBits, ChannelType_t celltype)
256321
return (static_cast<float>(energyBits) * resolutionApplied) + energyOffset;
257322
}
258323

324+
float Cell::decodeEnergyV2(uint16_t energyBits, ChannelType_t celltype)
325+
{
326+
float resolutionApplied = 0.,
327+
energyOffset = 0.;
328+
switch (celltype) {
329+
case ChannelType_t::HIGH_GAIN: {
330+
resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_HG;
331+
break;
332+
}
333+
case ChannelType_t::LOW_GAIN: {
334+
resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LG;
335+
energyOffset = EnergyEncoding::v2::OFFSET_LG;
336+
break;
337+
}
338+
case ChannelType_t::TRU: {
339+
resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_TRU;
340+
break;
341+
}
342+
case ChannelType_t::LEDMON: {
343+
resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LEDMON;
344+
break;
345+
}
346+
}
347+
return (static_cast<float>(energyBits) * resolutionApplied) + energyOffset;
348+
}
349+
259350
void Cell::PrintStream(std::ostream& stream) const
260351
{
261352
stream << "EMCAL Cell: Type " << getType() << ", Energy " << getEnergy() << ", Time " << getTimeStamp() << ", Tower " << getTower();

Detectors/EMCAL/reconstruction/include/EMCALReconstruction/CTFCoder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ o2::ctf::CTFIOSize CTFCoder::decode(const CTF::base& ec, VTRG& trigVec, VCELL& c
169169
Cell::EncoderVersion encodingversion = o2::emcal::Cell::EncoderVersion::EncodingV0;
170170
if (header.majorVersion == 1 && header.minorVersion == 1) {
171171
encodingversion = o2::emcal::Cell::EncoderVersion::EncodingV1;
172+
} else if (header.majorVersion == 1 && header.minorVersion == 2) {
173+
encodingversion = o2::emcal::Cell::EncoderVersion::EncodingV2;
172174
}
173175

174176
uint32_t firstEntry = 0, cellCount = 0;

Detectors/EMCAL/reconstruction/src/CTFCoder.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ void CTFCoder::assignDictVersion(o2::ctf::CTFDictHeader& h) const
6666
h = mExtHeader;
6767
} else {
6868
h.majorVersion = 1;
69-
h.minorVersion = 1;
69+
h.minorVersion = 2;
7070
}
7171
}

0 commit comments

Comments
 (0)