ATLAS Offline Software
LArRodBlockPhysicsV4.cxx
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2022 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"
13 //#include <cstdio>
15 #include <iostream>
16 
17 //#define LARBSDBGOUTPUT
18 #ifdef LARBSDBGOUTPUT
19 #define MYLEVEL (MSG::FATAL)
20 #define LARBSDBG(text) logstr<<MYLEVEL<<text<<endmsg
21 #else
22 #define LARBSDBG(text)
23 #endif
24 
26 {
27  m_iHeadBlockSize=endtag/2; // The implicit cast rounds down to the right size
30 }
31 
33 {
34  m_EnergyIndex=0;
37  m_TowerIndex=0;
38 
42  m_GainPointer=0;
43  m_MaskPointer=0;
45  m_SumPointer=0;
47 }
48 
50 {
51  m_EnergyIndex=0;
54  m_TowerIndex=0;
55 
57  {
58  int off = -8;
59  if (getHeader16(ResultsOff1)) {
60  if (getHeader16(ResultsDim1)>=8)
62  if (getHeader16(ResultsDim1)>=12)
64  if (getHeader16(ResultsDim1)>=13)
66  if (getHeader16(ResultsDim1)>13)
68  }
69  if (getHeader16(ResultsOff2)) {
70  if (getHeader16(ResultsOff2)>=4)
72  if (getHeader16(ResultsOff2)>=7)
73  m_SumPointer=(const int32_t*)(m_FebBlock+getHeader16(ResultsOff2)+4+off);
74  if (getHeader16(ResultsOff2)>7)
76  }
79 
80 #ifdef LARBSDBGOUTPUT
81  MsgStream logstr(Athena::getMessageSvc(), BlockType());
82  logstr << MYLEVEL << "***********************************************************************"<< endmsg;
83  logstr << MYLEVEL << "Header values :"<< endmsg;
84  logstr << MYLEVEL << "************************************************************************"<< endmsg;
85  logstr << MYLEVEL << "Fragment @ = 0x" << MSG::hex << m_FebBlock << endmsg;
86  logstr << MYLEVEL << "NWTot = " << MSG::dec << getNumberOfWords() << endmsg;
87  logstr << MYLEVEL << "FebID = 0x" << MSG::hex << getHeader32(FEBID) << endmsg;
88  logstr << MYLEVEL << "FebSN = 0x" << MSG::hex << getHeader32(FEB_SN) << endmsg;
89  logstr << MYLEVEL << "ResultsOff1 = 0x" << MSG::hex << getHeader16(ResultsOff1) << endmsg;
90  logstr << MYLEVEL << "ResultsDim1 = 0x" << MSG::hex << getHeader16(ResultsDim1) << endmsg;
91  logstr << MYLEVEL << "ResultsOff2 = 0x" << MSG::hex << getHeader16(ResultsOff2) << endmsg;
92  logstr << MYLEVEL << "ResultsDim2 = 0x" << MSG::hex << getHeader16(ResultsDim2) << endmsg;
93  logstr << MYLEVEL << "RawDataBlkOff = 0x" << MSG::hex << getHeader16(RawDataBlkOff) << endmsg;
94  logstr << MYLEVEL << "RawDataBlkDim = 0x" << MSG::hex << getHeader16(RawDataBlkDim) << endmsg;
95  logstr << MYLEVEL << "************************************************************************"<< MSG::dec << endmsg;
96 
97  int size = getNumberOfWords();
98  for(int i=0;i<size;i++) {
99  logstr << MYLEVEL << MSG::hex << i << " : " << MSG::hex << m_FebBlock+i << " : " << MSG::hex << m_FebBlock[i] << endmsg;
100  }
101 
102  if(m_MaskPointer) size = 4; else size = 0;
103  logstr << MYLEVEL << "Mask Block size = " << MSG::hex << size << endmsg;
104  logstr << MYLEVEL << "Mask Block address = " << MSG::hex << m_MaskPointer << endmsg;
105  for(int i=0;i<size;i++) {
106  logstr << MYLEVEL << i << " : " << MSG::hex << m_MaskPointer[i] << endmsg;
107  }
108  logstr << MYLEVEL << "End of Mask Block" << endmsg;
109 #endif
110  }
111 
112  return true;
113 }
114 
115 int LArRodBlockPhysicsV4::getNextRawData(int& channelNumber, std::vector<short>& samples, uint32_t& gain)
116 {
117  //std::cout << " I am here !!!!!!!!!!!!!!!!!!!!!! " << std::endl;
118 #ifdef LARBSDBGOUTPUT
119  MsgStream logstr(Athena::getMessageSvc(), BlockType());
120  //Debug output
121  logstr << MYLEVEL << "Let s go in getNextRawData..." << endmsg;
122  logstr << MYLEVEL << "GetNextRawData for FEB 0x" << MSG::hex << (uint32_t)getHeader32(FEBID) << MSG::dec << endmsg;
123  logstr << MYLEVEL << "m_RawDataPointer=" << m_RawDataPointer << " m_RawDataIndex="<< m_RawDataIndex
124  << " m_channelsPerFEB=" << m_channelsPerFEB << endmsg;
125 #endif
126 
127  if (m_RawDataIndex>=m_channelsPerFEB) { //Already beyond maximal number of channels
128 #ifdef LARBSDBGOUTPUT
129  logstr << MYLEVEL << "Maximum number of channels reached" << endmsg;
130 #endif
131  return 0;
132  }
133  //const uint16_t block = getHeader16(m_RawDataOff);//Position of the raw FEB data block
134  if (!m_RawDataPointer) { //Block does not exist
135 #ifdef LARBSDBGOUTPUT
136  logstr << MYLEVEL << "No Raw Data Block in this FEB" << endmsg;
137 #endif
138  return 0;
139  }
140 
141  // Get next channel
142  unsigned rodChannelNumber=m_RawDataIndex; // Index of Channel in ROD-Block
143  channelNumber=((rodChannelNumber&0xe)<<2) + ((rodChannelNumber&0x1)<<6) + (rodChannelNumber>>4); //channel number of the FEB
144  //channelNumber=(rodChannelNumber>>4) + ((rodChannelNumber&0xf)<<3); //channel number of the FEB
145  uint32_t febgain;
146  const unsigned int nsamples = getHeader16(NSamples) & 0xff;
147  const unsigned int ngains = getHeader16(NGains);
148 
149 #ifdef LARBSDBGOUTPUT
150  logstr << MYLEVEL << "This FEB has " << nsamples << " samples" << endmsg;
151  logstr << MYLEVEL << "This FEB has " << ngains << " gains" << endmsg;
152 #endif
153 
154  if(ngains==0 || nsamples==0) return 0;
155  int s_size = nsamples+1;
156  int offset = 12;
157  int index;
158  index = s_size*m_RawDataIndex + offset;
159  uint16_t s[2];
160  s[0] = m_RawDataPointer[index++]>>2;
161  febgain = m_RawDataPointer[index++];
162  samples.push_back(s[0]);
163  for(unsigned int i=0;i<nsamples/2;i++) {
164  s[1] = m_RawDataPointer[index++]>>2;
165  s[0] = m_RawDataPointer[index++]>>2;
166  samples.push_back(s[0]);
167  samples.push_back(s[1]);
168  }
169  gain=RawToOfflineGain(febgain);
170 
171 #ifdef LARBSDBGOUTPUT
172  logstr << MYLEVEL << " ===> ROD Channel = " << m_RawDataIndex << endmsg;
173  logstr << MYLEVEL << " ===> FEB Channel = " << channelNumber << endmsg;
174  logstr << MYLEVEL << " ===> Gain = " << gain << endmsg;
175  for(int i=0;i<nsamples;i++)
176  logstr << MYLEVEL << " ===> sample " << i << " = " << samples[i] << endmsg;
177  int n = m_RawDataIndex;
178  int32_t e,t,q;
179  uint32_t g;
181 #endif
182  //std::cout << "Gain= " << gain << " Febgain=" << febgain << std::endl;
183  ++m_RawDataIndex;
184  unsigned rearrangeFirstSample=0;
186  rearrangeFirstSample=m_rearrangeFirstSample; //Overwrite by jobOptions
187  else
188  rearrangeFirstSample=getFirstSampleIndex();
189  //std::cout << "FebConfig: "<< getFebConfig() << " FirstSampleIndex " << getFirstSampleIndex() <<std::endl;
190  if (rearrangeFirstSample && rearrangeFirstSample<samples.size()) //FIXME: Very ugly hack! See explanation in LArRodDecoder.h file
191  {//Change e.g. 3 0 1 2 4 to 0 1 2 3 4
192  short movedSample=samples[0];
193  for (unsigned i=1;i<=rearrangeFirstSample;i++)
194  samples[i-1]=samples[i];
195  samples[rearrangeFirstSample]=movedSample;
196  }
197 #ifdef LARBSDBGOUTPUT
198  logstr << MYLEVEL << "GetNextRawData for FEB finished 0x" << MSG::hex << (uint32_t)getHeader32(FEBID) << MSG::dec << endmsg;
199 #endif
200  return 1;
201 }
202 
204 {
205  return getHeader16(NSamples);
206 }
207 
209 {
210  return getHeader16(NGains);
211 }
212 
214 {
215  return getHeader16(ResultsDim1);
216 }
217 
219 {
220  return getHeader16(ResultsDim2);
221 }
222 
224 {
225  return getHeader16(RawDataBlkDim);
226 }
227 
229 {
230  if(!m_RawDataPointer) return 0;
231  int index;
232  if(sample==0) index=6;
233  else if(sample & 0x1) index=7+sample-1;
234  else index=7+sample+1;
236  if(adc>=8) return x>>8;
237  return x&0xff;
238 }
239 
241 {
242  if(!m_RawDataPointer) return 0;
243  int index=5;
245  return x;
246 }
247 
249 {
250  if(!m_RawDataPointer) return 0;
251  int index=4;
253  return x;
254 }
255 
257 {
258  if(!m_RawDataPointer) return 0;
259  int index=7;
261  return x;
262 }
263 
265 {
266  if(getNumberOfWords()<EventStatus/2) return 0;
268  return x;
269 }
270 
272 {
273  //int size = getNumberOfWords();
274  int index = getNumberOfWords()-1;
275  if(index<m_iHeadBlockSize) return 0;
277  //for(int i=size-10;i<size;i++) {
278  // std::cout << i << " : " << std::hex << m_FebBlock+i << " : " << m_FebBlock[i] << std::endl;
279  //}
280  return sum;
281 }
282 
284 {
285  int end = getNumberOfWords()-3;
286  //int start = 0; //m_iHeadBlockSize;
287  uint32_t sum = 0;
288  for(int i=0;i<end;i++) {
289  sum += m_FebBlock[i];
290  //std::cout << i << " : " << std::hex << sum << " : " << m_FebBlock[i] << std::endl;
291  }
292  return sum & 0x7fffffff;
293 }
294 
295 #ifdef LARBSDBGOUTPUT
296 #undef LARBSDBGOUTPUT
297 #endif
298 #undef LARBSDBG
LArRodBlockPhysicsV4::resetPointers
virtual void resetPointers()
Definition: LArRodBlockPhysicsV4.cxx:32
LArRodBlockStructure
Definition: LArRodBlockStructure.h:48
LArRodBlockPhysicsV4::m_EnergyPointer
const uint16_t * m_EnergyPointer
Definition: LArRodBlockPhysicsV4.h:107
LArRodBlockPhysicsV4::NGains
@ NGains
Definition: LArRodBlockPhysicsV4.h:50
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
LArRodBlockPhysicsV4::ResultsDim1
@ ResultsDim1
Definition: LArRodBlockPhysicsV4.h:43
LArRodBlockPhysicsV4::getNumberOfGains
virtual uint32_t getNumberOfGains() const
Definition: LArRodBlockPhysicsV4.cxx:208
LArRodBlockPhysicsV4::RawDataBlkOff
@ RawDataBlkOff
Definition: LArRodBlockPhysicsV4.h:46
LArRodBlockPhysicsV4::EventStatus
@ EventStatus
Definition: LArRodBlockPhysicsV4.h:48
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
LArRodBlockPhysicsV4::getNextEnergy
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
Definition: LArRodBlockPhysicsV4.h:136
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
LArRodBlockPhysicsV4::getRawDataSize
virtual uint16_t getRawDataSize() const
Definition: LArRodBlockPhysicsV4.cxx:223
LArRodBlockPhysicsV4::NSamples
@ NSamples
Definition: LArRodBlockPhysicsV4.h:51
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LArRodBlockStructure::getNumberOfWords
uint32_t getNumberOfWords() const
Definition: LArRodBlockStructure.h:428
index
Definition: index.py:1
LArRodBlockPhysicsV4::m_TimeQualityPointer
const uint16_t * m_TimeQualityPointer
Definition: LArRodBlockPhysicsV4.h:108
LArRodBlockPhysicsV4::getResults2Size
virtual uint16_t getResults2Size() const
Definition: LArRodBlockPhysicsV4.cxx:218
LArRodBlockStructure::m_FebBlockSize
int32_t m_FebBlockSize
Definition: LArRodBlockStructure.h:229
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArRodBlockPhysicsV4::getCtrl1
virtual uint16_t getCtrl1(uint32_t adc) const
Definition: LArRodBlockPhysicsV4.cxx:240
LArRodBlockPhysicsV4::FEBID
@ FEBID
Definition: LArRodBlockPhysicsV4.h:38
LArRodBlockStructure::m_FebBlock
const uint32_t * m_FebBlock
Definition: LArRodBlockStructure.h:227
LArRodBlockPhysicsV4::getResults1Size
virtual uint16_t getResults1Size() const
Definition: LArRodBlockPhysicsV4.cxx:213
LArRodBlockPhysicsV4::endtag
@ endtag
Definition: LArRodBlockPhysicsV4.h:56
LArRodBlockPhysicsV4::m_MaskPointer
const uint32_t * m_MaskPointer
Definition: LArRodBlockPhysicsV4.h:111
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
x
#define x
LArRodBlockPhysicsV4::getStatus
virtual uint32_t getStatus() const
Definition: LArRodBlockPhysicsV4.cxx:264
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
LArRodBlockPhysicsV4::m_RawDataPointer
const uint16_t * m_RawDataPointer
Definition: LArRodBlockPhysicsV4.h:109
LArRodBlockPhysicsV4::setPointers
virtual bool setPointers()
Definition: LArRodBlockPhysicsV4.cxx:49
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
LArRodBlockPhysicsV4.h
LArRodBlockPhysicsV4::ResultsOff2
@ ResultsOff2
Definition: LArRodBlockPhysicsV4.h:44
LArRodBlockPhysicsV4::m_GainPointer
const uint32_t * m_GainPointer
Definition: LArRodBlockPhysicsV4.h:110
LArRodBlockStructure::m_iHeadBlockSize
unsigned short m_iHeadBlockSize
Definition: LArRodBlockStructure.h:221
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
LArRodBlockStructure::m_rearrangeFirstSample
unsigned int m_rearrangeFirstSample
Definition: LArRodBlockStructure.h:241
LArRodBlockPhysicsV4::m_TowerPointer
const uint8_t * m_TowerPointer
Definition: LArRodBlockPhysicsV4.h:113
LArRodBlockStructure::getHeader32
uint32_t getHeader32(const unsigned n) const
Definition: LArRodBlockStructure.h:365
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
LArRodBlockStructure::RawToOfflineGain
uint32_t RawToOfflineGain(const uint32_t gain) const
Definition: LArRodBlockStructure.h:349
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
lumiFormat.i
int i
Definition: lumiFormat.py:92
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
01SubmitToGrid.samples
samples
Definition: 01SubmitToGrid.py:58
LArRodBlockPhysicsV4::getFirstSampleIndex
uint16_t getFirstSampleIndex() const
Definition: LArRodBlockPhysicsV4.h:131
LArRodBlockPhysicsV4::ResultsOff1
@ ResultsOff1
Definition: LArRodBlockPhysicsV4.h:42
MYLEVEL
#define MYLEVEL
Definition: LArRodBlockPhysicsV3.h:47
LArRodBlockPhysicsV4::m_fixedGain
int m_fixedGain
Definition: LArRodBlockPhysicsV4.h:117
LArRodBlockPhysicsV4::m_TowerIndex
int m_TowerIndex
Definition: LArRodBlockPhysicsV4.h:106
LArRodBlockPhysicsV4::m_SumPointer
const int32_t * m_SumPointer
Definition: LArRodBlockPhysicsV4.h:114
LArRodBlockPhysicsV4::getNextRawData
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
Definition: LArRodBlockPhysicsV4.cxx:115
LArRodBlockPhysicsV4::FEB_SN
@ FEB_SN
Definition: LArRodBlockPhysicsV4.h:40
LArRodBlockPhysicsV4::BlockType
std::string BlockType()
Definition: LArRodBlockPhysicsV4.h:62
ReadOfcFromCool.nsamples
nsamples
Definition: ReadOfcFromCool.py:115
DeMoScan.index
string index
Definition: DeMoScan.py:362
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
LArRodBlockPhysicsV4::ResultsDim2
@ ResultsDim2
Definition: LArRodBlockPhysicsV4.h:45
LArRodBlockPhysicsV4::getRadd
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
Definition: LArRodBlockPhysicsV4.cxx:228
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
LArRodBlockPhysicsV4::getCtrl3
virtual uint16_t getCtrl3(uint32_t adc) const
Definition: LArRodBlockPhysicsV4.cxx:256
LArRodBlockPhysicsV4::getNumberOfSamples
virtual uint32_t getNumberOfSamples() const
Definition: LArRodBlockPhysicsV4.cxx:203
LArRodBlockPhysicsV4::LArRodBlockPhysicsV4
LArRodBlockPhysicsV4()
Definition: LArRodBlockPhysicsV4.cxx:25
extractSporadic.q
list q
Definition: extractSporadic.py:98
LArRodBlockPhysicsV4::m_HotCellsPointer
const uint16_t * m_HotCellsPointer
Definition: LArRodBlockPhysicsV4.h:112
LArRodBlockPhysicsV4::m_TimeQualityIndex
int m_TimeQualityIndex
Definition: LArRodBlockPhysicsV4.h:105
LArRodBlockPhysicsV4::m_EnergyIndex
int m_EnergyIndex
Definition: LArRodBlockPhysicsV4.h:103
LArRodBlockStructure::m_channelsPerFEB
int m_channelsPerFEB
Definition: LArRodBlockStructure.h:225
LArRodBlockPhysicsV4::m_RawDataIndex
int m_RawDataIndex
Definition: LArRodBlockPhysicsV4.h:104
LArRodBlockStructure::getHeader16
uint16_t getHeader16(const unsigned n) const
Definition: LArRodBlockStructure.h:355
LArRodBlockPhysicsV4::offlineCheckSum
virtual uint32_t offlineCheckSum() const
Definition: LArRodBlockPhysicsV4.cxx:283
LArRodBlockPhysicsV4::onlineCheckSum
virtual uint32_t onlineCheckSum() const
Definition: LArRodBlockPhysicsV4.cxx:271
LArRodBlockPhysicsV4::getCtrl2
virtual uint16_t getCtrl2(uint32_t adc) const
Definition: LArRodBlockPhysicsV4.cxx:248
LArRodBlockPhysicsV4::RawDataBlkDim
@ RawDataBlkDim
Definition: LArRodBlockPhysicsV4.h:47