ATLAS Offline Software
CscRODReadOutV0.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MUONCSC_CNVTOOL_CSCRODREADOUTV0_H
6 #define MUONCSC_CNVTOOL_CSCRODREADOUTV0_H
7 
8 #include <stdint.h>
9 
10 #include <cmath>
11 #include <vector>
12 
14 
15 // CSC ROD encoder/decoder for CscRDO
16 // Author Ketevi A. Assamagan
17 // BNL December 27 2003
18 
20 public:
22  ~CscRODReadOutV0() = default;
23 
24  // get static head/footer information
29  double getSamplingTime() { return m_SAMPLING_TIME; }
30  double getStartTime() { return m_TIME_OFFSET; }
31  double getConversion() { return m_CHARGE_TO_ADC_COUNT; }
32  double getMaxTimeBin() { return m_Z0; }
33 
34  // encoding
36  void encodeFragments(const uint16_t* amplitude, const uint32_t& address, std::vector<uint32_t>& v) const;
37 
38  // initialize helper
39  void set(const CscIdHelper* cscHelper) { m_cscHelper = cscHelper; }
40 
41  // testing
42  bool isBody(const uint32_t fragment) const;
43  bool isAmplitude(const uint16_t fragment) const;
44  bool isAddress(const uint32_t fragment) const;
45 
46  // Decoding
47  void decodeSourceID(uint32_t sourceId);
48  void decodeAmplitude(const uint32_t fragment, int index);
49  void decodeAddress(const uint32_t fragment);
51  Identifier decodeAddress(const Identifier& moduleId);
52  double findCharge();
53  double signal_amplitude(double samplingTime) const;
54  uint32_t address(const Identifier& channelId, int& eta, int& phi) const;
55 
56  // Retrieve decoded results
57  uint16_t sourceID() const { return m_sourceID; }
58  uint16_t moduleType() const { return m_moduleType; }
60  uint16_t rodId() const { return m_rodId; }
61  uint16_t getAmp1() const { return m_amp1; }
62  uint16_t getAmp2() const { return m_amp2; }
63  uint16_t getAmp3() const { return m_amp3; }
64  uint16_t getAmp4() const { return m_amp4; }
65  uint32_t address() const { return m_address; }
66 
67 private:
78  double m_norm;
79 
80  double m_TIME_OFFSET;
85  double m_Z0;
86 
87  static const uint32_t ROD_HEADER = 0xEE1234EE;
88  static const uint32_t ROD_HEADER_SIZE = 0x8;
89  static const uint32_t ROD_VERSION = 0x00000000;
90  static const uint32_t ROD_FOOTER_SIZE = 0x3;
91 
92  static const uint16_t SOURCE_ID = 0x00;
93  static const uint16_t MODULE_TYPE = 0x00;
94 
95  static const uint16_t BODY_AMPLITUDE = 0x000A;
96  static const uint32_t BODY_ADDRESS = 0x0000000C;
97 
98  void set32bits(const uint16_t* v16, uint32_t& v32) const;
99  double signal(double z) const;
100 };
101 
103  uint32_t sourceIdentifier = 0;
104  sourceIdentifier = SOURCE_ID << 24 | MODULE_TYPE << 16 | side << 8 | rodId;
105  return sourceIdentifier;
106 }
107 
109  m_sourceID = (sourceID & 0xff000000) >> 24;
110  m_moduleType = (sourceID & 0x00ff0000) >> 16;
111  m_subDetectorId = (sourceID & 0x0000ff00) >> 8;
112  m_rodId = (sourceID & 0x000000ff);
113 }
114 
115 inline void CscRODReadOutV0::set32bits(const uint16_t* v16, uint32_t& v32) const {
116  uint32_t p = 0, v = 0;
117  uint16_t n = 2;
118  uint16_t pos[] = {0, 16};
119  for (uint16_t i = 0; i < n; i++) {
120  v = (uint32_t)(*(v16 + i));
121  p = (uint32_t)(*(pos + i));
122  v32 = v32 | (v << p);
123  }
124 }
125 
126 inline bool CscRODReadOutV0::isBody(const uint32_t fragment) const { return (0x80000000 & fragment); }
127 
128 inline bool CscRODReadOutV0::isAmplitude(const uint16_t fragment) const { return (0xA000 & fragment); }
129 
130 inline bool CscRODReadOutV0::isAddress(const uint32_t fragment) const { return (0xC0000000 & fragment); }
131 
132 inline void CscRODReadOutV0::decodeAmplitude(const uint32_t fragment, int index) {
133  uint32_t amp1 = 0;
134  uint32_t amp2 = 0;
135  amp1 = 0x0000FFFF & fragment;
136  amp2 = (0xFFFF0000 & fragment) >> 16;
137  if (index == 1) {
138  m_amp1 = 0x0FFF & amp1;
139  m_amp2 = 0x0FFF & amp2;
140  } else {
141  m_amp3 = 0x0FFF & amp1;
142  m_amp4 = 0x0FFF & amp2;
143  }
144 }
145 
146 inline void CscRODReadOutV0::decodeAddress(const uint32_t fragment) { m_address = 0x0003FFFF & fragment; }
147 
149  int stationName = ((m_address & 0x00020000) >> 17) + 50;
150  int stationEta = (((m_address & 0x00010000) >> 16) == 0x0) ? -1 : 1;
151  int stationPhi = ((m_address & 0x0000E000) >> 13) + 1;
152 
154 }
155 
157  int chamberLayer = ((m_address & 0x00001000) >> 12) + 1;
158  int wireLayer = ((m_address & 0x00000E00) >> 9) + 1;
159  int measuresPhi = ((m_address & 0x00000100) >> 8);
160  int strip = (m_address & 0x000000FF);
161  return m_cscHelper->channelID(moduleId, chamberLayer, wireLayer, measuresPhi, strip);
162 }
163 
164 // get the signal amplitude for a given sampling time (ns)
165 inline double CscRODReadOutV0::signal_amplitude(double samplingTime) const {
166  if (samplingTime <= m_TIME_OFFSET) return 0.0;
167  double z = (samplingTime - m_TIME_OFFSET) / m_SIGNAL_WIDTH;
168  return signal(z) / m_norm;
169 }
170 
171 // signal amplitude as a function of the time bin z
172 inline double CscRODReadOutV0::signal(double z) const {
173  double amplitude = (1.0 - z / (1 + m_NUMBER_OF_INTEGRATION)) * std::pow(z, m_NUMBER_OF_INTEGRATION) * exp(-z);
174  return amplitude;
175 }
176 
177 // find the address of this strip
178 inline uint32_t CscRODReadOutV0::address(const Identifier& channelId, int& eta, int& phi) const {
179  // unpack the strip identifier
183  int chamberLayer = m_cscHelper->chamberLayer(channelId);
184  int wireLayer = m_cscHelper->wireLayer(channelId);
185  int orientation = m_cscHelper->measuresPhi(channelId);
187 
188  // redefine the ranges
189  uint32_t nameIndex = uint32_t(name - 50);
190  uint32_t etaIndex = (eta == -1) ? 0 : 1;
191  uint32_t phiIndex = uint32_t(phi - 1);
192  uint32_t chamberIndex = uint32_t(chamberLayer - 1);
193  uint32_t layerIndex = uint32_t(wireLayer - 1);
194  uint32_t stripType = uint32_t(orientation);
195  uint32_t stripNumber = uint32_t(strip);
196 
197  // build the address
198  uint32_t address =
199  nameIndex << 17 | etaIndex << 16 | phiIndex << 13 | chamberIndex << 12 | layerIndex << 9 | stripType << 8 | stripNumber;
200 
201  return address;
202 }
203 
204 #endif // MUONCSC_CNVTOOL_CSCRODREADOUTV0_H
CscIdHelper.h
Muon::nsw::STGTPSegments::moduleIDBits::stationPhi
constexpr uint8_t stationPhi
station Phi 1 to 8
Definition: NSWSTGTPDecodeBitmaps.h:158
CscRODReadOutV0::address
uint32_t address() const
Definition: CscRODReadOutV0.h:65
SiliconTech::strip
@ strip
CscRODReadOutV0::m_SAMPLING_TIME
double m_SAMPLING_TIME
Definition: CscRODReadOutV0.h:82
CscRODReadOutV0::m_SIGNAL_WIDTH
double m_SIGNAL_WIDTH
Definition: CscRODReadOutV0.h:81
CscRODReadOutV0::m_sourceID
uint16_t m_sourceID
Definition: CscRODReadOutV0.h:69
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
CscRODReadOutV0::getMaxTimeBin
double getMaxTimeBin()
Definition: CscRODReadOutV0.h:32
CscRODReadOutV0::m_subDetectorId
uint16_t m_subDetectorId
Definition: CscRODReadOutV0.h:72
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
index
Definition: index.py:1
CscRODReadOutV0
Definition: CscRODReadOutV0.h:19
CscRODReadOutV0::m_moduleType
uint16_t m_moduleType
Definition: CscRODReadOutV0.h:70
CscRODReadOutV0::getSourceID
uint32_t getSourceID(uint16_t side, uint16_t rodId)
Definition: CscRODReadOutV0.h:102
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
CscRODReadOutV0::decodeAmplitude
void decodeAmplitude(const uint32_t fragment, int index)
Definition: CscRODReadOutV0.h:132
CscRODReadOutV0::~CscRODReadOutV0
~CscRODReadOutV0()=default
CscRODReadOutV0::getHeaderMarker
uint32_t getHeaderMarker()
Definition: CscRODReadOutV0.h:25
MuonIdHelper::stationName
int stationName(const Identifier &id) const
Definition: MuonIdHelper.cxx:800
CscRODReadOutV0::m_norm
double m_norm
Definition: CscRODReadOutV0.h:78
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
CscRODReadOutV0::MODULE_TYPE
static const uint16_t MODULE_TYPE
Definition: CscRODReadOutV0.h:93
CscRODReadOutV0::isAddress
bool isAddress(const uint32_t fragment) const
Definition: CscRODReadOutV0.h:130
CscRODReadOutV0::decodeAddress
Identifier decodeAddress()
Definition: CscRODReadOutV0.h:148
CscRODReadOutV0::m_NUMBER_OF_INTEGRATION
int m_NUMBER_OF_INTEGRATION
Definition: CscRODReadOutV0.h:83
CscRODReadOutV0::decodeSourceID
void decodeSourceID(uint32_t sourceId)
Definition: CscRODReadOutV0.h:108
CscRODReadOutV0::m_amp2
uint16_t m_amp2
Definition: CscRODReadOutV0.h:74
TRT::Hit::side
@ side
Definition: HitInfo.h:83
CscRODReadOutV0::ROD_HEADER_SIZE
static const uint32_t ROD_HEADER_SIZE
Definition: CscRODReadOutV0.h:88
CscIdHelper::wireLayer
int wireLayer(const Identifier &id) const
Definition: CscIdHelper.cxx:772
CscRODReadOutV0::signal
double signal(double z) const
Definition: CscRODReadOutV0.h:172
CscRODReadOutV0::ROD_VERSION
static const uint32_t ROD_VERSION
Definition: CscRODReadOutV0.h:89
CscRODReadOutV0::rodId
uint16_t rodId() const
Definition: CscRODReadOutV0.h:60
CscRODReadOutV0::signal_amplitude
double signal_amplitude(double samplingTime) const
Definition: CscRODReadOutV0.h:165
CscRODReadOutV0::CscRODReadOutV0
CscRODReadOutV0()
Definition: CscRODReadOutV0.cxx:8
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
CscRODReadOutV0::getHeaderSize
uint32_t getHeaderSize()
Definition: CscRODReadOutV0.h:26
CscRODReadOutV0::getAmp2
uint16_t getAmp2() const
Definition: CscRODReadOutV0.h:62
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
beamspotman.n
n
Definition: beamspotman.py:731
CscRODReadOutV0::set32bits
void set32bits(const uint16_t *v16, uint32_t &v32) const
Definition: CscRODReadOutV0.h:115
CscRODReadOutV0::m_amp3
uint16_t m_amp3
Definition: CscRODReadOutV0.h:75
CscRODReadOutV0::getAmp3
uint16_t getAmp3() const
Definition: CscRODReadOutV0.h:63
CscRODReadOutV0::findCharge
double findCharge()
Definition: CscRODReadOutV0.cxx:68
CscRODReadOutV0::m_Z0
double m_Z0
Definition: CscRODReadOutV0.h:85
CscRODReadOutV0::getStartTime
double getStartTime()
Definition: CscRODReadOutV0.h:30
CscRODReadOutV0::isAmplitude
bool isAmplitude(const uint16_t fragment) const
Definition: CscRODReadOutV0.h:128
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
CscRODReadOutV0::moduleType
uint16_t moduleType() const
Definition: CscRODReadOutV0.h:58
CscRODReadOutV0::getAmp1
uint16_t getAmp1() const
Definition: CscRODReadOutV0.h:61
CscRODReadOutV0::getConversion
double getConversion()
Definition: CscRODReadOutV0.h:31
CscRODReadOutV0::getFooterSize
uint32_t getFooterSize()
Definition: CscRODReadOutV0.h:27
MuonIdHelper::stationPhi
int stationPhi(const Identifier &id) const
Definition: MuonIdHelper.cxx:810
CscRODReadOutV0::ROD_FOOTER_SIZE
static const uint32_t ROD_FOOTER_SIZE
Definition: CscRODReadOutV0.h:90
CscRODReadOutV0::m_amp4
uint16_t m_amp4
Definition: CscRODReadOutV0.h:76
CscIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int chamberLayer, int wireLayer, int measuresPhi, int strip) const
Definition: CscIdHelper.cxx:706
CscRODReadOutV0::m_amp1
uint16_t m_amp1
Definition: CscRODReadOutV0.h:73
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CscRODReadOutV0::isBody
bool isBody(const uint32_t fragment) const
Definition: CscRODReadOutV0.h:126
CscRODReadOutV0::getAmp4
uint16_t getAmp4() const
Definition: CscRODReadOutV0.h:64
MuonIdHelper::stationEta
int stationEta(const Identifier &id) const
Definition: MuonIdHelper.cxx:805
CscRODReadOutV0::m_cscHelper
const CscIdHelper * m_cscHelper
Definition: CscRODReadOutV0.h:68
CscRODReadOutV0::sourceID
uint16_t sourceID() const
Definition: CscRODReadOutV0.h:57
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CscIdHelper::elementID
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Definition: CscIdHelper.cxx:678
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
CscRODReadOutV0::subDetectorId
uint16_t subDetectorId() const
Definition: CscRODReadOutV0.h:59
python.PyAthena.v
v
Definition: PyAthena.py:154
CscRODReadOutV0::BODY_AMPLITUDE
static const uint16_t BODY_AMPLITUDE
Definition: CscRODReadOutV0.h:95
CscIdHelper
Definition: CscIdHelper.h:52
CscRODReadOutV0::SOURCE_ID
static const uint16_t SOURCE_ID
Definition: CscRODReadOutV0.h:92
CscRODReadOutV0::getSamplingTime
double getSamplingTime()
Definition: CscRODReadOutV0.h:29
CscRODReadOutV0::BODY_ADDRESS
static const uint32_t BODY_ADDRESS
Definition: CscRODReadOutV0.h:96
CscIdHelper::strip
int strip(const Identifier &id) const
Definition: CscIdHelper.cxx:776
CscRODReadOutV0::m_CHARGE_TO_ADC_COUNT
double m_CHARGE_TO_ADC_COUNT
Definition: CscRODReadOutV0.h:84
CscRODReadOutV0::ROD_HEADER
static const uint32_t ROD_HEADER
Definition: CscRODReadOutV0.h:87
CscRODReadOutV0::m_rodId
uint16_t m_rodId
Definition: CscRODReadOutV0.h:71
CscIdHelper::measuresPhi
bool measuresPhi(const Identifier &id) const override
Definition: CscIdHelper.cxx:774
CscRODReadOutV0::getFormatVersion
uint32_t getFormatVersion()
Definition: CscRODReadOutV0.h:28
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:156
CscRODReadOutV0::set
void set(const CscIdHelper *cscHelper)
Definition: CscRODReadOutV0.h:39
CscRODReadOutV0::m_address
uint32_t m_address
Definition: CscRODReadOutV0.h:77
CscIdHelper::chamberLayer
int chamberLayer(const Identifier &id) const
Definition: CscIdHelper.cxx:770
CscRODReadOutV0::encodeFragments
void encodeFragments(const uint16_t *amplitude, const uint32_t &address, std::vector< uint32_t > &v) const
Definition: CscRODReadOutV0.cxx:53
CscRODReadOutV0::m_TIME_OFFSET
double m_TIME_OFFSET
Definition: CscRODReadOutV0.h:80
Identifier
Definition: IdentifierFieldParser.cxx:14