ATLAS Offline Software
PpmByteStreamReadV1V2Tool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGT1CALOBYTESTREAM_PPMBYTESTREAMREADV1V2TOOL_H
6 #define TRIGT1CALOBYTESTREAM_PPMBYTESTREAMREADV1V2TOOL_H
7 // ===========================================================================
8 // Includes
9 // ===========================================================================
10 // STD:
11 // ===========================================================================
12 #include <stdint.h>
13 #include <vector>
14 #include <unordered_map>
15 #include <unordered_set>
16 #include <atomic>
17 
18 
19 // ===========================================================================
20 // Athena:
21 // ===========================================================================
22 #include "AsgTools/AsgTool.h"
23 #include "GaudiKernel/ToolHandle.h"
24 #include "GaudiKernel/ServiceHandle.h"
25 
28 
31 
32 #include "CaloUserHeader.h"
33 #include "SubBlockHeader.h"
34 #include "SubBlockStatus.h"
35 
36 #include "../L1CaloErrorByteStreamTool.h"
37 
38 // ===========================================================================
39 // Forward declarations
40 // ===========================================================================
41 
42 
43 // ===========================================================================
44 namespace LVL1BS {
45 
46 // Forward declarations
47 class L1CaloSrcIdMap;
48 class L1CaloErrorByteStreamTool;
49 // ===========================================================================
50 
59 {
62 public:
63  PpmByteStreamReadV1V2Tool(const std::string& name);
65 
66  virtual StatusCode initialize() override;
67  virtual StatusCode finalize() override;
68 
69  // =========================================================================
71  StatusCode convert(xAOD::TriggerTowerContainer* const ttCollection) const;
72  StatusCode convert(const std::string& sgKey, xAOD::TriggerTowerContainer* const ttCollection) const;
73  // =========================================================================
74 
75 private:
76  enum class RequestType { PPM, CPM, CMX };
77  typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator;
80 
81  class BitReader
82  {
83  public:
84  BitReader (const std::vector<uint32_t>& ppBlock)
85  : m_ppPointer (0),
86  m_ppMaxBit (31 * ppBlock.size()),
87  m_ppBlock (ppBlock)
88  {
89  }
90 
91  uint32_t getField (const uint8_t numBits);
92 
93  private:
96  const std::vector<uint32_t>& m_ppBlock;
97  };
98 
99 
100  typedef std::map<uint8_t, std::vector<uint16_t>> LutsMap;
101  typedef std::map<uint8_t, std::vector<uint16_t>> FadcsMap;
102 
103  struct State
104  {
109  bool m_ppmIsRetMuon = false;
110  bool m_ppmIsRetSpare = false;
116  std::vector<uint32_t> m_ppBlock;
117  };
118 
119 
120 private:
122  State& state,
123  const IROBDataProviderSvc::VROBFRAG& robFrags) const;
124 
125 
126  void initSourceIDs();
127 
129  const std::vector<uint32_t>& ppmSourceIDs(State& state,
130  const std::string& sgKey) const;
131 
133  const ROBIterator& robFrag,
134  const RequestType& requestedType) const;
135 
136  // ==========================================================================
137  // PPM
138  // ==========================================================================
140  uint32_t word, int indata) const;
141  StatusCode processPpmBlock_(State& state) const;
142 
143  StatusCode processPpmBlockR4V1_(State& state) const;
144  StatusCode processPpmBlockR3V1_(State& state) const;
148  uint32_t word, int indata) const;
150  std::vector<uint16_t> getPpmAdcSamplesR3_(State& state,
151  BitReader& br, uint8_t format, uint8_t minIndex) const;
154  uint8_t numAdc, int8_t& encoding,
155  int8_t& minIndex) const;
156  std::vector<uint16_t> getPpmAdcSamplesR4_(State& state,
157  BitReader& br,
158  uint8_t encoding, uint8_t minIndex) const;
159  StatusCode processPpmNeutral_(State& state) const;
160 
162  State& state,
163  uint8_t crate,
164  uint8_t module,
166  std::vector<uint8_t>&& lcpVal,
167  std::vector<uint8_t>&& lcpBcidVec,
168 
169  std::vector<uint8_t>&& ljeVal,
170  std::vector<uint8_t>&& ljeSat80Vec,
171 
172  std::vector<uint16_t>&& adcVal,
173  std::vector<uint8_t>&& adcExt,
174  std::vector<int16_t>&& pedCor,
175  std::vector<uint8_t>&& pedEn) const;
176 
178  State& state,
179  uint8_t crate,
180  uint8_t module,
182  const std::vector<uint16_t>& luts,
183  const std::vector<uint16_t>& fadc
184  ) const;
185 
187  State& state,
188  uint8_t crate,
189  uint8_t module,
191  std::vector<uint8_t>&& luts,
192  std::vector<uint8_t>&& lcpBcidVec,
193  std::vector<uint16_t>&& fadc,
194  std::vector<uint8_t>&& bcidExt
195  ) const;
196 
197  void processSubBlockStatus_(State& state,
198  uint8_t crate, uint8_t module, uint32_t word) const;
199 
200 private:
201  ToolHandle<LVL1BS::L1CaloErrorByteStreamTool> m_errorTool;
203  ToolHandle<LVL1::IL1CaloMappingTool> m_ppmMaps;
206 
207 private:
208  std::vector<uint32_t> m_ppmSourceIDs;
209  std::vector<uint32_t> m_ppmSourceIDsMuon;
210  std::vector<uint32_t> m_ppmSourceIDsSpare;
212 
213  mutable std::atomic<size_t> m_maxSizeSeen;
214 
215 // ==========================================================================
216 private:
217  static const uint8_t s_crates = 8;
218  static const uint8_t s_modules = 16;
219  static const uint8_t s_channels = 64;
221 
222  bool m_useSWROD = false;
223 };
224 
225 // ===========================================================================
226 }// end namespace
227 // ===========================================================================
228 #endif
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
LVL1BS::PpmByteStreamReadV1V2Tool::processPpmBlock_
StatusCode processPpmBlock_(State &state) const
Definition: PpmByteStreamReadV1V2Tool.cxx:293
LVL1BS::PpmByteStreamReadV1V2Tool::ROBIterator
IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator
Definition: PpmByteStreamReadV1V2Tool.h:77
LVL1BS::PpmByteStreamReadV1V2Tool::BitReader::BitReader
BitReader(const std::vector< uint32_t > &ppBlock)
Definition: PpmByteStreamReadV1V2Tool.h:84
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_caloUserHeader
CaloUserHeader m_caloUserHeader
Definition: PpmByteStreamReadV1V2Tool.h:111
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_subBlockHeader
SubBlockHeader m_subBlockHeader
Definition: PpmByteStreamReadV1V2Tool.h:112
vtune_athena.format
format
Definition: vtune_athena.py:14
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
LVL1BS::PpmByteStreamReadV1V2Tool::m_maxSizeSeen
std::atomic< size_t > m_maxSizeSeen
Definition: PpmByteStreamReadV1V2Tool.h:213
LVL1BS::PpmByteStreamReadV1V2Tool::BitReader
Definition: PpmByteStreamReadV1V2Tool.h:82
SubBlockHeader.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LVL1BS::L1CaloSrcIdMap
This class provides conversion between Lower level Source ID to higher level source ID for L1Calo Byt...
Definition: L1CaloSrcIdMap.h:24
LVL1BS::PpmByteStreamReadV1V2Tool::processPpmBlockR4V1_
StatusCode processPpmBlockR4V1_(State &state) const
Definition: PpmByteStreamReadV1V2Tool.cxx:577
LVL1BS::PpmByteStreamReadV1V2Tool::BitReader::m_ppPointer
uint32_t m_ppPointer
Definition: PpmByteStreamReadV1V2Tool.h:94
TriggerTowerContainer.h
LVL1BS::PpmByteStreamReadV1V2Tool::m_errorTool
ToolHandle< LVL1BS::L1CaloErrorByteStreamTool > m_errorTool
Definition: PpmByteStreamReadV1V2Tool.h:201
LVL1BS::PpmByteStreamReadV1V2Tool::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: PpmByteStreamReadV1V2Tool.cxx:1003
LVL1BS::CaloUserHeader
L1Calo User Header class.
Definition: CaloUserHeader.h:22
LVL1BS::PpmByteStreamReadV1V2Tool::s_modules
static const uint8_t s_modules
Definition: PpmByteStreamReadV1V2Tool.h:218
LVL1BS::PpmByteStreamReadV1V2Tool::processRobFragment_
StatusCode processRobFragment_(State &state, const ROBIterator &robFrag, const RequestType &requestedType) const
Definition: PpmByteStreamReadV1V2Tool.cxx:156
LVL1BS::PpmByteStreamReadV1V2Tool::convert
StatusCode convert(xAOD::TriggerTowerContainer *const ttCollection) const
Convert ROB fragments to trigger towers.
Definition: PpmByteStreamReadV1V2Tool.cxx:134
LVL1BS::PpmByteStreamReadV1V2Tool::BitReader::m_ppMaxBit
uint32_t m_ppMaxBit
Definition: PpmByteStreamReadV1V2Tool.h:95
LVL1BS::PpmByteStreamReadV1V2Tool::processPpmCompressedR3V1_
StatusCode processPpmCompressedR3V1_(State &state) const
Definition: PpmByteStreamReadV1V2Tool.cxx:416
LVL1BS::SubBlockHeader
L1Calo User Header class.
Definition: SubBlockHeader.h:20
LVL1BS::PpmByteStreamReadV1V2Tool::getPpmAdcSamplesR3_
std::vector< uint16_t > getPpmAdcSamplesR3_(State &state, BitReader &br, uint8_t format, uint8_t minIndex) const
Definition: PpmByteStreamReadV1V2Tool.cxx:500
LVL1BS::PpmByteStreamReadV1V2Tool::m_srcIdMap
L1CaloSrcIdMap * m_srcIdMap
Definition: PpmByteStreamReadV1V2Tool.h:211
LVL1BS::PpmByteStreamReadV1V2Tool::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service for reading bytestream.
Definition: PpmByteStreamReadV1V2Tool.h:205
SubBlockStatus.h
LVL1BS::PpmByteStreamReadV1V2Tool::finalize
virtual StatusCode finalize() override
Definition: PpmByteStreamReadV1V2Tool.cxx:100
LVL1BS::PpmByteStreamReadV1V2Tool::LutsMap
std::map< uint8_t, std::vector< uint16_t > > LutsMap
Definition: PpmByteStreamReadV1V2Tool.h:100
LVL1BS::PpmByteStreamReadV1V2Tool::processSubBlockStatus_
void processSubBlockStatus_(State &state, uint8_t crate, uint8_t module, uint32_t word) const
Definition: PpmByteStreamReadV1V2Tool.cxx:908
LVL1BS::PpmByteStreamReadV1V2Tool::m_ppmMaps
ToolHandle< LVL1::IL1CaloMappingTool > m_ppmMaps
Channel mapping tool.
Definition: PpmByteStreamReadV1V2Tool.h:203
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.PyAthena.module
module
Definition: PyAthena.py:131
LVL1BS::PpmByteStreamReadV1V2Tool::m_ppmSourceIDs
std::vector< uint32_t > m_ppmSourceIDs
Definition: PpmByteStreamReadV1V2Tool.h:208
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
const DataType * PointerType
Definition: RawEvent.h:25
LVL1BS::PpmByteStreamReadV1V2Tool::s_channels
static const uint8_t s_channels
Definition: PpmByteStreamReadV1V2Tool.h:219
LVL1BS::PpmByteStreamReadV1V2Tool::processPpmStandardR4V1_
StatusCode processPpmStandardR4V1_(State &state) const
Definition: PpmByteStreamReadV1V2Tool.cxx:834
LVL1BS::PpmByteStreamReadV1V2Tool::m_useSWROD
bool m_useSWROD
Definition: PpmByteStreamReadV1V2Tool.h:222
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
LVL1BS::PpmByteStreamReadV1V2Tool::interpretPpmHeaderR4V1_
void interpretPpmHeaderR4V1_(BitReader &br, uint8_t numAdc, int8_t &encoding, int8_t &minIndex) const
Definition: PpmByteStreamReadV1V2Tool.cxx:736
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_ppmIsRetSpare
bool m_ppmIsRetSpare
Definition: PpmByteStreamReadV1V2Tool.h:110
CaloUserHeader.h
generateReferenceFile.encoding
encoding
Definition: generateReferenceFile.py:15
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_robSourceId
uint32_t m_robSourceId
Definition: PpmByteStreamReadV1V2Tool.h:106
ASG_TOOL_CLASS0
#define ASG_TOOL_CLASS0(CLASSNAME)
Definition: AsgToolMacros.h:62
LVL1BS::PpmByteStreamReadV1V2Tool::addTriggerTowerV2_
StatusCode addTriggerTowerV2_(State &state, uint8_t crate, uint8_t module, uint8_t channel, std::vector< uint8_t > &&lcpVal, std::vector< uint8_t > &&lcpBcidVec, std::vector< uint8_t > &&ljeVal, std::vector< uint8_t > &&ljeSat80Vec, std::vector< uint16_t > &&adcVal, std::vector< uint8_t > &&adcExt, std::vector< int16_t > &&pedCor, std::vector< uint8_t > &&pedEn) const
Definition: PpmByteStreamReadV1V2Tool.cxx:930
LVL1BS::PpmByteStreamReadV1V2Tool::State
Definition: PpmByteStreamReadV1V2Tool.h:104
IROBDataProviderSvc::VROBFRAG
std::vector< const ROBF * > VROBFRAG
Definition: IROBDataProviderSvc.h:27
ASG_TOOL_INTERFACE
#define ASG_TOOL_INTERFACE(CLASSNAME)
Definition: AsgToolMacros.h:40
LVL1BS::PpmByteStreamReadV1V2Tool::PpmByteStreamReadV1V2Tool
PpmByteStreamReadV1V2Tool(const std::string &name)
Definition: PpmByteStreamReadV1V2Tool.cxx:63
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
LVL1BS::PpmByteStreamReadV1V2Tool::processPpmNeutral_
StatusCode processPpmNeutral_(State &state) const
Definition: PpmByteStreamReadV1V2Tool.cxx:331
LVL1BS::PpmByteStreamReadV1V2Tool::m_ppmSourceIDsSpare
std::vector< uint32_t > m_ppmSourceIDsSpare
Definition: PpmByteStreamReadV1V2Tool.h:210
LVL1BS::PpmByteStreamReadV1V2Tool::s_crates
static const uint8_t s_crates
Definition: PpmByteStreamReadV1V2Tool.h:217
LVL1BS::PpmByteStreamReadV1V2Tool::RequestType::CMX
@ CMX
LVL1BS::PpmByteStreamReadV1V2Tool::~PpmByteStreamReadV1V2Tool
virtual ~PpmByteStreamReadV1V2Tool()
Definition: PpmByteStreamReadV1V2Tool.h:64
LVL1BS::PpmByteStreamReadV1V2Tool::BitReader::getField
uint32_t getField(const uint8_t numBits)
Definition: PpmByteStreamReadV1V2Tool.cxx:1092
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_subDetectorID
uint8_t m_subDetectorID
Definition: PpmByteStreamReadV1V2Tool.h:108
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_ppFadcs
FadcsMap m_ppFadcs
Definition: PpmByteStreamReadV1V2Tool.h:115
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LVL1BS::PpmByteStreamReadV1V2Tool::RequestType::CPM
@ CPM
LVL1BS::PpmByteStreamReadV1V2Tool
Tool to perform ROB fragments to trigger towers and trigger towers to raw data conversions.
Definition: PpmByteStreamReadV1V2Tool.h:59
IL1CaloMappingTool.h
LVL1BS::PpmByteStreamReadV1V2Tool::processPpmBlockR3V1_
StatusCode processPpmBlockR3V1_(State &state) const
Definition: PpmByteStreamReadV1V2Tool.cxx:822
LVL1BS::PpmByteStreamReadV1V2Tool::RequestType
RequestType
Definition: PpmByteStreamReadV1V2Tool.h:76
LVL1BS::PpmByteStreamReadV1V2Tool::initSourceIDs
void initSourceIDs()
Definition: PpmByteStreamReadV1V2Tool.cxx:1039
LVL1BS::PpmByteStreamReadV1V2Tool::RODPointer
OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer
Definition: PpmByteStreamReadV1V2Tool.h:79
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_rodSourceId
uint32_t m_rodSourceId
Definition: PpmByteStreamReadV1V2Tool.h:105
LVL1BS::PpmByteStreamReadV1V2Tool::processPpmWord_
StatusCode processPpmWord_(State &state, uint32_t word, int indata) const
Definition: PpmByteStreamReadV1V2Tool.cxx:273
LVL1BS::PpmByteStreamReadV1V2Tool::RequestType::PPM
@ PPM
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_triggerTowers
xAOD::TriggerTowerContainer * m_triggerTowers
Definition: PpmByteStreamReadV1V2Tool.h:113
LVL1BS::PpmByteStreamReadV1V2Tool::m_ppmSourceIDsMuon
std::vector< uint32_t > m_ppmSourceIDsMuon
Definition: PpmByteStreamReadV1V2Tool.h:209
TriggerTower.h
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_ppLuts
LutsMap m_ppLuts
Definition: PpmByteStreamReadV1V2Tool.h:114
LVL1BS
Definition: ZdcModifySlices.h:10
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_ppmIsRetMuon
bool m_ppmIsRetMuon
Definition: PpmByteStreamReadV1V2Tool.h:109
LVL1BS::PpmByteStreamReadV1V2Tool::processPpmCompressedR4V1_
StatusCode processPpmCompressedR4V1_(State &state) const
Definition: PpmByteStreamReadV1V2Tool.cxx:589
LVL1BS::PpmByteStreamReadV1V2Tool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: PpmByteStreamReadV1V2Tool.cxx:84
LVL1BS::PpmByteStreamReadV1V2Tool::processPpmStandardR3V1_
StatusCode processPpmStandardR3V1_(State &state) const
Definition: PpmByteStreamReadV1V2Tool.cxx:894
LVL1BS::PpmByteStreamReadV1V2Tool::getPpmAdcSamplesR4_
std::vector< uint16_t > getPpmAdcSamplesR4_(State &state, BitReader &br, uint8_t encoding, uint8_t minIndex) const
Definition: PpmByteStreamReadV1V2Tool.cxx:787
LVL1BS::PpmByteStreamReadV1V2Tool::ROBPointer
OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer
Definition: PpmByteStreamReadV1V2Tool.h:78
LVL1BS::PpmByteStreamReadV1V2Tool::FadcsMap
std::map< uint8_t, std::vector< uint16_t > > FadcsMap
Definition: PpmByteStreamReadV1V2Tool.h:101
AsgTool.h
LVL1BS::PpmByteStreamReadV1V2Tool::BitReader::m_ppBlock
const std::vector< uint32_t > & m_ppBlock
Definition: PpmByteStreamReadV1V2Tool.h:96
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_verCode
uint8_t m_verCode
Definition: PpmByteStreamReadV1V2Tool.h:107
LVL1BS::PpmByteStreamReadV1V2Tool::s_maxtowers
static const uint16_t s_maxtowers
Definition: PpmByteStreamReadV1V2Tool.h:220
LVL1BS::PpmByteStreamReadV1V2Tool::State::m_ppBlock
std::vector< uint32_t > m_ppBlock
Definition: PpmByteStreamReadV1V2Tool.h:116
IROBDataProviderSvc.h
PlotCalibFromCool.br
br
Definition: PlotCalibFromCool.py:355
ServiceHandle< IROBDataProviderSvc >
LVL1BS::PpmByteStreamReadV1V2Tool::ppmSourceIDs
const std::vector< uint32_t > & ppmSourceIDs(State &state, const std::string &sgKey) const
Return reference to vector with all possible Source Identifiers.
Definition: PpmByteStreamReadV1V2Tool.cxx:1065