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, const EventContext& eventContext) override;
63
65 virtual const std::vector<uint32_t>& robIds() const override {
66 return m_robIds.value();
67 }
68
69
70 private:
71 // ------------------------- Properties --------------------------------------
72 ToolHandle<GenericMonitoringTool> m_monTool{this,"MonTool","","Monitoring tool"};
73 bool m_UseMonitoring = false;
74
75 // FiberMapping property required by the interface
76 Gaudi::Property<std::string> m_FiberMapping{
77 this, "gFexFiberTowerMapping",
78 "Run3L1CaloSimulation/L1CaloFEXAlgos/gFEX/gFex_gCaloTowerMap_weighted_v1.txt",
79 "Text file to convert from hardware fiber to eta-phi location"};
80
81 std::unordered_map<unsigned int, std::array<float, 4> > m_Firm2Tower_map;
82
83 // ROBIDs property required by the interface
84 Gaudi::Property<std::vector<uint32_t>> m_robIds {this, "ROBIDs", {}, "List of ROB IDs required for conversion to/from xAOD RoI"};
85
86 //Write handle keys for the L1Calo EDMs for BS->xAOD mode of operation
87 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
88 SG::WriteHandleKey< xAOD::gFexTowerContainer> m_gTowers50WriteKey {this,"gTowers50WriteKey" ,"", "Write gFexEDM Trigger Tower container with 50 MeV resolution"};
89 SG::WriteHandleKey< xAOD::gFexTowerContainer> m_gTowers200WriteKey {this,"gTowers200WriteKey" ,"", "Write gFexEDM Trigger Tower container with 200 MeV resolution (default)"};
90
91 // Read handle keys for the L1Calo EDMs for xAOD->BS mode of operation
92 SG::ReadHandleKey < xAOD::gFexTowerContainer> m_gTowersReadKey {this,"gTowersReadKey" ,"L1_gFexDataTowers","Read gFexEDM Trigger Tower container"};
93
94 virtual void a_gtrx_map( const gfiber &inputData, gfiber &jf_lar_rx_data) const;
95 virtual void b_gtrx_map( const gfiber &inputData, gfiber &jf_lar_rx_data) const;
96 virtual void c_gtrx_map( const gfiber &inputData, gfiber &outputData) const;
97
98 virtual void gtReconstructABC( int XFPGA,
99 const gfiber & Xfiber,
100 int Xin,
101 gtFPGA &XgtF,
102 gtFPGA &Xgt,
103 int *BCIDptr,
104 int do_lconv,
105 const std::array<int, gPos::MAX_FIBERS> &XMPD_NFI,
106 const std::array<int, gPos::MAX_FIBERS> &XCALO_TYPE,
107 const gCaloTwr & XMPD_GTRN_ARR,
108 const gType & XMPD_DSTRT_ARR,
109 gTypeChar XMPD_DTYP_ARR,
110 const std::array<int, gPos::MAX_FIBERS> &XMSK,
111 gtFPGA &Xsatur,
112 std::array<int, (gPos::AB_FIBERS*gPos::MAX_E_FIELDS)> &FiberTower,
113 std::array<int, (gPos::AB_FIBERS*gPos::MAX_E_FIELDS)> &FiberTowerSatur) const;
114
115 virtual int crc9d32(const std::array<uint32_t, 6> &inWords,int numWords,int reverse) const;
116 uint32_t crc9d23(uint32_t inword, uint32_t in_crc, int reverse ) const;
117
118 virtual void undoMLE(int &datumPtr ) const;
119
120 virtual void getEtaPhi(float &Eta, float &Phi, int iEta, int iPhi, int gFEXtowerID) const;
121
122 virtual void signExtend(int *xptr, int upto) const;
123
124 virtual void gtCalib(gtFPGA &gtf, int towerLSB, int fpga, unsigned int offset) const;
125
126 StatusCode ReadFibersfromFile(const std::string&);
127
128 void printError(const std::string& location, const std::string& title, MSG::Level type, const std::string& detail) const;
129
130};
131
132#endif // GFEXINPUTBYTESTREAMTOOL_H
void printError()
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
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
virtual StatusCode convertToBS(std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const EventContext &eventContext) override
xAOD->BS conversion
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:60
constexpr int AB_FIBERS
Definition gFexPos.h:58