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
16
17#include <cfloat>
18#include <climits>
19
20namespace o2::emcal
21{
22
56class Cell
57{
58 public:
59 enum class EncoderVersion {
63 };
65 Cell() = default;
66
72 Cell(short tower, float energy, float timestamp, ChannelType_t ctype = ChannelType_t::LOW_GAIN);
73
80 Cell(uint16_t towerBits, uint16_t energyBits, uint16_t timestampBits, uint16_t channelBits, EncoderVersion version = EncoderVersion::EncodingV1);
81
83 ~Cell() = default; // override
84
87 void setTower(short tower) { mTowerID = tower; }
88
91 [[nodiscard]] short getTower() const { return mTowerID; }
92
95 void setTimeStamp(float timestamp) { mTimestamp = timestamp; }
96
99 [[nodiscard]] float getTimeStamp() const { return mTimestamp; }
100
103 void setEnergy(float energy) { mEnergy = energy; }
104
107 [[nodiscard]] float getEnergy() const { return mEnergy; }
108
111 void setAmplitude(float amplitude) { setEnergy(amplitude); }
112
115 [[nodiscard]] float getAmplitude() const { return getEnergy(); }
116
119 void setType(ChannelType_t ctype) { mChannelType = ctype; }
120
123 [[nodiscard]] ChannelType_t getType() const { return mChannelType; }
124
128 [[nodiscard]] bool isChannelType(ChannelType_t ctype) const { return mChannelType == ctype; }
129
132
135 [[nodiscard]] Bool_t getLowGain() const { return isChannelType(ChannelType_t::LOW_GAIN); }
136
139
142 [[nodiscard]] Bool_t getHighGain() const { return isChannelType(ChannelType_t::HIGH_GAIN); };
143
146
149 [[nodiscard]] Bool_t getLEDMon() const { return isChannelType(ChannelType_t::LEDMON); }
150
153
156 [[nodiscard]] Bool_t getTRU() const { return isChannelType(ChannelType_t::TRU); }
157
161
162 void PrintStream(std::ostream& stream) const;
163
170 void initialiseFromEncoded(uint16_t towerIDBits, uint16_t timestampBits, uint16_t energyBits, uint16_t celltypeBits, EncoderVersion version = EncoderVersion::EncodingV1)
171 {
172 setEnergyEncoded(energyBits, static_cast<ChannelType_t>(celltypeBits), version);
173 setTimestampEncoded(timestampBits);
174 setTowerIDEncoded(towerIDBits);
175 setChannelTypeEncoded(celltypeBits);
176 }
177
182 [[nodiscard]] uint16_t getTowerIDEncoded() const;
183
192 [[nodiscard]] uint16_t getTimeStampEncoded() const;
193
205
208 [[nodiscard]] uint16_t getCellTypeEncoded() const;
209
211
212 static float getEnergyFromPackedBitfieldV0(const char* bitfield);
213 static float getTimeFromPackedBitfieldV0(const char* bitfield);
215 static short getTowerFromPackedBitfieldV0(const char* bitfield);
216
217 static uint16_t encodeTime(float timestamp);
218 static uint16_t encodeEnergyV0(float energy);
219 static uint16_t encodeEnergyV1(float energy, ChannelType_t celltype);
220 static uint16_t encodeEnergyV2(float energy, ChannelType_t celltype);
221 static uint16_t V0toV1(uint16_t energybits, ChannelType_t celltype);
222 static uint16_t V0toV2(uint16_t energybits, ChannelType_t celltype);
223 static uint16_t V1toV2(uint16_t energybits, ChannelType_t celltype);
224 static float decodeTime(uint16_t timestampBits);
225 static float decodeEnergyV0(uint16_t energybits);
226 static float decodeEnergyV1(uint16_t energybits, ChannelType_t celltype);
227 static float decodeEnergyV2(uint16_t energybits, ChannelType_t celltype);
228
229 private:
233 void setEnergyEncoded(uint16_t energyBits, uint16_t channelTypeBits, EncoderVersion version = EncoderVersion::EncodingV1);
234
237 void setTimestampEncoded(uint16_t timestampBits);
238
241 void setTowerIDEncoded(uint16_t towerIDBits);
242
245 void setChannelTypeEncoded(uint16_t channelTypeBits);
246
247 float mEnergy = FLT_MIN;
248 float mTimestamp = FLT_MIN;
249 short mTowerID = SHRT_MAX;
251
252 ClassDefNV(Cell, 3);
253};
254
259std::ostream& operator<<(std::ostream& stream, const Cell& cell);
260} // namespace o2::emcal
261
262#endif
uint32_t version
Definition RawData.h:8
EMCAL compressed cell information.
Definition Cell.h:57
void setLEDMon()
Mark cell as LED monitor cell.
Definition Cell.h:145
static uint16_t encodeEnergyV2(float energy, ChannelType_t celltype)
Definition Cell.cxx:250
void setType(ChannelType_t ctype)
Set the type of the cell.
Definition Cell.h:119
static short getTowerFromPackedBitfieldV0(const char *bitfield)
Definition Cell.cxx:183
uint16_t getCellTypeEncoded() const
Get encoded bit representation of cell type (for CTF)
Definition Cell.cxx:124
bool isChannelType(ChannelType_t ctype) const
Check whether the cell is of a given type.
Definition Cell.h:128
static uint16_t encodeTime(float timestamp)
Definition Cell.cxx:194
void setTimeStamp(float timestamp)
Set the time stamp.
Definition Cell.h:95
void initializeFromPackedBitfieldV0(const char *bitfield)
Definition Cell.cxx:159
static uint16_t V0toV1(uint16_t energybits, ChannelType_t celltype)
Definition Cell.cxx:281
void setTower(short tower)
Set the tower ID.
Definition Cell.h:87
Bool_t getLEDMon() const
Check whether the cell is a LED monitor cell.
Definition Cell.h:149
uint16_t getTowerIDEncoded() const
Get encoded bit representation of tower ID (for CTF)
Definition Cell.cxx:95
void truncate(EncoderVersion version=EncoderVersion::EncodingV1)
Apply compression as done during writing to / reading from CTF.
Definition Cell.cxx:188
ChannelType_t getType() const
Get the type of the cell.
Definition Cell.h:123
Cell()=default
Default constructor.
Bool_t getLowGain() const
Check whether the cell is a low gain cell.
Definition Cell.h:135
Bool_t getHighGain() const
Check whether the cell is a high gain cell.
Definition Cell.h:142
static ChannelType_t getCellTypeFromPackedBitfieldV0(const char *bitfield)
Definition Cell.cxx:178
Bool_t getTRU() const
Check whether the cell is a TRU cell.
Definition Cell.h:156
static uint16_t V1toV2(uint16_t energybits, ChannelType_t celltype)
Definition Cell.cxx:293
void setEnergy(float energy)
Set the energy of the cell.
Definition Cell.h:103
~Cell()=default
Destructor.
uint16_t getEnergyEncoded(EncoderVersion version=EncoderVersion::EncodingV2) const
Get encoded bit representation of energy (for CTF)
Definition Cell.cxx:105
static float decodeEnergyV1(uint16_t energybits, ChannelType_t celltype)
Definition Cell.cxx:309
void setTRU()
Mark cell as TRU cell.
Definition Cell.h:152
uint16_t getTimeStampEncoded() const
Get encoded bit representation of timestamp (for CTF)
Definition Cell.cxx:100
void setHighGain()
Mark cell as high gain cell.
Definition Cell.h:138
void setAmplitude(float amplitude)
Set the amplitude of the cell.
Definition Cell.h:111
static uint16_t encodeEnergyV1(float energy, ChannelType_t celltype)
Definition Cell.cxx:219
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:170
float getEnergy() const
Get the energy of the cell.
Definition Cell.h:107
void PrintStream(std::ostream &stream) const
Definition Cell.cxx:361
float getTimeStamp() const
Get the time stamp.
Definition Cell.h:99
static float getTimeFromPackedBitfieldV0(const char *bitfield)
Definition Cell.cxx:173
float getAmplitude() const
Get cell amplitude.
Definition Cell.h:115
void setLowGain()
Mark cell as low gain cell.
Definition Cell.h:131
static uint16_t V0toV2(uint16_t energybits, ChannelType_t celltype)
Definition Cell.cxx:287
static float getEnergyFromPackedBitfieldV0(const char *bitfield)
Definition Cell.cxx:168
static float decodeEnergyV2(uint16_t energybits, ChannelType_t celltype)
Definition Cell.cxx:335
static float decodeTime(uint16_t timestampBits)
Definition Cell.cxx:299
short getTower() const
Get the tower ID.
Definition Cell.h:91
static uint16_t encodeEnergyV0(float energy)
Definition Cell.cxx:208
static float decodeEnergyV0(uint16_t energybits)
Definition Cell.cxx:304
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
Definition Cell.cxx:366
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