ATLAS Offline Software
Loading...
Searching...
No Matches
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)
23const int GAIN_BIT = 0x8000;
24const int AMPLITUDE_SIGN = 0x4000;
25const int AMPLITUDE_RANGE = 0x3FFF;
26
27// Time encoding: sign bit + Value(15bits)
28const int TIME_SIGN = 0x8000;
29const int TIME_RANGE = 0x7FFF;
30
31// Quality encoding: sign bit + Value(15bits)
32const int QUALITY_SIGN = 0x8000;
33const int QUALITY_RANGE = 0x7FFF;
34
35// Conversion factors from double to int values
36const float AMPLITUDE_FACTOR = 16.0F;
37const float TIME_FACTOR = 256.0F;
38const float QUALITY_FACTOR = 32768.0F;
39
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 }
74
75 inline int time_range() {
76 return TIME_RANGE;
77 }
78
79 inline int quality_range() {
80 return QUALITY_RANGE;
81 }
82
85};
86
87// inline functions
88
89inline int TileRawChannel2Bytes::gain(short s) const {
90 // s >>= AMPLITUDE_SHIFT;
91 int g = (s & GAIN_BIT) ? 1 : 0;
92 return g;
93}
94
95inline 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
102inline 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
109inline 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
static Double_t a
static Double_t rc
const int AMPLITUDE_RANGE
const float QUALITY_FACTOR
const int QUALITY_SIGN
const float AMPLITUDE_FACTOR
const int TIME_RANGE
const int QUALITY_RANGE
const float TIME_FACTOR
const int TIME_SIGN
const int AMPLITUDE_SIGN
const int GAIN_BIT
int quality_range()
Retuns QUALITY_RANGE .
int gain(short i) const
Returns the gain unpacked from the single 16-bit word w.
void setVerbose(bool verbose)
Sets verbose mode true or false.
int amplitude_range()
Returns AMPLITUDE_RANGE .
bool m_verbose
Verbose flag.
float quality(short i) const
Returns the quality factor unpacked from a single 16-bit word w.
float amplitude(short i) const
Returns the non calibrated amplitude unpacked from a single 16-bit word w.
int time_range()
Returns TIME_RANGE .
int getBytes(const TileFastRawChannel *rc, int gain, std::vector< short > &v)
Pack TileRawChannel information (gain, amplitude, phase and quality) in 3 16-bit words.
float time(short i) const
Returns the phase of the pulse, unpacked from a single 16-bit word w.
bool verbose
Definition hcg.cxx:73