ATLAS Offline Software
TileRawChannel2Bytes.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TILEBYTESTREAM_TILERAWCHANNEL2BYTES_H
6 #define TILEBYTESTREAM_TILERAWCHANNEL2BYTES_H
7 // This class converts the TileRawChannel object into bytes
8 //
9 
20 #include <vector>
21 
22 // Amplitude encoding: gain bit + sign bit + Value(14bits)
23 const int GAIN_BIT = 0x8000;
24 const int AMPLITUDE_SIGN = 0x4000;
25 const int AMPLITUDE_RANGE = 0x3FFF;
26 
27 // Time encoding: sign bit + Value(15bits)
28 const int TIME_SIGN = 0x8000;
29 const int TIME_RANGE = 0x7FFF;
30 
31 // Quality encoding: sign bit + Value(15bits)
32 const int QUALITY_SIGN = 0x8000;
33 const int QUALITY_RANGE = 0x7FFF;
34 
35 // Conversion factors from double to int values
36 const float AMPLITUDE_FACTOR = 16.0F;
37 const float TIME_FACTOR = 256.0F;
38 const float QUALITY_FACTOR = 32768.0F;
39 
40 class TileFastRawChannel;
41 
43  public:
45  : m_verbose(false) {
46  }
47 
51  int getBytes(const TileFastRawChannel* rc, int gain, std::vector<short>& v);
52 
53  // unpack short to double
55  inline int gain(short i) const;
57  inline float amplitude(short i) const;
59  inline float time(short i) const;
61  inline float quality(short i) const;
62 
64  inline void setVerbose(bool verbose) {
66  }
67 
68  private:
69 
71  inline int amplitude_range() {
72  return AMPLITUDE_RANGE;
73  }
75  inline int time_range() {
76  return TIME_RANGE;
77  }
79  inline int quality_range() {
80  return QUALITY_RANGE;
81  }
82 
84  bool m_verbose;
85 };
86 
87 // inline functions
88 
89 inline int TileRawChannel2Bytes::gain(short s) const {
90  // s >>= AMPLITUDE_SHIFT;
91  int g = (s & GAIN_BIT) ? 1 : 0;
92  return g;
93 }
94 
95 inline float TileRawChannel2Bytes::amplitude(short s) const {
96  // s >>= AMPLITUDE_SHIFT;
97  float a = (s & AMPLITUDE_RANGE) * (1./AMPLITUDE_FACTOR);
98  if (s & AMPLITUDE_SIGN) a = -a;
99  return a;
100 }
101 
102 inline float TileRawChannel2Bytes::time(short s) const {
103  // s >>= TIME_SHIFT;
104  float t = (s & TIME_RANGE) * (1./TIME_FACTOR);
105  if (s & TIME_SIGN) t = -t;
106  return t;
107 }
108 
109 inline float TileRawChannel2Bytes::quality(short s) const {
110  // s >>= QUALITY_SHIFT;
111  float q = (s & QUALITY_RANGE) * (1./QUALITY_FACTOR);
112  if (s & QUALITY_SIGN) q = -q;
113  return q;
114 }
115 
116 #endif
AMPLITUDE_SIGN
const int AMPLITUDE_SIGN
Definition: TileRawChannel2Bytes.h:24
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
GAIN_BIT
const int GAIN_BIT
Definition: TileRawChannel2Bytes.h:23
TileRawChannel2Bytes::setVerbose
void setVerbose(bool verbose)
Sets verbose mode true or false.
Definition: TileRawChannel2Bytes.h:64
TileRawChannel2Bytes::amplitude
float amplitude(short i) const
Returns the non calibrated amplitude unpacked from a single 16-bit word w.
Definition: TileRawChannel2Bytes.h:95
QUALITY_SIGN
const int QUALITY_SIGN
Definition: TileRawChannel2Bytes.h:32
TileRawChannel2Bytes::time_range
int time_range()
Returns TIME_RANGE .
Definition: TileRawChannel2Bytes.h:75
AMPLITUDE_RANGE
const int AMPLITUDE_RANGE
Definition: TileRawChannel2Bytes.h:25
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
TileRawChannel2Bytes::amplitude_range
int amplitude_range()
Returns AMPLITUDE_RANGE .
Definition: TileRawChannel2Bytes.h:71
TileRawChannel2Bytes::m_verbose
bool m_verbose
Verbose flag.
Definition: TileRawChannel2Bytes.h:84
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
QUALITY_FACTOR
const float QUALITY_FACTOR
Definition: TileRawChannel2Bytes.h:38
QUALITY_RANGE
const int QUALITY_RANGE
Definition: TileRawChannel2Bytes.h:33
TileRawChannel2Bytes::quality
float quality(short i) const
Returns the quality factor unpacked from a single 16-bit word w.
Definition: TileRawChannel2Bytes.h:109
TileRawChannel2Bytes::gain
int gain(short i) const
Returns the gain unpacked from the single 16-bit word w.
Definition: TileRawChannel2Bytes.h:89
TileRawChannel2Bytes::getBytes
int getBytes(const TileFastRawChannel *rc, int gain, std::vector< short > &v)
Pack TileRawChannel information (gain, amplitude, phase and quality) in 3 16-bit words.
Definition: TileRawChannel2Bytes.cxx:10
TileRawChannel2Bytes::time
float time(short i) const
Returns the phase of the pulse, unpacked from a single 16-bit word w.
Definition: TileRawChannel2Bytes.h:102
TIME_FACTOR
const float TIME_FACTOR
Definition: TileRawChannel2Bytes.h:37
TileRawChannel2Bytes
Converts the TileRawChannel object into bytes.
Definition: TileRawChannel2Bytes.h:42
TileRawChannel2Bytes::TileRawChannel2Bytes
TileRawChannel2Bytes()
Definition: TileRawChannel2Bytes.h:44
python.PyAthena.v
v
Definition: PyAthena.py:154
TileRawChannel2Bytes::quality_range
int quality_range()
Retuns QUALITY_RANGE .
Definition: TileRawChannel2Bytes.h:79
a
TList * a
Definition: liststreamerinfos.cxx:10
AMPLITUDE_FACTOR
const float AMPLITUDE_FACTOR
Definition: TileRawChannel2Bytes.h:36
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
TIME_RANGE
const int TIME_RANGE
Definition: TileRawChannel2Bytes.h:29
extractSporadic.q
list q
Definition: extractSporadic.py:98
TileFastRawChannel
Definition: TileFastRawChannel.h:17
TIME_SIGN
const int TIME_SIGN
Definition: TileRawChannel2Bytes.h:28