ATLAS Offline Software
Loading...
Searching...
No Matches
gFexInputByteStreamTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
29#include <array>
30#include <vector>
31#include <cstdint>
32namespace gPos = LVL1::gFEXPos;
33
38
39
40class gFexInputByteStreamTool : public extends<AthAlgTool, IL1TriggerByteStreamTool> {
41 public:
42 typedef std::array<std::array<uint32_t, 7>, 100> gfiber;
43 typedef std::array<std::array<int, 6>, 32> gEngines;
44 typedef std::array<std::array<int, 12>, 32> gtFPGA;
45 typedef std::array<std::array<int, 20>, 100> gFields;
46 typedef std::array<std::array<int, 16>, 100> gCaloTwr;
47 typedef std::array<std::array<int, 8>, 100> gSatur;
48 typedef std::array<std::array<char, 20>, 100> gFieldsChar;
49 typedef std::array<std::array<int, 20>, 4> gType;
50 typedef std::array<std::array<char, 20>, 4> gTypeChar;
51 gFexInputByteStreamTool(const std::string& type, const std::string& name, const IInterface* parent);
52 virtual ~gFexInputByteStreamTool() override = default;
53
54 // ------------------------- IAlgTool methods --------------------------------
55 virtual StatusCode initialize() override;
56
57 // ------------------------- IL1TriggerByteStreamTool methods ----------------------
59 virtual StatusCode convertFromBS(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& vrobf, const EventContext& eventContext)const override;
60
62 virtual StatusCode convertToBS(std::vector<OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment*>& vrobf,
64 const EventContext& eventContext) override;
65
67 virtual const std::vector<uint32_t>& robIds() const override {
68 return m_robIds.value();
69 }
70
71
72 private:
73 // ------------------------- Properties --------------------------------------
74 ToolHandle<GenericMonitoringTool> m_monTool{this,"MonTool","","Monitoring tool"};
75 bool m_UseMonitoring = false;
76
77 // FiberMapping property required by the interface
78 Gaudi::Property<std::string> m_FiberMapping{
79 this, "gFexFiberTowerMapping",
80 "Run3L1CaloSimulation/L1CaloFEXAlgos/gFEX/gFex_gCaloTowerMap_weighted_v1.txt",
81 "Text file to convert from hardware fiber to eta-phi location"};
82
83 std::unordered_map<unsigned int, std::array<float, 4> > m_Firm2Tower_map;
84
85 // ROBIDs property required by the interface
86 Gaudi::Property<std::vector<uint32_t>> m_robIds {this, "ROBIDs", {}, "List of ROB IDs required for conversion to/from xAOD RoI"};
87
88 //Write handle keys for the L1Calo EDMs for BS->xAOD mode of operation
89 SG::WriteHandleKey< xAOD::gFexTowerContainer> m_gTowersWriteKey {this,"gTowersWriteKey" ,"L1_gFexDataTowers", "Name of the gFEX Input Data Towers"}; // TODO: This will be the only output of this class in the future
90 SG::WriteHandleKey< xAOD::gFexTowerContainer> m_gTowers50WriteKey {this,"gTowers50WriteKey" ,"", "Write gFexEDM Trigger Tower container with 50 MeV resolution"};
91 SG::WriteHandleKey< xAOD::gFexTowerContainer> m_gTowers200WriteKey {this,"gTowers200WriteKey" ,"", "Write gFexEDM Trigger Tower container with 200 MeV resolution (default)"};
92
93 // Read handle keys for the L1Calo EDMs for xAOD->BS mode of operation
94 SG::ReadHandleKey < xAOD::gFexTowerContainer> m_gTowersReadKey {this,"gTowersReadKey" ,"L1_gFexDataTowers","Read gFexEDM Trigger Tower container"};
95
96 virtual void a_gtrx_map( const gfiber &inputData, gfiber &jf_lar_rx_data) const;
97 virtual void b_gtrx_map( const gfiber &inputData, gfiber &jf_lar_rx_data) const;
98 virtual void c_gtrx_map( const gfiber &inputData, gfiber &outputData) const;
99
100 virtual void gtReconstructABC( int XFPGA,
101 const gfiber & Xfiber,
102 int Xin,
103 gtFPGA &XgtF,
104 gtFPGA &Xgt,
105 int *BCIDptr,
106 int do_lconv,
107 const std::array<int, gPos::MAX_FIBERS> &XMPD_NFI,
108 const std::array<int, gPos::MAX_FIBERS> &XCALO_TYPE,
109 const gCaloTwr & XMPD_GTRN_ARR,
110 const gType & XMPD_DSTRT_ARR,
111 gTypeChar XMPD_DTYP_ARR,
112 const std::array<int, gPos::MAX_FIBERS> &XMSK,
113 gtFPGA &Xsatur,
114 std::array<int, (gPos::AB_FIBERS*gPos::MAX_E_FIELDS)> &FiberTower,
115 std::array<int, (gPos::AB_FIBERS*gPos::MAX_E_FIELDS)> &FiberTowerSatur) const;
116
117 virtual int crc9d32(const std::array<uint32_t, 6> &inWords,int numWords,int reverse) const;
118 uint32_t crc9d23(uint32_t inword, uint32_t in_crc, int reverse ) const;
119
120 virtual void undoMLE(int &datumPtr ) const;
121
122 virtual void getEtaPhi(float &Eta, float &Phi, int iEta, int iPhi, int gFEXtowerID) const;
123
124 virtual void signExtend(int *xptr, int upto) const;
125
126 virtual void gtCalib(gtFPGA &gtf, int towerLSB, int fpga, unsigned int offset) const;
127
128 StatusCode ReadFibersfromFile(const std::string&);
129
130 void printError(const std::string& location, const std::string& title, MSG::Level type, const std::string& detail) const;
131
132};
133
134#endif // GFEXINPUTBYTESTREAMTOOL_H
void printError()
static Double_t tc
Header file to be included by clients of the Monitored infrastructure.
Property holding a SG store/key/clid from which a WriteHandle is made.
virtual void signExtend(int *xptr, int upto) const
std::unordered_map< unsigned int, std::array< float, 4 > > m_Firm2Tower_map
SG::WriteHandleKey< xAOD::gFexTowerContainer > m_gTowersWriteKey
virtual void gtReconstructABC(int XFPGA, const 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, std::array< int,(gPos::AB_FIBERS *gPos::MAX_E_FIELDS)> &FiberTower, std::array< int,(gPos::AB_FIBERS *gPos::MAX_E_FIELDS)> &FiberTowerSatur) const
virtual StatusCode convertToBS(std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const xAOD::TrigCompositeContainer *tc, const EventContext &eventContext) override
xAOD->BS conversion
SG::ReadHandleKey< xAOD::gFexTowerContainer > m_gTowersReadKey
uint32_t crc9d23(uint32_t inword, uint32_t in_crc, int reverse) const
virtual void b_gtrx_map(const gfiber &inputData, gfiber &jf_lar_rx_data) const
gFexInputByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
std::array< std::array< int, 6 >, 32 > gEngines
Gaudi::Property< std::vector< uint32_t > > m_robIds
{map index(towerid), {fpga, eta, phi, source}}
std::array< std::array< uint32_t, 7 >, 100 > gfiber
virtual void c_gtrx_map(const gfiber &inputData, gfiber &outputData) const
virtual StatusCode convertFromBS(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf, const EventContext &eventContext) const override
BS->xAOD conversion.
virtual void a_gtrx_map(const gfiber &inputData, gfiber &jf_lar_rx_data) const
virtual StatusCode initialize() override
std::array< std::array< int, 12 >, 32 > gtFPGA
std::array< std::array< int, 16 >, 100 > gCaloTwr
virtual void gtCalib(gtFPGA &gtf, int towerLSB, int fpga, unsigned int offset) const
std::array< std::array< char, 20 >, 100 > gFieldsChar
virtual void undoMLE(int &datumPtr) const
SG::WriteHandleKey< xAOD::gFexTowerContainer > m_gTowers200WriteKey
std::array< std::array< int, 8 >, 100 > gSatur
virtual const std::vector< uint32_t > & robIds() const override
Declare ROB IDs for conversion.
StatusCode ReadFibersfromFile(const std::string &)
ToolHandle< GenericMonitoringTool > m_monTool
virtual ~gFexInputByteStreamTool() override=default
SG::WriteHandleKey< xAOD::gFexTowerContainer > m_gTowers50WriteKey
std::array< std::array< char, 20 >, 4 > gTypeChar
std::array< std::array< int, 20 >, 4 > gType
virtual int crc9d32(const std::array< uint32_t, 6 > &inWords, int numWords, int reverse) const
std::array< std::array< int, 20 >, 100 > gFields
Gaudi::Property< std::string > m_FiberMapping
virtual void getEtaPhi(float &Eta, float &Phi, int iEta, int iPhi, int gFEXtowerID) const
constexpr int MAX_E_FIELDS
Definition gFexPos.h:62
constexpr int AB_FIBERS
Definition gFexPos.h:60
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.