ATLAS Offline Software
LArRodBlockPhysicsV1.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_LARRODBLOCKPYSICSV1_H
8 #define LARBYTESTREAM_LARRODBLOCKPYSICSV1_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("RodBlockPhysicsV1");}
77  // ----------------- Encoding methods -----------------
78  // Never to be used while decoding!
79  //Header setting methods (different from base class for backward compatibility)
80  //virtual void buildHeader();
81  virtual void initializeFragment(std::vector<uint32_t>& fragment);
82  virtual void initializeFEB(const uint32_t id);
83  virtual void setNumberOfSamples(const uint8_t n);
84  virtual void setNumberOfGains(const uint8_t n);
85  virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain);
86  virtual void setRawData(const int channel, const std::vector<short>& samples, const uint32_t gain);
87  virtual void finalizeFEB();
88  // build full ROD fragment
89  virtual void concatinateFEBs();
90  //Function to sort RawData Container before encoding:
91  using LArRodBlockStructure::sortDataVector; // avoid warnings.
92  virtual void sortDataVector(std::vector<const LArRawChannel*>& );
93  virtual void sortDataVector( std::vector<const LArDigit*>& );
94  // declare capabilities of this Rod Block Structure
95  virtual bool canSetEnergy() { return true;}
96  virtual bool canSetRawData() {return true;}
97  //Ordering relation for channels & digits
98  template<class RAWDATA>
99  bool operator () (const RAWDATA* ch1, const RAWDATA* ch2) const;
100 
101  // ----------------- Decoding methods -----------------
102  // Never to be used while encoding!
103  // set full ROD fragment before trying to get anything!
104  // in case there is more than 1 FEB in 1 fragment, jump to next FEB
105  virtual bool setPointers();
106  virtual inline int getNextEnergy(int& channelNumber, int32_t& energy, int32_t& time,int32_t& quality,uint32_t& gain);
107  virtual int getNextRawData(int& channelNumber, std::vector<short>& samples, uint32_t& gain);
108 
109  // ----------------- Printing methods -----------------
110  // print the full ROD fragment
111  //virtual void dumpFragment();
112  virtual inline uint32_t hasPhysicsBlock() const {return getHeader16(LowEBlkOffset);} ;
113  virtual inline uint32_t hasRawDataBlock() const {return getHeader16(RawDataBlkOffset);} ;
114 
115  private:
116  void clearBlocks();
117  virtual void resetPointers();
118  //Separated blocks for encoding
119  std::vector<uint32_t> m_LowEnergyBlock;
120  std::vector<uint32_t> m_HighEnergyBlock;
121  std::vector<uint32_t> m_RawDataBlock;
122  //Counter for channels inside of a FEB
123  int m_ECounter = 0;
125  int m_LowEIndex = 0;
126  int m_RawDataIndex = 0;
127  int m_HighEIndex = 0;
128  int m_EIndex = 0; //For writing....
129  const int32_t *m_HighEPtr;
132  //Number of flagging words at the beginning of Block 2, 3, and 4 (Depends on the number of channels)
133  unsigned short m_NFlaggingWords;
134 
135  //LArCablingService* m_cablingSvc;
137  static const uint32_t m_DummyBitMap[4];
138  //Private functions:
139  inline int FebToRodChannel(int ch) const;
140  void setNextEnergy(const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain);
141 
142  // log message
143  MsgStream m_logstr;
144 
145 };
146 
148  //{return ch/8 + 16 * (ch%8);}
149 {return (ch>>3) + ((ch&0x7)<<4);}
150 
151 inline int LArRodBlockPhysicsV1::getNextEnergy(int& channelNumber,int32_t& energy,int32_t& time,int32_t& quality, uint32_t& gain)
152 {
153  LARBSDBG("in LArRodBlockPhysicsV1::getEnergy.");
154  LARBSDBG("m_LowEIndex=" <<m_LowEIndex << " m_HighEIndex" << m_HighEIndex);
155  LARBSDBG("m_channelsPerFEB=" << m_channelsPerFEB);
156  if (m_LowEIndex+m_HighEIndex>=m_channelsPerFEB) //Already beyond maximal number of channels
157  return 0;
158  if (!m_FlagPtr || !m_LowEPtr) //No data block present
159  return 0;
160  uint32_t gtQ;
161  channelNumber=m_LowEIndex+m_HighEIndex; //Index of Channel in ROD-Block
162  if (getBit(m_FlagPtr,channelNumber)) //Data in high energy block
164  gtQ=m_HighEPtr[m_HighEIndex*2+1];
165  // Q in bits 0-15
166  // t in bits 16-29
167  // gain in bits 30-31
168  quality = gtQ & 0xffff;
169  gtQ = gtQ >> 16;
170  //time = gtQ & 0x3fff;
171  time = gtQ & 0x1fff;
172  if (gtQ & 0x2000)
173  time*=-1;
174  gain=(gtQ >> 14);
175  m_HighEIndex++;
176  LARBSDBG("Channel " << channelNumber << " Reading Raw data form High E block. E=" << energy << " Q=" << quality);
177  }
178  else //Data in low energy block
179  {if (!m_LowEPtr)
180  return 0; //Block does not exist;
182  gain=0; //=CaloGain::LARHIGHGAIN
183  time=0;
184  quality=-1;
185  m_LowEIndex++;
186  LARBSDBG("Channel " << channelNumber << " Reading Raw data form Low E block. E=" << energy);
187  }
188  /*
189  if (energy>10000000)
190  std::cout << " Read: Large E found. E=" << energy
191  << " t=" << time
192  << " Q=" << quality
193  << " G=" << gain
194  << " channel Number=" << channelNumber
195  << " LowEIndex=" << m_LowEIndex
196  << " HighEIndex="<<m_HighEIndex << std::endl;
197  else
198  std::cout << "Read energy" << std::endl;
199  */
200  return 1;
201 }
202 
203 #ifdef LARBSDBGOUTPUT
204 #undef LARBSDBGOUTPUT
205 #endif
206 #undef LARBSDBG
207 
208 #endif
LArRodBlockStructure
Definition: LArRodBlockStructure.h:48
LArRodBlockPhysicsV1::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: LArRodBlockPhysicsV1.h:136
LArRodBlockPhysicsV1::NWTot_h
@ NWTot_h
Definition: LArRodBlockPhysicsV1.h:57
LArRodBlockPhysicsV1::m_EIndex
int m_EIndex
Definition: LArRodBlockPhysicsV1.h:128
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
LArRodBlockPhysicsV1::m_FlagPtr
const uint32_t * m_FlagPtr
Definition: LArRodBlockPhysicsV1.h:130
LArRodBlockPhysicsV1::EventID
@ EventID
Definition: LArRodBlockPhysicsV1.h:69
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
LArRodBlockPhysicsV1::FEBID
@ FEBID
Definition: LArRodBlockPhysicsV1.h:58
LArRodBlockPhysicsV1::m_LowEnergyBlock
std::vector< uint32_t > m_LowEnergyBlock
Definition: LArRodBlockPhysicsV1.h:119
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LArRodBlockPhysicsV1::hasPhysicsBlock
virtual uint32_t hasPhysicsBlock() const
Definition: LArRodBlockPhysicsV1.h:112
LArRodBlockPhysicsV1::setNextEnergy
virtual void setNextEnergy(const int channel, const int32_t energy, const int32_t time, const int32_t quality, const uint32_t gain)
Definition: LArRodBlockPhysicsV1.cxx:142
LArRodBlockPhysicsV1::HighEBlkOffset
@ HighEBlkOffset
Definition: LArRodBlockPhysicsV1.h:63
LArRodBlockPhysicsV1::m_LowEIndex
int m_LowEIndex
Definition: LArRodBlockPhysicsV1.h:125
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArRodBlockPhysicsV1::setNumberOfSamples
virtual void setNumberOfSamples(const uint8_t n)
Definition: LArRodBlockPhysicsV1.cxx:131
LArRodBlockPhysicsV1::initializeFragment
virtual void initializeFragment(std::vector< uint32_t > &fragment)
Definition: LArRodBlockPhysicsV1.cxx:243
LArRodBlockPhysicsV1::BCID
@ BCID
Definition: LArRodBlockPhysicsV1.h:68
LArRodBlockPhysicsV1::m_LowEPtr
const int16_t * m_LowEPtr
Definition: LArRodBlockPhysicsV1.h:131
LArRodBlockPhysicsV1::FEBID_h
@ FEBID_h
Definition: LArRodBlockPhysicsV1.h:59
LArRodBlockPhysicsV1::m_RawDataCounter
int m_RawDataCounter
Definition: LArRodBlockPhysicsV1.h:124
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
LArRodBlockPhysicsV1::m_RawDataBlock
std::vector< uint32_t > m_RawDataBlock
Definition: LArRodBlockPhysicsV1.h:121
LArRodBlockPhysicsV1::RADD1
@ RADD1
Definition: LArRodBlockPhysicsV1.h:70
LArRodBlockPhysicsV1::Status2
@ Status2
Definition: LArRodBlockPhysicsV1.h:67
LArRodBlockPhysicsV1::setPointers
virtual bool setPointers()
Definition: LArRodBlockPhysicsV1.cxx:85
LArRodBlockPhysicsV1::LowEBlkOffset
@ LowEBlkOffset
Definition: LArRodBlockPhysicsV1.h:62
LArRodBlockPhysicsV1::NWTot
@ NWTot
Definition: LArRodBlockPhysicsV1.h:56
LArRodBlockPhysicsV1::concatinateFEBs
virtual void concatinateFEBs()
Definition: LArRodBlockPhysicsV1.cxx:335
LArRodBlockPhysicsV1::setNumberOfGains
virtual void setNumberOfGains(const uint8_t n)
Definition: LArRodBlockPhysicsV1.cxx:136
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
LArRodBlockPhysicsV1::getNextEnergy
virtual int getNextEnergy(int &channelNumber, int32_t &energy, int32_t &time, int32_t &quality, uint32_t &gain)
Definition: LArRodBlockPhysicsV1.h:151
beamspotman.n
n
Definition: beamspotman.py:731
LArRodBlockPhysicsV1::m_HighEPtr
const int32_t * m_HighEPtr
Definition: LArRodBlockPhysicsV1.h:129
LArRodBlockPhysicsV1::canSetEnergy
virtual bool canSetEnergy()
Definition: LArRodBlockPhysicsV1.h:95
LArRodBlockPhysicsV1::RADD2
@ RADD2
Definition: LArRodBlockPhysicsV1.h:71
LArRodBlockStructure::getBit
int getBit(const uint32_t *const p, const unsigned chan) const
Definition: LArRodBlockStructure.h:433
LArRodBlockPhysicsV1::m_logstr
MsgStream m_logstr
Definition: LArRodBlockPhysicsV1.h:143
LArRodBlockPhysicsV1::m_RawDataIndex
int m_RawDataIndex
Definition: LArRodBlockPhysicsV1.h:126
LArRodBlockPhysicsV1::initializeFEB
virtual void initializeFEB(const uint32_t id)
Definition: LArRodBlockPhysicsV1.cxx:271
LArRodBlockPhysicsV1::resetPointers
virtual void resetPointers()
Definition: LArRodBlockPhysicsV1.cxx:75
LArRodBlockPhysicsV1::FebToRodChannel
int FebToRodChannel(int ch) const
Definition: LArRodBlockPhysicsV1.h:147
LArRodBlockPhysicsV1::m_DummyBitMap
static const uint32_t m_DummyBitMap[4]
Definition: LArRodBlockPhysicsV1.h:137
LArRodBlockPhysicsV1::FEB_SN
@ FEB_SN
Definition: LArRodBlockPhysicsV1.h:60
LArRodBlockPhysicsV1::clearBlocks
void clearBlocks()
Definition: LArRodBlockPhysicsV1.cxx:69
LArRodBlockPhysicsV1::NGainNSamples
@ NGainNSamples
Definition: LArRodBlockPhysicsV1.h:65
LArOnlineID
Definition: LArOnlineID.h:20
LArRodBlockPhysicsV1::hasRawDataBlock
virtual uint32_t hasRawDataBlock() const
Definition: LArRodBlockPhysicsV1.h:113
LArRodBlockPhysicsV1::setRawData
virtual void setRawData(const int channel, const std::vector< short > &samples, const uint32_t gain)
Definition: LArRodBlockPhysicsV1.cxx:210
LArRodBlockStructure::sortDataVector
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
Definition: LArRodBlockStructure.cxx:230
LArRodBlockStructure.h
LArRodBlockPhysicsV1::endtag
@ endtag
Definition: LArRodBlockPhysicsV1.h:72
LArRodBlockPhysicsV1::BlockType
std::string BlockType()
Definition: LArRodBlockPhysicsV1.h:76
LArRodBlockPhysicsV1::operator()
bool operator()()(const RAWDATA *ch1
LArRodBlockPhysicsV1::RawDataBlkOffset
@ RawDataBlkOffset
Definition: LArRodBlockPhysicsV1.h:64
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
LArRodBlockPhysicsV1::m_HighEnergyBlock
std::vector< uint32_t > m_HighEnergyBlock
Definition: LArRodBlockPhysicsV1.h:120
LArRodBlockPhysicsV1::sortDataVector
virtual void sortDataVector(std::vector< const LArRawChannel * > &)
LArRodBlockPhysicsV1::LArRodBlockPhysicsV1
LArRodBlockPhysicsV1()
Definition: LArRodBlockPhysicsV1.cxx:37
LArRodBlockPhysicsV1::sortDataVector
virtual void sortDataVector(std::vector< const LArDigit * > &)
LArRodBlockPhysicsV1::m_ECounter
int m_ECounter
Definition: LArRodBlockPhysicsV1.h:123
LArRodBlockPhysicsV1::canSetRawData
virtual bool canSetRawData()
Definition: LArRodBlockPhysicsV1.h:96
LARBSDBG
#define LARBSDBG(text)
This class provides decoding/encoding from/to ROD format.
Definition: LArRodBlockPhysicsV1.h:44
LArRodBlockPhysicsV1
Definition: LArRodBlockPhysicsV1.h:48
LArRodBlockPhysicsV1::finalizeFEB
virtual void finalizeFEB()
Definition: LArRodBlockPhysicsV1.cxx:283
LArRodBlockStructure::m_channelsPerFEB
int m_channelsPerFEB
Definition: LArRodBlockStructure.h:225
LArRodBlockPhysicsV1::m_HighEIndex
int m_HighEIndex
Definition: LArRodBlockPhysicsV1.h:127
StoreGateSvc.h
LArRodBlockStructure::getHeader16
uint16_t getHeader16(const unsigned n) const
Definition: LArRodBlockStructure.h:355
LArRodBlockPhysicsV1::getNextRawData
virtual int getNextRawData(int &channelNumber, std::vector< short > &samples, uint32_t &gain)
Definition: LArRodBlockPhysicsV1.cxx:366
LArRodBlockPhysicsV1::m_NFlaggingWords
unsigned short m_NFlaggingWords
Definition: LArRodBlockPhysicsV1.h:133
LArRodBlockPhysicsV1::Status1
@ Status1
Definition: LArRodBlockPhysicsV1.h:66
LArRodBlockPhysicsV1::FEB_SN_h
@ FEB_SN_h
Definition: LArRodBlockPhysicsV1.h:61