ATLAS Offline Software
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 
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  NGainNSamples, //Elements below this are not used by the converter
71  RADD2, //Could have more RADD's in real data
72  endtag
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();
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;
125  int m_RawDataIndex = 0;
126  int m_HighEIndex = 0;
127  int m_EIndex = 0; //For writing....
128  const int32_t *m_HighEPtr;
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 
149 inline 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
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;
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
LArRodBlockStructure
Definition: LArRodBlockStructure.h:48
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
LArRodBlockPhysicsV0::m_HighEIndex
int m_HighEIndex
Definition: LArRodBlockPhysicsV0.h:126
LArRodBlockPhysicsV0::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: LArRodBlockPhysicsV0.h:135
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LArRodBlockPhysicsV0::setRawData
virtual void setRawData(const int channel, const std::vector< short > &samples, const uint32_t gain)
Definition: LArRodBlockPhysicsV0.cxx:211
LArRodBlockPhysicsV0::hasRawDataBlock
virtual uint32_t hasRawDataBlock() const
Definition: LArRodBlockPhysicsV0.h:111
LArRodBlockPhysicsV0::BCID
@ BCID
Definition: LArRodBlockPhysicsV0.h:68
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArRodBlockPhysicsV0::m_LowEPtr
const int16_t * m_LowEPtr
Definition: LArRodBlockPhysicsV0.h:130
LArRodBlockPhysicsV0::HighEBlkOffset
@ HighEBlkOffset
Definition: LArRodBlockPhysicsV0.h:63
LArRodBlockPhysicsV0::initializeFragment
virtual void initializeFragment(std::vector< uint32_t > &fragment)
Definition: LArRodBlockPhysicsV0.cxx:244
LArRodBlockPhysicsV0::m_RawDataIndex
int m_RawDataIndex
Definition: LArRodBlockPhysicsV0.h:125
LArRodBlockPhysicsV0::getNextRawData
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
Definition: LArRodBlockPhysicsV0.cxx:368
LArRodBlockPhysicsV0::m_ECounter
int m_ECounter
Definition: LArRodBlockPhysicsV0.h:122
LArRodBlockPhysicsV0::setNextEnergy
virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
Definition: LArRodBlockPhysicsV0.cxx:142
LArRodBlockPhysicsV0::setPointers
virtual bool setPointers()
Definition: LArRodBlockPhysicsV0.cxx:85
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
LArRodBlockPhysicsV0::LowEBlkOffset
@ LowEBlkOffset
Definition: LArRodBlockPhysicsV0.h:62
LArRodBlockPhysicsV0::concatinateFEBs
virtual void concatinateFEBs()
Definition: LArRodBlockPhysicsV0.cxx:336
LArRodBlockPhysicsV0::hasPhysicsBlock
virtual uint32_t hasPhysicsBlock() const
Definition: LArRodBlockPhysicsV0.h:110
LArRodBlockPhysicsV0::FEBID_h
@ FEBID_h
Definition: LArRodBlockPhysicsV0.h:59
LArRodBlockPhysicsV0::m_HighEnergyBlock
std::vector< uint32_t > m_HighEnergyBlock
Definition: LArRodBlockPhysicsV0.h:119
LArRodBlockPhysicsV0::finalizeFEB
virtual void finalizeFEB()
Definition: LArRodBlockPhysicsV0.cxx:284
LArRodBlockPhysicsV0::EventID
@ EventID
Definition: LArRodBlockPhysicsV0.h:69
LArRodBlockPhysicsV0::Status1
@ Status1
Definition: LArRodBlockPhysicsV0.h:66
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
LArRodBlockPhysicsV0::m_logstr
MsgStream m_logstr
Definition: LArRodBlockPhysicsV0.h:142
LArRodBlockPhysicsV0::LArRodBlockPhysicsV0
LArRodBlockPhysicsV0()
Definition: LArRodBlockPhysicsV0.cxx:37
LArRodBlockPhysicsV0::operator()
bool operator()()(const RAWDATA *ch1
LArRodBlockPhysicsV0::NWTot
@ NWTot
Definition: LArRodBlockPhysicsV0.h:56
LArRodBlockPhysicsV0::FebToRodChannel
int FebToRodChannel(int ch) const
Definition: LArRodBlockPhysicsV0.h:145
beamspotman.n
n
Definition: beamspotman.py:731
LArRodBlockPhysicsV0::FEBID
@ FEBID
Definition: LArRodBlockPhysicsV0.h:58
LArRodBlockPhysicsV0::clearBlocks
void clearBlocks()
Definition: LArRodBlockPhysicsV0.cxx:69
LArRodBlockPhysicsV0::NWTot_h
@ NWTot_h
Definition: LArRodBlockPhysicsV0.h:57
LArRodBlockPhysicsV0::RawDataBlkOffset
@ RawDataBlkOffset
Definition: LArRodBlockPhysicsV0.h:64
LArRodBlockPhysicsV0::setNumberOfSamples
virtual void setNumberOfSamples(const uint8_t n)
Definition: LArRodBlockPhysicsV0.cxx:131
LArRodBlockPhysicsV0::getNextEnergy
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
Definition: LArRodBlockPhysicsV0.h:149
LArRodBlockPhysicsV0::m_DummyBitMap
static const uint32_t m_DummyBitMap[4]
Definition: LArRodBlockPhysicsV0.h:136
LArRodBlockPhysicsV0::m_LowEnergyBlock
std::vector< uint32_t > m_LowEnergyBlock
Definition: LArRodBlockPhysicsV0.h:118
LARBSDBG
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
Definition: LArRodBlockPhysicsV0.h:44
LArRodBlockPhysicsV0::NGainNSamples
@ NGainNSamples
Definition: LArRodBlockPhysicsV0.h:65
LArRodBlockPhysicsV0::initializeFEB
virtual void initializeFEB(const uint32_t id)
Definition: LArRodBlockPhysicsV0.cxx:272
LArRodBlockPhysicsV0
Definition: LArRodBlockPhysicsV0.h:48
LArRodBlockPhysicsV0::BlockType
std::string BlockType()
Definition: LArRodBlockPhysicsV0.h:76
LArRodBlockStructure::getBit
int getBit(const uint32_t *const p, const unsigned chan) const
Definition: LArRodBlockStructure.h:433
LArRodBlockPhysicsV0::resetPointers
virtual void resetPointers()
Definition: LArRodBlockPhysicsV0.cxx:75
LArRodBlockPhysicsV0::FEB_SN_h
@ FEB_SN_h
Definition: LArRodBlockPhysicsV0.h:61
LArRodBlockPhysicsV0::RADD2
@ RADD2
Definition: LArRodBlockPhysicsV0.h:71
LArRodBlockPhysicsV0::FEB_SN
@ FEB_SN
Definition: LArRodBlockPhysicsV0.h:60
LArOnlineID
Definition: LArOnlineID.h:20
LArRodBlockPhysicsV0::m_LowEIndex
int m_LowEIndex
Definition: LArRodBlockPhysicsV0.h:124
LArRodBlockPhysicsV0::setNumberOfGains
virtual void setNumberOfGains(const uint8_t n)
Definition: LArRodBlockPhysicsV0.cxx:136
LArRodBlockStructure::sortDataVector
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
Definition: LArRodBlockStructure.cxx:230
LArRodBlockPhysicsV0::sortDataVector
virtual void sortDataVector(std::vector< const LArDigit * > &)
LArRodBlockPhysicsV0::m_HighEPtr
const int32_t * m_HighEPtr
Definition: LArRodBlockPhysicsV0.h:128
LArRodBlockStructure::LE_getHeader16
uint16_t LE_getHeader16(const unsigned n) const
Definition: LArRodBlockStructure.h:405
LArRodBlockStructure.h
LArRodBlockPhysicsV0::m_NFlaggingWords
unsigned short m_NFlaggingWords
Definition: LArRodBlockPhysicsV0.h:132
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
LArRodBlockPhysicsV0::canSetRawData
virtual bool canSetRawData()
Definition: LArRodBlockPhysicsV0.h:95
LArRodBlockPhysicsV0::Status2
@ Status2
Definition: LArRodBlockPhysicsV0.h:67
LArRodBlockPhysicsV0::canSetEnergy
virtual bool canSetEnergy()
Definition: LArRodBlockPhysicsV0.h:94
LArRodBlockPhysicsV0::m_FlagPtr
const uint32_t * m_FlagPtr
Definition: LArRodBlockPhysicsV0.h:129
LArRodBlockPhysicsV0::endtag
@ endtag
Definition: LArRodBlockPhysicsV0.h:72
LArRodBlockPhysicsV0::m_RawDataCounter
int m_RawDataCounter
Definition: LArRodBlockPhysicsV0.h:123
LArRodBlockPhysicsV0::m_EIndex
int m_EIndex
Definition: LArRodBlockPhysicsV0.h:127
LArRodBlockStructure::m_channelsPerFEB
int m_channelsPerFEB
Definition: LArRodBlockStructure.h:225
LArRodBlockPhysicsV0::m_RawDataBlock
std::vector< uint32_t > m_RawDataBlock
Definition: LArRodBlockPhysicsV0.h:120
LArRodBlockPhysicsV0::RADD1
@ RADD1
Definition: LArRodBlockPhysicsV0.h:70
StoreGateSvc.h
LArRodBlockPhysicsV0::sortDataVector
virtual void sortDataVector(std::vector< const LArRawChannel * > &)