ATLAS Offline Software
Loading...
Searching...
No Matches
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
19
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{
33public:
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
99private:
100 virtual void resetPointers();
101 virtual bool setPointers();
102
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
119public:
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
136inline 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);
174 gain=RawToOfflineGain(gain);
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);
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
216inline int32_t LArRodBlockPhysicsV4::getEx() const // To be checked
217{
218 if(m_SumPointer) return m_SumPointer[0];
219 return 0;
220}
221
222inline int32_t LArRodBlockPhysicsV4::getEy() const // To be checked
223{
224 if(m_SumPointer) return m_SumPointer[1];
225 return 0;
226}
227
228inline int32_t LArRodBlockPhysicsV4::getEz() const
229{
230 if(m_SumPointer) return m_SumPointer[2];
231 return 0;
232}
233
234inline int16_t LArRodBlockPhysicsV4::getHottestCellIndex() // to be checked
235{
237 return -1;
238}
239
240inline 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;
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
#define endmsg
#define MYLEVEL
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
int sign(int a)
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 hasCalibBlock() const
uint16_t getFebConfig() const
virtual int setGain(const int)
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
virtual int32_t getEy() const
uint16_t getFirstSampleIndex() const
const uint16_t * m_HotCellsPointer
virtual int16_t getHottestCellIndex()
virtual int32_t getEx() const
virtual uint32_t getNumberOfSamples() const
virtual uint16_t getResults2Size() const
const uint16_t * m_EnergyPointer
virtual uint32_t onlineCheckSum() const
virtual uint32_t hasRawDataBlock() const
virtual uint16_t getResults1Size() const
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
virtual uint32_t hasControlWords() const
virtual uint16_t getNumberOfHotCells() const
virtual int32_t getHottestCellEnergy() const
virtual uint32_t hasPhysicsBlock() const
virtual int32_t getEz() const
uint16_t getHeader16(const unsigned n) const
uint32_t RawToOfflineGain(const uint32_t gain) const
IMessageSvc * getMessageSvc(bool quiet=false)