ATLAS Offline Software
Loading...
Searching...
No Matches
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
27
28#include <vector>
29
30// Gain encoding: one most significant bit
31const unsigned int GAIN_RANGE4 = 0x1;
32const int GAIN_SHIFT4 = 31;
33const 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
40const float AMPLITUDE_OFFSET4[2] = { 512.0F, 2048.0F };
41const float AMPLITUDE_FACTOR4[4] = { 16.0F, 32.0F, 32.0F, 1.0F / 32.0F };
42const int AMPLITUDE_RANGE4 = 0x7FFF;
43const int AMPLITUDE_SHIFT4 = 16;
44
45// Time encoding: 11 bits
46// Value = time*factor + offset
47// time = (Value - offset)/factor
48const float TIME_OFFSET4 = 1024.0F;
49const float TIME_FACTOR4 = 16.0F;
50const int TIME_RANGE4 = 0x7FF;
51const int TIME_SHIFT4 = 5;
52
53// Quality encoding: 4+1 bits
54// Value = Qfactor*factor + offset
55// Qfactor = (Value - offset)/factor
56const float QUALITY_OFFSET4 = 0.0F;
57const float QUALITY_FACTOR4 = 1.0F;
58const int QUALITY_RANGE4 = 0x1F;
59const int QUALITY_RANGE4_NOFLAG = 0xF;
60const int QUALITY_RANGE4_FLAG = 0x10;
61const float QUALITY_THRESHOLD = 15.999F; // just a number between 0xF and 0x10
62const int QUALITY_SHIFT4 = 0;
63
65
67 public:
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
97inline int TileRawChannel2Bytes4::gain(unsigned int w) const {
98 int g = (w >> GAIN_SHIFT4) & GAIN_RANGE4;
99 return g;
100}
101
102inline float TileRawChannel2Bytes4::amplitude(unsigned int w, unsigned int unit) const {
103 int g = (w >> GAIN_SHIFT4) & GAIN_RANGE4;
104 float a = (((w >> AMPLITUDE_SHIFT4) & AMPLITUDE_RANGE4) - AMPLITUDE_OFFSET4[g])
106 if (unit != 0 && g == 1) a = a / 64.0F;
107 return a;
108}
109
110inline 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
115inline 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
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
static Double_t a
static Double_t rc
const int QUALITY_RANGE4
const float AMPLITUDE_OFFSET4[2]
const unsigned int GAIN_RANGE4
const float QUALITY_FACTOR4
const float QUALITY_THRESHOLD
const float TIME_FACTOR4
const unsigned int GAIN_BIT4
const int TIME_SHIFT4
const float QUALITY_OFFSET4
const int QUALITY_RANGE4_NOFLAG
const float TIME_OFFSET4
const int AMPLITUDE_SHIFT4
const int TIME_RANGE4
const int QUALITY_SHIFT4
const float AMPLITUDE_FACTOR4[4]
const int AMPLITUDE_RANGE4
const int GAIN_SHIFT4
const int QUALITY_RANGE4_FLAG
float time(unsigned int w) const
Returns the phase of the pulse in ns, unpacked from the single 32-bit word w.
float quality(unsigned int w) const
Returns the quality factor unpacked from the single 32-bit word w.
float amplitude(unsigned int w, unsigned int unit) const
Returns the amplitude in the corresponding units, unpacked from the single 32-bit word w.
void setVerbose(bool)
Sets verbose mode true or false.
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,...
int gain(unsigned int w) const
Returns the gain unpacked from the single 32-bit word w.
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.