ATLAS Offline Software
CpByteStreamTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGT1CALOBYTESTREAM_CPBYTESTREAMTOOL_H
6 #define TRIGT1CALOBYTESTREAM_CPBYTESTREAMTOOL_H
7 
8 #include <stdint.h>
9 
10 #include <map>
11 #include <string>
12 #include <vector>
13 
14 #include "L1CaloSrcIdMap.h"
20 #include "eformat/SourceIdentifier.h"
21 #include "GaudiKernel/ToolHandle.h"
22 
23 class IInterface;
24 class InterfaceID;
25 class StatusCode;
26 
27 template <typename> class FullEventAssembler;
28 
29 namespace LVL1 {
30  class CMMCPHits;
31  class CPMHits;
32  class CPMTower;
33  class CPBSCollection;
34  class IL1CaloMappingTool;
35  class TriggerTowerKey;
36 }
37 
38 namespace LVL1BS {
39 
40 class CmmCpSubBlock;
41 class CpmSubBlock;
42 class L1CaloErrorByteStreamTool;
43 class L1CaloSrcIdMap;
44 
53 class CpByteStreamTool : public AthAlgTool {
54 
55  public:
56  CpByteStreamTool(const std::string& type, const std::string& name,
57  const IInterface* parent);
58  virtual ~CpByteStreamTool();
59 
61  static const InterfaceID& interfaceID();
62 
63  virtual StatusCode initialize() override;
64 
66  StatusCode convert(const std::string& sgKey,
67  const IROBDataProviderSvc::VROBFRAG& robFrags,
68  DataVector<LVL1::CPMTower>* ttCollection) const;
70  StatusCode convert(const std::string& sgKey,
71  const IROBDataProviderSvc::VROBFRAG& robFrags,
72  DataVector<LVL1::CPMHits>* hitCollection) const;
74  StatusCode convert(const std::string& sgKey,
75  const IROBDataProviderSvc::VROBFRAG& robFrags,
76  DataVector<LVL1::CMMCPHits>* hitCollection) const;
77 
80 
82  const std::vector<uint32_t>& sourceIDs() const;
83 
84  private:
86  { this, "ByteStreamCnvSvc", "ByteStreamCnvSvc" };
87 
88  struct LocalData
89  {
93  unsigned int rodErr = 0;
95  std::vector<unsigned int> hitsVec0;
97  std::vector<unsigned int> hitsVec1;
99  std::vector<int> errVec0;
101  std::vector<int> errVec1;
103  std::vector<int> emVec;
105  std::vector<int> hadVec;
107  std::vector<int> emErrVec;
109  std::vector<int> hadErrVec;
112  };
113 
115 
119  typedef std::map<unsigned int, LVL1::CPMTower*> CpmTowerMap;
120  typedef std::map<unsigned int, const LVL1::CPMTower*> ConstCpmTowerMap;
121  typedef std::map<int, LVL1::CPMHits*> CpmHitsMap;
122  typedef std::map<int, const LVL1::CPMHits*> ConstCpmHitsMap;
123  typedef std::map<int, LVL1::CMMCPHits*> CmmCpHitsMap;
124  typedef std::map<int, const LVL1::CMMCPHits*> ConstCmmCpHitsMap;
125  typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator;
128 
130  {
132  : m_collection(collection){}
134  };
136  {
137  CpmTowerData (CpmTowerCollection* const ttCollection)
138  : CpByteStreamToolData (CPM_TOWERS), m_ttCollection (ttCollection) {}
141  };
143  {
144  CpmHitsData (CpmHitsCollection* const hitCollection)
145  : CpByteStreamToolData (CPM_HITS), m_hitCollection (hitCollection) {}
148  };
150  {
151  CmmHitsData (CmmCpHitsCollection* const hitCollection)
152  : CpByteStreamToolData (CMM_CP_HITS), m_cmmHitCollection (hitCollection) {}
155  };
156 
158  std::vector<uint32_t> makeSourceIDs() const;
159 
161  StatusCode convertBs(const std::string& sgKey,
162  const IROBDataProviderSvc::VROBFRAG& robFrags,
163  CpByteStreamToolData& data) const;
165  void decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm, CmmHitsData& data,
166  LocalData& ld) const;
168  void decodeCpm(CpmSubBlock* subBlock, int trigCpm, CpByteStreamToolData& data,
169  LocalData& ld) const;
170 
172  const LVL1::CPMTower* findCpmTower(unsigned int key,
173  const ConstCpmTowerMap& ttMap) const;
174  LVL1::CPMTower* findCpmTower(const CpmTowerData& data, unsigned int key) const;
176  const LVL1::CPMHits* findCpmHits(int crate, int module,
177  const ConstCpmHitsMap& hitsMap) const;
178  LVL1::CPMHits* findCpmHits(const CpmHitsData& data, int crate, int module) const;
180  const LVL1::CMMCPHits* findCmmCpHits(int crate, int dataID,
181  const ConstCmmCpHitsMap& cmmHitsMap) const;
183  int crate, int dataID) const;
184 
186  void setupCpmTowerMap(const CpmTowerCollection* ttCollection,
187  ConstCpmTowerMap& ttMap,
188  LVL1::TriggerTowerKey& towerKey) const;
190  void setupCpmHitsMap(const CpmHitsCollection* hitCollection,
191  ConstCpmHitsMap& hitsMap) const;
193  void setupCmmCpHitsMap(const CmmCpHitsCollection* hitCollection,
194  ConstCmmCpHitsMap& cmmHitsMap) const;
195 
197  bool slinkSlices(int crate, int module, int modulesPerSlink,
198  int& timeslices, int& trigJem,
199  const ConstCpmTowerMap& ttMap,
200  const ConstCpmHitsMap& hitsMap,
201  const ConstCmmCpHitsMap& cmmHitsMap,
202  LVL1::TriggerTowerKey& towerKey) const;
203 
205  ToolHandle<LVL1::IL1CaloMappingTool> m_cpmMaps;
207  ToolHandle<LVL1BS::L1CaloErrorByteStreamTool> m_errorTool;
208 
218  const int m_channels;
220  const int m_crates;
222  const int m_modules;
224  int m_slinks;
230  std::vector<uint32_t> m_sourceIDsProp;
232  const eformat::SubDetector m_subDetector;
235 };
236 
237 } // end namespace
238 
239 #endif
LVL1BS::CpByteStreamTool::CmmHitsData
Definition: CpByteStreamTool.h:150
LVL1BS::CpByteStreamTool::CmmCpHitsMap
std::map< int, LVL1::CMMCPHits * > CmmCpHitsMap
Definition: CpByteStreamTool.h:123
LVL1BS::CpByteStreamTool::m_crates
const int m_crates
Number of crates.
Definition: CpByteStreamTool.h:220
LVL1BS::CpByteStreamTool::LocalData
Definition: CpByteStreamTool.h:89
LVL1BS::CpByteStreamTool::LocalData::hitsVec1
std::vector< unsigned int > hitsVec1
Hits1 vector for unpacking.
Definition: CpByteStreamTool.h:97
LVL1BS::CpByteStreamTool::CpByteStreamToolData
Definition: CpByteStreamTool.h:130
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
LVL1BS::CpByteStreamTool::ConstCpmTowerMap
std::map< unsigned int, const LVL1::CPMTower * > ConstCpmTowerMap
Definition: CpByteStreamTool.h:120
FullEventAssembler
Template class for assembling a full atlas raw event from subfragments.
Definition: FullEventAssembler.h:40
LVL1BS::CpByteStreamTool::CpByteStreamTool
CpByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: CpByteStreamTool.cxx:48
LVL1::CPBSCollection
Cluster Processor container for writing bytestream.
Definition: CPBSCollection.h:24
LVL1BS::CpByteStreamTool::m_slinks
int m_slinks
Property: Number of slinks per crate when writing out bytestream.
Definition: CpByteStreamTool.h:224
LVL1BS::CmmCpSubBlock
Sub-Block class for CMM-CP data.
Definition: CmmCpSubBlock.h:23
LVL1BS::CpByteStreamTool::CpByteStreamToolData::CpByteStreamToolData
CpByteStreamToolData(const CollectionType collection)
Definition: CpByteStreamTool.h:131
LVL1BS::CpByteStreamTool::m_dfltSlices
int m_dfltSlices
Property: Default number of slices in simulation.
Definition: CpByteStreamTool.h:226
LVL1BS::CpByteStreamTool::initialize
virtual StatusCode initialize() override
Definition: CpByteStreamTool.cxx:94
LVL1BS::L1CaloSrcIdMap
This class provides conversion between Lower level Source ID to higher level source ID for L1Calo Byt...
Definition: L1CaloSrcIdMap.h:24
LVL1BS::CpByteStreamTool::sourceIDs
const std::vector< uint32_t > & sourceIDs() const
Return reference to vector with all possible Source Identifiers.
Definition: CpByteStreamTool.cxx:447
LVL1BS::CpByteStreamTool::CmmCpHitsCollection
DataVector< LVL1::CMMCPHits > CmmCpHitsCollection
Definition: CpByteStreamTool.h:118
LVL1BS::CpByteStreamTool::CpmHitsMap
std::map< int, LVL1::CPMHits * > CpmHitsMap
Definition: CpByteStreamTool.h:121
LVL1BS::CpByteStreamTool::LocalData::towerKey
LVL1::TriggerTowerKey * towerKey
Trigger tower key provider.
Definition: CpByteStreamTool.h:111
LVL1BS::CpByteStreamTool::m_subDetector
const eformat::SubDetector m_subDetector
Sub-detector type.
Definition: CpByteStreamTool.h:232
LVL1BS::CpByteStreamTool::setupCpmHitsMap
void setupCpmHitsMap(const CpmHitsCollection *hitCollection, ConstCpmHitsMap &hitsMap) const
Set up CPM hits map.
Definition: CpByteStreamTool.cxx:1059
LVL1BS::CpByteStreamTool::LocalData::coreOverlap
int coreOverlap
Tower channels to accept (1=Core, 2=Overlap)
Definition: CpByteStreamTool.h:91
LVL1BS::CpByteStreamTool::CpmTowerMap
std::map< unsigned int, LVL1::CPMTower * > CpmTowerMap
Definition: CpByteStreamTool.h:119
LVL1::CPMHits
The CPMHits object contains the hit data produced by a given Cluster Processor Module,...
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMHits.h:35
LVL1BS::CpByteStreamTool::CpmTowerData
Definition: CpByteStreamTool.h:136
LVL1BS::CpByteStreamTool::decodeCpm
void decodeCpm(CpmSubBlock *subBlock, int trigCpm, CpByteStreamToolData &data, LocalData &ld) const
Unpack CPM sub-block.
Definition: CpByteStreamTool.cxx:784
xAOD::CPMTower
CPMTower_v2 CPMTower
Define the latest version of the CPMTower class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMTower.h:16
LVL1BS::CpByteStreamTool::m_sourceIDsProp
std::vector< uint32_t > m_sourceIDsProp
Property: ROB source IDs.
Definition: CpByteStreamTool.h:230
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1BS::CpByteStreamTool::LocalData::hitsVec0
std::vector< unsigned int > hitsVec0
Hits0 vector for unpacking.
Definition: CpByteStreamTool.h:95
LVL1BS::CpByteStreamTool::LocalData::hadVec
std::vector< int > hadVec
Had data vector for unpacking.
Definition: CpByteStreamTool.h:105
LVL1BS::CpByteStreamTool::CpmTowerData::m_ttMap
CpmTowerMap m_ttMap
Definition: CpByteStreamTool.h:140
LVL1BS::CpByteStreamTool::CollectionType
CollectionType
Definition: CpByteStreamTool.h:114
LVL1BS::CpByteStreamTool::CpmHitsData::m_hitsMap
CpmHitsMap m_hitsMap
Definition: CpByteStreamTool.h:147
LVL1BS::CpByteStreamTool::LocalData::errVec0
std::vector< int > errVec0
Error0 vector for unpacking.
Definition: CpByteStreamTool.h:99
LVL1BS::CpByteStreamTool::m_channels
const int m_channels
Number of channels per module.
Definition: CpByteStreamTool.h:218
python.PyAthena.module
module
Definition: PyAthena.py:131
LVL1BS::CpByteStreamTool::convertBs
StatusCode convertBs(const std::string &sgKey, const IROBDataProviderSvc::VROBFRAG &robFrags, CpByteStreamToolData &data) const
Convert bytestream to given container type.
Definition: CpByteStreamTool.cxx:455
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
const DataType * PointerType
Definition: RawEvent.h:25
LVL1BS::CpByteStreamTool::slinkSlices
bool slinkSlices(int crate, int module, int modulesPerSlink, int &timeslices, int &trigJem, const ConstCpmTowerMap &ttMap, const ConstCpmHitsMap &hitsMap, const ConstCmmCpHitsMap &cmmHitsMap, LVL1::TriggerTowerKey &towerKey) const
Get number of slices and triggered slice offset for next slink.
Definition: CpByteStreamTool.cxx:1097
LVL1BS::CpByteStreamTool::CMM_CP_HITS
@ CMM_CP_HITS
Definition: CpByteStreamTool.h:114
LVL1::CPMTower
The CPMTower class contains the TriggerTower information received by the Cluster Processor Modules.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CPMTower.h:36
LVL1BS::CpByteStreamTool::m_crateOffsetSw
int m_crateOffsetSw
Property: Software crate number offset.
Definition: CpByteStreamTool.h:212
LVL1BS::CpByteStreamTool::findCmmCpHits
const LVL1::CMMCPHits * findCmmCpHits(int crate, int dataID, const ConstCmmCpHitsMap &cmmHitsMap) const
Find CMM-CP hits for given crate, data ID.
Definition: CpByteStreamTool.cxx:1020
LVL1BS::CpByteStreamTool::CpmTowerData::m_ttCollection
CpmTowerCollection *const m_ttCollection
Definition: CpByteStreamTool.h:139
LVL1BS::CpByteStreamTool::LocalData::rodErr
unsigned int rodErr
Unpacking error code.
Definition: CpByteStreamTool.h:93
LVL1BS::CpByteStreamTool::m_cpmMaps
ToolHandle< LVL1::IL1CaloMappingTool > m_cpmMaps
Property: Channel mapping tool.
Definition: CpByteStreamTool.h:205
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LVL1::CMMCPHits
Summary of CP (EM/tau) hits received by the merger modules.
Definition: Trigger/TrigT1/TrigT1CaloEvent/TrigT1CaloEvent/CMMCPHits.h:30
LVL1BS::CpByteStreamTool::LocalData::hadErrVec
std::vector< int > hadErrVec
Had error data vector for unpacking.
Definition: CpByteStreamTool.h:109
LVL1BS::CpByteStreamTool::CPM_TOWERS
@ CPM_TOWERS
Definition: CpByteStreamTool.h:114
LVL1BS::CpmSubBlock
Sub-Block class for CPM data.
Definition: CpmSubBlock.h:23
AthAlgTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LVL1BS::CpByteStreamTool::CmmHitsData::m_cmmHitCollection
CmmCpHitsCollection *const m_cmmHitCollection
Definition: CpByteStreamTool.h:153
LVL1BS::CpByteStreamTool::CpmHitsCollection
DataVector< LVL1::CPMHits > CpmHitsCollection
Definition: CpByteStreamTool.h:117
xAOD::CPMHits
CPMHits_v1 CPMHits
Define the latest version of the CPMHits class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMHits.h:14
LVL1BS::CpByteStreamTool::CpmHitsData::CpmHitsData
CpmHitsData(CpmHitsCollection *const hitCollection)
Definition: CpByteStreamTool.h:144
LVL1BS::CpByteStreamTool::CpmTowerData::CpmTowerData
CpmTowerData(CpmTowerCollection *const ttCollection)
Definition: CpByteStreamTool.h:137
LVL1BS::CpByteStreamTool::convert
StatusCode convert(const std::string &sgKey, const IROBDataProviderSvc::VROBFRAG &robFrags, DataVector< LVL1::CPMTower > *ttCollection) const
Convert ROB fragments to CPM towers.
Definition: CpByteStreamTool.cxx:107
IROBDataProviderSvc::VROBFRAG
std::vector< const ROBF * > VROBFRAG
Definition: IROBDataProviderSvc.h:27
LVL1BS::CpByteStreamTool::setupCpmTowerMap
void setupCpmTowerMap(const CpmTowerCollection *ttCollection, ConstCpmTowerMap &ttMap, LVL1::TriggerTowerKey &towerKey) const
Set up CPM tower map.
Definition: CpByteStreamTool.cxx:1040
LVL1BS::CpByteStreamTool::m_dataFormat
int m_dataFormat
Property: Data compression format.
Definition: CpByteStreamTool.h:216
DataVector< LVL1::CPMTower >
LVL1BS::CpByteStreamTool::RODPointer
OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer
Definition: CpByteStreamTool.h:127
LVL1BS::CpByteStreamTool::CmmHitsData::CmmHitsData
CmmHitsData(CmmCpHitsCollection *const hitCollection)
Definition: CpByteStreamTool.h:151
LVL1BS::CpByteStreamTool::m_srcIdMap
const L1CaloSrcIdMap m_srcIdMap
Source ID converter.
Definition: CpByteStreamTool.h:234
LVL1BS::CpByteStreamTool::LocalData::emErrVec
std::vector< int > emErrVec
EM error data vector for unpacking.
Definition: CpByteStreamTool.h:107
LVL1BS::CpByteStreamTool::m_byteStreamCnvSvc
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
Definition: CpByteStreamTool.h:86
LVL1BS::CpByteStreamTool::CpmHitsData::m_hitCollection
CpmHitsCollection *const m_hitCollection
Definition: CpByteStreamTool.h:146
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LVL1BS::CpByteStreamTool::makeSourceIDs
std::vector< uint32_t > makeSourceIDs() const
Create list of all source IDs.
Definition: CpByteStreamTool.cxx:422
LVL1BS::CpByteStreamTool
Tool to perform ROB fragments to CPM towers, CPM hits and CMM-CP hits, and CP container to raw data c...
Definition: CpByteStreamTool.h:53
LVL1BS::CpByteStreamTool::ConstCmmCpHitsMap
std::map< int, const LVL1::CMMCPHits * > ConstCmmCpHitsMap
Definition: CpByteStreamTool.h:124
LArNewCalib_PedestalAutoCorr.cp
cp
Definition: LArNewCalib_PedestalAutoCorr.py:185
LVL1BS::CpByteStreamTool::m_crateOffsetHw
int m_crateOffsetHw
Property: Hardware crate number offset.
Definition: CpByteStreamTool.h:210
LVL1BS::CpByteStreamTool::decodeCmmCp
void decodeCmmCp(CmmCpSubBlock *subBlock, int trigCmm, CmmHitsData &data, LocalData &ld) const
Unpack CMM-CP sub-block.
Definition: CpByteStreamTool.cxx:639
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
LVL1BS::CpByteStreamTool::m_modules
const int m_modules
Number of CPM modules per crate.
Definition: CpByteStreamTool.h:222
LVL1BS::CpByteStreamTool::ROBPointer
OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer
Definition: CpByteStreamTool.h:126
LVL1BS::CpByteStreamTool::ConstCpmHitsMap
std::map< int, const LVL1::CPMHits * > ConstCpmHitsMap
Definition: CpByteStreamTool.h:122
LVL1BS::CpByteStreamTool::CpByteStreamToolData::m_collection
const CollectionType m_collection
Definition: CpByteStreamTool.h:133
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LVL1BS::CpByteStreamTool::CPM_HITS
@ CPM_HITS
Definition: CpByteStreamTool.h:114
LVL1BS::CpByteStreamTool::LocalData::errVec1
std::vector< int > errVec1
Error1 vector for unpacking.
Definition: CpByteStreamTool.h:101
LVL1BS
Definition: ZdcByteStreamReadV1V2Tool.h:47
LVL1BS::CpByteStreamTool::ROBIterator
IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator
Definition: CpByteStreamTool.h:125
LVL1BS::CpByteStreamTool::setupCmmCpHitsMap
void setupCmmCpHitsMap(const CmmCpHitsCollection *hitCollection, ConstCmmCpHitsMap &cmmHitsMap) const
Set up CMM-CP hits map.
Definition: CpByteStreamTool.cxx:1078
L1CaloSrcIdMap.h
LVL1BS::CpByteStreamTool::LocalData::emVec
std::vector< int > emVec
EM data vector for unpacking.
Definition: CpByteStreamTool.h:103
LVL1BS::CpByteStreamTool::interfaceID
static const InterfaceID & interfaceID()
AlgTool InterfaceID.
Definition: CpByteStreamTool.cxx:41
AthAlgTool
Definition: AthAlgTool.h:26
LVL1BS::CpByteStreamTool::CpmTowerCollection
DataVector< LVL1::CPMTower > CpmTowerCollection
Definition: CpByteStreamTool.h:116
LVL1BS::CpByteStreamTool::findCpmTower
const LVL1::CPMTower * findCpmTower(unsigned int key, const ConstCpmTowerMap &ttMap) const
Find a CPM tower for given key.
Definition: CpByteStreamTool.cxx:979
LVL1BS::CpByteStreamTool::CmmHitsData::m_cmmHitsMap
CmmCpHitsMap m_cmmHitsMap
Definition: CpByteStreamTool.h:154
IByteStreamCnvSvc.h
LVL1BS::CpByteStreamTool::~CpByteStreamTool
virtual ~CpByteStreamTool()
Definition: CpByteStreamTool.cxx:87
xAOD::CMMCPHits
CMMCPHits_v1 CMMCPHits
Define the latest version of the CMMCPHits class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CMMCPHits.h:17
geometry_dat_to_json.ld
ld
Definition: geometry_dat_to_json.py:32
LVL1BS::CpByteStreamTool::CpmHitsData
Definition: CpByteStreamTool.h:143
LVL1::TriggerTowerKey
The TriggerTowerKey object provides the key for each trigger tower depending on its eta-phi coords.
Definition: TriggerTowerKey.h:56
LVL1BS::CpByteStreamTool::m_forceSlices
int m_forceSlices
Property: Force number of slices in bytestream.
Definition: CpByteStreamTool.h:228
LVL1BS::CpByteStreamTool::m_version
int m_version
Property: Sub_block header version.
Definition: CpByteStreamTool.h:214
IROBDataProviderSvc.h
LVL1BS::CpByteStreamTool::m_errorTool
ToolHandle< LVL1BS::L1CaloErrorByteStreamTool > m_errorTool
Error collection tool.
Definition: CpByteStreamTool.h:207
LVL1BS::CpByteStreamTool::findCpmHits
const LVL1::CPMHits * findCpmHits(int crate, int module, const ConstCpmHitsMap &hitsMap) const
Find CPM hits for given crate, module.
Definition: CpByteStreamTool.cxx:998
ServiceHandle< IByteStreamCnvSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37