ATLAS Offline Software
TileRawChannel2Bytes2.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_TILERAWCHANNEL2BYTES2_H
6 #define TILEBYTESTREAM_TILERAWCHANNEL2BYTES2_H
7 // This class converts the TileRawChannel object into bytes
8 // as it is defined at the testbeam
9 // in one 32-bits word 16 bits are used for energy,
10 // 12 bits for time and 4 bits for quality
11 
24 #include <vector>
25 
26 // Gain encoding: one most significant bit
27 const unsigned int GAIN_RANGE2 = 0x1;
28 const int GAIN_SHIFT2 = 31;
29 const unsigned int GAIN_BIT2 = (GAIN_RANGE2 << GAIN_SHIFT2);
30 
31 // Amplitude encoding: 15 bits
32 // // Value = (amp + 64) * 32, shifted by 16 bits
33 // const double AMPLITUDE_OFFSET2 = 64.0;
34 // const double AMPLITUDE_FACTOR2 = 32.0;
35 // Value = (amp + 1024) * 16, shifted by 16 bits
36 const float AMPLITUDE_OFFSET2 = 1024.0F;
37 const float AMPLITUDE_FACTOR2 = 16.0F;
38 const int AMPLITUDE_RANGE2 = 0x7FFF;
39 const int AMPLITUDE_SHIFT2 = 16;
40 const float AMPLITUDE_MINVALUE = -800.0F;
41 
42 // Time encoding: 12 bits
43 // Value = (time + 128) * 16, shifted by 4 bits
44 const float TIME_OFFSET2 = 128.0F;
45 const float TIME_FACTOR2 = 16.0F;
46 const int TIME_RANGE2 = 0xFFF;
47 const int TIME_SHIFT2 = 4;
48 
49 // Quality encoding: 4 bits
50 // Value = q, not shifted
51 const float QUALITY_OFFSET2 = 0.0F;
52 const float QUALITY_FACTOR2 = 1.0F;
53 const int QUALITY_RANGE2 = 0xF;
54 const int QUALITY_SHIFT2 = 0;
55 
56 class TileFastRawChannel;
57 
59  public:
61  : m_verbose(false) {
62  }
63 
67  int getBytes(const TileFastRawChannel* rc, int gain, std::vector<unsigned int>& v);
70  unsigned int getWord(const TileFastRawChannel* rc, int gain);
71 
73  inline int gain(unsigned int w) const;
75  inline float amplitude(unsigned int w) const;
77  inline float time(unsigned int w) const;
79  inline float quality(unsigned int w) const;
80 
82  inline void setVerbose(bool verbose) {
84  }
85 
86  private:
88  bool m_verbose;
89 };
90 
91 // inline functions
92 
93 inline int TileRawChannel2Bytes2::gain(unsigned int w) const {
94  int g = (w >> GAIN_SHIFT2) & GAIN_RANGE2;
95  return g;
96 }
97 
98 inline float TileRawChannel2Bytes2::amplitude(unsigned int w) const {
100  if (a < AMPLITUDE_MINVALUE) a += 2 * AMPLITUDE_OFFSET2;
101  return a;
102 }
103 
104 inline float TileRawChannel2Bytes2::time(unsigned int w) const {
105  float t = ((w >> TIME_SHIFT2) & TIME_RANGE2) * (1./TIME_FACTOR2) - TIME_OFFSET2;
106  return t;
107 }
108 
109 inline float TileRawChannel2Bytes2::quality(unsigned int w) const {
111  return q;
112 }
113 
114 #endif
TIME_SHIFT2
const int TIME_SHIFT2
Definition: TileRawChannel2Bytes2.h:47
AMPLITUDE_MINVALUE
const float AMPLITUDE_MINVALUE
Definition: TileRawChannel2Bytes2.h:40
TileRawChannel2Bytes2::m_verbose
bool m_verbose
Verbose flag.
Definition: TileRawChannel2Bytes2.h:88
AMPLITUDE_SHIFT2
const int AMPLITUDE_SHIFT2
Definition: TileRawChannel2Bytes2.h:39
AMPLITUDE_OFFSET2
const float AMPLITUDE_OFFSET2
Definition: TileRawChannel2Bytes2.h:36
TileRawChannel2Bytes2
Converts the TileRawChannel object into bytes as it is defined at the testbeam.
Definition: TileRawChannel2Bytes2.h:58
QUALITY_SHIFT2
const int QUALITY_SHIFT2
Definition: TileRawChannel2Bytes2.h:54
AMPLITUDE_RANGE2
const int AMPLITUDE_RANGE2
Definition: TileRawChannel2Bytes2.h:38
GAIN_BIT2
const unsigned int GAIN_BIT2
Definition: TileRawChannel2Bytes2.h:29
TileRawChannel2Bytes2::getBytes
int getBytes(const TileFastRawChannel *rc, int gain, std::vector< unsigned int > &v)
Adds an entry to the vector<int> v for this TileRawChannel.
Definition: TileRawChannel2Bytes2.cxx:10
QUALITY_FACTOR2
const float QUALITY_FACTOR2
Definition: TileRawChannel2Bytes2.h:52
QUALITY_OFFSET2
const float QUALITY_OFFSET2
Definition: TileRawChannel2Bytes2.h:51
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
GAIN_SHIFT2
const int GAIN_SHIFT2
Definition: TileRawChannel2Bytes2.h:28
TileRawChannel2Bytes2::time
float time(unsigned int w) const
Returns the phase of the pulse in ns, unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes2.h:104
TileRawChannel2Bytes2::getWord
unsigned int getWord(const TileFastRawChannel *rc, int gain)
Returns a single 32-bit word which encodes the TileRawChannel information (gain,amplitude,...
Definition: TileRawChannel2Bytes2.cxx:18
GAIN_RANGE2
const unsigned int GAIN_RANGE2
Definition: TileRawChannel2Bytes2.h:27
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
TIME_OFFSET2
const float TIME_OFFSET2
Definition: TileRawChannel2Bytes2.h:44
TileRawChannel2Bytes2::amplitude
float amplitude(unsigned int w) const
Returns the non calibrated amplitude unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes2.h:98
TIME_FACTOR2
const float TIME_FACTOR2
Definition: TileRawChannel2Bytes2.h:45
TileRawChannel2Bytes2::gain
int gain(unsigned int w) const
Returns the gain unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes2.h:93
AMPLITUDE_FACTOR2
const float AMPLITUDE_FACTOR2
Definition: TileRawChannel2Bytes2.h:37
TileRawChannel2Bytes2::quality
float quality(unsigned int w) const
Returns the quality factor unpacked from the single 32-bit word w.
Definition: TileRawChannel2Bytes2.h:109
python.PyAthena.v
v
Definition: PyAthena.py:154
a
TList * a
Definition: liststreamerinfos.cxx:10
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
extractSporadic.q
list q
Definition: extractSporadic.py:98
TileRawChannel2Bytes2::TileRawChannel2Bytes2
TileRawChannel2Bytes2()
Definition: TileRawChannel2Bytes2.h:60
TileFastRawChannel
Definition: TileFastRawChannel.h:17
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
TileRawChannel2Bytes2::setVerbose
void setVerbose(bool verbose)
Sets verbose mode true or false.
Definition: TileRawChannel2Bytes2.h:82
QUALITY_RANGE2
const int QUALITY_RANGE2
Definition: TileRawChannel2Bytes2.h:53
TIME_RANGE2
const int TIME_RANGE2
Definition: TileRawChannel2Bytes2.h:46