ATLAS Offline Software
TileRawChannel2Bytes4.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TILEBYTESTREAM_TILERAWCHANNEL2BYTES4_H
6 #define TILEBYTESTREAM_TILERAWCHANNEL2BYTES4_H
7 // This class converts the TileRawChannel object into bytes
8 // as it is defined at the commissioning 2007
9 // in one 32-bit word, 1 bit for the gain, 15 for the energy,
10 // 11 bits for time and 4+1 bits for quality factor and energy
11 // trigger flag
12 
28 #include <vector>
29 
30 // Gain encoding: one most significant bit
31 const unsigned int GAIN_RANGE4 = 0x1;
32 const int GAIN_SHIFT4 = 31;
33 const unsigned int GAIN_BIT4 = (GAIN_RANGE4 << GAIN_SHIFT4);
34 
35 // Amplitude encoding: 15 bits
36 // Value = amp*factor + offset
37 // amp = (Value - offset)/factor
38 // the offset depends on the gain
39 // the factor depends on the units
40 const float AMPLITUDE_OFFSET4[2] = { 512.0F, 2048.0F };
41 const float AMPLITUDE_FACTOR4[4] = { 16.0F, 32.0F, 32.0F, 1.0F / 32.0F };
42 const int AMPLITUDE_RANGE4 = 0x7FFF;
43 const int AMPLITUDE_SHIFT4 = 16;
44 
45 // Time encoding: 11 bits
46 // Value = time*factor + offset
47 // time = (Value - offset)/factor
48 const float TIME_OFFSET4 = 1024.0F;
49 const float TIME_FACTOR4 = 16.0F;
50 const int TIME_RANGE4 = 0x7FF;
51 const int TIME_SHIFT4 = 5;
52 
53 // Quality encoding: 4+1 bits
54 // Value = Qfactor*factor + offset
55 // Qfactor = (Value - offset)/factor
56 const float QUALITY_OFFSET4 = 0.0F;
57 const float QUALITY_FACTOR4 = 1.0F;
58 const int QUALITY_RANGE4 = 0x1F;
59 const int QUALITY_RANGE4_NOFLAG = 0xF;
60 const int QUALITY_RANGE4_FLAG = 0x10;
61 const float QUALITY_THRESHOLD = 15.999F; // just a number between 0xF and 0x10
62 const int QUALITY_SHIFT4 = 0;
63 
64 class TileFastRawChannel;
65 
67  public:
69  {
70  }
71 
75  int getBytes(const TileFastRawChannel& rc, unsigned int unit,
76  int gain, std::vector<unsigned int>& v) const;
79  unsigned int getWord(const TileFastRawChannel& rc, unsigned int unit, int gain) const;
80 
82  inline int gain(unsigned int w) const;
84  inline float amplitude(unsigned int w, unsigned int unit) const;
86  inline float time(unsigned int w) const;
88  inline float quality(unsigned int w) const;
89 
91  inline void setVerbose(bool /*verbose*/) {
92  }
93 };
94 
95 // inline functions
96 
97 inline int TileRawChannel2Bytes4::gain(unsigned int w) const {
98  int g = (w >> GAIN_SHIFT4) & GAIN_RANGE4;
99  return g;
100 }
101 
102 inline float TileRawChannel2Bytes4::amplitude(unsigned int w, unsigned int unit) const {
103  int g = (w >> GAIN_SHIFT4) & GAIN_RANGE4;
106  if (unit != 0 && g == 1) a = a / 64.0F;
107  return a;
108 }
109 
110 inline float TileRawChannel2Bytes4::time(unsigned int w) const {
111  float t = (((w >> TIME_SHIFT4) & TIME_RANGE4) - TIME_OFFSET4) * (1./TIME_FACTOR4);
112  return t;
113 }
114 
115 inline float TileRawChannel2Bytes4::quality(unsigned int w) const {
116  float q = (((w >> QUALITY_SHIFT4) & QUALITY_RANGE4) - QUALITY_OFFSET4) * (1./QUALITY_FACTOR4);
117  return q;
118 }
119 
120 #endif
QUALITY_RANGE4
const int QUALITY_RANGE4
Definition: TileRawChannel2Bytes4.h:58
TileRawChannel2Bytes4::TileRawChannel2Bytes4
TileRawChannel2Bytes4()
Definition: TileRawChannel2Bytes4.h:68
TIME_RANGE4
const int TIME_RANGE4
Definition: TileRawChannel2Bytes4.h:50
TileRawChannel2Bytes4::gain
int gain(unsigned int w) const
Returns the gain unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes4.h:97
TileRawChannel2Bytes4::quality
float quality(unsigned int w) const
Returns the quality factor unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes4.h:115
QUALITY_THRESHOLD
const float QUALITY_THRESHOLD
Definition: TileRawChannel2Bytes4.h:61
TileRawChannel2Bytes4
Converts the TileRawChannel object into bytes as it is defined at the commissioning 2007....
Definition: TileRawChannel2Bytes4.h:66
TIME_SHIFT4
const int TIME_SHIFT4
Definition: TileRawChannel2Bytes4.h:51
GAIN_RANGE4
const unsigned int GAIN_RANGE4
Definition: TileRawChannel2Bytes4.h:31
TileRawChannel2Bytes4::setVerbose
void setVerbose(bool)
Sets verbose mode true or false.
Definition: TileRawChannel2Bytes4.h:91
TIME_FACTOR4
const float TIME_FACTOR4
Definition: TileRawChannel2Bytes4.h:49
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AMPLITUDE_RANGE4
const int AMPLITUDE_RANGE4
Definition: TileRawChannel2Bytes4.h:42
QUALITY_OFFSET4
const float QUALITY_OFFSET4
Definition: TileRawChannel2Bytes4.h:56
TileRawChannel2Bytes4::amplitude
float amplitude(unsigned int w, unsigned int unit) const
Returns the amplitude in the corresponding units, unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes4.h:102
TileRawChannel2Bytes4::getBytes
int getBytes(const TileFastRawChannel &rc, unsigned int unit, int gain, std::vector< unsigned int > &v) const
Adds an entry to the vector<int> v for this TileRawChannel.
Definition: TileRawChannel2Bytes4.cxx:10
AMPLITUDE_OFFSET4
const float AMPLITUDE_OFFSET4[2]
Definition: TileRawChannel2Bytes4.h:40
TileRawChannel2Bytes4::time
float time(unsigned int w) const
Returns the phase of the pulse in ns, unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes4.h:110
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
QUALITY_RANGE4_FLAG
const int QUALITY_RANGE4_FLAG
Definition: TileRawChannel2Bytes4.h:60
AMPLITUDE_FACTOR4
const float AMPLITUDE_FACTOR4[4]
Definition: TileRawChannel2Bytes4.h:41
QUALITY_FACTOR4
const float QUALITY_FACTOR4
Definition: TileRawChannel2Bytes4.h:57
TIME_OFFSET4
const float TIME_OFFSET4
Definition: TileRawChannel2Bytes4.h:48
AMPLITUDE_SHIFT4
const int AMPLITUDE_SHIFT4
Definition: TileRawChannel2Bytes4.h:43
python.PyAthena.v
v
Definition: PyAthena.py:157
TileRawChannel2Bytes4::getWord
unsigned int getWord(const TileFastRawChannel &rc, unsigned int unit, int gain) const
Returns a single 32-bit word which encodes the TileRawChannel information (gain,amplitude,...
Definition: TileRawChannel2Bytes4.cxx:21
a
TList * a
Definition: liststreamerinfos.cxx:10
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:20
QUALITY_RANGE4_NOFLAG
const int QUALITY_RANGE4_NOFLAG
Definition: TileRawChannel2Bytes4.h:59
extractSporadic.q
list q
Definition: extractSporadic.py:98
TileFastRawChannel
Definition: TileFastRawChannel.h:17
QUALITY_SHIFT4
const int QUALITY_SHIFT4
Definition: TileRawChannel2Bytes4.h:62
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
GAIN_SHIFT4
const int GAIN_SHIFT4
Definition: TileRawChannel2Bytes4.h:32
GAIN_BIT4
const unsigned int GAIN_BIT4
Definition: TileRawChannel2Bytes4.h:33