ATLAS Offline Software
Loading...
Searching...
No Matches
LArRodBlockPhysicsV4.cxx
Go to the documentation of this file.
1//Dear emacs, this is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7// Implementation of a LArRODBlockStructure class
8// This version contains LArDigits in fixed gain.
9// See .h file for more details.
10
11#include "GaudiKernel/MsgStream.h"
14#include <iostream>
15
16#ifdef LARBSDBGOUTPUT
17#define MYLEVEL (MSG::FATAL)
18#define LARBSDBG(text) logstr<<MYLEVEL<<text<<endmsg
19#else
20#define LARBSDBG(text)
21#endif
22
25{
26 m_iHeadBlockSize=endtag/2; // The implicit cast rounds down to the right size
29}
30
47
49{
54
56 {
57 int off = -8;
59 if (getHeader16(ResultsDim1)>=8)
60 m_GainPointer=reinterpret_cast<const uint32_t*>(m_FebBlock+getHeader16(ResultsOff1)+off);
61 if (getHeader16(ResultsDim1)>=12)
62 m_MaskPointer=(const uint32_t*)(m_FebBlock+getHeader16(ResultsOff1)+8+off);
63 if (getHeader16(ResultsDim1)>=13)
64 m_HotCellsPointer=reinterpret_cast<const uint16_t*> (m_FebBlock+getHeader16(ResultsOff1)+12+off);
66 m_EnergyPointer=reinterpret_cast<const uint16_t*> (m_FebBlock+getHeader16(ResultsOff1)+13+off);
67 }
69 if (getHeader16(ResultsOff2)>=4)
70 m_TowerPointer=reinterpret_cast<const uint8_t*>(m_FebBlock+getHeader16(ResultsOff2)+off);
71 if (getHeader16(ResultsOff2)>=7)
72 m_SumPointer=reinterpret_cast<const int32_t*>(m_FebBlock+getHeader16(ResultsOff2)+4+off);
74 m_TimeQualityPointer=reinterpret_cast<const uint16_t*>(m_FebBlock+getHeader16(ResultsOff2)+7+off);
75 }
77 m_RawDataPointer=reinterpret_cast<const uint16_t*>(m_FebBlock+getHeader16(RawDataBlkOff)+off);
78
79#ifdef LARBSDBGOUTPUT
80 MsgStream logstr(Athena::getMessageSvc(), BlockType());
81 logstr << MYLEVEL << "***********************************************************************"<< endmsg;
82 logstr << MYLEVEL << "Header values :"<< endmsg;
83 logstr << MYLEVEL << "************************************************************************"<< endmsg;
84 logstr << MYLEVEL << "Fragment @ = 0x" << MSG::hex << m_FebBlock << endmsg;
85 logstr << MYLEVEL << "NWTot = " << MSG::dec << getNumberOfWords() << endmsg;
86 logstr << MYLEVEL << "FebID = 0x" << MSG::hex << getHeader32(FEBID) << endmsg;
87 logstr << MYLEVEL << "FebSN = 0x" << MSG::hex << getHeader32(FEB_SN) << endmsg;
88 logstr << MYLEVEL << "ResultsOff1 = 0x" << MSG::hex << getHeader16(ResultsOff1) << endmsg;
89 logstr << MYLEVEL << "ResultsDim1 = 0x" << MSG::hex << getHeader16(ResultsDim1) << endmsg;
90 logstr << MYLEVEL << "ResultsOff2 = 0x" << MSG::hex << getHeader16(ResultsOff2) << endmsg;
91 logstr << MYLEVEL << "ResultsDim2 = 0x" << MSG::hex << getHeader16(ResultsDim2) << endmsg;
92 logstr << MYLEVEL << "RawDataBlkOff = 0x" << MSG::hex << getHeader16(RawDataBlkOff) << endmsg;
93 logstr << MYLEVEL << "RawDataBlkDim = 0x" << MSG::hex << getHeader16(RawDataBlkDim) << endmsg;
94 logstr << MYLEVEL << "************************************************************************"<< MSG::dec << endmsg;
95
96 int size = getNumberOfWords();
97 for(int i=0;i<size;i++) {
98 logstr << MYLEVEL << MSG::hex << i << " : " << MSG::hex << m_FebBlock+i << " : " << MSG::hex << m_FebBlock[i] << endmsg;
99 }
100
101 if(m_MaskPointer) size = 4; else size = 0;
102 logstr << MYLEVEL << "Mask Block size = " << MSG::hex << size << endmsg;
103 logstr << MYLEVEL << "Mask Block address = " << MSG::hex << m_MaskPointer << endmsg;
104 for(int i=0;i<size;i++) {
105 logstr << MYLEVEL << i << " : " << MSG::hex << m_MaskPointer[i] << endmsg;
106 }
107 logstr << MYLEVEL << "End of Mask Block" << endmsg;
108#endif
109 }
110
111 return true;
112}
113
114int LArRodBlockPhysicsV4::getNextRawData(int& channelNumber, std::vector<short>& samples, uint32_t& gain)
115{
116#ifdef LARBSDBGOUTPUT
117 MsgStream logstr(Athena::getMessageSvc(), BlockType());
118 //Debug output
119 logstr << MYLEVEL << "Let s go in getNextRawData..." << endmsg;
120 logstr << MYLEVEL << "GetNextRawData for FEB 0x" << MSG::hex << (uint32_t)getHeader32(FEBID) << MSG::dec << endmsg;
121 logstr << MYLEVEL << "m_RawDataPointer=" << m_RawDataPointer << " m_RawDataIndex="<< m_RawDataIndex
122 << " m_channelsPerFEB=" << m_channelsPerFEB << endmsg;
123#endif
124
125 if (m_RawDataIndex>=m_channelsPerFEB) { //Already beyond maximal number of channels
126#ifdef LARBSDBGOUTPUT
127 logstr << MYLEVEL << "Maximum number of channels reached" << endmsg;
128#endif
129 return 0;
130 }
131 if (!m_RawDataPointer) { //Block does not exist
132#ifdef LARBSDBGOUTPUT
133 logstr << MYLEVEL << "No Raw Data Block in this FEB" << endmsg;
134#endif
135 return 0;
136 }
137
138 // Get next channel
139 unsigned rodChannelNumber=m_RawDataIndex; // Index of Channel in ROD-Block
140 channelNumber=((rodChannelNumber&0xe)<<2) + ((rodChannelNumber&0x1)<<6) + (rodChannelNumber>>4); //channel number of the FEB
141 //channelNumber=(rodChannelNumber>>4) + ((rodChannelNumber&0xf)<<3); //channel number of the FEB
142 uint32_t febgain;
143 const unsigned int nsamples = getHeader16(NSamples) & 0xff;
144 const unsigned int ngains = getHeader16(NGains);
145
146#ifdef LARBSDBGOUTPUT
147 logstr << MYLEVEL << "This FEB has " << nsamples << " samples" << endmsg;
148 logstr << MYLEVEL << "This FEB has " << ngains << " gains" << endmsg;
149#endif
150
151 if(ngains==0 || nsamples==0) return 0;
152 int s_size = nsamples+1;
153 int offset = 12;
154 int index;
155 index = s_size*m_RawDataIndex + offset;
156 uint16_t s[2];
157 s[0] = m_RawDataPointer[index++]>>2;
158 febgain = m_RawDataPointer[index++];
159 samples.push_back(s[0]);
160 for(unsigned int i=0;i<nsamples/2;i++) {
161 s[1] = m_RawDataPointer[index++]>>2;
162 s[0] = m_RawDataPointer[index++]>>2;
163 samples.push_back(s[0]);
164 samples.push_back(s[1]);
165 }
166 gain=RawToOfflineGain(febgain);
167
168#ifdef LARBSDBGOUTPUT
169 logstr << MYLEVEL << " ===> ROD Channel = " << m_RawDataIndex << endmsg;
170 logstr << MYLEVEL << " ===> FEB Channel = " << channelNumber << endmsg;
171 logstr << MYLEVEL << " ===> Gain = " << gain << endmsg;
172 for(int i=0;i<nsamples;i++)
173 logstr << MYLEVEL << " ===> sample " << i << " = " << samples[i] << endmsg;
174 int n = m_RawDataIndex;
175 int32_t e,t,q;
176 uint32_t g;
178#endif
180 unsigned rearrangeFirstSample=0;
182 rearrangeFirstSample=m_rearrangeFirstSample; //Overwrite by jobOptions
183 else
184 rearrangeFirstSample=getFirstSampleIndex();
185 if (rearrangeFirstSample && rearrangeFirstSample<samples.size()) //FIXME: Very ugly hack! See explanation in LArRodDecoder.h file
186 {//Change e.g. 3 0 1 2 4 to 0 1 2 3 4
187 short movedSample=samples[0];
188 for (unsigned i=1;i<=rearrangeFirstSample;i++)
189 samples[i-1]=samples[i];
190 samples[rearrangeFirstSample]=movedSample;
191 }
192#ifdef LARBSDBGOUTPUT
193 logstr << MYLEVEL << "GetNextRawData for FEB finished 0x" << MSG::hex << (uint32_t)getHeader32(FEBID) << MSG::dec << endmsg;
194#endif
195 return 1;
196}
197
199{
200 return getHeader16(NSamples);
201}
202
204{
205 return getHeader16(NGains);
206}
207
209{
210 return getHeader16(ResultsDim1);
211}
212
214{
215 return getHeader16(ResultsDim2);
216}
217
219{
221}
222
223uint32_t LArRodBlockPhysicsV4::getRadd(uint32_t adc, uint32_t sample) const
224{
225 if(!m_RawDataPointer) return 0;
226 int index;
227 if(sample==0) index=6;
228 else if(sample & 0x1) index=7+sample-1;
229 else index=7+sample+1;
230 uint32_t x=m_RawDataPointer[index];
231 if(adc>=8) return x>>8;
232 return x&0xff;
233}
234
235uint16_t LArRodBlockPhysicsV4::getCtrl1(uint32_t /*adc*/) const
236{
237 if(!m_RawDataPointer) return 0;
238 int index=5;
239 uint16_t x=m_RawDataPointer[index];
240 return x;
241}
242
243uint16_t LArRodBlockPhysicsV4::getCtrl2(uint32_t /*adc*/) const
244{
245 if(!m_RawDataPointer) return 0;
246 int index=4;
247 uint16_t x=m_RawDataPointer[index];
248 return x;
249}
250
251uint16_t LArRodBlockPhysicsV4::getCtrl3(uint32_t /*adc*/) const
252{
253 if(!m_RawDataPointer) return 0;
254 int index=7;
255 uint16_t x=m_RawDataPointer[index];
256 return x;
257}
258
260{
261 if(getNumberOfWords()<EventStatus/2) return 0;
262 uint32_t x=getHeader32(EventStatus);
263 return x;
264}
265
267{
268 int index = getNumberOfWords()-1;
269 if(index<m_iHeadBlockSize) return 0;
270 uint32_t sum = m_FebBlock[index];
271 return sum;
272}
273
275{
276 int end = getNumberOfWords()-3;
277 uint32_t sum = 0;
278 for(int i=0;i<end;i++) {
279 sum += m_FebBlock[i];
280 }
281 return sum & 0x7fffffff;
282}
283
284#ifdef LARBSDBGOUTPUT
285#undef LARBSDBGOUTPUT
286#endif
287#undef LARBSDBG
#define endmsg
#define MYLEVEL
#define x
const uint16_t * m_RawDataPointer
virtual uint16_t getCtrl2(uint32_t adc) const
const uint32_t * m_GainPointer
virtual uint16_t getCtrl1(uint32_t adc) const
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
uint16_t getFirstSampleIndex() const
const uint16_t * m_HotCellsPointer
virtual uint32_t getNumberOfSamples() const
virtual uint16_t getResults2Size() const
const uint16_t * m_EnergyPointer
static std::string BlockType()
virtual uint32_t onlineCheckSum() const
virtual uint16_t getResults1Size() const
LArRodBlockPhysicsV4(IMessageSvc *msgSvc)
virtual uint16_t getCtrl3(uint32_t adc) const
virtual uint32_t offlineCheckSum() const
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
virtual uint32_t getNumberOfGains() const
const uint32_t * m_MaskPointer
const uint16_t * m_TimeQualityPointer
virtual uint16_t getRawDataSize() const
virtual uint32_t getStatus() const
uint16_t getHeader16(const unsigned n) const
uint32_t getHeader32(const unsigned n) const
LArRodBlockStructure(IMessageSvc *msgSvc, const std::string &blockType)
uint32_t RawToOfflineGain(const uint32_t gain) const
uint32_t getNumberOfWords() const
singleton-like access to IMessageSvc via open function and helper
IMessageSvc * getMessageSvc(bool quiet=false)
@ LARNGAIN
Definition CaloGain.h:19
Definition index.py:1