Project
Loading...
Searching...
No Matches
Cell.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef ALICEO2_EMCAL_CELL_H_
13#define ALICEO2_EMCAL_CELL_H_
14
15#include <bitset>
16#include <cfloat>
17#include <climits>
19
20namespace o2
21{
22namespace emcal
23{
24
58class Cell
59{
60 public:
61 enum class EncoderVersion {
65 };
67 Cell() = default;
68
74 Cell(short tower, float energy, float timestamp, ChannelType_t ctype = ChannelType_t::LOW_GAIN);
75
82 Cell(uint16_t towerBits, uint16_t energyBits, uint16_t timestampBits, uint16_t channelBits, EncoderVersion version = EncoderVersion::EncodingV1);
83
85 ~Cell() = default; // override
86
89 void setTower(short tower) { mTowerID = tower; }
90
93 short getTower() const { return mTowerID; }
94
97 void setTimeStamp(float timestamp) { mTimestamp = timestamp; }
98
101 float getTimeStamp() const { return mTimestamp; }
102
105 void setEnergy(float energy) { mEnergy = energy; }
106
109 float getEnergy() const { return mEnergy; }
110
113 void setAmplitude(float amplitude) { setEnergy(amplitude); }
114
117 float getAmplitude() const { return getEnergy(); }
118
121 void setType(ChannelType_t ctype) { mChannelType = ctype; }
122
125 ChannelType_t getType() const { return mChannelType; }
126
130 bool isChannelType(ChannelType_t ctype) const { return mChannelType == ctype; }
131
134
138
141
145
148
152
155
158 Bool_t getTRU() const { return isChannelType(ChannelType_t::TRU); }
159
163
164 void PrintStream(std::ostream& stream) const;
165
172 void initialiseFromEncoded(uint16_t towerIDBits, uint16_t timestampBits, uint16_t energyBits, uint16_t celltypeBits, EncoderVersion version = EncoderVersion::EncodingV1)
173 {
174 setEnergyEncoded(energyBits, static_cast<ChannelType_t>(celltypeBits), version);
175 setTimestampEncoded(timestampBits);
176 setTowerIDEncoded(towerIDBits);
177 setChannelTypeEncoded(celltypeBits);
178 }
179
184 uint16_t getTowerIDEncoded() const;
185
194 uint16_t getTimeStampEncoded() const;
195
207
210 uint16_t getCellTypeEncoded() const;
211
213
214 static float getEnergyFromPackedBitfieldV0(const char* bitfield);
215 static float getTimeFromPackedBitfieldV0(const char* bitfield);
217 static short getTowerFromPackedBitfieldV0(const char* bitfield);
218
219 static uint16_t encodeTime(float timestamp);
220 static uint16_t encodeEnergyV0(float energy);
221 static uint16_t encodeEnergyV1(float energy, ChannelType_t celltype);
222 static uint16_t encodeEnergyV2(float energy, ChannelType_t celltype);
223 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);
226 static float decodeTime(uint16_t timestampBits);
227 static float decodeEnergyV0(uint16_t energybits);
228 static float decodeEnergyV1(uint16_t energybits, ChannelType_t celltype);
229 static float decodeEnergyV2(uint16_t energybits, ChannelType_t celltype);
230
231 private:
235 void setEnergyEncoded(uint16_t energyBits, uint16_t cellTypeBits, EncoderVersion version = EncoderVersion::EncodingV1);
236
239 void setTimestampEncoded(uint16_t timestampBits);
240
243 void setTowerIDEncoded(uint16_t towerIDBits);
244
247 void setChannelTypeEncoded(uint16_t channelTypeBits);
248
249 float mEnergy = FLT_MIN;
250 float mTimestamp = FLT_MIN;
251 short mTowerID = SHRT_MAX;
253
254 ClassDefNV(Cell, 3);
255};
256
261std::ostream& operator<<(std::ostream& stream, const Cell& cell);
262} // namespace emcal
263} // namespace o2
264
265#endif
uint32_t version
Definition RawData.h:8
EMCAL compressed cell information.
Definition Cell.h:59
void setLEDMon()
Mark cell as LED monitor cell.
Definition Cell.h:147
static uint16_t encodeEnergyV2(float energy, ChannelType_t celltype)
Definition Cell.cxx:239
void setType(ChannelType_t ctype)
Set the type of the cell.
Definition Cell.h:121
static short getTowerFromPackedBitfieldV0(const char *bitfield)
Definition Cell.cxx:172
uint16_t getCellTypeEncoded() const
Get encoded bit representation of cell type (for CTF)
Definition Cell.cxx:113
bool isChannelType(ChannelType_t ctype) const
Check whether the cell is of a given type.
Definition Cell.h:130
static uint16_t encodeTime(float timestamp)
Definition Cell.cxx:183
void setTimeStamp(float timestamp)
Set the time stamp.
Definition Cell.h:97
void initializeFromPackedBitfieldV0(const char *bitfield)
Definition Cell.cxx:148
static uint16_t V0toV1(uint16_t energybits, ChannelType_t celltype)
Definition Cell.cxx:270
void setTower(short tower)
Set the tower ID.
Definition Cell.h:89
Bool_t getLEDMon() const
Check whether the cell is a LED monitor cell.
Definition Cell.h:151
uint16_t getTowerIDEncoded() const
Get encoded bit representation of tower ID (for CTF)
Definition Cell.cxx:84
void truncate(EncoderVersion version=EncoderVersion::EncodingV1)
Apply compression as done during writing to / reading from CTF.
Definition Cell.cxx:177
ChannelType_t getType() const
Get the type of the cell.
Definition Cell.h:125
Cell()=default
Default constructor.
Bool_t getLowGain() const
Check whether the cell is a low gain cell.
Definition Cell.h:137
Bool_t getHighGain() const
Check whether the cell is a high gain cell.
Definition Cell.h:144
static ChannelType_t getCellTypeFromPackedBitfieldV0(const char *bitfield)
Definition Cell.cxx:167
Bool_t getTRU() const
Check whether the cell is a TRU cell.
Definition Cell.h:158
static uint16_t V1toV2(uint16_t energybits, ChannelType_t celltype)
Definition Cell.cxx:282
void setEnergy(float energy)
Set the energy of the cell.
Definition Cell.h:105
~Cell()=default
Destructor.
uint16_t getEnergyEncoded(EncoderVersion version=EncoderVersion::EncodingV2) const
Get encoded bit representation of energy (for CTF)
Definition Cell.cxx:94
static float decodeEnergyV1(uint16_t energybits, ChannelType_t celltype)
Definition Cell.cxx:298
void setTRU()
Mark cell as TRU cell.
Definition Cell.h:154
uint16_t getTimeStampEncoded() const
Get encoded bit representation of timestamp (for CTF)
Definition Cell.cxx:89
void setHighGain()
Mark cell as high gain cell.
Definition Cell.h:140
void setAmplitude(float amplitude)
Set the amplitude of the cell.
Definition Cell.h:113
static uint16_t encodeEnergyV1(float energy, ChannelType_t celltype)
Definition Cell.cxx:208
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)
Definition Cell.h:172
float getEnergy() const
Get the energy of the cell.
Definition Cell.h:109
void PrintStream(std::ostream &stream) const
Definition Cell.cxx:350
float getTimeStamp() const
Get the time stamp.
Definition Cell.h:101
static float getTimeFromPackedBitfieldV0(const char *bitfield)
Definition Cell.cxx:162
float getAmplitude() const
Get cell amplitude.
Definition Cell.h:117
void setLowGain()
Mark cell as low gain cell.
Definition Cell.h:133
static uint16_t V0toV2(uint16_t energybits, ChannelType_t celltype)
Definition Cell.cxx:276
static float getEnergyFromPackedBitfieldV0(const char *bitfield)
Definition Cell.cxx:157
static float decodeEnergyV2(uint16_t energybits, ChannelType_t celltype)
Definition Cell.cxx:324
static float decodeTime(uint16_t timestampBits)
Definition Cell.cxx:288
short getTower() const
Get the tower ID.
Definition Cell.h:93
static uint16_t encodeEnergyV0(float energy)
Definition Cell.cxx:197
static float decodeEnergyV0(uint16_t energybits)
Definition Cell.cxx:293
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
Definition Cell.cxx:355
ChannelType_t
Type of a raw data channel.
Definition Constants.h:33
@ TRU
TRU channel.
Definition Constants.h:36
@ HIGH_GAIN
High gain channel.
Definition Constants.h:35
@ LOW_GAIN
Low gain channel.
Definition Constants.h:34
@ LEDMON
LED monitor channel.
Definition Constants.h:37
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...