ATLAS Offline Software
gFexInputByteStreamTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //***************************************************************************
6 // gFexInputByteStreamTool - This tool decodes Run3 gFEX input data!
7 // -------------------
8 // begin : 10 08 2022
9 // email : cecilia.tosciri@cern.ch
10 // ***************************************************************************/
11 
12 #ifndef GFEXINPUTBYTESTREAMTOOL_H
13 #define GFEXINPUTBYTESTREAMTOOL_H
14 
15 // Trigger includes
19 
20 // Athena includes
23 
24 // Gaudi includes
25 #include "Gaudi/Property.h"
26 
27 #include "gFexPos.h"
28 #include <array>
29 #include <vector>
30 #include <cstdint>
31 namespace gPos = LVL1::gFEXPos;
32 
41 class gFexInputByteStreamTool : public extends<AthAlgTool, IL1TriggerByteStreamTool> {
42  public:
43  typedef std::array<std::array<uint32_t, 7>, 100> gfiber;
44  typedef std::array<std::array<int, 6>, 32> gEngines;
45  typedef std::array<std::array<int, 12>, 32> gtFPGA;
46  typedef std::array<std::array<int, 20>, 100> gFields;
47  typedef std::array<std::array<int, 16>, 100> gCaloTwr;
48  typedef std::array<std::array<int, 8>, 100> gSatur;
49  typedef std::array<std::array<char, 20>, 100> gFieldsChar;
50  typedef std::array<std::array<int, 20>, 4> gType;
51  typedef std::array<std::array<char, 20>, 4> gTypeChar;
52  gFexInputByteStreamTool(const std::string& type, const std::string& name, const IInterface* parent);
53  virtual ~gFexInputByteStreamTool() override = default;
54 
55  // ------------------------- IAlgTool methods --------------------------------
56  virtual StatusCode initialize() override;
57 
58  // ------------------------- IL1TriggerByteStreamTool methods ----------------------
60  virtual StatusCode convertFromBS(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vrobf, const EventContext& eventContext)const override;
61 
63  virtual StatusCode convertToBS(std::vector<OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment*>& vrobf, const EventContext& eventContext) override;
64 
66  virtual const std::vector<uint32_t>& robIds() const override {
67  return m_robIds.value();
68  }
69 
70 
71  private:
72  // ------------------------- Properties --------------------------------------
73  ToolHandle<GenericMonitoringTool> m_monTool{this,"MonTool","","Monitoring tool"};
74  bool m_UseMonitoring = false;
75 
76 
77 
78  // ROBIDs property required by the interface
79  Gaudi::Property<std::vector<uint32_t>> m_robIds {this, "ROBIDs", {}, "List of ROB IDs required for conversion to/from xAOD RoI"};
80 
81  //Write handle keys for the L1Calo EDMs for BS->xAOD mode of operation
82  SG::WriteHandleKey< xAOD::gFexTowerContainer> m_gTowersWriteKey {this,"gTowersWriteKey" ,"L1_gFexDataTowers","Write gFexEDM Trigger Tower container with 200 MeV resolution (default)"};
83  SG::WriteHandleKey< xAOD::gFexTowerContainer> m_gTowers50WriteKey {this,"gTowers50WriteKey" ,"L1_gFexDataTowers50","Write gFexEDM Trigger Tower container with 50 MeV resolution"};
84 
85  // Read handle keys for the L1Calo EDMs for xAOD->BS mode of operation
86  SG::ReadHandleKey < xAOD::gFexTowerContainer> m_gTowersReadKey {this,"gTowersReadKey" ,"L1_gFexDataTowers","Read gFexEDM Trigger Tower container"};
87 
88  virtual void a_gtrx_map( const gfiber &inputData, gfiber &jf_lar_rx_data) const;
89 
90  virtual void b_gtrx_map( const gfiber &inputData, gfiber &jf_lar_rx_data) const;
91 
92  virtual void c_gtrx_map( const gfiber &inputData, gfiber &outputData) const;
93 
94  virtual void gtReconstructABC( int XFPGA,
95  gfiber Xfiber,
96  int Xin,
97  gtFPGA &XgtF,
98  gtFPGA &Xgt,
99  int *BCIDptr,
100  int do_lconv,
101  const std::array<int, gPos::MAX_FIBERS> &XMPD_NFI,
102  const std::array<int, gPos::MAX_FIBERS> &XCALO_TYPE,
103  const gCaloTwr & XMPD_GTRN_ARR,
104  const gType & XMPD_DSTRT_ARR,
105  gTypeChar XMPD_DTYP_ARR,
106  const std::array<int, gPos::MAX_FIBERS> &XMSK,
107  gtFPGA &Xsatur) const;
108 
109  virtual int crc9d32(const std::array<uint32_t, 6> &inWords,int numWords,int reverse) const;
110 
111  uint32_t crc9d23(uint32_t inword, uint32_t in_crc, int reverse ) const;
112 
113  virtual void undoMLE(int &datumPtr ) const;
114 
115  virtual void getEtaPhi(float &Eta, float &Phi, int iEta, int iPhi, int gFEXtowerID) const;
116 
117  virtual void signExtend(int *xptr, int upto) const;
118 
119  virtual void gtCalib(gtFPGA &gtf, int towerLSB, int fpga, unsigned int offset) const;
120 
121 
122 
123  void printError(const std::string& location, const std::string& title, MSG::Level type, const std::string& detail) const;
124 
125 };
126 
127 #endif // GFEXINPUTBYTESTREAMTOOL_H
gFexInputByteStreamTool::m_robIds
Gaudi::Property< std::vector< uint32_t > > m_robIds
Definition: gFexInputByteStreamTool.h:79
gFexTowerContainer.h
gFexInputByteStreamTool::convertFromBS
virtual StatusCode convertFromBS(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf, const EventContext &eventContext) const override
BS->xAOD conversion.
Definition: gFexInputByteStreamTool.cxx:54
gFexInputByteStreamTool::gType
std::array< std::array< int, 20 >, 4 > gType
Definition: gFexInputByteStreamTool.h:50
gFexInputByteStreamTool::m_gTowers50WriteKey
SG::WriteHandleKey< xAOD::gFexTowerContainer > m_gTowers50WriteKey
Definition: gFexInputByteStreamTool.h:83
gFexInputByteStreamTool::gtCalib
virtual void gtCalib(gtFPGA &gtf, int towerLSB, int fpga, unsigned int offset) const
Definition: gFexInputByteStreamTool.cxx:1514
gFexInputByteStreamTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: gFexInputByteStreamTool.h:73
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
gFexInputByteStreamTool::signExtend
virtual void signExtend(int *xptr, int upto) const
Definition: gFexInputByteStreamTool.cxx:1496
gFexInputByteStreamTool::~gFexInputByteStreamTool
virtual ~gFexInputByteStreamTool() override=default
gFexInputByteStreamTool::m_UseMonitoring
bool m_UseMonitoring
Definition: gFexInputByteStreamTool.h:74
gFexPos.h
detail
Definition: extract_histogram_tag.cxx:14
IL1TriggerByteStreamTool.h
gFexInputByteStreamTool::gtFPGA
std::array< std::array< int, 12 >, 32 > gtFPGA
Definition: gFexInputByteStreamTool.h:45
gFexInputByteStreamTool::undoMLE
virtual void undoMLE(int &datumPtr) const
Definition: gFexInputByteStreamTool.cxx:1279
Phi
@ Phi
Definition: RPCdef.h:8
gFexInputByteStreamTool::a_gtrx_map
virtual void a_gtrx_map(const gfiber &inputData, gfiber &jf_lar_rx_data) const
Definition: gFexInputByteStreamTool.cxx:324
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
gFexInputByteStreamTool::gtReconstructABC
virtual void gtReconstructABC(int XFPGA, gfiber Xfiber, int Xin, gtFPGA &XgtF, gtFPGA &Xgt, int *BCIDptr, int do_lconv, const std::array< int, gPos::MAX_FIBERS > &XMPD_NFI, const std::array< int, gPos::MAX_FIBERS > &XCALO_TYPE, const gCaloTwr &XMPD_GTRN_ARR, const gType &XMPD_DSTRT_ARR, gTypeChar XMPD_DTYP_ARR, const std::array< int, gPos::MAX_FIBERS > &XMSK, gtFPGA &Xsatur) const
Definition: gFexInputByteStreamTool.cxx:387
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
gFexInputByteStreamTool::crc9d23
uint32_t crc9d23(uint32_t inword, uint32_t in_crc, int reverse) const
Definition: gFexInputByteStreamTool.cxx:1218
gFexInputByteStreamTool::printError
void printError(const std::string &location, const std::string &title, MSG::Level type, const std::string &detail) const
Definition: gFexInputByteStreamTool.cxx:1576
gFexInputByteStreamTool::crc9d32
virtual int crc9d32(const std::array< uint32_t, 6 > &inWords, int numWords, int reverse) const
Definition: gFexInputByteStreamTool.cxx:1154
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
gFexInputByteStreamTool::initialize
virtual StatusCode initialize() override
Definition: gFexInputByteStreamTool.cxx:30
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
gFexInputByteStreamTool::gEngines
std::array< std::array< int, 6 >, 32 > gEngines
Definition: gFexInputByteStreamTool.h:44
gFexInputByteStreamTool::m_gTowersReadKey
SG::ReadHandleKey< xAOD::gFexTowerContainer > m_gTowersReadKey
Definition: gFexInputByteStreamTool.h:86
gFexInputByteStreamTool::gSatur
std::array< std::array< int, 8 >, 100 > gSatur
Definition: gFexInputByteStreamTool.h:48
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
covarianceTool.title
title
Definition: covarianceTool.py:542
gFexInputByteStreamTool
Implementation of a tool for L1 input data conversion from BS to xAOD and from xAOD to BS (IL1Trigger...
Definition: gFexInputByteStreamTool.h:41
AthAlgTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
gFexInputByteStreamTool::gCaloTwr
std::array< std::array< int, 16 >, 100 > gCaloTwr
Definition: gFexInputByteStreamTool.h:47
gFexInputByteStreamTool::gfiber
std::array< std::array< uint32_t, 7 >, 100 > gfiber
Definition: gFexInputByteStreamTool.h:43
gFexInputByteStreamTool::m_gTowersWriteKey
SG::WriteHandleKey< xAOD::gFexTowerContainer > m_gTowersWriteKey
Definition: gFexInputByteStreamTool.h:82
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
gFexTowerAuxContainer.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
gFexInputByteStreamTool::gFexInputByteStreamTool
gFexInputByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: gFexInputByteStreamTool.cxx:25
gFexInputByteStreamTool::getEtaPhi
virtual void getEtaPhi(float &Eta, float &Phi, int iEta, int iPhi, int gFEXtowerID) const
Definition: gFexInputByteStreamTool.cxx:1408
gFexInputByteStreamTool::gFields
std::array< std::array< int, 20 >, 100 > gFields
Definition: gFexInputByteStreamTool.h:46
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:47
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
LVL1::gFEXPos
Definition: gFexPos.h:11
gFexInputByteStreamTool::b_gtrx_map
virtual void b_gtrx_map(const gfiber &inputData, gfiber &jf_lar_rx_data) const
Definition: gFexInputByteStreamTool.cxx:345
gFexInputByteStreamTool::gTypeChar
std::array< std::array< char, 20 >, 4 > gTypeChar
Definition: gFexInputByteStreamTool.h:51
gFexInputByteStreamTool::convertToBS
virtual StatusCode convertToBS(std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const EventContext &eventContext) override
xAOD->BS conversion
Definition: gFexInputByteStreamTool.cxx:1571
xAOD::iEta
setScale setgFexType iEta
Definition: gFexJetRoI_v1.cxx:74
Eta
@ Eta
Definition: RPCdef.h:8
gFexInputByteStreamTool::robIds
virtual const std::vector< uint32_t > & robIds() const override
Declare ROB IDs for conversion.
Definition: gFexInputByteStreamTool.h:66
gFexInputByteStreamTool::c_gtrx_map
virtual void c_gtrx_map(const gfiber &inputData, gfiber &outputData) const
Definition: gFexInputByteStreamTool.cxx:366
gFexInputByteStreamTool::gFieldsChar
std::array< std::array< char, 20 >, 100 > gFieldsChar
Definition: gFexInputByteStreamTool.h:49