ATLAS Offline Software
LArRodBlockPhysicsV4.h
Go to the documentation of this file.
1 //Dear emacs, this is -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef LARBYTESTREAM_LARRODBLOCKPHYSICSV4_H
8 #define LARBYTESTREAM_LARRODBLOCKPHYSICSV4_H
9 
22 
23 //#define LARBSDBGOUTPUT
24 #ifdef LARBSDBGOUTPUT
25 #define MYLEVEL (MSG::FATAL)
26 #define LARBSDBG(text) logstr<<MYLEVEL<<text<<endmsg
27 #else
28 #define LARBSDBG(text)
29 #endif
30 
32 {
33 public:
34  // ----------------- Header words indexes -----------------
35  enum {
36  NWTot, // First words: DSP event header
40  FEB_SN, // FEB serial number
41  FEB_SN_h, // FEB serial number
42  ResultsOff1, // Size of results (Physics averages in DSP)
43  ResultsDim1, // Offset to results
44  ResultsOff2, // Size of times (in physics)
45  ResultsDim2, // Offset to times (in physics)
47  RawDataBlkDim, // Raw FEB event offset
48  EventStatus, // Bits describing the event
54  InFPGAFormat, // added 08.09.2005 - wrong 28.09.2005?
56  endtag //This tag needs to be an odd number, see *) for constructor
57  };
58  // constructor
60 
61  // ------ Identify RodBlockStructure -------
62  std::string BlockType() { return std::string("RodBlockPhysicsV4");}
63  public:
64  // ----------------- Decoding methods -----------------
65  // Never to be used while encoding!
66  // set full ROD fragment before trying to get anything!
67  // in case there is more than 1 FEB in 1 fragment, jump to next FEB
68  virtual inline int getNextEnergy(int& channelNumber, int32_t& energy, int32_t& time,int32_t& quality,uint32_t& gain);
69  virtual int getNextRawData(int& channelNumber, std::vector<short>& samples, uint32_t& gain);
70  virtual uint16_t getResults1Size() const;
71  virtual uint16_t getResults2Size() const;
72  virtual uint16_t getRawDataSize() const;
73  virtual uint32_t getNumberOfSamples() const;
74  virtual uint32_t getNumberOfGains() const;
75  virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const;
76  virtual uint16_t getCtrl1(uint32_t adc) const;
77  virtual uint16_t getCtrl2(uint32_t adc) const;
78  virtual uint16_t getCtrl3(uint32_t adc) const;
79  virtual uint32_t getStatus() const;
80 
81  virtual uint32_t onlineCheckSum() const;
82  virtual uint32_t offlineCheckSum() const;
83 
84  virtual inline uint32_t hasCalibBlock() const {return 0;} ;
85  virtual inline uint32_t hasPhysicsBlock() const {return getHeader16(ResultsOff1);} ;
86  virtual inline uint32_t hasRawDataBlock() const {return getHeader16(RawDataBlkOff);} ;
87  virtual inline uint32_t hasControlWords() const {return getHeader16(RawDataBlkOff);} ;
88 
89  // Decode counter block
90  virtual inline uint16_t getNumberOfHotCells() const;
91  virtual inline int32_t getEx() const;
92  virtual inline int32_t getEy() const;
93  virtual inline int32_t getEz() const;
94  virtual inline int16_t getHottestCellIndex();
95  virtual inline int32_t getHottestCellEnergy() const;
96 
97  virtual inline int setGain(const int /*GainValue*/) { return 1; };
98 
99 private:
100  virtual void resetPointers();
101  virtual bool setPointers();
102 
103  int m_EnergyIndex = 0;
104  int m_RawDataIndex = 0;
106  int m_TowerIndex = 0;
107  const uint16_t* m_EnergyPointer = nullptr;
108  const uint16_t* m_TimeQualityPointer = nullptr;
109  const uint16_t* m_RawDataPointer = nullptr;
110  const uint32_t* m_GainPointer = nullptr;
111  const uint32_t* m_MaskPointer = nullptr;
112  const uint16_t* m_HotCellsPointer = nullptr;
113  const uint8_t* m_TowerPointer = nullptr;
114  const int32_t* m_SumPointer = nullptr;
115 
116  //For fixed gain mode
118  //FIXME, very ugly hack! See explanation in LArRodDecoder.h
119 public:
120  inline uint16_t getFebConfig() const;
121  inline uint16_t getFirstSampleIndex() const;
122 
123  virtual bool canSetCalibration() {return false;}
124 };
125 
127 {
128  return getHeader16(FebConfig);
129 }
130 
132 {
134 }
135 
136 inline int LArRodBlockPhysicsV4::getNextEnergy(int& channelNumber,int32_t& energy,int32_t& time,int32_t& quality, uint32_t& gain)
137 {
138  #ifdef LARBSDBGOUTPUT
139  MsgStream logstr(Athena::getMessageSvc(), BlockType());
140  #endif
141 
142  LARBSDBG("in LArRodBlockPhysicsV4::getNextEnergy.");
143  LARBSDBG("m_channelsPerFEB=" << m_channelsPerFEB);
144  if (m_EnergyIndex>=m_channelsPerFEB) // Already beyond maximal number of channels
145  return 0;
146  if (!m_EnergyPointer) // No data block present
147  return 0;
148 
149  unsigned rodChannelNumber=m_EnergyIndex; // Index of Channel in ROD-Block
150  channelNumber=((rodChannelNumber&0xe)<<2) + ((rodChannelNumber&0x1)<<6) + (rodChannelNumber>>4); //channel number of the FEB
151  //channelNumber=(rodChannelNumber>>4) + ((rodChannelNumber&0xf)<<3); //channel number of the FEB
152 
153  // get information available for all cells
154  // Energy on a 16 bit word and decode ranges
155  uint16_t encodedEnergy; // 16 bits Encoded Energy word
156  int32_t aux;
157  uint16_t range; // 2 bits range
158  uint16_t sign;
159 
160  LARBSDBG("-------->>>> in LArRodBlockPhysicsV4::getNextEnergy : decode energy.....");
161  // decode energy
162  if(m_EnergyIndex & 0x1) encodedEnergy = m_EnergyPointer[m_EnergyIndex-1]; // Big/Little Endien stuff
163  else encodedEnergy = m_EnergyPointer[m_EnergyIndex+1]; // Big/Little Endien stuff
164 
165  aux = (int32_t) (encodedEnergy&0x1fff);
166  range = (encodedEnergy & 0xc000) >> 14;
167  sign = encodedEnergy & 0x2000;
168  aux <<= 3*range;
169  if(sign) aux = -aux;
170  energy = aux;
171 
172  // gain in 2 bits of a 32 bits word
173  gain = (uint32_t) ((m_GainPointer[m_EnergyIndex>>4] >> (m_EnergyIndex&0xf)*2) & 0x3);
175 
176  // Get Time and Quality if the information is present according to summary block
177  uint32_t hasTQ = (uint32_t) ((m_MaskPointer[m_EnergyIndex>>5] >> (m_EnergyIndex&0x1f)) &0x1);
178  m_EnergyIndex++;
179  if (m_TimeQualityPointer && hasTQ) // Data has Time and Quality information
180  {
184 
185 #ifdef LARBSDBGOUTPUT
186  logstr << MYLEVEL <<"This cell has time and Quality information "<<endmsg;
187 #endif
188  }
189  else // Data has no Time and Quality information
190  {
191  time=0;
192  quality=-1;
193  }
194 
195 
196 #ifdef LARBSDBGOUTPUT
197  logstr << MYLEVEL <<"Range = "<<range<<endmsg;
198  logstr << MYLEVEL <<"Sign = "<<sign<<endmsg;
199  logstr << MYLEVEL <<" Encoded Energy ="<< MSG::hex << encodedEnergy << MSG::dec << " E=" << energy
200  << " t=" << time
201  << " Q=" << quality
202  << " G=" << gain
203  << " channel Number=" << channelNumber
204  << endmsg;
205 #endif
206 
207  return 1;
208 }
209 
211 {
213  return 0;
214 }
215 
216 inline int32_t LArRodBlockPhysicsV4::getEx() const // To be checked
217 {
218  if(m_SumPointer) return m_SumPointer[0];
219  return 0;
220 }
221 
222 inline int32_t LArRodBlockPhysicsV4::getEy() const // To be checked
223 {
224  if(m_SumPointer) return m_SumPointer[1];
225  return 0;
226 }
227 
228 inline int32_t LArRodBlockPhysicsV4::getEz() const
229 {
230  if(m_SumPointer) return m_SumPointer[2];
231  return 0;
232 }
233 
235 {
237  return -1;
238 }
239 
240 inline int32_t LArRodBlockPhysicsV4::getHottestCellEnergy() const // to be checked
241 {
242  uint16_t encodedEnergy; // 16 bits Encoded Energy word
243  int32_t aux;
244  uint16_t range; // 2 bits range
245  int32_t sign=1;
246 
247  if(!m_TowerPointer) return 0;
248  encodedEnergy = m_EnergyPointer[m_TowerPointer[m_TowerIndex]];
249 
250  if (encodedEnergy&0x8000) sign=-1;
251  range = ((encodedEnergy)>>13)&0x0003; // range is encoded in bits 14 and 13
252 
253  aux = (int32_t) (encodedEnergy&0x1FFF);
254  if (range==1) aux=(aux<<3)+4; // shift left by 3 bits and add 4 MeV
255  else if (range==2) aux=(aux<<6)+32; // shift left by 6 bits and add 32 MeV
256  else if (range==3) aux=(aux<<9)+256; // shift left by 9 bits and add 256 MeV
257 
258  return sign*aux;
259 }
260 
261 #ifdef LARBSDBGOUTPUT
262 #undef LARBSDBGOUTPUT
263 #endif
264 #undef LARBSDBG
265 
266 #endif
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
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
LArRodBlockPhysicsV4::getNumberOfGains
virtual uint32_t getNumberOfGains() const
Definition: LArRodBlockPhysicsV4.cxx:208
LArRodBlockPhysicsV4::getNextEnergy
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
Definition: LArRodBlockPhysicsV4.h:136
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
LArRodBlockPhysicsV4::getHottestCellIndex
virtual int16_t getHottestCellIndex()
Definition: LArRodBlockPhysicsV4.h:234
LArRodBlockPhysicsV4::getRawDataSize
virtual uint16_t getRawDataSize() const
Definition: LArRodBlockPhysicsV4.cxx:223
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LArRodBlockPhysicsV4::m_TimeQualityPointer
const uint16_t * m_TimeQualityPointer
Definition: LArRodBlockPhysicsV4.h:108
LArRodBlockPhysicsV4::getResults2Size
virtual uint16_t getResults2Size() const
Definition: LArRodBlockPhysicsV4.cxx:218
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArRodBlockPhysicsV4::getCtrl1
virtual uint16_t getCtrl1(uint32_t adc) const
Definition: LArRodBlockPhysicsV4.cxx:240
LArRodBlockPhysicsV4::getResults1Size
virtual uint16_t getResults1Size() const
Definition: LArRodBlockPhysicsV4.cxx:213
LArRodBlockPhysicsV4::hasRawDataBlock
virtual uint32_t hasRawDataBlock() const
Definition: LArRodBlockPhysicsV4.h:86
LArRodBlockPhysicsV4::m_MaskPointer
const uint32_t * m_MaskPointer
Definition: LArRodBlockPhysicsV4.h:111
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
LArRodBlockPhysicsV4::getStatus
virtual uint32_t getStatus() const
Definition: LArRodBlockPhysicsV4.cxx:264
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
LArRodBlockPhysicsV4::m_RawDataPointer
const uint16_t * m_RawDataPointer
Definition: LArRodBlockPhysicsV4.h:109
LArRodBlockPhysicsV4::hasControlWords
virtual uint32_t hasControlWords() const
Definition: LArRodBlockPhysicsV4.h:87
LArRodBlockPhysicsV4::setPointers
virtual bool setPointers()
Definition: LArRodBlockPhysicsV4.cxx:49
LArRodBlockPhysicsV4::ResultsOff2
@ ResultsOff2
Definition: LArRodBlockPhysicsV4.h:44
LArRodBlockPhysicsV4::m_GainPointer
const uint32_t * m_GainPointer
Definition: LArRodBlockPhysicsV4.h:110
LArRodBlockPhysicsV4::RawDataBlkOff
@ RawDataBlkOff
Definition: LArRodBlockPhysicsV4.h:46
LArRodBlockPhysicsV4::m_TowerPointer
const uint8_t * m_TowerPointer
Definition: LArRodBlockPhysicsV4.h:113
LArRodBlockPhysicsV4::FEBID
@ FEBID
Definition: LArRodBlockPhysicsV4.h:38
LArRodBlockPhysicsV4::NSamples
@ NSamples
Definition: LArRodBlockPhysicsV4.h:51
LArRodBlockPhysicsV4::endtag
@ endtag
Definition: LArRodBlockPhysicsV4.h:56
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
LArRodBlockStructure::RawToOfflineGain
uint32_t RawToOfflineGain(const uint32_t gain) const
Definition: LArRodBlockStructure.h:349
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:113
LArRodBlockPhysicsV4::InFPGAFormat
@ InFPGAFormat
Definition: LArRodBlockPhysicsV4.h:54
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LArRodBlockPhysicsV4::canSetCalibration
virtual bool canSetCalibration()
Definition: LArRodBlockPhysicsV4.h:123
LArRodBlockPhysicsV4::getFirstSampleIndex
uint16_t getFirstSampleIndex() const
Definition: LArRodBlockPhysicsV4.h:131
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
LArRodBlockPhysicsV4::getEy
virtual int32_t getEy() const
Definition: LArRodBlockPhysicsV4.h:222
LArRodBlockPhysicsV4::NGains
@ NGains
Definition: LArRodBlockPhysicsV4.h:50
MYLEVEL
#define MYLEVEL
Definition: LArRodBlockPhysicsV3.h:47
LArRodBlockPhysicsV4::InFPGAFormat_h
@ InFPGAFormat_h
Definition: LArRodBlockPhysicsV4.h:55
LArRodBlockPhysicsV4::m_fixedGain
int m_fixedGain
Definition: LArRodBlockPhysicsV4.h:117
LArRodBlockPhysicsV4::FEBID_h
@ FEBID_h
Definition: LArRodBlockPhysicsV4.h:39
LArRodBlockPhysicsV4::m_TowerIndex
int m_TowerIndex
Definition: LArRodBlockPhysicsV4.h:106
LArRodBlockPhysicsV4::m_SumPointer
const int32_t * m_SumPointer
Definition: LArRodBlockPhysicsV4.h:114
LArRodBlockPhysicsV4::hasCalibBlock
virtual uint32_t hasCalibBlock() const
Definition: LArRodBlockPhysicsV4.h:84
LArRodBlockPhysicsV4::NWTot
@ NWTot
Definition: LArRodBlockPhysicsV4.h:36
LArRodBlockPhysicsV4::EventStatus
@ EventStatus
Definition: LArRodBlockPhysicsV4.h:48
LArRodBlockPhysicsV4::getNextRawData
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
Definition: LArRodBlockPhysicsV4.cxx:115
LArRodBlockPhysicsV4::getEz
virtual int32_t getEz() const
Definition: LArRodBlockPhysicsV4.h:228
LArRodBlockPhysicsV4
Definition: LArRodBlockPhysicsV4.h:32
LArRodBlockPhysicsV4::getNumberOfHotCells
virtual uint16_t getNumberOfHotCells() const
Definition: LArRodBlockPhysicsV4.h:210
LArRodBlockPhysicsV4::FEB_SN
@ FEB_SN
Definition: LArRodBlockPhysicsV4.h:40
LArRodBlockPhysicsV4::BlockType
std::string BlockType()
Definition: LArRodBlockPhysicsV4.h:62
LArRodBlockPhysicsV4::FEB_SN_h
@ FEB_SN_h
Definition: LArRodBlockPhysicsV4.h:41
LArRodBlockPhysicsV4::RawDataBlkDim
@ RawDataBlkDim
Definition: LArRodBlockPhysicsV4.h:47
LArRodBlockPhysicsV4::ResultsOff1
@ ResultsOff1
Definition: LArRodBlockPhysicsV4.h:42
LArRodBlockPhysicsV4::ResultsDim2
@ ResultsDim2
Definition: LArRodBlockPhysicsV4.h:45
LArRodBlockStructure.h
LArRodBlockPhysicsV4::NWTot_h
@ NWTot_h
Definition: LArRodBlockPhysicsV4.h:37
LArRodBlockPhysicsV4::EventStatus_h
@ EventStatus_h
Definition: LArRodBlockPhysicsV4.h:49
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
LArRodBlockPhysicsV4::getRadd
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
Definition: LArRodBlockPhysicsV4.cxx:228
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
LArRodBlockPhysicsV4::FebConfig
@ FebConfig
Definition: LArRodBlockPhysicsV4.h:53
LArRodBlockPhysicsV4::m_HotCellsPointer
const uint16_t * m_HotCellsPointer
Definition: LArRodBlockPhysicsV4.h:112
LArRodBlockPhysicsV4::setGain
virtual int setGain(const int)
Definition: LArRodBlockPhysicsV4.h:97
LArRodBlockPhysicsV4::m_TimeQualityIndex
int m_TimeQualityIndex
Definition: LArRodBlockPhysicsV4.h:105
LArRodBlockPhysicsV4::getEx
virtual int32_t getEx() const
Definition: LArRodBlockPhysicsV4.h:216
LArRodBlockPhysicsV4::FirstSampleIndex
@ FirstSampleIndex
Definition: LArRodBlockPhysicsV4.h:52
LArRodBlockPhysicsV4::m_EnergyIndex
int m_EnergyIndex
Definition: LArRodBlockPhysicsV4.h:103
LArRodBlockPhysicsV4::getHottestCellEnergy
virtual int32_t getHottestCellEnergy() const
Definition: LArRodBlockPhysicsV4.h:240
LArRodBlockStructure::m_channelsPerFEB
int m_channelsPerFEB
Definition: LArRodBlockStructure.h:225
CaloGain.h
LArRodBlockPhysicsV4::m_RawDataIndex
int m_RawDataIndex
Definition: LArRodBlockPhysicsV4.h:104
LArRodBlockPhysicsV4::getFebConfig
uint16_t getFebConfig() const
Definition: LArRodBlockPhysicsV4.h:126
LArRodBlockStructure::getHeader16
uint16_t getHeader16(const unsigned n) const
Definition: LArRodBlockStructure.h:355
LArRodBlockPhysicsV4::ResultsDim1
@ ResultsDim1
Definition: LArRodBlockPhysicsV4.h:43
LARBSDBG
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
Definition: LArRodBlockPhysicsV4.h:28
LArRodBlockPhysicsV4::hasPhysicsBlock
virtual uint32_t hasPhysicsBlock() const
Definition: LArRodBlockPhysicsV4.h:85
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