ATLAS Offline Software
TileRawChannel2Bytes.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <algorithm>
8 #include <cmath>
9 
10 int TileRawChannel2Bytes::getBytes(const TileFastRawChannel* rc, int gain, std::vector<short>& v) {
11  // pack raw data into 16bit integers
12 
13  int a = std::lround(rc->amplitude() * AMPLITUDE_FACTOR);
14  int t = std::lround(rc->time() * TIME_FACTOR);
15  int q = std::lround(rc->quality() * QUALITY_FACTOR);
16 
17  short w1 = std::min(abs(a), amplitude_range());
18  if (a < 0) w1 |= AMPLITUDE_SIGN;
19  if (gain) w1 |= GAIN_BIT;
20  // w1 <<= AMPLITUDE_SHIFT;
21 
22  short w2 = std::min(abs(t), time_range());
23  if (t < 0) w2 |= TIME_SIGN;
24  // w2 <<= TIME_SHIFT;
25 
26  short w3 = std::min(abs(q), quality_range());
27  if (q < 0) w3 |= QUALITY_SIGN;
28  // w3 <<= QUALITY_SHIFT;
29 
30  v.push_back(w1);
31  v.push_back(w2);
32  v.push_back(w3);
33 
34  return 3;
35 }
36 
AMPLITUDE_SIGN
const int AMPLITUDE_SIGN
Definition: TileRawChannel2Bytes.h:24
GAIN_BIT
const int GAIN_BIT
Definition: TileRawChannel2Bytes.h:23
QUALITY_SIGN
const int QUALITY_SIGN
Definition: TileRawChannel2Bytes.h:32
TileRawChannel2Bytes::time_range
int time_range()
Returns TIME_RANGE .
Definition: TileRawChannel2Bytes.h:75
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
TileRawChannel2Bytes::amplitude_range
int amplitude_range()
Returns AMPLITUDE_RANGE .
Definition: TileRawChannel2Bytes.h:71
QUALITY_FACTOR
const float QUALITY_FACTOR
Definition: TileRawChannel2Bytes.h:38
TileRawChannel2Bytes::gain
int gain(short i) const
Returns the gain unpacked from the single 16-bit word w.
Definition: TileRawChannel2Bytes.h:89
min
#define min(a, b)
Definition: cfImp.cxx:40
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
TIME_FACTOR
const float TIME_FACTOR
Definition: TileRawChannel2Bytes.h:37
python.PyAthena.v
v
Definition: PyAthena.py:157
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
extractSporadic.q
list q
Definition: extractSporadic.py:98
TileFastRawChannel
Definition: TileFastRawChannel.h:17
TileFastRawChannel.h
TIME_SIGN
const int TIME_SIGN
Definition: TileRawChannel2Bytes.h:28
TileRawChannel2Bytes.h