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-2026 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#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 LArRodBlockPhysicsV1(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("RodBlockPhysicsV1");}
76 // ----------------- Encoding methods -----------------
77 // Never to be used while decoding!
78 //Header setting methods (different from base class for backward compatibility)
79 virtual void initializeFragment(std::vector<uint32_t>& fragment);
80 virtual void initializeFEB(const uint32_t id);
81 virtual void setNumberOfSamples(const uint8_t n);
82 virtual void setNumberOfGains(const uint8_t n);
83 virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain);
84 virtual void setRawData(const int channel, const std::vector<short>& samples, const uint32_t gain);
85 virtual void finalizeFEB();
86 // build full ROD fragment
87 virtual void concatinateFEBs();
88 //Function to sort RawData Container before encoding:
89 using LArRodBlockStructure::sortDataVector; // avoid warnings.
90 virtual void sortDataVector(std::vector<const LArRawChannel*>& );
91 virtual void sortDataVector( std::vector<const LArDigit*>& );
92 // declare capabilities of this Rod Block Structure
93 virtual bool canSetEnergy() { return true;}
94 virtual bool canSetRawData() {return true;}
95 //Ordering relation for channels & digits
96 template<class RAWDATA>
97 bool operator () (const RAWDATA* ch1, const RAWDATA* ch2) const;
98
99 // ----------------- Decoding methods -----------------
100 // Never to be used while encoding!
101 // set full ROD fragment before trying to get anything!
102 // in case there is more than 1 FEB in 1 fragment, jump to next FEB
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
107 virtual inline uint32_t hasPhysicsBlock() const {return getHeader16(LowEBlkOffset);} ;
108 virtual inline uint32_t hasRawDataBlock() const {return getHeader16(RawDataBlkOffset);} ;
109
110 private:
111 void clearBlocks();
112 virtual void resetPointers();
113 //Separated blocks for encoding
114 std::vector<uint32_t> m_LowEnergyBlock;
115 std::vector<uint32_t> m_HighEnergyBlock;
116 std::vector<uint32_t> m_RawDataBlock;
117 //Counter for channels inside of a FEB
118 int m_ECounter = 0;
120 int m_LowEIndex = 0;
123 int m_EIndex = 0; //For writing....
124 const int32_t *m_HighEPtr;
125 const uint32_t *m_FlagPtr;
126 const int16_t *m_LowEPtr;
127 //Number of flagging words at the beginning of Block 2, 3, and 4 (Depends on the number of channels)
128 unsigned short m_NFlaggingWords;
129
131 static const uint32_t m_DummyBitMap[4];
132 //Private functions:
133 inline int FebToRodChannel(int ch) const;
134 void setNextEnergy(const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain);
135};
136
138 //{return ch/8 + 16 * (ch%8);}
139{return (ch>>3) + ((ch&0x7)<<4);}
140
141inline int LArRodBlockPhysicsV1::getNextEnergy(int& channelNumber,int32_t& energy,int32_t& time,int32_t& quality, uint32_t& gain)
142{
143 LARBSDBG("in LArRodBlockPhysicsV1::getEnergy.");
144 LARBSDBG("m_LowEIndex=" <<m_LowEIndex << " m_HighEIndex" << m_HighEIndex);
145 LARBSDBG("m_channelsPerFEB=" << m_channelsPerFEB);
146 if (m_LowEIndex+m_HighEIndex>=m_channelsPerFEB) //Already beyond maximal number of channels
147 return 0;
148 if (!m_FlagPtr || !m_LowEPtr) //No data block present
149 return 0;
150 uint32_t gtQ;
151 channelNumber=m_LowEIndex+m_HighEIndex; //Index of Channel in ROD-Block
152 if (getBit(m_FlagPtr,channelNumber)) //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 LARBSDBG("Channel " << channelNumber << " Reading Raw data form High E block. E=" << energy << " Q=" << quality);
167 }
168 else //Data in low energy block
169 {if (!m_LowEPtr)
170 return 0; //Block does not exist;
171 energy=m_LowEPtr[m_LowEIndex];
172 gain=0; //=CaloGain::LARHIGHGAIN
173 time=0;
174 quality=-1;
175 m_LowEIndex++;
176 LARBSDBG("Channel " << channelNumber << " Reading Raw data form Low E block. E=" << energy);
177 }
178 return 1;
179}
180
181#ifdef LARBSDBGOUTPUT
182#undef LARBSDBGOUTPUT
183#endif
184#undef LARBSDBG
185
186#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)
static std::string BlockType()
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)
LArRodBlockPhysicsV1(IMessageSvc *msgSvc)
bool operator()(const RAWDATA *ch1, const RAWDATA *ch2) const
virtual void initializeFragment(std::vector< uint32_t > &fragment)
int FebToRodChannel(int ch) const
std::vector< uint32_t > m_RawDataBlock
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 * > &)
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
LArRodBlockStructure(IMessageSvc *msgSvc, const std::string &blockType)
singleton-like access to IMessageSvc via open function and helper