ATLAS Offline Software
L1TopoLUT.h
Go to the documentation of this file.
1 // This file is really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef TRIGT1MUCTPIPHASE1_L1TOPOLUT_H
8 #define TRIGT1MUCTPIPHASE1_L1TOPOLUT_H
9 
10 #include <boost/property_tree/ptree.hpp>
11 
12 #include <unordered_map>
13 #include <map>
14 #include <set>
15 #include <utility>
16 #include <sstream>
17 
18 namespace LVL1MUCTPIPHASE1
19 {
20  namespace pt = boost::property_tree;
21 
23  {
24  bool operator==(const L1TopoCoordinates& rhs) const
25  {
26  return (eta == rhs.eta && phi == rhs.phi &&
27  eta_min == rhs.eta_min && phi_min == rhs.phi_min &&
28  ieta == rhs.ieta && iphi == rhs.iphi);
29  }
30  double eta=0;
31  double phi=0;
32  double eta_min=0;
33  double eta_max=0;
34  double phi_min=0;
35  double phi_max=0;
36  unsigned short ieta=0;
37  unsigned short iphi=0;
38  };
39 
40  class L1TopoLUT //: public extends<AthService IL1TopoLUT>
41  {
42  public:
43  bool initializeLUT(const std::string& barrelFileName,
44  const std::string& ecfFileName,
45  const std::string& side0LUTFileName,
46  const std::string& side1LUTFileName);
47 
48  L1TopoCoordinates getCoordinates(const unsigned short& side,
49  const unsigned short& subsystem,
50  const unsigned short& sectorID,
51  const unsigned short& roi) const;
52 
53  unsigned short getBarrelROI(unsigned short side, unsigned short sector, unsigned short ieta, unsigned short iphi) const;
54 
55  const std::vector<std::string>& getErrors() const {return m_errors;}
56 
57  float getCompactedValue_eta(unsigned short subsystem, unsigned short side, unsigned short sectorID, unsigned short roi);
58  float getCompactedValue_phi(unsigned short subsystem, unsigned short side, unsigned short sectorID, unsigned short roi);
59 
60  protected:
61 
62  //for coordinate LUTs (they fit in the same data types, but meaning of indices is non-trivial;
63  // maps used where indices are not guaranteed to be continuous and/or relevant json files do not use arrays)
64  // phi row = roi & 0x3 , eta col = roi >> 2, sector low bit = sector & 0x1
65  // barrel eta/phi: /* sector */, /* eta/phi LUT code */ -> float eta/phi value
66  // endcap eta : /* eta col */, /* sector low bit */ -> float eta value
67  // endcap phi : /* sector */, /* phi row */ -> float phi value
68  // forward eta : /* sector low bit */, /* eta col */ -> float eta value
69  // forward phi : /* phi row */, /* sector */ -> float phi value
70  void fillFromPtree(const boost::property_tree::ptree& node, std::map<unsigned short,std::vector<float>>& theLut) const;
71 
72  //for barrel "encoding" LUT /*sectorID*/ , /* roi */ , /* eta LUT code */, /* phi LUT code */
73  void fillFromPtree(const boost::property_tree::ptree& node, std::map<unsigned short,std::map<unsigned short, std::pair<unsigned short, unsigned short>>>& theLut) const;
74 
75  bool initializeCompactedLUTs(const std::string& side0LUTFileName,
76  const std::string& side1LUTFileName);
77  bool initializeLUT(const std::string& inFileName, const bool& isBarrel);
78  bool initializeJSON(const std::string& inFileName, bool side);
80  const std::string& nodeName,
81  bool side,
82  unsigned short subsystem);
83 
84  struct L1TopoLUTKey
85  {
86  unsigned short side;
87  unsigned short subsystem;
88  unsigned short sectorID;
89  unsigned short roi;
90 
91  std::string info()
92  {
93  std::stringstream str;
94  str << "side, subsystem, sectorID, roi = "
95  << side << ", " << subsystem << ", " << sectorID << ", " << roi;
96  return str.str();
97  }
98 
99  //implement == operator for hashing within unordered_map
100  bool operator==(const L1TopoLUTKey& rhs) const
101  {
102  return (side == rhs.side &&
103  subsystem == rhs.subsystem &&
104  sectorID == rhs.sectorID &&
105  roi == rhs.roi);
106  }
107  };
108 
110  {
111  unsigned long operator()(const L1TopoLUTKey& key) const
112  {
113  return key.side | (key.subsystem << 8) | (key.sectorID << 16) | (key.roi << 24);
114  }
115  };
116  std::map<unsigned short,std::vector<float>> m_barrel_eta_lookup0;
117  std::map<unsigned short,std::vector<float>> m_barrel_eta_lookup1;
118  std::map<unsigned short,std::vector<float>> m_barrel_phi_lookup0;
119  std::map<unsigned short,std::vector<float>> m_barrel_phi_lookup1;
120  std::map<unsigned short,std::vector<float>> m_endcap_eta_lookup0;
121  std::map<unsigned short,std::vector<float>> m_endcap_eta_lookup1;
122  std::map<unsigned short,std::vector<float>> m_endcap_phi_lookup0;
123  std::map<unsigned short,std::vector<float>> m_endcap_phi_lookup1;
124  std::map<unsigned short,std::vector<float>> m_forward_eta_lookup0;
125  std::map<unsigned short,std::vector<float>> m_forward_eta_lookup1;
126  std::map<unsigned short,std::vector<float>> m_forward_phi_lookup0;
127  std::map<unsigned short,std::vector<float>> m_forward_phi_lookup1;
128 
129  std::map<unsigned short,std::map<unsigned short, std::pair<unsigned short, unsigned short>>> m_barrel_encoding0;
130  std::map<unsigned short,std::map<unsigned short, std::pair<unsigned short, unsigned short>>> m_barrel_encoding1;
131 
132  //reverse map: eta/phi subword(16b) as sent to Topo -> ROI
133  std::map<unsigned short, unsigned short> m_barrel_reverse_encoding0;
134  std::map<unsigned short, unsigned short> m_barrel_reverse_encoding1;
135 
136  std::unordered_map<L1TopoLUTKey, L1TopoCoordinates, L1TopoLUTKeyHasher> m_encoding;
137  std::vector<std::string> m_errors;
138  };
139 }
140 
141 #endif
LVL1MUCTPIPHASE1::L1TopoLUT::m_forward_eta_lookup1
std::map< unsigned short, std::vector< float > > m_forward_eta_lookup1
Definition: L1TopoLUT.h:125
LVL1MUCTPIPHASE1::L1TopoLUT::m_endcap_phi_lookup1
std::map< unsigned short, std::vector< float > > m_endcap_phi_lookup1
Definition: L1TopoLUT.h:123
LVL1MUCTPIPHASE1::L1TopoLUT::getBarrelROI
unsigned short getBarrelROI(unsigned short side, unsigned short sector, unsigned short ieta, unsigned short iphi) const
Definition: L1TopoLUT.cxx:232
LVL1MUCTPIPHASE1::L1TopoLUT::m_barrel_reverse_encoding0
std::map< unsigned short, unsigned short > m_barrel_reverse_encoding0
Definition: L1TopoLUT.h:133
LVL1MUCTPIPHASE1::L1TopoLUT::L1TopoLUTKey::info
std::string info()
Definition: L1TopoLUT.h:91
LVL1MUCTPIPHASE1::L1TopoLUT::fillFromPtree
void fillFromPtree(const boost::property_tree::ptree &node, std::map< unsigned short, std::vector< float >> &theLut) const
Definition: L1TopoLUT.cxx:13
LVL1MUCTPIPHASE1::L1TopoLUT::L1TopoLUTKey::subsystem
unsigned short subsystem
Definition: L1TopoLUT.h:87
test_pyathena.pt
pt
Definition: test_pyathena.py:11
LVL1MUCTPIPHASE1::L1TopoLUT::m_encoding
std::unordered_map< L1TopoLUTKey, L1TopoCoordinates, L1TopoLUTKeyHasher > m_encoding
Definition: L1TopoLUT.h:136
LVL1MUCTPIPHASE1::L1TopoLUT::m_barrel_encoding1
std::map< unsigned short, std::map< unsigned short, std::pair< unsigned short, unsigned short > > > m_barrel_encoding1
Definition: L1TopoLUT.h:130
LVL1MUCTPIPHASE1::L1TopoLUT::m_errors
std::vector< std::string > m_errors
Definition: L1TopoLUT.h:137
LVL1MUCTPIPHASE1::L1TopoLUT::getCompactedValue_eta
float getCompactedValue_eta(unsigned short subsystem, unsigned short side, unsigned short sectorID, unsigned short roi)
Definition: L1TopoLUT.cxx:244
LVL1MUCTPIPHASE1::L1TopoLUT::L1TopoLUTKey::roi
unsigned short roi
Definition: L1TopoLUT.h:89
sendEI_SPB.root
root
Definition: sendEI_SPB.py:34
LVL1MUCTPIPHASE1::L1TopoCoordinates
Definition: L1TopoLUT.h:23
LVL1MUCTPIPHASE1::L1TopoLUT::m_barrel_phi_lookup1
std::map< unsigned short, std::vector< float > > m_barrel_phi_lookup1
Definition: L1TopoLUT.h:119
LVL1MUCTPIPHASE1::L1TopoCoordinates::phi_max
double phi_max
Definition: L1TopoLUT.h:35
LVL1MUCTPIPHASE1::L1TopoLUT::m_endcap_phi_lookup0
std::map< unsigned short, std::vector< float > > m_endcap_phi_lookup0
Definition: L1TopoLUT.h:122
TRT::Hit::side
@ side
Definition: HitInfo.h:83
LVL1MUCTPIPHASE1::L1TopoLUT::m_barrel_eta_lookup0
std::map< unsigned short, std::vector< float > > m_barrel_eta_lookup0
Definition: L1TopoLUT.h:116
LVL1MUCTPIPHASE1::L1TopoCoordinates::operator==
bool operator==(const L1TopoCoordinates &rhs) const
Definition: L1TopoLUT.h:24
LVL1MUCTPIPHASE1::L1TopoLUT::m_barrel_eta_lookup1
std::map< unsigned short, std::vector< float > > m_barrel_eta_lookup1
Definition: L1TopoLUT.h:117
LVL1MUCTPIPHASE1
Definition: Configuration.h:11
LVL1MUCTPIPHASE1::L1TopoLUT::getCoordinates
L1TopoCoordinates getCoordinates(const unsigned short &side, const unsigned short &subsystem, const unsigned short &sectorID, const unsigned short &roi) const
Definition: L1TopoLUT.cxx:218
LVL1MUCTPIPHASE1::L1TopoCoordinates::ieta
unsigned short ieta
Definition: L1TopoLUT.h:36
LVL1MUCTPIPHASE1::L1TopoLUT::L1TopoLUTKey
Definition: L1TopoLUT.h:85
LVL1MUCTPIPHASE1::L1TopoLUT::m_barrel_phi_lookup0
std::map< unsigned short, std::vector< float > > m_barrel_phi_lookup0
Definition: L1TopoLUT.h:118
IDTPMcnv.inFileName
inFileName
Definition: IDTPMcnv.py:17
LVL1MUCTPIPHASE1::L1TopoCoordinates::eta_min
double eta_min
Definition: L1TopoLUT.h:32
LVL1MUCTPIPHASE1::L1TopoLUT::L1TopoLUTKey::sectorID
unsigned short sectorID
Definition: L1TopoLUT.h:88
LVL1MUCTPIPHASE1::L1TopoLUT::initializeCompactedLUTs
bool initializeCompactedLUTs(const std::string &side0LUTFileName, const std::string &side1LUTFileName)
Definition: L1TopoLUT.cxx:60
LVL1MUCTPIPHASE1::L1TopoLUT::m_barrel_encoding0
std::map< unsigned short, std::map< unsigned short, std::pair< unsigned short, unsigned short > > > m_barrel_encoding0
Definition: L1TopoLUT.h:129
LVL1MUCTPIPHASE1::L1TopoLUT::L1TopoLUTKey::operator==
bool operator==(const L1TopoLUTKey &rhs) const
Definition: L1TopoLUT.h:100
LVL1MUCTPIPHASE1::L1TopoLUT::initializeJSONForSubsystem
bool initializeJSONForSubsystem(pt::ptree &root, const std::string &nodeName, bool side, unsigned short subsystem)
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
LVL1MUCTPIPHASE1::L1TopoLUT::m_endcap_eta_lookup1
std::map< unsigned short, std::vector< float > > m_endcap_eta_lookup1
Definition: L1TopoLUT.h:121
LVL1MUCTPIPHASE1::L1TopoLUT::L1TopoLUTKeyHasher::operator()
unsigned long operator()(const L1TopoLUTKey &key) const
Definition: L1TopoLUT.h:111
LVL1MUCTPIPHASE1::L1TopoCoordinates::eta
double eta
Definition: L1TopoLUT.h:30
LVL1MUCTPIPHASE1::L1TopoLUT
Definition: L1TopoLUT.h:41
LVL1MUCTPIPHASE1::L1TopoLUT::m_barrel_reverse_encoding1
std::map< unsigned short, unsigned short > m_barrel_reverse_encoding1
Definition: L1TopoLUT.h:134
LVL1MUCTPIPHASE1::L1TopoLUT::L1TopoLUTKeyHasher
Definition: L1TopoLUT.h:110
LVL1MUCTPIPHASE1::L1TopoLUT::getCompactedValue_phi
float getCompactedValue_phi(unsigned short subsystem, unsigned short side, unsigned short sectorID, unsigned short roi)
Definition: L1TopoLUT.cxx:275
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
LVL1MUCTPIPHASE1::L1TopoCoordinates::phi
double phi
Definition: L1TopoLUT.h:31
LVL1MUCTPIPHASE1::L1TopoLUT::initializeLUT
bool initializeLUT(const std::string &barrelFileName, const std::string &ecfFileName, const std::string &side0LUTFileName, const std::string &side1LUTFileName)
Definition: L1TopoLUT.cxx:101
python.LArCondContChannels.isBarrel
isBarrel
Definition: LArCondContChannels.py:659
LVL1MUCTPIPHASE1::L1TopoLUT::initializeJSON
bool initializeJSON(const std::string &inFileName, bool side)
LVL1MUCTPIPHASE1::L1TopoCoordinates::iphi
unsigned short iphi
Definition: L1TopoLUT.h:37
str
Definition: BTagTrackIpAccessor.cxx:11
LVL1MUCTPIPHASE1::L1TopoLUT::m_forward_phi_lookup0
std::map< unsigned short, std::vector< float > > m_forward_phi_lookup0
Definition: L1TopoLUT.h:126
LVL1MUCTPIPHASE1::L1TopoLUT::L1TopoLUTKey::side
unsigned short side
Definition: L1TopoLUT.h:86
LVL1MUCTPIPHASE1::L1TopoLUT::getErrors
const std::vector< std::string > & getErrors() const
Definition: L1TopoLUT.h:55
LVL1MUCTPIPHASE1::L1TopoLUT::m_forward_phi_lookup1
std::map< unsigned short, std::vector< float > > m_forward_phi_lookup1
Definition: L1TopoLUT.h:127
LVL1MUCTPIPHASE1::L1TopoLUT::m_endcap_eta_lookup0
std::map< unsigned short, std::vector< float > > m_endcap_eta_lookup0
Definition: L1TopoLUT.h:120
L1TopoSimulationConfig.subsystem
subsystem
Definition: L1TopoSimulationConfig.py:263
LVL1MUCTPIPHASE1::L1TopoLUT::m_forward_eta_lookup0
std::map< unsigned short, std::vector< float > > m_forward_eta_lookup0
Definition: L1TopoLUT.h:124
LVL1MUCTPIPHASE1::L1TopoCoordinates::eta_max
double eta_max
Definition: L1TopoLUT.h:33
node
Definition: memory_hooks-stdcmalloc.h:74
LVL1MUCTPIPHASE1::L1TopoCoordinates::phi_min
double phi_min
Definition: L1TopoLUT.h:34
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37