ATLAS Offline Software
jFexRoiByteStreamTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //***************************************************************************
6 // jFexRoiByteStreamTool - This tool decodes Run3 jFEX RoI data!
7 // -------------------
8 // begin : 01 01 2022
9 // email : Sergi.Rodriguez@cern.ch
10 // ***************************************************************************/
11 
12 #ifndef JFEXROIBYTESTREAMTOOL_H
13 #define JFEXROIBYTESTREAMTOOL_H
14 
15 // Trigger includes
17 
30 
31 #include "TrigConfData/L1Menu.h"
32 
33 // Athena includes
36 
38 
39 // Gaudi includes
40 #include "Gaudi/Property.h"
41 
46 class jFexRoiByteStreamTool : public extends<AthAlgTool, IL1TriggerByteStreamTool> {
47  public:
48  jFexRoiByteStreamTool(const std::string& type, const std::string& name, const IInterface* parent);
49  virtual ~jFexRoiByteStreamTool() override = default;
50 
51  // ------------------------- IAlgTool methods --------------------------------
52  virtual StatusCode initialize() override;
53  virtual StatusCode start() override;
54 
55  // ------------------------- IL1TriggerByteStreamTool methods ----------------------
57  virtual StatusCode convertFromBS(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vrobf, const EventContext& eventContext)const override;
58 
60  virtual StatusCode convertToBS(std::vector<OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment*>& vrobf, const EventContext& eventContext) override;
61 
63  virtual const std::vector<uint32_t>& robIds() const override {
64  return m_robIds.value();
65  }
66 
67  private:
68  // ------------------------- Properties --------------------------------------
69  ToolHandle<GenericMonitoringTool> m_monTool{this,"MonTool","","Monitoring tool"};
70  bool m_UseMonitoring = false;
71 
72 
73 
74  // ROBIDs property required by the interface
75  Gaudi::Property<std::vector<uint32_t>> m_robIds {this, "ROBIDs", {}, "List of ROB IDs required for conversion to/from xAOD RoI"};
76  Gaudi::Property<bool> m_convertExtendedTOBs {this, "ConvertExtendedTOBs", false, "Convert xTOBs instead of TOBs"};
77 
78  Gaudi::Property<std::string> m_TobMapping {this, "jFexTobMapping", "L1CaloFEXByteStream/2022-10-19/jFexTobMap.txt", "Text file to convert from hardware internal coordinates to eta-phi location"};
79 
80  //Read handle key for the L1Menu
81  SG::ReadHandleKey<TrigConf::L1Menu> m_l1MenuKey {this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu","Name of the L1Menu object to read configuration from"};
82 
83 
84  // Write handle keys for the L1Calo EDMs for BS->xAOD mode of operation
85  SG::WriteHandleKey< xAOD::jFexSRJetRoIContainer> m_jJWriteKey {this,"jJRoIContainerWriteKey" ,"L1_jFexSRJetRoI","Write jFexEDM SRjet container"};
86  SG::WriteHandleKey< xAOD::jFexLRJetRoIContainer> m_jLJWriteKey {this,"jLJRoIContainerWriteKey" ,"L1_jFexLRJetRoI","Write jFexEDM LRjet container"};
87  SG::WriteHandleKey< xAOD::jFexTauRoIContainer > m_jTauWriteKey {this,"jTauRoIContainerWriteKey","L1_jFexTauRoI" ,"Write jFexEDM tau container"};
88  SG::WriteHandleKey< xAOD::jFexSumETRoIContainer> m_jTEWriteKey {this,"jTERoIContainerWriteKey" ,"L1_jFexSumETRoI","Write jFexEDM SumET container"};
89  SG::WriteHandleKey< xAOD::jFexMETRoIContainer > m_jXEWriteKey {this,"jXERoIContainerWriteKey" ,"L1_jFexMETRoI" ,"Write jFexEDM Met container"};
90  SG::WriteHandleKey< xAOD::jFexFwdElRoIContainer> m_jEMWriteKey {this,"jEMRoIContainerWriteKey" ,"L1_jFexFwdElRoI","Write jFexEDM fwdEl container"};
91 
92  // Read handle keys for the L1Calo EDMs for xAOD->BS mode of operation
93  SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer> m_jJReadKey {this,"jJRoIContainerReadKey" ,"L1_jFexSRJetRoI","Read jFexEDM SRjet container"};
94  SG::ReadHandleKey< xAOD::jFexLRJetRoIContainer> m_jLJReadKey {this,"jLJRoIContainerReadKey" ,"L1_jFexLRJetRoI","Read jFexEDM LRjet container"};
95  SG::ReadHandleKey< xAOD::jFexTauRoIContainer > m_jTauReadKey {this,"jTauRoIContainerReadKey","L1_jFexTauRoI" ,"Read jFexEDM tau container"};
96  SG::ReadHandleKey< xAOD::jFexSumETRoIContainer> m_jTEReadKey {this,"jTERoIContainerReadKey" ,"L1_jFexSumETRoI","Read jFexEDM SumET container"};
97  SG::ReadHandleKey< xAOD::jFexMETRoIContainer > m_jXEReadKey {this,"jXERoIContainerReadKey" ,"L1_jFexMETRoI" ,"Read jFexEDM Met container"};
98  SG::ReadHandleKey< xAOD::jFexFwdElRoIContainer> m_jEMReadKey {this,"jEMRoIContainerReadKey" ,"L1_jFexFwdElRoI","Read jFexEDM fwdEl container"};
99 
100  std::array<uint32_t,6> TOBCounterTrailer (uint32_t word) const;
101  std::array<uint32_t,4> xTOBCounterTrailer(uint32_t word) const;
102  std::array<uint32_t,4> jFEXtoRODTrailer (uint32_t word0, uint32_t word1) const;
103  std::array<uint32_t,1> RODTrailer (uint32_t word0, uint32_t word1) const;
104  void jFEXtoRODHeader (uint32_t word0, uint32_t word1) const;
105 
106 
107  //unpacking internal coordinates
108 
109  std::array<float,2> getEtaPhi (unsigned int jfex, unsigned int fpga, uint32_t word, const char* obj) const;
110  std::array<uint8_t,2> unpackLocalCoords (uint32_t word) const;
111  static const int s_etaBit = 5;
112  static const int s_phiBit = 1;
113  static const int s_etaMask = 0x1f;
114  static const int s_phiMask = 0xf;
115 
116  int m_jTauRes = 0;
117  int m_jJRes = 0;
118  int m_jLJRes = 0;
119  int m_jEMRes = 0;
120  int m_jXERes = 0;
121  int m_jTERes = 0;
122 
123 
124 
125  // Read Mapping file to link internal word eta/phi to float Eta/Phi coordinates
126  StatusCode ReadfromFile(const std::string&);
127 
128  // hash the index into one integer in the format 0xJFCCT (hexadecimal)
129  constexpr static unsigned int mapIndex(unsigned int jfex, unsigned int fpga, unsigned int iEta, unsigned int iPhi);
130  std::unordered_map<unsigned int, std::array<float,2> > m_TobPos_map;
131 
132  void printError(const std::string& location, const std::string& title, MSG::Level type, const std::string& detail) const;
133 
134 };
135 
136 #endif // JFEXROIBYTESTREAMTOOL_H
jFexFwdElRoIContainer.h
jFexRoiByteStreamTool::ReadfromFile
StatusCode ReadfromFile(const std::string &)
Definition: jFexRoiByteStreamTool.cxx:685
jFexRoiByteStreamTool::s_etaBit
static const int s_etaBit
Definition: jFexRoiByteStreamTool.h:111
jFexRoiByteStreamTool::m_jTEWriteKey
SG::WriteHandleKey< xAOD::jFexSumETRoIContainer > m_jTEWriteKey
Definition: jFexRoiByteStreamTool.h:88
jFexSumETRoIContainer.h
jFexRoiByteStreamTool::m_jTERes
int m_jTERes
Definition: jFexRoiByteStreamTool.h:121
jFexRoiByteStreamTool::mapIndex
constexpr static unsigned int mapIndex(unsigned int jfex, unsigned int fpga, unsigned int iEta, unsigned int iPhi)
Definition: jFexRoiByteStreamTool.cxx:733
jFexRoiByteStreamTool::m_TobPos_map
std::unordered_map< unsigned int, std::array< float, 2 > > m_TobPos_map
Definition: jFexRoiByteStreamTool.h:130
xAOD::word1
word1
Definition: eFexEMRoI_v1.cxx:82
jFexRoiByteStreamTool::initialize
virtual StatusCode initialize() override
Definition: jFexRoiByteStreamTool.cxx:46
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
jFexSumETRoIAuxContainer.h
jFexRoiByteStreamTool::~jFexRoiByteStreamTool
virtual ~jFexRoiByteStreamTool() override=default
jFexRoiByteStreamTool::xTOBCounterTrailer
std::array< uint32_t, 4 > xTOBCounterTrailer(uint32_t word) const
Definition: jFexRoiByteStreamTool.cxx:600
jFexRoiByteStreamTool::m_jTEReadKey
SG::ReadHandleKey< xAOD::jFexSumETRoIContainer > m_jTEReadKey
Definition: jFexRoiByteStreamTool.h:96
detail
Definition: extract_histogram_tag.cxx:14
IL1TriggerByteStreamTool.h
jFexLRJetRoIAuxContainer.h
jFexRoiByteStreamTool::TOBCounterTrailer
std::array< uint32_t, 6 > TOBCounterTrailer(uint32_t word) const
Definition: jFexRoiByteStreamTool.cxx:575
SG::ReadHandleKey< TrigConf::L1Menu >
jFexRoiByteStreamTool::jFEXtoRODTrailer
std::array< uint32_t, 4 > jFEXtoRODTrailer(uint32_t word0, uint32_t word1) const
Definition: jFexRoiByteStreamTool.cxx:620
jFexTauRoIContainer.h
jFexTauRoIAuxContainer.h
jFexRoiByteStreamTool::convertToBS
virtual StatusCode convertToBS(std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const EventContext &eventContext) override
xAOD->BS conversion
Definition: jFexRoiByteStreamTool.cxx:765
jFexRoiByteStreamTool::RODTrailer
std::array< uint32_t, 1 > RODTrailer(uint32_t word0, uint32_t word1) const
Definition: jFexRoiByteStreamTool.cxx:649
jFexLRJetRoIContainer.h
jFexRoiByteStreamTool::m_jLJWriteKey
SG::WriteHandleKey< xAOD::jFexLRJetRoIContainer > m_jLJWriteKey
Definition: jFexRoiByteStreamTool.h:86
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
jFexRoiByteStreamTool::m_jJRes
int m_jJRes
Definition: jFexRoiByteStreamTool.h:117
jFexRoiByteStreamTool::m_jXEWriteKey
SG::WriteHandleKey< xAOD::jFexMETRoIContainer > m_jXEWriteKey
Definition: jFexRoiByteStreamTool.h:89
jFexRoiByteStreamTool::m_jXEReadKey
SG::ReadHandleKey< xAOD::jFexMETRoIContainer > m_jXEReadKey
Definition: jFexRoiByteStreamTool.h:97
jFexRoiByteStreamTool::m_jJReadKey
SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer > m_jJReadKey
Definition: jFexRoiByteStreamTool.h:93
jFexRoiByteStreamTool::m_jEMReadKey
SG::ReadHandleKey< xAOD::jFexFwdElRoIContainer > m_jEMReadKey
Definition: jFexRoiByteStreamTool.h:98
jFexRoiByteStreamTool::getEtaPhi
std::array< float, 2 > getEtaPhi(unsigned int jfex, unsigned int fpga, uint32_t word, const char *obj) const
Definition: jFexRoiByteStreamTool.cxx:747
jFexRoiByteStreamTool::m_jEMRes
int m_jEMRes
Definition: jFexRoiByteStreamTool.h:119
jFexSRJetRoIContainer.h
jFexRoiByteStreamTool::robIds
virtual const std::vector< uint32_t > & robIds() const override
Declare ROB IDs for conversion.
Definition: jFexRoiByteStreamTool.h:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
python.sizes.location
string location
Definition: sizes.py:11
jFexRoiByteStreamTool::printError
void printError(const std::string &location, const std::string &title, MSG::Level type, const std::string &detail) const
{map index, {eta,phi}}
Definition: jFexRoiByteStreamTool.cxx:796
jFexRoiByteStreamTool::s_phiBit
static const int s_phiBit
Definition: jFexRoiByteStreamTool.h:112
jFexRoiByteStreamTool::m_l1MenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_l1MenuKey
Definition: jFexRoiByteStreamTool.h:81
jFexRoiByteStreamTool::unpackLocalCoords
std::array< uint8_t, 2 > unpackLocalCoords(uint32_t word) const
Definition: jFexRoiByteStreamTool.cxx:738
covarianceTool.title
title
Definition: covarianceTool.py:542
AthAlgTool.h
jFexRoiByteStreamTool::start
virtual StatusCode start() override
Definition: jFexRoiByteStreamTool.cxx:118
jFexRoiByteStreamTool::s_phiMask
static const int s_phiMask
Definition: jFexRoiByteStreamTool.h:114
test_pyathena.parent
parent
Definition: test_pyathena.py:15
jFexRoiByteStreamTool::m_robIds
Gaudi::Property< std::vector< uint32_t > > m_robIds
Definition: jFexRoiByteStreamTool.h:75
jFexRoiByteStreamTool::m_UseMonitoring
bool m_UseMonitoring
Definition: jFexRoiByteStreamTool.h:70
jFexRoiByteStreamTool::s_etaMask
static const int s_etaMask
Definition: jFexRoiByteStreamTool.h:113
jFexRoiByteStreamTool::m_TobMapping
Gaudi::Property< std::string > m_TobMapping
Definition: jFexRoiByteStreamTool.h:78
jFexMETRoIAuxContainer.h
jFexRoiByteStreamTool::jFEXtoRODHeader
void jFEXtoRODHeader(uint32_t word0, uint32_t word1) const
Definition: jFexRoiByteStreamTool.cxx:660
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
jFexRoiByteStreamTool::m_jJWriteKey
SG::WriteHandleKey< xAOD::jFexSRJetRoIContainer > m_jJWriteKey
Definition: jFexRoiByteStreamTool.h:85
jFexRoiByteStreamTool::m_convertExtendedTOBs
Gaudi::Property< bool > m_convertExtendedTOBs
Definition: jFexRoiByteStreamTool.h:76
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
jFexFwdElRoIAuxContainer.h
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:53
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
jFexRoiByteStreamTool::m_jEMWriteKey
SG::WriteHandleKey< xAOD::jFexFwdElRoIContainer > m_jEMWriteKey
Definition: jFexRoiByteStreamTool.h:90
jFexRoiByteStreamTool::m_jLJRes
int m_jLJRes
Definition: jFexRoiByteStreamTool.h:118
jFexRoiByteStreamTool::convertFromBS
virtual StatusCode convertFromBS(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf, const EventContext &eventContext) const override
BS->xAOD conversion.
Definition: jFexRoiByteStreamTool.cxx:158
jFexRoiByteStreamTool::m_jLJReadKey
SG::ReadHandleKey< xAOD::jFexLRJetRoIContainer > m_jLJReadKey
Definition: jFexRoiByteStreamTool.h:94
jFexRoiByteStreamTool::m_jTauRes
int m_jTauRes
Definition: jFexRoiByteStreamTool.h:116
jFexRoiByteStreamTool
Definition: jFexRoiByteStreamTool.h:46
L1Menu.h
jFexRoiByteStreamTool::m_jTauWriteKey
SG::WriteHandleKey< xAOD::jFexTauRoIContainer > m_jTauWriteKey
Definition: jFexRoiByteStreamTool.h:87
python.PyAthena.obj
obj
Definition: PyAthena.py:135
jFexRoiByteStreamTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: jFexRoiByteStreamTool.h:69
xAOD::iEta
setScale setgFexType iEta
Definition: gFexJetRoI_v1.cxx:74
jFexSRJetRoIAuxContainer.h
jFexRoiByteStreamTool::m_jTauReadKey
SG::ReadHandleKey< xAOD::jFexTauRoIContainer > m_jTauReadKey
Definition: jFexRoiByteStreamTool.h:95
jFexMETRoIContainer.h
jFexRoiByteStreamTool::m_jXERes
int m_jXERes
Definition: jFexRoiByteStreamTool.h:120
jFexRoiByteStreamTool::jFexRoiByteStreamTool
jFexRoiByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: jFexRoiByteStreamTool.cxx:41