ATLAS Offline Software
Loading...
Searching...
No Matches
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
10int 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
static Double_t a
static Double_t rc
const float QUALITY_FACTOR
const int QUALITY_SIGN
const float AMPLITUDE_FACTOR
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.
int amplitude_range()
Returns AMPLITUDE_RANGE .
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.