ATLAS Offline Software
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 
33 #include <stdint.h>
34 #include <vector>
36 #include "StoreGate/StoreGateSvc.h"
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 {
49 public:
50  // constructor
52 
53 protected:
54  // ----------------- Header words indexes -----------------
55  enum {
65  RawDataBlkOffset, //Elements below this are not used by the converter
70  endtag
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;
131  int m_RawDataIndex = 0;
132  int m_HighEIndex = 0;
133  int m_EIndex = 0; //For writing....
137  const int32_t *m_HighEPtr;
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 
160 inline 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
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)
195  else
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
LArRodBlockStructure
Definition: LArRodBlockStructure.h:48
LArRodBlockPhysicsV2::getStatus
virtual uint32_t getStatus() const
Definition: LArRodBlockPhysicsV2.cxx:666
LArRodBlockPhysicsV2::BlockType
std::string BlockType()
Definition: LArRodBlockPhysicsV2.h:74
LArRodBlockPhysicsV2::LowEBlkOffset
@ LowEBlkOffset
Definition: LArRodBlockPhysicsV2.h:63
LArRodBlockPhysicsV2::m_ECounter
int m_ECounter
Definition: LArRodBlockPhysicsV2.h:128
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
LArRodBlockPhysicsV2::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: LArRodBlockPhysicsV2.h:144
LArRodBlockPhysicsV2::NWTot
@ NWTot
Definition: LArRodBlockPhysicsV2.h:56
LArRodBlockPhysicsV2::FebToRodChannel
int FebToRodChannel(int ch) const
Definition: LArRodBlockPhysicsV2.h:156
LArRodBlockPhysicsV2::m_RawDataCounter
int m_RawDataCounter
Definition: LArRodBlockPhysicsV2.h:129
LArRodBlockPhysicsV2::setNumberOfSamples
virtual void setNumberOfSamples(const uint8_t n)
Definition: LArRodBlockPhysicsV2.cxx:167
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
LArRodBlockPhysicsV2::m_RawDataBlock
std::vector< uint32_t > m_RawDataBlock
Definition: LArRodBlockPhysicsV2.h:126
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
LArRodBlockPhysicsV2
Definition: LArRodBlockPhysicsV2.h:48
LArRodBlockPhysicsV2::clearBlocks
void clearBlocks()
Definition: LArRodBlockPhysicsV2.cxx:74
LArRodBlockPhysicsV2::setRawData
virtual void setRawData(const int channel, const std::vector< short > &samples, const uint32_t gain)
Definition: LArRodBlockPhysicsV2.cxx:246
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LArRodBlockPhysicsV2::endtag
@ endtag
Definition: LArRodBlockPhysicsV2.h:70
LArRodBlockPhysicsV2::initializeFEB
virtual void initializeFEB(const uint32_t id)
Definition: LArRodBlockPhysicsV2.cxx:307
LArRodBlockPhysicsV2::getNextRawData
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
Definition: LArRodBlockPhysicsV2.cxx:402
LArRodBlockPhysicsV2::NGainNSamples
@ NGainNSamples
Definition: LArRodBlockPhysicsV2.h:64
LArRodBlockPhysicsV2::setNextEnergy
virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
Definition: LArRodBlockPhysicsV2.cxx:178
LArRodBlockPhysicsV2::canSetRawData
virtual bool canSetRawData()
Definition: LArRodBlockPhysicsV2.h:93
LArRodBlockPhysicsV2::m_RawDataIndex
int m_RawDataIndex
Definition: LArRodBlockPhysicsV2.h:131
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArRodBlockPhysicsV2::m_NFlaggingWords
unsigned short m_NFlaggingWords
Definition: LArRodBlockPhysicsV2.h:141
LArRodBlockPhysicsV2::hasRawDataBlock
virtual uint32_t hasRawDataBlock() const
Definition: LArRodBlockPhysicsV2.h:118
LArRodBlockPhysicsV2::EventID
@ EventID
Definition: LArRodBlockPhysicsV2.h:69
LArRodBlockPhysicsV2::sortDataVector
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
LArRodBlockPhysicsV2::RawDataBlkOffset
@ RawDataBlkOffset
Definition: LArRodBlockPhysicsV2.h:65
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
LArRodBlockPhysicsV2::getRadd
virtual uint32_t getRadd(uint32_t adc, uint32_t sample) const
Definition: LArRodBlockPhysicsV2.cxx:629
LArRodBlockPhysicsV2::m_logstr
MsgStream m_logstr
Definition: LArRodBlockPhysicsV2.h:151
LArRodBlockPhysicsV2::finalizeFEB
virtual void finalizeFEB()
Definition: LArRodBlockPhysicsV2.cxx:319
LArRodBlockPhysicsV2::FEB_SN_h
@ FEB_SN_h
Definition: LArRodBlockPhysicsV2.h:61
LArRodBlockPhysicsV2::FEBID
@ FEBID
Definition: LArRodBlockPhysicsV2.h:58
LArRodBlockPhysicsV2::m_HighEIndex
int m_HighEIndex
Definition: LArRodBlockPhysicsV2.h:132
LArRodBlockPhysicsV2::sortDataVector
virtual void sortDataVector(std::vector< const LArDigit * > &)
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
LArRodBlockPhysicsV2::Status2
@ Status2
Definition: LArRodBlockPhysicsV2.h:66
beamspotman.n
n
Definition: beamspotman.py:731
LArRodBlockPhysicsV2::NWTot_h
@ NWTot_h
Definition: LArRodBlockPhysicsV2.h:57
LArRodBlockPhysicsV2::m_GainPtr
const uint32_t * m_GainPtr
Definition: LArRodBlockPhysicsV2.h:136
01SubmitToGrid.samples
samples
Definition: 01SubmitToGrid.py:58
LArRodBlockPhysicsV2::getCtrl2
virtual uint16_t getCtrl2(uint32_t adc) const
Definition: LArRodBlockPhysicsV2.cxx:648
LArRodBlockPhysicsV2::m_LowEnergyBlock
std::vector< uint32_t > m_LowEnergyBlock
Definition: LArRodBlockPhysicsV2.h:124
LArRodBlockPhysicsV2::getNextEnergy
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
Definition: LArRodBlockPhysicsV2.h:160
LArRodBlockPhysicsV2::getCtrl1
virtual uint16_t getCtrl1(uint32_t adc) const
Definition: LArRodBlockPhysicsV2.cxx:639
LArRodBlockPhysicsV2::getNumberOfSamples
virtual uint32_t getNumberOfSamples() const
LArRodBlockStructure::getBit
int getBit(const uint32_t *const p, const unsigned chan) const
Definition: LArRodBlockStructure.h:433
LArRodBlockPhysicsV2::setGain
virtual int setGain(const int)
Definition: LArRodBlockPhysicsV2.h:102
LArRodBlockPhysicsV2::m_RawDataPtr
const uint16_t * m_RawDataPtr
Definition: LArRodBlockPhysicsV2.h:134
LArRodBlockPhysicsV2::FEBID_h
@ FEBID_h
Definition: LArRodBlockPhysicsV2.h:59
LArRodBlockPhysicsV2::m_DummyBitMap
static const uint32_t m_DummyBitMap[4]
Definition: LArRodBlockPhysicsV2.h:145
LArRodBlockPhysicsV2::setPointers
virtual bool setPointers()
Definition: LArRodBlockPhysicsV2.cxx:90
LArRodBlockPhysicsV2::getNumberOfGains
virtual uint32_t getNumberOfGains() const
LArRodBlockPhysicsV2::setNumberOfGains
virtual void setNumberOfGains(const uint8_t n)
Definition: LArRodBlockPhysicsV2.cxx:172
LArOnlineID
Definition: LArOnlineID.h:20
LArRodBlockPhysicsV2::m_LowEPtr
const int16_t * m_LowEPtr
Definition: LArRodBlockPhysicsV2.h:139
LArRodBlockStructure::sortDataVector
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
Definition: LArRodBlockStructure.cxx:230
LArRodBlockStructure::LE_getHeader16
uint16_t LE_getHeader16(const unsigned n) const
Definition: LArRodBlockStructure.h:405
LArRodBlockPhysicsV2::m_EIndex
int m_EIndex
Definition: LArRodBlockPhysicsV2.h:133
LArRodBlockStructure.h
LArRodBlockPhysicsV2::concatinateFEBs
virtual void concatinateFEBs()
Definition: LArRodBlockPhysicsV2.cxx:371
LArRodBlockPhysicsV2::canSetEnergy
virtual bool canSetEnergy()
Definition: LArRodBlockPhysicsV2.h:92
LArRodBlockPhysicsV2::resetPointers
virtual void resetPointers()
Definition: LArRodBlockPhysicsV2.cxx:80
LArRodBlockPhysicsV2::hasPhysicsBlock
virtual uint32_t hasPhysicsBlock() const
Definition: LArRodBlockPhysicsV2.h:117
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
LArRodBlockPhysicsV2::initializeFragment
virtual void initializeFragment(std::vector< uint32_t > &fragment)
Definition: LArRodBlockPhysicsV2.cxx:279
LArRodBlockPhysicsV2::m_FlagPtr
const uint32_t * m_FlagPtr
Definition: LArRodBlockPhysicsV2.h:138
LArRodBlockPhysicsV2::m_HighEnergyBlock
std::vector< uint32_t > m_HighEnergyBlock
Definition: LArRodBlockPhysicsV2.h:125
LARBSDBG
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
Definition: LArRodBlockPhysicsV2.h:44
LArRodBlockPhysicsV2::operator()
bool operator()()(const RAWDATA *ch1
LArRodBlockPhysicsV2::FEB_SN
@ FEB_SN
Definition: LArRodBlockPhysicsV2.h:60
LArRodBlockPhysicsV2::m_LowEIndex
int m_LowEIndex
Definition: LArRodBlockPhysicsV2.h:130
LArRodBlockPhysicsV2::getCtrl3
virtual uint16_t getCtrl3(uint32_t adc) const
Definition: LArRodBlockPhysicsV2.cxx:657
LArRodBlockPhysicsV2::m_RawDataFlagsPtr
const uint32_t * m_RawDataFlagsPtr
Definition: LArRodBlockPhysicsV2.h:135
LArRodBlockPhysicsV2::Status1
@ Status1
Definition: LArRodBlockPhysicsV2.h:67
LArRodBlockPhysicsV2::m_HighEPtr
const int32_t * m_HighEPtr
Definition: LArRodBlockPhysicsV2.h:137
LArRodBlockStructure::m_channelsPerFEB
int m_channelsPerFEB
Definition: LArRodBlockStructure.h:225
LArRodBlockPhysicsV2::BCID
@ BCID
Definition: LArRodBlockPhysicsV2.h:68
StoreGateSvc.h
LArRodBlockPhysicsV2::LArRodBlockPhysicsV2
LArRodBlockPhysicsV2()
Definition: LArRodBlockPhysicsV2.cxx:37
LArRodBlockPhysicsV2::HighEBlkOffset
@ HighEBlkOffset
Definition: LArRodBlockPhysicsV2.h:62