ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannel2Bytes4.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
11 unsigned int unit,
12 int gain,
13 std::vector<unsigned int>& v) const
14{
15 // pack raw data into one 32-bits integer
16 v.push_back(getWord(rc, unit, gain));
17
18 return 1; // one int added to vector
19}
20
22 unsigned int unit,
23 int gain) const
24{
25 // pack raw data into one 32-bits integer
26 float tmp = rc.amplitude();
27 if (unit != 0 && gain == 1) tmp = tmp * 64.0F;
28 unsigned int a = std::max(0, std::min(AMPLITUDE_RANGE4
29 , (int) std::lround(tmp * AMPLITUDE_FACTOR4[unit] + AMPLITUDE_OFFSET4[gain])));
30
31 unsigned int t = std::max(0,std::min(TIME_RANGE4
32 , (int) std::lround(rc.time() * TIME_FACTOR4 + TIME_OFFSET4)));
33
34 unsigned int q = std::max(0,
35 std::min(QUALITY_RANGE4_NOFLAG,
36 (int) std::lround(rc.quality() * QUALITY_FACTOR4 + QUALITY_OFFSET4)));
37
38 unsigned int w = (a << AMPLITUDE_SHIFT4) | (t << TIME_SHIFT4) | (q << QUALITY_SHIFT4);
39
40 if (gain) w |= GAIN_BIT4;
41
42 return w;
43}
44
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 float AMPLITUDE_OFFSET4[2]
const float QUALITY_FACTOR4
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
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.