ATLAS Offline Software
Loading...
Searching...
No Matches
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
23
24#include <vector>
25
26// Gain encoding: one most significant bit
27const unsigned int GAIN_RANGE2 = 0x1;
28const int GAIN_SHIFT2 = 31;
29const 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
36const float AMPLITUDE_OFFSET2 = 1024.0F;
37const float AMPLITUDE_FACTOR2 = 16.0F;
38const int AMPLITUDE_RANGE2 = 0x7FFF;
39const int AMPLITUDE_SHIFT2 = 16;
40const float AMPLITUDE_MINVALUE = -800.0F;
41
42// Time encoding: 12 bits
43// Value = (time + 128) * 16, shifted by 4 bits
44const float TIME_OFFSET2 = 128.0F;
45const float TIME_FACTOR2 = 16.0F;
46const int TIME_RANGE2 = 0xFFF;
47const int TIME_SHIFT2 = 4;
48
49// Quality encoding: 4 bits
50// Value = q, not shifted
51const float QUALITY_OFFSET2 = 0.0F;
52const float QUALITY_FACTOR2 = 1.0F;
53const int QUALITY_RANGE2 = 0xF;
54const int QUALITY_SHIFT2 = 0;
55
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:
89};
90
91// inline functions
92
93inline int TileRawChannel2Bytes2::gain(unsigned int w) const {
94 int g = (w >> GAIN_SHIFT2) & GAIN_RANGE2;
95 return g;
96}
97
98inline float TileRawChannel2Bytes2::amplitude(unsigned int w) const {
101 return a;
102}
103
104inline 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
109inline float TileRawChannel2Bytes2::quality(unsigned int w) const {
110 float q = ((w >> QUALITY_SHIFT2) & QUALITY_RANGE2) * (1./QUALITY_FACTOR2) - QUALITY_OFFSET2;
111 return q;
112}
113
114#endif
static Double_t a
static Double_t rc
const int TIME_RANGE2
const unsigned int GAIN_BIT2
const int GAIN_SHIFT2
const float QUALITY_OFFSET2
const int TIME_SHIFT2
const int AMPLITUDE_RANGE2
const float AMPLITUDE_FACTOR2
const int QUALITY_SHIFT2
const float TIME_FACTOR2
const unsigned int GAIN_RANGE2
const float QUALITY_FACTOR2
const float TIME_OFFSET2
const float AMPLITUDE_MINVALUE
const int QUALITY_RANGE2
const int AMPLITUDE_SHIFT2
const float AMPLITUDE_OFFSET2
float quality(unsigned int w) const
Returns the quality factor unpacked from the single 32-bit word w.
float amplitude(unsigned int w) const
Returns the non calibrated amplitude unpacked from the single 32-bit word w.
float time(unsigned int w) const
Returns the phase of the pulse in ns, unpacked from the single 32-bit word w.
unsigned int getWord(const TileFastRawChannel *rc, int gain)
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.
void setVerbose(bool verbose)
Sets verbose mode true or false.
int getBytes(const TileFastRawChannel *rc, int gain, std::vector< unsigned int > &v)
Adds an entry to the vector<int> v for this TileRawChannel.
bool verbose
Definition hcg.cxx:73