41 HGLGTRANSITION = o2::emcal::constants::EMCAL_HGLGTRANSITION * o2::emcal::constants::EMCAL_ADCENERGY,
54 HGLGTRANSITION = o2::emcal::constants::OVERFLOWCUT * o2::emcal::constants::EMCAL_ADCENERGY,
68 uint16_t mTowerID : 15;
70 uint16_t mEnergy : 14;
71 uint16_t mCellStatus : 2;
78inline DecodingV0::CellDataPacked unpackV0(
const char*
bitfield)
80 DecodingV0::CellDataPacked out{};
81 std::memcpy(&out,
bitfield,
sizeof(out));
86Cell::Cell(
short tower,
float energy,
float timestamp,
ChannelType_t ctype) : mTowerID(tower), mEnergy(energy), mTimestamp(timestamp), mChannelType(ctype)
107 uint16_t energyBits = 0;
126 return static_cast<uint16_t
>(mChannelType);
129void Cell::setEnergyEncoded(uint16_t energyBits, uint16_t channelTypeBits, EncoderVersion
version)
144void Cell::setTimestampEncoded(uint16_t timestampBits)
149void Cell::setTowerIDEncoded(uint16_t towerIDBits)
151 mTowerID = towerIDBits;
154void Cell::setChannelTypeEncoded(uint16_t channelTypeBits)
161 auto bitrepresentation = unpackV0(
bitfield);
163 mTimestamp =
decodeTime(bitrepresentation.mTime);
164 mTowerID = bitrepresentation.mTowerID;
165 mChannelType =
static_cast<ChannelType_t>(bitrepresentation.mCellStatus);
197 auto timestampTruncated = timestamp;
200 if (timestampTruncated < TIME_MIN) {
201 timestampTruncated = TIME_MIN;
202 }
else if (timestampTruncated > TIME_MAX) {
203 timestampTruncated = TIME_MAX;
210 auto truncatedEnergy = energy;
211 if (truncatedEnergy < 0.) {
212 truncatedEnergy = 0.;
213 }
else if (truncatedEnergy > EnergyEncoding::v0::ENERGY_TRUNCATION) {
214 truncatedEnergy = EnergyEncoding::v0::ENERGY_TRUNCATION;
216 return static_cast<uint16_t
>(std::round(truncatedEnergy / EnergyEncoding::v0::ENERGY_RESOLUTION));
221 double truncatedEnergy = energy;
222 if (truncatedEnergy < 0.) {
223 truncatedEnergy = 0.;
224 }
else if (truncatedEnergy > EnergyEncoding::v1::ENERGY_TRUNCATION) {
225 truncatedEnergy = EnergyEncoding::v1::ENERGY_TRUNCATION;
227 float resolutionApplied = 0., energyOffset = 0.;
230 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_HG;
234 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_LG;
235 energyOffset = EnergyEncoding::v1::HGLGTRANSITION;
239 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_TRU;
243 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_LEDMON;
247 return static_cast<uint16_t
>(std::round((truncatedEnergy - energyOffset) / resolutionApplied));
252 double truncatedEnergy = energy;
253 if (truncatedEnergy < 0.) {
254 truncatedEnergy = 0.;
255 }
else if (truncatedEnergy > EnergyEncoding::v2::ENERGY_TRUNCATION) {
256 truncatedEnergy = EnergyEncoding::v2::ENERGY_TRUNCATION;
258 float resolutionApplied = 0., energyOffset = 0.;
261 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_HG;
265 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LG;
266 energyOffset = EnergyEncoding::v2::OFFSET_LG;
270 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_TRU;
274 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LEDMON;
278 return static_cast<uint16_t
>(std::round((truncatedEnergy - energyOffset) / resolutionApplied));
306 return static_cast<float>(energyBits) * EnergyEncoding::v0::ENERGY_RESOLUTION;
311 float resolutionApplied = 0.,
315 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_HG;
319 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_LG;
320 energyOffset = EnergyEncoding::v1::HGLGTRANSITION;
324 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_TRU;
328 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_LEDMON;
332 return (
static_cast<float>(energyBits) * resolutionApplied) + energyOffset;
337 float resolutionApplied = 0.,
341 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_HG;
345 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LG;
346 energyOffset = EnergyEncoding::v2::OFFSET_LG;
350 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_TRU;
354 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LEDMON;
358 return (
static_cast<float>(energyBits) * resolutionApplied) + energyOffset;
EMCAL compressed cell information.
static uint16_t encodeEnergyV2(float energy, ChannelType_t celltype)
static short getTowerFromPackedBitfieldV0(const char *bitfield)
uint16_t getCellTypeEncoded() const
Get encoded bit representation of cell type (for CTF)
static uint16_t encodeTime(float timestamp)
void initializeFromPackedBitfieldV0(const char *bitfield)
static uint16_t V0toV1(uint16_t energybits, ChannelType_t celltype)
uint16_t getTowerIDEncoded() const
Get encoded bit representation of tower ID (for CTF)
void truncate(EncoderVersion version=EncoderVersion::EncodingV1)
Apply compression as done during writing to / reading from CTF.
ChannelType_t getType() const
Get the type of the cell.
Cell()=default
Default constructor.
static ChannelType_t getCellTypeFromPackedBitfieldV0(const char *bitfield)
static uint16_t V1toV2(uint16_t energybits, ChannelType_t celltype)
uint16_t getEnergyEncoded(EncoderVersion version=EncoderVersion::EncodingV2) const
Get encoded bit representation of energy (for CTF)
static float decodeEnergyV1(uint16_t energybits, ChannelType_t celltype)
uint16_t getTimeStampEncoded() const
Get encoded bit representation of timestamp (for CTF)
static uint16_t encodeEnergyV1(float energy, ChannelType_t celltype)
void initialiseFromEncoded(uint16_t towerIDBits, uint16_t timestampBits, uint16_t energyBits, uint16_t celltypeBits, EncoderVersion version=EncoderVersion::EncodingV1)
Initialize cell class from bit representation (for CTF decoding)
float getEnergy() const
Get the energy of the cell.
void PrintStream(std::ostream &stream) const
float getTimeStamp() const
Get the time stamp.
static float getTimeFromPackedBitfieldV0(const char *bitfield)
static uint16_t V0toV2(uint16_t energybits, ChannelType_t celltype)
static float getEnergyFromPackedBitfieldV0(const char *bitfield)
static float decodeEnergyV2(uint16_t energybits, ChannelType_t celltype)
static float decodeTime(uint16_t timestampBits)
short getTower() const
Get the tower ID.
static uint16_t encodeEnergyV0(float energy)
static float decodeEnergyV0(uint16_t energybits)
GLfloat GLfloat GLfloat v2
const float ENERGY_TRUNCATION
const float ENERGY_RESOLUTION
const float ENERGY_RESOLUTION_TRU
const float ENERGY_RESOLUTION_HG
const float ENERGY_RESOLUTION_LG
const float HGLGTRANSITION
const float ENERGY_TRUNCATION
const float ENERGY_RESOLUTION_LEDMON
const float HGLGTRANSITION
const float ENERGY_TRUNCATION
const float ENERGY_RESOLUTION_HG
const float ENERGY_RESOLUTION_LEDMON
const float ENERGY_RESOLUTION_TRU
const float ENERGY_RESOLUTION_LG
const float TIME_RESOLUTION
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
ChannelType_t
Type of a raw data channel.
@ HIGH_GAIN
High gain channel.
@ LOW_GAIN
Low gain channel.
@ LEDMON
LED monitor channel.