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-2026 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#ifdef LARBSDBGOUTPUT
41#define LARBSDBG(text) m_logstr<<MSG::DEBUG<<text<<endmsg
42#else
43#define LARBSDBG(text)
44#endif
45
47{
48public:
49 // constructor
50 LArRodBlockPhysicsV0(IMessageSvc* msgSvc);
51
52protected:
53 // ----------------- Header words indexes -----------------
54 enum {
64 NGainNSamples, //Elements below this are not used by the converter
70 RADD2, //Could have more RADD's in real data
72 };
73
74 public:
75 static std::string BlockType() { return std::string("RodBlockPhysicsV0");}
76 // ----------------- Encoding methods -----------------
77 // Never to be used while decoding!
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 getNextEnergy(int& channelNumber, int32_t& energy, int32_t& time,int32_t& quality,uint32_t& gain);
103 virtual int getNextRawData(int& channelNumber, std::vector<short>& samples, uint32_t& gain);
104
105 virtual inline uint32_t hasPhysicsBlock() const {return LE_getHeader16(LowEBlkOffset)+LE_getHeader16(HighEBlkOffset);} ;
106 virtual inline uint32_t hasRawDataBlock() const {return LE_getHeader16(RawDataBlkOffset);} ;
107
108 private:
109 virtual bool setPointers();
110 void clearBlocks();
111 virtual void resetPointers();
112 //Separated blocks for encoding
113 std::vector<uint32_t> m_LowEnergyBlock;
114 std::vector<uint32_t> m_HighEnergyBlock;
115 std::vector<uint32_t> m_RawDataBlock;
116 //Counter for channels inside of a FEB
117 int m_ECounter = 0;
119 int m_LowEIndex = 0;
122 int m_EIndex = 0; //For writing....
123 const int32_t *m_HighEPtr;
124 const uint32_t *m_FlagPtr;
125 const int16_t *m_LowEPtr;
126 //Number of flagging words at the beginning of Block 2, 3, and 4 (Depends on the number of channels)
127 unsigned short m_NFlaggingWords;
128
130 static const uint32_t m_DummyBitMap[4];
131 //Private functions:
132 inline int FebToRodChannel(int ch) const;
133 void setNextEnergy(const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain);
134};
135
137 //{return ch/8 + 16 * (ch%8);}
138{return (ch>>3) + ((ch&0x7)<<4);}
139
140inline int LArRodBlockPhysicsV0::getNextEnergy(int& channelNumber,int32_t& energy,int32_t& time,int32_t& quality, uint32_t& gain)
141{
142 LARBSDBG("in LArRodBlockPhysicsV0::getEnergy.");
143 LARBSDBG("m_ECounter=" << m_ECounter << " m_RawDataIndex="<< m_EIndex);
144 LARBSDBG("m_channelsPerFEB=" << m_channelsPerFEB);
145 if (m_LowEIndex+m_HighEIndex>=m_channelsPerFEB) //Already beyond maximal number of channels
146 return 0;
147 if (!m_FlagPtr || !m_LowEPtr) //No data block present
148 return 0;
149 uint32_t gtQ;
150 int rodChannelNumber=m_LowEIndex+m_HighEIndex; //Index of Channel in ROD-Block
151 channelNumber=(rodChannelNumber>>4) + ((rodChannelNumber&0xf)<<3); //channel number of the FEB
152 if (getBit(m_FlagPtr,rodChannelNumber)) //Data in high energy block
153 {energy = m_HighEPtr[m_HighEIndex*2];
154 gtQ=m_HighEPtr[m_HighEIndex*2+1];
155 // Q in bits 0-15
156 // t in bits 16-29
157 // gain in bits 30-31
158 quality = gtQ & 0xffff;
159 gtQ = gtQ >> 16;
160 //time = gtQ & 0x3fff;
161 time = gtQ & 0x1fff;
162 if (gtQ & 0x2000)
163 time*=-1;
164 gain=(gtQ >> 14);
165 m_HighEIndex++;
166 }
167 else //Data in low energy block
168 {if (!m_LowEPtr)
169 return 0; //Block does not exist;
170 energy=m_LowEPtr[m_LowEIndex];
171 gain=0; //=CaloGain::LARHIGHGAIN
172 time=0;
173 quality=-1;
174 m_LowEIndex++;
175 }
176 return 1;
177}
178
179#ifdef LARBSDBGOUTPUT
180#undef LARBSDBGOUTPUT
181#endif
182#undef LARBSDBG
183
184#endif
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
virtual uint32_t hasPhysicsBlock() const
bool operator()(const RAWDATA *ch1, const RAWDATA *ch2) const
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)
LArRodBlockPhysicsV0(IMessageSvc *msgSvc)
virtual void initializeFEB(const uint32_t id)
virtual void setNumberOfSamples(const uint8_t n)
int FebToRodChannel(int ch) const
static std::string BlockType()
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)
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
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
LArRodBlockStructure(IMessageSvc *msgSvc, const std::string &blockType)
uint16_t LE_getHeader16(const unsigned n) const
singleton-like access to IMessageSvc via open function and helper