ATLAS Offline Software
Loading...
Searching...
No Matches
jFEXtauAlgo.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4//***************************************************************************
5// jFEXtauAlgo - Algorithm for Tau Algorithm in jFEX
6// -------------------
7// begin : 18 02 2021
8// email : Sergi.Rodriguez@cern.ch
9//***************************************************************************
10
11#include "jFEXtauAlgo.h"
12#include "L1CaloFEXSim/jTower.h"
15#include <fstream>
16#include <sstream>
17namespace LVL1{
18
19//Default Constructor
20LVL1::jFEXtauAlgo::jFEXtauAlgo(const std::string& type, const std::string& name, const IInterface* parent): AthAlgTool(type, name, parent) {
21 declareInterface<IjFEXtauAlgo>(this);
22}
23
27
37
38//calls container for TT
40
42 if(! m_jTowerContainer.isValid()) {
43 ATH_MSG_ERROR("Could not retrieve jTowerContainer " << m_jTowerContainerKey.key());
44 return StatusCode::FAILURE;
45 }
46
47 return StatusCode::SUCCESS;
48}
49
50void LVL1::jFEXtauAlgo::setup(int seed[3][3]) {
51
52 ATH_MSG_DEBUG(m_color.BLUE<<"---------------- jFEXtauAlgo::setup ----------------"<<m_color.END);
53
54 m_TauSaturation = false;
55 for(int phi=0; phi<3; phi++) {
56 for (int eta=0; eta<3; eta++) {
57 m_TTwindow[phi][eta] = seed[2-phi][eta]; // We need to flip the matrix for an increasing phi order: [0, 2Phi]
59 }
60 }
61
62}
63
64//check if central TT is a local maxima
66
67 m_ClusterEt = 0;
68 int central_seed = getTTowerET(m_TTwindow[1][1]);
69
70 for (int iphi = 0; iphi < 3; iphi++) {
71 for (int ieta = 0; ieta < 3; ieta++) {
72
73 int ttEt = getTTowerET(m_TTwindow[iphi][ieta]);
74 m_ClusterEt += ttEt;
75 //avoid comparing central seed to itself
76 if ((iphi == 1) && (ieta == 1)) {
77 continue;
78 }
79 else if( (iphi > ieta) || (iphi==0 && ieta==0) ) { //less than or equal to central
80 if(central_seed<ttEt) {
81 return false;
82 }
83 }
84 else if( (iphi < ieta) || (iphi == 2 && ieta == 2)) { //strictly less than central
85 if(central_seed<=ttEt) {
86 return false;
87 }
88 }
89 }
90 }
91
92 ATH_MSG_DEBUG("Tau Local Maxima found. with ClusterET = "<<m_ClusterEt);
93 return true;
94}
95
97
98 m_TauSaturation = false;
99
100 int centreEt = getTTowerET(TTID);
101 m_ClusterEt = centreEt;
103 //centreEt greater than ?
104 auto it_map = m_SearchGMap.find(TTID);
105 if(it_map == m_SearchGMap.end()) {
106 ATH_MSG_ERROR("Could not find TT" << TTID << " in the (greater than) file for Taus.");
107 }
108
109 for(const auto& lTT : it_map->second){
110 int seachTTET = getTTowerET(lTT);
111 if(centreEt <= seachTTET ){
112 return false;
113 }
114 m_ClusterEt += seachTTET;
116 }
117
118 //centreEt greater or equal than ?
119 it_map = m_SearchGeMap.find(TTID);
120 if(it_map == m_SearchGeMap.end()) {
121 ATH_MSG_ERROR("Could not find TT" << TTID << " in the (greater or equal than) file for Taus.");
122 }
123
124 for(const auto& lTT : it_map->second){
125 int seachTTET = getTTowerET(lTT);
126 if(centreEt < seachTTET ){
127 return false;
128 }
129 m_ClusterEt += seachTTET;
131 }
132
133 // If we never returned false above.. we have a local maxima!
134 //Calculating now all the Tau iso
135
136 m_TauIsolation = 0;
137 it_map = m_IsoRingMap.find(TTID);
138 if(it_map == m_IsoRingMap.end()) {
139 ATH_MSG_ERROR("Could not find TT" << TTID << " in the isolation file for Taus.");
140 }
141
142 for(const auto& lTT : it_map->second){
145 }
146
147 return true;
148}
149
150//getter for tower saturation
151bool LVL1::jFEXtauAlgo::getTTowerSat(unsigned int TTID ) {
152 if(TTID == 0) {
153 return false;
154 }
155
156 const LVL1::jTower * tmpTower = m_jTowerContainer->findTower(TTID);
157 return tmpTower->getTowerSat();
158}
159
160//Gets the ET for the TT. This ET is EM + HAD
161int LVL1::jFEXtauAlgo::getTTowerET(unsigned int TTID ) const {
162 if(TTID == 0) {
163 return 0;
164 }
165
166 auto itr = m_map_Etvalues.find(TTID);
167 if( itr == m_map_Etvalues.end()) {
168 return 0;
169 }
170 return (itr->second).at(0);
171}
172
173//Gets the seed total ET
175 return m_ClusterEt;
176}
177
178//Gets the Isolation/FirstEtRing of jFEX Tau
179
180void LVL1::jFEXtauAlgo::setFirstEtRing(int First_ETring[36]) {
181
182 ATH_MSG_DEBUG("Calculating the jFEXTau ISO");
183
185 for(int i=0; i<36; i++) {
186 m_TauIsolation += getTTowerET(First_ETring[i]);
187 m_TauSaturation = m_TauSaturation || getTTowerSat(First_ETring[i]);
188 }
189}
190
194
196 return m_TauSaturation;
197}
198
199void LVL1::jFEXtauAlgo::setFPGAEnergy(const std::unordered_map<int,std::vector<int> >& et_map){
200 m_map_Etvalues=et_map;
201}
202
203
204StatusCode LVL1::jFEXtauAlgo::ReadfromFile(const std::string & fileName, std::unordered_map<unsigned int, std::vector<unsigned int> >& fillingMap) const {
205
206 std::string myline;
207
208 //openning file with ifstream
209 std::ifstream myfile(fileName);
210
211 if ( !myfile.is_open() ){
212 ATH_MSG_ERROR("Could not open file:" << fileName);
213 return StatusCode::FAILURE;
214 }
215
216 //loading the mapping information
217 while ( std::getline (myfile, myline) ) {
218
219 //removing the header of the file (it is just information!)
220 if(myline[0] == '#') continue;
221
222 //Splitting myline in different substrings
223 std::stringstream oneLine(myline);
224
225 //reading elements
226 std::vector<unsigned int> elements;
227 std::string element;
228 while(std::getline(oneLine, element, ' '))
229 {
230 elements.push_back(std::stoi(element));
231 }
232
233 // We should have at least two elements! Central TT and (at least) itself
234 if(elements.size() < 1){
235 ATH_MSG_ERROR("Unexpected number of elemennts (<1 expected) in file: "<< fileName);
236 return StatusCode::FAILURE;
237 }
238 //Central TiggerTower
239 unsigned int TTID = elements.at(0);
240 // rest of TTs that need to be check
241 elements.erase(elements.begin());
242 fillingMap[TTID] = std::move(elements);
243 }
244 myfile.close();
245
246 return StatusCode::SUCCESS;
247}
248
249
250
251}// end of namespace LVL1
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
jFEXtauAlgo(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
bool getTTowerSat(unsigned int TTID)
SG::ReadHandle< jTowerContainer > m_jTowerContainer
Definition jFEXtauAlgo.h:53
virtual int getFirstEtRing() const override
virtual void setFirstEtRing(int First_ETring[36]) override
virtual bool getTauSat() const override
virtual StatusCode initialize() override
standard Athena-Algorithm method
int getTTowerET(unsigned int TTID) const
SG::ReadHandleKey< LVL1::jTowerContainer > m_jTowerContainerKey
Definition jFEXtauAlgo.h:52
std::unordered_map< unsigned int, std::vector< unsigned int > > m_IsoRingMap
Definition jFEXtauAlgo.h:59
virtual ~jFEXtauAlgo()
Destructor.
std::unordered_map< unsigned int, std::vector< unsigned int > > m_SearchGMap
Definition jFEXtauAlgo.h:60
virtual int getClusterEt() const override
Gaudi::Property< std::string > m_IsoRingStr
Definition jFEXtauAlgo.h:55
std::unordered_map< int, std::vector< int > > m_map_Etvalues
Definition jFEXtauAlgo.h:72
int m_TTwindow[3][3]
Definition jFEXtauAlgo.h:67
std::unordered_map< unsigned int, std::vector< unsigned int > > m_SearchGeMap
Definition jFEXtauAlgo.h:61
virtual bool isSeedLocalMaxima() override
Gaudi::Property< std::string > m_SearchGeStr
Definition jFEXtauAlgo.h:57
virtual bool isSeedLocalMaxima_fwd(unsigned int TTID) override
virtual void setFPGAEnergy(const std::unordered_map< int, std::vector< int > > &et_map) override
virtual void setup(int seed[3][3]) override
struct LVL1::jFEXtauAlgo::color m_color
StatusCode ReadfromFile(const std::string &, std::unordered_map< unsigned int, std::vector< unsigned int > > &) const
virtual StatusCode safetyTest() override
Gaudi::Property< std::string > m_SearchGStr
Definition jFEXtauAlgo.h:56
The jTower class is an interface object for jFEX trigger algorithms The purposes are twofold:
Definition jTower.h:36
bool getTowerSat() const
Definition jTower.h:61
static std::string find_calib_file(const std::string &logical_file_name)
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...