ATLAS Offline Software
Loading...
Searching...
No Matches
LArRodBlockPhysicsV2.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_LARRODBLOCKPYSICSV2_H
8#define LARBYTESTREAM_LARRODBLOCKPYSICSV2_H
9
30
31
32
33#include <stdint.h>
34#include <vector>
38
39
40//#define LARBSDBGOUTPUT
41#ifdef LARBSDBGOUTPUT
42#define LARBSDBG(text) m_logstr<<MSG::DEBUG<<text<<endmsg
43#else
44#define LARBSDBG(text)
45#endif
46
48{
49public:
50 // constructor
52
53protected:
54 // ----------------- Header words indexes -----------------
55 enum {
65 RawDataBlkOffset, //Elements below this are not used by the converter
71 };
72
73 public:
74 std::string BlockType() { return std::string("RodBlockPhysicsV2");}
75 // ----------------- Encoding methods -----------------
76 // Never to be used while decoding!
77 //virtual void buildHeader();
78 virtual void initializeFragment(std::vector<uint32_t>& fragment);
79 virtual void initializeFEB(const uint32_t id);
80 virtual void setNumberOfSamples(const uint8_t n);
81 virtual void setNumberOfGains(const uint8_t n);
82 virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain);
83 virtual void setRawData(const int channel, const std::vector<short>& samples, const uint32_t gain);
84 virtual void finalizeFEB();
85 // build full ROD fragment
86 virtual void concatinateFEBs();
87 //Function to sort RawData Container before encoding:
88 using LArRodBlockStructure::sortDataVector; // avoid warnings.
89 virtual void sortDataVector(std::vector<const LArRawChannel*>& );
90 virtual void sortDataVector( std::vector<const LArDigit*>& );
91 // declare capabilities of this Rod Block Structure
92 virtual bool canSetEnergy() { return true;}
93 virtual bool canSetRawData() {return true;}
94 //Ordering relation for channels & digits
95 template<class RAWDATA>
96 bool operator () (const RAWDATA* ch1, const RAWDATA* ch2) const;
97
98 // ----------------- Decoding methods -----------------
99 // Never to be used while encoding!
100 // set full ROD fragment before trying to get anything!
101 // in case there is more than 1 FEB in 1 fragment, jump to next FEB
102 virtual inline int setGain(const int /*GainValue*/) { return 1; };
103 virtual bool setPointers();
104 virtual inline int getNextEnergy(int& channelNumber, int32_t& energy, int32_t& time,int32_t& quality,uint32_t& gain);
105 virtual int getNextRawData(int& channelNumber, std::vector<short>& samples, uint32_t& gain);
106 virtual uint32_t getNumberOfSamples() const;
107 virtual uint32_t getNumberOfGains() const;
108 virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const;
109 virtual uint16_t getCtrl1(uint32_t adc) const;
110 virtual uint16_t getCtrl2(uint32_t adc) const;
111 virtual uint16_t getCtrl3(uint32_t adc) const;
112 virtual uint32_t getStatus() const;
113
114 // ----------------- Printing methods -----------------
115 // print the full ROD fragment
116 //virtual void dumpFragment();
117 virtual inline uint32_t hasPhysicsBlock() const {return LE_getHeader16(LowEBlkOffset);} ;
118 virtual inline uint32_t hasRawDataBlock() const {return LE_getHeader16(RawDataBlkOffset);} ;
119
120 private:
121 void clearBlocks();
122 virtual void resetPointers();
123 //Separated blocks for encoding
124 std::vector<uint32_t> m_LowEnergyBlock;
125 std::vector<uint32_t> m_HighEnergyBlock;
126 std::vector<uint32_t> m_RawDataBlock;
127 //Counter for channels inside of a FEB
128 int m_ECounter = 0;
130 int m_LowEIndex = 0;
133 int m_EIndex = 0; //For writing....
134 const uint16_t *m_RawDataPtr;
135 const uint32_t *m_RawDataFlagsPtr;
136 const uint32_t *m_GainPtr;
137 const int32_t *m_HighEPtr;
138 const uint32_t*m_FlagPtr;
139 const int16_t *m_LowEPtr;
140 //Number of flagging words at the beginning of Block 2, 3, and 4 (Depends on the number of channels)
141 unsigned short m_NFlaggingWords;
142
143 //LArCablingService* m_cablingSvc;
145 static const uint32_t m_DummyBitMap[4];
146 //Private functions:
147 inline int FebToRodChannel(int ch) const;
148 void setNextEnergy(const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain);
149
150 // log message
151 MsgStream m_logstr;
152
153
154};
155
157 //{return ch/8 + 16 * (ch%8);}
158{return (ch>>3) + ((ch&0x7)<<4);}
159
160inline int LArRodBlockPhysicsV2::getNextEnergy(int& channelNumber,int32_t& energy,int32_t& time,int32_t& quality, uint32_t& gain)
161{
162 LARBSDBG("in LArRodBlockPhysicsV2::getEnergy.");
163 LARBSDBG("m_ECounter=" << m_ECounter << " m_RawDataIndex="<< m_EIndex);
164 LARBSDBG("m_channelsPerFEB=" << m_channelsPerFEB);
165 if (m_LowEIndex+m_HighEIndex>=m_channelsPerFEB) //Already beyond maximal number of channels
166 return 0;
167 if (!m_FlagPtr || !m_LowEPtr) //No data block present
168 return 0;
169 uint32_t gtQ;
170 int rodChannelNumber=m_LowEIndex+m_HighEIndex; //Index of Channel in ROD-Block
171 channelNumber=rodChannelNumber; // Arno claims he is using FEB numbering
172 //channelNumber=(rodChannelNumber>>4) + ((rodChannelNumber&0xf)<<3); //channel number of the FEB
173 if (getBit(m_FlagPtr,rodChannelNumber)) //Data in high energy block
174 {energy = m_HighEPtr[m_HighEIndex*2];
175 gtQ=m_HighEPtr[m_HighEIndex*2+1];
176 // Q in bits 0-15
177 // t in bits 16-29
178 // gain in bits 30-31
179 quality = gtQ & 0xffff;
180 gtQ = gtQ >> 16;
181 //time = gtQ & 0x3fff;
182 time = gtQ & 0x7fff;
183 if (gtQ & 0x8000)
184 time*=-1;
185 gain=3-((m_GainPtr[channelNumber/16] >> (channelNumber%16)*2) & 0x3);
186 m_HighEIndex++;
187 LARBSDBG("Reading Raw data form High E block. E=" << energy << " Q=" << quality);
188 }
189 else //Data in low energy block
190 {
191 if (!m_LowEPtr)
192 return 0; //Block does not exist;
193 if(m_LowEIndex%2==0)
194 energy=m_LowEPtr[m_LowEIndex+1];
195 else
196 energy=m_LowEPtr[m_LowEIndex-1];
197
198 gain=3-((m_GainPtr[channelNumber/16] >> (channelNumber%16)*2) & 0x3);
199 time=0;
200 quality=-1;
201 m_LowEIndex++;
202 LARBSDBG("*** Reading Raw data form Low E block. E=" << energy);
203 }
204 /*
205 if (energy>10000000)
206 std::cout << " Read: Large E found. E=" << energy
207 << " t=" << time
208 << " Q=" << quality
209 << " G=" << gain
210 << " channel Number=" << channelNumber
211 << " LowEIndex=" << m_LowEIndex
212 << " HighEIndex="<<m_HighEIndex << std::endl;
213 else
214 std::cout << "Read energy" << std::endl;
215 */
216 return 1;
217}
218
219#ifdef LARBSDBGOUTPUT
220#undef LARBSDBGOUTPUT
221#endif
222#undef LARBSDBG
223
224#endif
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
std::vector< uint32_t > m_LowEnergyBlock
std::vector< uint32_t > m_HighEnergyBlock
std::vector< uint32_t > m_RawDataBlock
virtual uint32_t hasPhysicsBlock() const
virtual uint32_t getNumberOfSamples() const
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
virtual void setNumberOfSamples(const uint8_t n)
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
virtual void sortDataVector(std::vector< const LArDigit * > &)
virtual void setNumberOfGains(const uint8_t n)
virtual uint32_t getStatus() const
virtual int setGain(const int)
virtual uint16_t getCtrl2(uint32_t adc) const
virtual uint32_t hasRawDataBlock() const
const uint16_t * m_RawDataPtr
bool operator()()(const RAWDATA *ch1
virtual void initializeFragment(std::vector< uint32_t > &fragment)
virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
const LArOnlineID * m_onlineHelper
virtual void setRawData(const int channel, const std::vector< short > &samples, const uint32_t gain)
virtual uint16_t getCtrl1(uint32_t adc) const
const uint32_t * m_RawDataFlagsPtr
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
virtual uint32_t getNumberOfGains() const
static const uint32_t m_DummyBitMap[4]
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
virtual uint16_t getCtrl3(uint32_t adc) const
int FebToRodChannel(int ch) const
virtual void initializeFEB(const uint32_t id)
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
int getBit(const uint32_t *const p, const unsigned chan) const
uint16_t LE_getHeader16(const unsigned n) const
singleton-like access to IMessageSvc via open function and helper