ATLAS Offline Software
Loading...
Searching...
No Matches
LArRodBlockPhysicsV1.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_LARRODBLOCKPYSICSV1_H
8#define LARBYTESTREAM_LARRODBLOCKPYSICSV1_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 NGainNSamples, //Elements below this are not used by the converter
71 RADD2, //Could have more RADD's in real data
73 };
74
75 public:
76 std::string BlockType() { return std::string("RodBlockPhysicsV1");}
77 // ----------------- Encoding methods -----------------
78 // Never to be used while decoding!
79 //Header setting methods (different from base class for backward compatibility)
80 //virtual void buildHeader();
81 virtual void initializeFragment(std::vector<uint32_t>& fragment);
82 virtual void initializeFEB(const uint32_t id);
83 virtual void setNumberOfSamples(const uint8_t n);
84 virtual void setNumberOfGains(const uint8_t n);
85 virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain);
86 virtual void setRawData(const int channel, const std::vector<short>& samples, const uint32_t gain);
87 virtual void finalizeFEB();
88 // build full ROD fragment
89 virtual void concatinateFEBs();
90 //Function to sort RawData Container before encoding:
91 using LArRodBlockStructure::sortDataVector; // avoid warnings.
92 virtual void sortDataVector(std::vector<const LArRawChannel*>& );
93 virtual void sortDataVector( std::vector<const LArDigit*>& );
94 // declare capabilities of this Rod Block Structure
95 virtual bool canSetEnergy() { return true;}
96 virtual bool canSetRawData() {return true;}
97 //Ordering relation for channels & digits
98 template<class RAWDATA>
99 bool operator () (const RAWDATA* ch1, const RAWDATA* ch2) const;
100
101 // ----------------- Decoding methods -----------------
102 // Never to be used while encoding!
103 // set full ROD fragment before trying to get anything!
104 // in case there is more than 1 FEB in 1 fragment, jump to next FEB
105 virtual bool setPointers();
106 virtual inline int getNextEnergy(int& channelNumber, int32_t& energy, int32_t& time,int32_t& quality,uint32_t& gain);
107 virtual int getNextRawData(int& channelNumber, std::vector<short>& samples, uint32_t& gain);
108
109 // ----------------- Printing methods -----------------
110 // print the full ROD fragment
111 //virtual void dumpFragment();
112 virtual inline uint32_t hasPhysicsBlock() const {return getHeader16(LowEBlkOffset);} ;
113 virtual inline uint32_t hasRawDataBlock() const {return getHeader16(RawDataBlkOffset);} ;
114
115 private:
116 void clearBlocks();
117 virtual void resetPointers();
118 //Separated blocks for encoding
119 std::vector<uint32_t> m_LowEnergyBlock;
120 std::vector<uint32_t> m_HighEnergyBlock;
121 std::vector<uint32_t> m_RawDataBlock;
122 //Counter for channels inside of a FEB
123 int m_ECounter = 0;
125 int m_LowEIndex = 0;
128 int m_EIndex = 0; //For writing....
129 const int32_t *m_HighEPtr;
130 const uint32_t *m_FlagPtr;
131 const int16_t *m_LowEPtr;
132 //Number of flagging words at the beginning of Block 2, 3, and 4 (Depends on the number of channels)
133 unsigned short m_NFlaggingWords;
134
135 //LArCablingService* m_cablingSvc;
137 static const uint32_t m_DummyBitMap[4];
138 //Private functions:
139 inline int FebToRodChannel(int ch) const;
140 void setNextEnergy(const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain);
141
142 // log message
143 MsgStream m_logstr;
144
145};
146
148 //{return ch/8 + 16 * (ch%8);}
149{return (ch>>3) + ((ch&0x7)<<4);}
150
151inline int LArRodBlockPhysicsV1::getNextEnergy(int& channelNumber,int32_t& energy,int32_t& time,int32_t& quality, uint32_t& gain)
152{
153 LARBSDBG("in LArRodBlockPhysicsV1::getEnergy.");
154 LARBSDBG("m_LowEIndex=" <<m_LowEIndex << " m_HighEIndex" << m_HighEIndex);
155 LARBSDBG("m_channelsPerFEB=" << m_channelsPerFEB);
156 if (m_LowEIndex+m_HighEIndex>=m_channelsPerFEB) //Already beyond maximal number of channels
157 return 0;
158 if (!m_FlagPtr || !m_LowEPtr) //No data block present
159 return 0;
160 uint32_t gtQ;
161 channelNumber=m_LowEIndex+m_HighEIndex; //Index of Channel in ROD-Block
162 if (getBit(m_FlagPtr,channelNumber)) //Data in high energy block
163 {energy = m_HighEPtr[m_HighEIndex*2];
164 gtQ=m_HighEPtr[m_HighEIndex*2+1];
165 // Q in bits 0-15
166 // t in bits 16-29
167 // gain in bits 30-31
168 quality = gtQ & 0xffff;
169 gtQ = gtQ >> 16;
170 //time = gtQ & 0x3fff;
171 time = gtQ & 0x1fff;
172 if (gtQ & 0x2000)
173 time*=-1;
174 gain=(gtQ >> 14);
175 m_HighEIndex++;
176 LARBSDBG("Channel " << channelNumber << " Reading Raw data form High E block. E=" << energy << " Q=" << quality);
177 }
178 else //Data in low energy block
179 {if (!m_LowEPtr)
180 return 0; //Block does not exist;
181 energy=m_LowEPtr[m_LowEIndex];
182 gain=0; //=CaloGain::LARHIGHGAIN
183 time=0;
184 quality=-1;
185 m_LowEIndex++;
186 LARBSDBG("Channel " << channelNumber << " Reading Raw data form Low E block. E=" << energy);
187 }
188 /*
189 if (energy>10000000)
190 std::cout << " Read: Large E found. E=" << energy
191 << " t=" << time
192 << " Q=" << quality
193 << " G=" << gain
194 << " channel Number=" << channelNumber
195 << " LowEIndex=" << m_LowEIndex
196 << " HighEIndex="<<m_HighEIndex << std::endl;
197 else
198 std::cout << "Read energy" << std::endl;
199 */
200 return 1;
201}
202
203#ifdef LARBSDBGOUTPUT
204#undef LARBSDBGOUTPUT
205#endif
206#undef LARBSDBG
207
208#endif
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
virtual void initializeFEB(const uint32_t id)
virtual uint32_t hasRawDataBlock() const
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
virtual void sortDataVector(std::vector< const LArDigit * > &)
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
const LArOnlineID * m_onlineHelper
static const uint32_t m_DummyBitMap[4]
virtual void setNumberOfGains(const uint8_t n)
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
virtual void initializeFragment(std::vector< uint32_t > &fragment)
int FebToRodChannel(int ch) const
std::vector< uint32_t > m_RawDataBlock
bool operator()()(const RAWDATA *ch1
std::vector< uint32_t > m_LowEnergyBlock
virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
virtual uint32_t hasPhysicsBlock() const
virtual void setRawData(const int channel, const std::vector< short > &samples, const uint32_t gain)
virtual void setNumberOfSamples(const uint8_t n)
std::vector< uint32_t > m_HighEnergyBlock
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
int getBit(const uint32_t *const p, const unsigned chan) const
uint16_t getHeader16(const unsigned n) const
singleton-like access to IMessageSvc via open function and helper