ATLAS Offline Software
ZdcByteStreamReadV1V2Tool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGT1CALOBYTESTREAM_ZDCBYTESTREAMREADV1V2TOOL_H
6 #define TRIGT1CALOBYTESTREAM_ZDCBYTESTREAMREADV1V2TOOL_H
7 
8 #include "AsgTools/AsgTool.h"
9 #include "GaudiKernel/ToolHandle.h"
10 #include "GaudiKernel/ServiceHandle.h"
11 
13 
15 
18 
20 
21 #include <stdint.h>
22 #include <vector>
23 #include <set>
24 #include <map>
25 
26 
27 class ZdcSrcIdMap;
28 class ZdcID;
30 
31 
40 {
43 public:
44  ZdcByteStreamReadV1V2Tool(const std::string& name);
46 
47  virtual StatusCode initialize();
48  virtual StatusCode finalize();
49 
50  // =========================================================================
53  const IROBDataProviderSvc::VROBFRAG& robFrags,
54  xAOD::TriggerTowerContainer* const ttCollection
55  ) const;
56 
58  ZdcDigitsCollection* zdcCollection) const;
59 
60  StatusCode convert(xAOD::TriggerTowerContainer* const ttCollection) const;
61  StatusCode convert(const std::string& sgKey, xAOD::TriggerTowerContainer* const ttCollection) const;
62 
64 
65 
66  // =========================================================================
68  const std::vector<uint32_t>& ppmSourceIDs(const std::string& sgKey) const;
69 
70 private:
71  enum class RequestType { PPM, CPM, CMX };
72  typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator;
75 
76 
77  class BitReader
78  {
79  public:
80  BitReader (const std::vector<uint32_t>& ppBlock)
81  : m_ppPointer (0),
82  m_ppMaxBit (31 * ppBlock.size()),
83  m_ppBlock (ppBlock)
84  {
85  }
86 
87  uint32_t getField (const uint8_t numBits);
88 
89 
90  private:
93  const std::vector<uint32_t>& m_ppBlock;
94  };
95 
96 
97  struct State
98  {
99  std::set<uint32_t> m_coolIds;
101 
104 
109 
110  // For RUN2
111  std::vector<uint32_t> m_ppBlock;
112  // For RUN1
113  std::map<uint8_t, std::vector<uint16_t>> m_ppFadcs;
114  std::map<uint8_t, std::vector<uint16_t>> m_ppLuts;
115  };
116 
117 
118 private:
120  const ROBIterator& robFrag,
121  const RequestType& requestedType) const;
122 
123  // ==========================================================================
124  // PPM
125  // ==========================================================================
126  StatusCode processPpmWord_(State& state, uint32_t word, int indata) const;
127  StatusCode processPpmBlock_(State& state) const;
128 
129  StatusCode processPpmBlockR4V1_(State& state) const;
130  StatusCode processPpmBlockR3V1_(State& state) const;
133  StatusCode processPpmStandardR3V1_(State& state, uint32_t word, int indata) const;
135  std::vector<uint16_t> getPpmAdcSamplesR3_(State& state, BitReader& br, uint8_t format, uint8_t minIndex) const;
138  uint8_t numAdc, int8_t& encoding,
139  int8_t& minIndex) const;
140  std::vector<uint16_t> getPpmAdcSamplesR4_(State& state,
141  BitReader& br,
142  uint8_t encoding, uint8_t minIndex) const;
143  StatusCode processPpmNeutral_(State& state) const;
144 
146  State& state,
147  uint8_t crate,
148  uint8_t module,
150  const std::vector<uint8_t>& lcpVal,
151  const std::vector<uint8_t>& lcpBcidVec,
152 
153  const std::vector<uint8_t>& ljeVal,
154  const std::vector<uint8_t>& ljeSat80Vec,
155 
156  const std::vector<uint16_t>& adcVal,
157  const std::vector<uint8_t>& adcExt,
158  const std::vector<int16_t>& pedCor,
159  const std::vector<uint8_t>& pedEn) const;
160 
162  State& state,
163  uint8_t crate,
164  uint8_t module,
166  const std::vector<uint16_t>& luts,
167  const std::vector<uint16_t>& fadc
168  ) const;
169 
171  State& state,
172  uint8_t crate,
173  uint8_t module,
175  const std::vector<uint8_t>& luts,
176  const std::vector<uint8_t>& lcpBcidVec,
177  const std::vector<uint16_t>& fadc,
178  const std::vector<uint8_t>& bcidExt
179  ) const;
180 
181  void initSourceIDs();
182 
183 private:
184  ToolHandle<ZdcL1CaloErrorByteStreamTool> m_errorTool;
185 
188 
189 private:
190  std::vector<uint32_t> m_ppmSourceIDs;
191  std::vector<uint32_t> m_ppmSourceIDsMuon;
192  std::vector<uint32_t> m_ppmSourceIDsSpare;
194  const ZdcID* m_zdcID{};
195 };
196 
197 
198 // PAS 8/14 used to be here
199 // ===========================================================================
200 //}// end namespace
201 // ===========================================================================
202 #endif
ZdcByteStreamReadV1V2Tool::convert
StatusCode convert(const IROBDataProviderSvc::VROBFRAG &robFrags, xAOD::TriggerTowerContainer *const ttCollection) const
Convert ROB fragments to trigger towers.
Definition: ZdcByteStreamReadV1V2Tool.cxx:121
ZdcByteStreamReadV1V2Tool::RODPointer
OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer
Definition: ZdcByteStreamReadV1V2Tool.h:74
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
ZdcByteStreamReadV1V2Tool::State::m_ppFadcs
std::map< uint8_t, std::vector< uint16_t > > m_ppFadcs
Definition: ZdcByteStreamReadV1V2Tool.h:113
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
ZdcByteStreamReadV1V2Tool::m_ppmSourceIDs
std::vector< uint32_t > m_ppmSourceIDs
Definition: ZdcByteStreamReadV1V2Tool.h:190
vtune_athena.format
format
Definition: vtune_athena.py:14
ZdcByteStreamReadV1V2Tool::~ZdcByteStreamReadV1V2Tool
virtual ~ZdcByteStreamReadV1V2Tool()
Definition: ZdcByteStreamReadV1V2Tool.h:45
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
ZdcByteStreamReadV1V2Tool::getPpmAdcSamplesR4_
std::vector< uint16_t > getPpmAdcSamplesR4_(State &state, BitReader &br, uint8_t encoding, uint8_t minIndex) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:835
ZdcByteStreamReadV1V2Tool::ZdcByteStreamReadV1V2Tool
ZdcByteStreamReadV1V2Tool(const std::string &name)
Definition: ZdcByteStreamReadV1V2Tool.cxx:73
ZdcByteStreamReadV1V2Tool::RequestType::CPM
@ CPM
ZdcByteStreamReadV1V2Tool::State::m_caloUserHeader
ZdcCaloUserHeader m_caloUserHeader
Definition: ZdcByteStreamReadV1V2Tool.h:102
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
ZdcByteStreamReadV1V2Tool::initSourceIDs
void initSourceIDs()
Definition: ZdcByteStreamReadV1V2Tool.cxx:1070
ZdcCaloUserHeader.h
ZdcByteStreamReadV1V2Tool
Tool to perform ROB fragments to trigger towers and trigger towers to raw data conversions.
Definition: ZdcByteStreamReadV1V2Tool.h:40
ZdcByteStreamReadV1V2Tool::m_zdcID
const ZdcID * m_zdcID
Definition: ZdcByteStreamReadV1V2Tool.h:194
ZdcSubBlockHeader.h
ZdcByteStreamReadV1V2Tool::State::m_triggerTowers
xAOD::TriggerTowerContainer * m_triggerTowers
Definition: ZdcByteStreamReadV1V2Tool.h:100
ZdcByteStreamReadV1V2Tool::BitReader::m_ppPointer
uint32_t m_ppPointer
Definition: ZdcByteStreamReadV1V2Tool.h:91
TriggerTowerContainer.h
ZdcByteStreamReadV1V2Tool::processPpmBlockR3V1_
StatusCode processPpmBlockR3V1_(State &state) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:868
ZdcByteStreamReadV1V2Tool::State::m_ppBlock
std::vector< uint32_t > m_ppBlock
Definition: ZdcByteStreamReadV1V2Tool.h:111
ZdcSubBlockHeader
L1Calo User Header class.
Definition: ZdcSubBlockHeader.h:20
ZdcByteStreamReadV1V2Tool::processPpmBlock_
StatusCode processPpmBlock_(State &state) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:339
ZdcByteStreamReadV1V2Tool::ROBPointer
OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer
Definition: ZdcByteStreamReadV1V2Tool.h:73
ZdcByteStreamReadV1V2Tool::BitReader::m_ppBlock
const std::vector< uint32_t > & m_ppBlock
Definition: ZdcByteStreamReadV1V2Tool.h:93
ZdcByteStreamReadV1V2Tool::BitReader::BitReader
BitReader(const std::vector< uint32_t > &ppBlock)
Definition: ZdcByteStreamReadV1V2Tool.h:80
ZdcByteStreamReadV1V2Tool::State::m_rodSourceId
uint32_t m_rodSourceId
Definition: ZdcByteStreamReadV1V2Tool.h:106
ZdcByteStreamReadV1V2Tool::addTriggerTowerV2_
StatusCode addTriggerTowerV2_(State &state, uint8_t crate, uint8_t module, uint8_t channel, const std::vector< uint8_t > &lcpVal, const std::vector< uint8_t > &lcpBcidVec, const std::vector< uint8_t > &ljeVal, const std::vector< uint8_t > &ljeSat80Vec, const std::vector< uint16_t > &adcVal, const std::vector< uint8_t > &adcExt, const std::vector< int16_t > &pedCor, const std::vector< uint8_t > &pedEn) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:950
ZdcL1CaloErrorByteStreamTool.h
ZdcByteStreamReadV1V2Tool::convertTT2ZD
ZdcDigitsCollection * convertTT2ZD(xAOD::TriggerTowerContainer *const ttCollection) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:1138
ZdcByteStreamReadV1V2Tool::State::m_coolIds
std::set< uint32_t > m_coolIds
Definition: ZdcByteStreamReadV1V2Tool.h:99
ZdcByteStreamReadV1V2Tool::processPpmCompressedR3V1_
StatusCode processPpmCompressedR3V1_(State &state) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:464
ZdcByteStreamReadV1V2Tool::interpretPpmHeaderR4V1_
void interpretPpmHeaderR4V1_(BitReader &br, uint8_t numAdc, int8_t &encoding, int8_t &minIndex) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:785
ZdcByteStreamReadV1V2Tool::BitReader
Definition: ZdcByteStreamReadV1V2Tool.h:78
ZdcByteStreamReadV1V2Tool::RequestType::CMX
@ CMX
ZdcByteStreamReadV1V2Tool::processPpmStandardR4V1_
StatusCode processPpmStandardR4V1_(State &state) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:879
ZdcByteStreamReadV1V2Tool::processPpmStandardR3V1_
StatusCode processPpmStandardR3V1_(State &state) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:937
ZdcByteStreamReadV1V2Tool::ppmSourceIDs
const std::vector< uint32_t > & ppmSourceIDs(const std::string &sgKey) const
Return reference to vector with all possible Source Identifiers.
Definition: ZdcByteStreamReadV1V2Tool.cxx:1098
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.PyAthena.module
module
Definition: PyAthena.py:131
ZdcByteStreamReadV1V2Tool::finalize
virtual StatusCode finalize()
Definition: ZdcByteStreamReadV1V2Tool.cxx:114
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
const DataType * PointerType
Definition: RawEvent.h:25
ZdcByteStreamReadV1V2Tool::processPpmWord_
StatusCode processPpmWord_(State &state, uint32_t word, int indata) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:320
ZdcByteStreamReadV1V2Tool::BitReader::getField
uint32_t getField(const uint8_t numBits)
Definition: ZdcByteStreamReadV1V2Tool.cxx:1114
ZdcByteStreamReadV1V2Tool::State::m_ppLuts
std::map< uint8_t, std::vector< uint16_t > > m_ppLuts
Definition: ZdcByteStreamReadV1V2Tool.h:114
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
generateReferenceFile.encoding
encoding
Definition: generateReferenceFile.py:15
ZdcByteStreamReadV1V2Tool::State::m_robSourceId
uint32_t m_robSourceId
Definition: ZdcByteStreamReadV1V2Tool.h:107
ZdcByteStreamReadV1V2Tool::RequestType::PPM
@ PPM
ASG_TOOL_CLASS0
#define ASG_TOOL_CLASS0(CLASSNAME)
Definition: AsgToolMacros.h:62
ZdcByteStreamReadV1V2Tool::State::m_subDetectorID
uint8_t m_subDetectorID
Definition: ZdcByteStreamReadV1V2Tool.h:105
ZdcByteStreamReadV1V2Tool::getPpmAdcSamplesR3_
std::vector< uint16_t > getPpmAdcSamplesR3_(State &state, BitReader &br, uint8_t format, uint8_t minIndex) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:547
IROBDataProviderSvc::VROBFRAG
std::vector< const ROBF * > VROBFRAG
Definition: IROBDataProviderSvc.h:27
ASG_TOOL_INTERFACE
#define ASG_TOOL_INTERFACE(CLASSNAME)
Definition: AsgToolMacros.h:40
ZdcByteStreamReadV1V2Tool::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service for reading bytestream.
Definition: ZdcByteStreamReadV1V2Tool.h:187
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ZdcByteStreamReadV1V2Tool::RequestType
RequestType
Definition: ZdcByteStreamReadV1V2Tool.h:71
ZdcByteStreamReadV1V2Tool::processPpmCompressedR4V1_
StatusCode processPpmCompressedR4V1_(State &state) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:634
ZdcByteStreamReadV1V2Tool::State::m_subBlockHeader
ZdcSubBlockHeader m_subBlockHeader
Definition: ZdcByteStreamReadV1V2Tool.h:103
ZdcByteStreamReadV1V2Tool::State::m_verCode
uint8_t m_verCode
Definition: ZdcByteStreamReadV1V2Tool.h:108
ZdcCaloUserHeader
L1Calo User Header class.
Definition: ZdcCaloUserHeader.h:22
ZdcByteStreamReadV1V2Tool::State
Definition: ZdcByteStreamReadV1V2Tool.h:98
ZdcByteStreamReadV1V2Tool::m_srcIdMap
ZdcSrcIdMap * m_srcIdMap
Definition: ZdcByteStreamReadV1V2Tool.h:193
ZdcByteStreamReadV1V2Tool::m_errorTool
ToolHandle< ZdcL1CaloErrorByteStreamTool > m_errorTool
Definition: ZdcByteStreamReadV1V2Tool.h:184
ZdcDigitsCollection
Definition: ZdcDigitsCollection.h:20
ZdcByteStreamReadV1V2Tool::processPpmNeutral_
StatusCode processPpmNeutral_(State &state) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:381
ZdcByteStreamReadV1V2Tool::ROBIterator
IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator
Definition: ZdcByteStreamReadV1V2Tool.h:72
ZdcSrcIdMap
This class provides conversion between Lower level Source ID to higher level source ID for L1Calo Byt...
Definition: ZdcSrcIdMap.h:24
AsgTool.h
ZdcByteStreamReadV1V2Tool::processPpmBlockR4V1_
StatusCode processPpmBlockR4V1_(State &state) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:622
ZdcByteStreamReadV1V2Tool::m_ppmSourceIDsMuon
std::vector< uint32_t > m_ppmSourceIDsMuon
Definition: ZdcByteStreamReadV1V2Tool.h:191
ZdcID
Definition: ZdcID.h:25
ZdcByteStreamReadV1V2Tool::m_ppmSourceIDsSpare
std::vector< uint32_t > m_ppmSourceIDsSpare
Definition: ZdcByteStreamReadV1V2Tool.h:192
IROBDataProviderSvc.h
ZdcByteStreamReadV1V2Tool::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: ZdcByteStreamReadV1V2Tool.cxx:90
ZdcByteStreamReadV1V2Tool::addTriggerTowerV1_
StatusCode addTriggerTowerV1_(State &state, uint8_t crate, uint8_t module, uint8_t channel, const std::vector< uint16_t > &luts, const std::vector< uint16_t > &fadc) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:1039
PlotCalibFromCool.br
br
Definition: PlotCalibFromCool.py:355
ZdcByteStreamReadV1V2Tool::BitReader::m_ppMaxBit
uint32_t m_ppMaxBit
Definition: ZdcByteStreamReadV1V2Tool.h:92
ServiceHandle< IROBDataProviderSvc >
ZdcByteStreamReadV1V2Tool::processRobFragment_
StatusCode processRobFragment_(State &state, const ROBIterator &robFrag, const RequestType &requestedType) const
Definition: ZdcByteStreamReadV1V2Tool.cxx:202