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_PHOS_CELL_H_
13#define ALICEO2_PHOS_CELL_H_
14
15#include <bitset>
16#include "Rtypes.h"
17
18// Structure:
19// Bits 39: Cell type: 0=Low Gain, 1=High Gain
20// Bits 27-38: 12 bit, Amplitude (HG, resolution 0.25 ADC count, LG resolution 1 ADC count, dynamic range 4096)
21// Bits 14-26: 13 bit, Time (ns)
22// Bits 0-13: 14 bit, Address: absID or TRU address
23
24namespace o2
25{
26namespace phos
27{
28
29constexpr int kOffset = 1792; // offset due to missing half of module 1: 56*32
30constexpr int kNmaxCell = 14336; // maximal readout channel address 56*64*4
31 // -1500<t<-800 ns, 1. ns binning => 700 bin
32 // -800<t<-200 ns, 0.6 ns binning => 1000 bin
33 // -200<t< 200 ns, 0.2 ns binning => 2000 bin
34 // 200<t< 800 ns, 0.6 ns binning => 1000 bin
35 // 800<t<4290 ns, 1 ns binning => 4290 bin
36constexpr float kTimeAccuracy1 = 1.e-9; // Time digitization step
37constexpr float kTimeAccuracy2 = 0.6e-9; // Time digitization step
38constexpr float kTimeAccuracy3 = 0.2e-9; // Time digitization step
39constexpr float kTimeAccuracy4 = 0.6e-9; // Time digitization step
40constexpr float kTimeAccuracy5 = 1.e-9; // Time digitization step
41constexpr float kTime0 = -1500.e-9; // Minimal time to be digitized with 13 bits -1500<t<4290 ns
42constexpr float kTime1 = -800.e-9; // Switch to 0.6 ns accuracy
43constexpr float kTime2 = -200.e-9; // Switch to 0.2 ns accuracy
44constexpr float kTime3 = 200.e-9; // Switch to 0.6 ns accuracy
45constexpr float kTime4 = 800.e-9; // Switch to 1 ns accuracy
46constexpr uint16_t kTimeOffset1 = 1 + (kTime1 - kTime0) / kTimeAccuracy1; // underflow bin+...
50
57
58class Cell
59{
60 public:
61 Cell() = default;
62 Cell(short absId, float energy, float time, ChannelType_t ctype);
63 ~Cell() = default; // override
64
65 void setAbsId(short absId);
66 short getAbsId() const;
67
68 // return pure TRUid (absId with subtracted readout channels offset)
69 short getTRUId() const;
70
71 // time in seconds
72 void setTime(float time);
73 float getTime() const;
74
75 // make sure that type of Cell (HG/LG) set before filling energy: scale will be different!
76 // Energy stored in ADC counts!
77 void setEnergy(float energy);
78 float getEnergy() const;
79
80 void setType(ChannelType_t ctype);
81 ChannelType_t getType() const;
82
83 void setLowGain();
84 bool getLowGain() const;
85
86 void setHighGain();
87 bool getHighGain() const;
88
89 bool getTRU() const;
90
91 void setLong(ULong_t l);
92 ULong_t getLong() const { return mBits.to_ulong(); }
93
94 void PrintStream(std::ostream& stream) const;
95
96 // raw access for CTF encoding
97 uint16_t getPackedID() const { return getLong() & 0x3fff; }
98 void setPackedID(uint16_t v) { mBits = (getLong() & 0xffffffc000) + (v & 0x3fff); }
99
100 uint16_t getPackedTime() const { return (getLong() >> 14) & 0x1fff; }
101 void setPackedTime(uint16_t v) { mBits = (getLong() & 0xfff8003fff) + (uint64_t(v & 0x1fff) << 14); }
102
103 uint16_t getPackedEnergy() const { return (getLong() >> 27) & 0xfff; }
104 void setPackedEnergy(uint16_t v) { mBits = (getLong() & 0x8007ffffff) + (uint64_t(v & 0xfff) << 27); }
105
106 uint8_t getPackedCellStatus() const { return mBits[39]; }
107 void setPackedCellStatus(uint8_t v) { mBits[39] = v ? true : false; }
108
109 void setPacked(uint16_t id, uint16_t t, uint16_t en, uint16_t status)
110 {
111 mBits = uint64_t(id & 0x3fff) + (uint64_t(t & 0x1fff) << 14) + (uint64_t(en & 0xfff) << 27) + (uint64_t(status & 0x1) << 39);
112 }
113
114 private:
115 std::bitset<40> mBits;
116
117 ClassDefNV(Cell, 1);
118};
119
120std::ostream& operator<<(std::ostream& stream, const Cell& c);
121} // namespace phos
122} // namespace o2
123
124#endif
int16_t time
Definition RawEventData.h:4
uint32_t c
Definition RawData.h:2
short getTRUId() const
Definition Cell.cxx:55
void setType(ChannelType_t ctype)
Definition Cell.cxx:159
Cell()=default
uint16_t getPackedEnergy() const
Definition Cell.h:103
uint8_t getPackedCellStatus() const
Definition Cell.h:106
~Cell()=default
void setAbsId(short absId)
Definition Cell.cxx:33
uint16_t getPackedTime() const
Definition Cell.h:100
ULong_t getLong() const
Definition Cell.h:92
ChannelType_t getType() const
Definition Cell.cxx:174
void setHighGain()
Definition Cell.cxx:206
void setPackedEnergy(uint16_t v)
Definition Cell.h:104
short getAbsId() const
Definition Cell.cxx:44
bool getHighGain() const
Definition Cell.cxx:212
bool getLowGain() const
Definition Cell.cxx:197
float getTime() const
Definition Cell.cxx:103
uint16_t getPackedID() const
Definition Cell.h:97
void setLowGain()
Definition Cell.cxx:191
bool getTRU() const
Definition Cell.cxx:221
float getEnergy() const
Definition Cell.cxx:147
void PrintStream(std::ostream &stream) const
Definition Cell.cxx:235
void setPacked(uint16_t id, uint16_t t, uint16_t en, uint16_t status)
Definition Cell.h:109
void setPackedCellStatus(uint8_t v)
Definition Cell.h:107
void setTime(float time)
Definition Cell.cxx:62
void setPackedTime(uint16_t v)
Definition Cell.h:101
void setLong(ULong_t l)
Definition Cell.cxx:229
void setEnergy(float energy)
Definition Cell.cxx:131
void setPackedID(uint16_t v)
Definition Cell.h:98
const GLdouble * v
Definition glcorearb.h:832
GLuint GLuint stream
Definition glcorearb.h:1806
constexpr uint16_t kTimeOffset3
Definition Cell.h:48
constexpr uint16_t kTimeOffset2
Definition Cell.h:47
constexpr uint16_t kTimeOffset4
Definition Cell.h:49
constexpr float kTimeAccuracy4
Definition Cell.h:39
constexpr float kTimeAccuracy5
Definition Cell.h:40
std::ostream & operator<<(std::ostream &in, const BadChannelsMap &bcm)
Printing bad channel map on the stream.
constexpr float kTimeAccuracy3
Definition Cell.h:38
constexpr float kTime4
Definition Cell.h:45
ChannelType_t
Definition Cell.h:51
@ TRU4x4
TRU channel, 4x4 trigger.
Definition Cell.h:55
@ LOW_GAIN
Low gain channel.
Definition Cell.h:52
@ HIGH_GAIN
High gain channel.
Definition Cell.h:53
@ TRU2x2
TRU channel, 2x2 trigger.
Definition Cell.h:54
constexpr float kTime3
Definition Cell.h:44
constexpr int kNmaxCell
Definition Cell.h:30
constexpr float kTimeAccuracy1
Definition Cell.h:36
constexpr int kOffset
Definition Cell.h:29
constexpr float kTime2
Definition Cell.h:43
constexpr uint16_t kTimeOffset1
Definition Cell.h:46
constexpr float kTimeAccuracy2
Definition Cell.h:37
constexpr float kTime0
Definition Cell.h:41
constexpr float kTime1
Definition Cell.h:42
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...