40 HGLGTRANSITION = o2::emcal::constants::EMCAL_HGLGTRANSITION * o2::emcal::constants::EMCAL_ADCENERGY,
53 HGLGTRANSITION = o2::emcal::constants::OVERFLOWCUT * o2::emcal::constants::EMCAL_ADCENERGY,
67 uint16_t mTowerID : 15;
69 uint16_t mEnergy : 14;
70 uint16_t mCellStatus : 2;
75Cell::Cell(
short tower,
float energy,
float timestamp,
ChannelType_t ctype) : mTowerID(tower), mEnergy(energy), mTimestamp(timestamp), mChannelType(ctype)
96 uint16_t energyBits = 0;
115 return static_cast<uint16_t
>(mChannelType);
118void Cell::setEnergyEncoded(uint16_t energyBits, uint16_t channelTypeBits, EncoderVersion
version)
133void Cell::setTimestampEncoded(uint16_t timestampBits)
138void Cell::setTowerIDEncoded(uint16_t towerIDBits)
140 mTowerID = towerIDBits;
143void Cell::setChannelTypeEncoded(uint16_t channelTypeBits)
150 auto bitrepresentation =
reinterpret_cast<const DecodingV0::CellDataPacked*
>(
bitfield);
152 mTimestamp =
decodeTime(bitrepresentation->mTime);
153 mTowerID = bitrepresentation->mTowerID;
154 mChannelType =
static_cast<ChannelType_t>(bitrepresentation->mCellStatus);
164 return decodeTime(
reinterpret_cast<const DecodingV0::CellDataPacked*
>(
bitfield)->mTime);
169 return static_cast<ChannelType_t>(
reinterpret_cast<const DecodingV0::CellDataPacked*
>(
bitfield)->mCellStatus);
174 return reinterpret_cast<const DecodingV0::CellDataPacked*
>(
bitfield)->mTowerID;
186 auto timestampTruncated = timestamp;
189 if (timestampTruncated < TIME_MIN) {
190 timestampTruncated = TIME_MIN;
191 }
else if (timestampTruncated > TIME_MAX) {
192 timestampTruncated = TIME_MAX;
199 auto truncatedEnergy = energy;
200 if (truncatedEnergy < 0.) {
201 truncatedEnergy = 0.;
202 }
else if (truncatedEnergy > EnergyEncoding::v0::ENERGY_TRUNCATION) {
203 truncatedEnergy = EnergyEncoding::v0::ENERGY_TRUNCATION;
205 return static_cast<uint16_t
>(std::round(truncatedEnergy / EnergyEncoding::v0::ENERGY_RESOLUTION));
210 double truncatedEnergy = energy;
211 if (truncatedEnergy < 0.) {
212 truncatedEnergy = 0.;
213 }
else if (truncatedEnergy > EnergyEncoding::v1::ENERGY_TRUNCATION) {
214 truncatedEnergy = EnergyEncoding::v1::ENERGY_TRUNCATION;
216 float resolutionApplied = 0., energyOffset = 0.;
219 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_HG;
223 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_LG;
224 energyOffset = EnergyEncoding::v1::HGLGTRANSITION;
228 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_TRU;
232 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_LEDMON;
236 return static_cast<uint16_t
>(std::round((truncatedEnergy - energyOffset) / resolutionApplied));
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;
247 float resolutionApplied = 0., energyOffset = 0.;
250 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_HG;
254 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LG;
255 energyOffset = EnergyEncoding::v2::OFFSET_LG;
259 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_TRU;
263 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LEDMON;
267 return static_cast<uint16_t
>(std::round((truncatedEnergy - energyOffset) / resolutionApplied));
295 return static_cast<float>(energyBits) * EnergyEncoding::v0::ENERGY_RESOLUTION;
300 float resolutionApplied = 0.,
304 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_HG;
308 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_LG;
309 energyOffset = EnergyEncoding::v1::HGLGTRANSITION;
313 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_TRU;
317 resolutionApplied = EnergyEncoding::v1::ENERGY_RESOLUTION_LEDMON;
321 return (
static_cast<float>(energyBits) * resolutionApplied) + energyOffset;
326 float resolutionApplied = 0.,
330 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_HG;
334 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LG;
335 energyOffset = EnergyEncoding::v2::OFFSET_LG;
339 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_TRU;
343 resolutionApplied = EnergyEncoding::v2::ENERGY_RESOLUTION_LEDMON;
347 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.