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