ATLAS Offline Software
Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <cmath>
6 
7 #include "cTauMultiplicity.h"
8 #include "isocut.h"
9 
11 
12 #include "../IO/cTauTOBArray.h"
13 #include "../IO/Count.h"
14 
15 #include <sstream>
16 
17 
18 namespace GlobalSim {
19 
21  unsigned int nbits,
23  const std::map<std::string, int>& isolationFW_CTAU,
24  const std::map<std::string, int>& isolationFW_CTAU_jTAUCoreScale
25  // const L1MenuResources& resources
26  ):
27  m_name{name},
28  m_nbits{nbits},
29  m_threshold{threshold},
30  m_isoFW_CTAU{isolationFW_CTAU},
31  m_isoFW_CTAU_jTAUCoreScale{isolationFW_CTAU_jTAUCoreScale}
32  {
33 
34  if (m_nbits == 0) {
35  throw std::runtime_error("cTauMultiplicity m_nbits == 0 ");
36  }
37  }
38 
41  Count & count) {
42 
43  // candidate for being moved to the base class
44  count.setNBits(m_nbits);
45 
46  int counting = 0;
47  // Loop over eTau candidates
48  for (const auto& etauCand : cTaus) {
49  if(etauCand->tobType() != TCS::ETAU) continue;
50 
51  // accept = true if:
52  // (isMatched==true && isIsolated==true) || (isMatched==false)
53  bool accept = false;
54 
55  // Is the eTau matched to a jTau?
56  bool isMatched = false;
57 
58  // If matched: does the resulting cTau pass the isolation cut?
59  bool isIsolated = false;
60 
61  // cTau Loose partial isolation (0 if no match is found)
62  float isolation_partial_loose = 0;
63 
64  // cTau Medium partial isolation (0 if no match is found)
65  float isolation_partial_medium = 0;
66 
67  // cTau Tight partial isolation (0 if no match is found)
68  float isolation_partial_tight = 0;
69 
70  // cTau isolation score (0 if no match is found)
71  unsigned int isoScore = 0;
72 
73  // Loop over jTau candidates
74  for (const auto& jtauCand : cTaus) {
75 
76  if(jtauCand->tobType() != TCS::JTAU) continue;
77 
78  isMatched = cTauMatching(etauCand, jtauCand);
79 
80  if (isMatched) {
81  // Updated isolation condition, WP-dependent (ATR-28641)
82  // "Partial" isolation formula:
83  // I = (E_T^{jTAU Iso} + jTAUCoreScale * E_T^{jTAU Core}) / E_T^{eTAU}
84  // This formula is missing the eTAU Core substraction from
85  //the numerator, grouped with the isolation cut value
86 
87  // variables to be monitored
88  float denominator = static_cast<float>(etauCand->Et());
89 
90 
91  float numerator = static_cast<float>(jtauCand->EtIso()) +
92  m_isoFW_CTAU_jTAUCoreScale.at("Loose")/1024.0 *
93  static_cast<float>(jtauCand->Et());
94 
95  m_TOB_isolation_partial_loose.push_back(numerator/denominator);
96 
97 
98  numerator = static_cast<float>(jtauCand->EtIso()) +
99  m_isoFW_CTAU_jTAUCoreScale.at("Medium")/1024.0 *
100  static_cast<float>(jtauCand->Et());
101 
102  m_TOB_isolation_partial_medium.push_back(numerator/denominator);
103 
104  numerator = static_cast<float>(jtauCand->EtIso()) +
105  m_isoFW_CTAU_jTAUCoreScale.at("Tight")/1024.0 *
106  static_cast<float>(jtauCand->Et());
107 
108  m_TOB_isolation_partial_tight.push_back(numerator/denominator);
109 
110  // Old isolation condition coded as in firmware:
111  // https://indico.cern.ch/event/1079697/contributions/4541419/
112  // attachments/2315137/3940824/cTAU_FirmwareAlgoProposal.pdf page 8
113 
114  isoScore = convertIsoToBit(etauCand, jtauCand);
115  isIsolated =
117  isoScore );
118  break; // Break loop when a match is found
119  }
120 
121  } // End of jTau loop
122 
123  // Fill cTau TOB histograms before threshold cuts (matched cTaus only)
124  if (isMatched) {
125  m_TOB_et.push_back(etauCand->EtDouble());
126  m_TOB_eta.push_back(etauCand->eta());
127  m_TOB_phi.push_back(etauCand->phi());
128 
129  m_TOB_isolation_partial_loose.push_back(isolation_partial_loose);
130  m_TOB_isolation_partial_medium.push_back(isolation_partial_medium);
131  m_TOB_isolation_partial_tight.push_back(isolation_partial_tight);
132  m_TOB_isoScore.push_back(isoScore);
133 
134  }
135 
136  // This is a good cTau
137  if ( isMatched && isIsolated ) { accept = true; }
138 
139  // This is a non-matched eTau
140  if ( not isMatched ) { accept = true; }
141 
142  // 6/2024 there have been updates to the L1TopoSimulation code
143  // not included here.
144 
145  // Menu threshold uses 0.1 eta granularity but eFex objects
146  // have 0.025 eta granularity
147  // eFex eta is calculated as
148  // 4*eta_tower (0.1 gran.) + seed (0.025 gran.), eta from -25 to 24
149  int eta_thr;
150  if ( etauCand->eta()%4 >= 0 ) {
151  eta_thr = etauCand->eta() - etauCand->eta()%4;
152  } else {
153  eta_thr = etauCand->eta() - etauCand->eta()%4 - 4;
154  }
155 
156  // Convert eta_thr to units of 0.1 to pass as an argument
157  accept = accept && etauCand->Et() > m_threshold.thrValue100MeV(eta_thr/4);
158  if (accept) {
159  counting++;
160 
161  m_accept_eta.push_back(etauCand->eta());
162  m_accept_et.push_back(etauCand->EtDouble());
163 
164  }
165 
166  } // End of eTau loop
167 
168  m_counts.push_back(counting);
169 
170 
171  // Pass counting to TCS::Count object - output bits are composed there
172  count.setSizeCount(counting);
173 
174  return StatusCode::SUCCESS;
175  }
176 
177 
178  unsigned int
180  const TCS::cTauTOB * jtauCand) const {
181  unsigned int bit = 0;
182 
183  // Assign the tightest accept WP as default bit
184  if( jtauCand->EtIso()*1024 +
185  jtauCand->Et()*m_isoFW_CTAU_jTAUCoreScale.at("Loose") <
186  etauCand->Et()*m_isoFW_CTAU.at("Loose") ) bit = 1;
187 
188  if( jtauCand->EtIso()*1024 +
189  jtauCand->Et()*m_isoFW_CTAU_jTAUCoreScale.at("Medium") <
190  etauCand->Et()*m_isoFW_CTAU.at("Medium") ) bit = 2;
191 
192  if( jtauCand->EtIso()*1024 +
193  jtauCand->Et()*m_isoFW_CTAU_jTAUCoreScale.at("Tight") <
194  etauCand->Et()*m_isoFW_CTAU.at("Tight") ) bit = 3;
195 
196  return bit;
197  }
198 
199 
200  bool
202  const TCS::cTauTOB * jtauCand) const {
203 
204  bool matching = false;
205 
206  // Matching is done comparing eta_tower and phi_tower (granularity = 0.1)
207  // These coordinates represent the lower edge of the towers
208  // (both for eFEX and jFEX)
209 
210  // eTau eta = 4*eta_tower + seed, eta from -25 to 24
211  int eTauEtaTower;
212  if (etauCand->eta()%4 >= 0 ) {
213  eTauEtaTower = etauCand->eta() - etauCand->eta()%4;
214  } else {
215  eTauEtaTower = etauCand->eta() - etauCand->eta()%4 - 4;
216  }
217 
218  int jTauEtaTower;
219  if (jtauCand->eta()%4 >= 0 ) {
220  jTauEtaTower = jtauCand->eta() - jtauCand->eta()%4;
221  } else {
222  jTauEtaTower = jtauCand->eta() - jtauCand->eta()%4 - 4;
223  }
224 
225  //int jTauEtaTower = jtauCand->eta();
226  // jTau eta = 4*eta_tower
227 
228  // eTau phi = 2*phi_tower
229  unsigned int eTauPhiTower = etauCand->phi() >> 1;
230  unsigned int jTauPhiTower = jtauCand->phi() >> 1;
231  // jTau phi = 2*phi_tower + 1 (jTau coordinates are at center of tower)
232 
233  matching = (eTauEtaTower == jTauEtaTower) && (eTauPhiTower == jTauPhiTower);
234 
235  return matching;
236 
237  }
238 
239  unsigned int
240  cTauMultiplicity::convertIsoToBit(const std::map<std::string, int>& isoFW_CTAU,
241  const std::map<std::string, int>& isoFW_CTAU_jTAUCoreScale,
242  const float jTauCore,
243  const float jTauIso,
244  const float eTauEt){
245  unsigned int bit = 0;
246  // Assign the tightest accept WP as default bit
247  if( jTauIso*1024 + jTauCore*isoFW_CTAU_jTAUCoreScale.at("Loose") <
248  eTauEt*isoFW_CTAU.at("Loose") ) bit = 1;
249 
250  if( jTauIso*1024 + jTauCore*isoFW_CTAU_jTAUCoreScale.at("Medium") <
251  eTauEt*isoFW_CTAU.at("Medium") ) bit = 2;
252 
253  if( jTauIso*1024 + jTauCore*isoFW_CTAU_jTAUCoreScale.at("Tight") <
254  eTauEt*isoFW_CTAU.at("Tight") ) bit = 3;
255 
256  return bit;
257  }
258 
259  std::string cTauMultiplicity::toString() const {
260  std::stringstream ss;
261  ss << "cTauMultiplicity. name: " << m_name << '\n'
262  << "numberOfBits: " << m_nbits;
263 
264  return ss.str();
265 
266  }
267 
268  const std::vector<double>&
270  return m_TOB_et;
271  }
272 
273  const std::vector<double>& cTauMultiplicity::TOB_eta() const {
274  return m_TOB_eta;
275  }
276 
277  const std::vector<double>&
279  return m_TOB_phi;
280  }
281 
282  const std::vector<double>&
285  }
286 
287  const std::vector<double>&
290  }
291 
292  const std::vector<double>&
295  }
296 
297  const std::vector<double>&
299  return m_TOB_isoScore;
300  }
301 
302  const std::vector<double>&
304  return m_accept_eta;
305  }
306 
307  const std::vector<double>&
309  return m_accept_et;
310  }
311 
312  const std::vector<double>&
314  return m_counts;
315  }
316 }
317 
GlobalSim::cTauMultiplicity::m_name
std::string m_name
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:76
TrigConf::L1Threshold_cTAU
Definition: L1Threshold.h:255
GlobalSim::cTauMultiplicity::TOB_et
const std::vector< double > & TOB_et() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:269
GlobalSim::cTauMultiplicity::TOB_isolation_partial_medium
const std::vector< double > & TOB_isolation_partial_medium() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:288
TCS::cTauTOB::EtIso
unsigned int EtIso() const
Definition: cTauTOB.h:44
GlobalSim::cTauMultiplicity::m_TOB_et
std::vector< double > m_TOB_et
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:83
GlobalSim::cTauMultiplicity::counts
const std::vector< double > & counts() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:313
GlobalSim::cTauMultiplicity::m_TOB_eta
std::vector< double > m_TOB_eta
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:84
GlobalSim::cTauTOBArray
Definition: Global/GlobalSimulation/src/IO/cTauTOBArray.h:17
GlobalSim::cTauMultiplicity::m_accept_eta
std::vector< double > m_accept_eta
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:90
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
GlobalSim::cTauMultiplicity::TOB_eta
const std::vector< double > & TOB_eta() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:273
GlobalSim::cTauMultiplicity::TOB_isolation_partial_loose
const std::vector< double > & TOB_isolation_partial_loose() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:283
GlobalSim::cTauMultiplicity::TOB_phi
const std::vector< double > & TOB_phi() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:278
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
TrigConf::Selection::wpToString
static std::string wpToString(WP)
Definition: L1ThresholdBase.cxx:347
GlobalSim::cTauMultiplicity::m_counts
std::vector< double > m_counts
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:92
InDetSecVtxTruthMatchUtils::isMatched
bool isMatched(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:48
L1Threshold.h
GlobalSim::cTauMultiplicity::run
StatusCode run(const cTauTOBArray &input, Count &count)
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:40
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
GlobalSim::cTauMultiplicity::m_accept_et
std::vector< double > m_accept_et
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:91
GlobalSim::Count
Definition: Global/GlobalSimulation/src/IO/Count.h:23
TrigConf::L1Threshold_Calo::thrValue100MeV
virtual unsigned int thrValue100MeV(int eta=0) const
as above above but in 100 MeV
Definition: L1ThresholdBase.cxx:284
GlobalSim::cTauMultiplicity::toString
std::string toString() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:259
GlobalSim::cTauMultiplicity::m_TOB_phi
std::vector< double > m_TOB_phi
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:85
GlobalSim
AlgTool to obtain a selection of eFex RoIs read in from the event store.
Definition: dump.h:8
GlobalSim::cTauMultiplicity::cTauMultiplicity
cTauMultiplicity(const std::string &name, unsigned int nbits, const TrigConf::L1Threshold_cTAU &, const std::map< std::string, int > &isoFW_CTAU, const std::map< std::string, int > &isoFW_CTAU_jTAUCoreScale)
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:20
GlobalSim::cTauMultiplicity::m_TOB_isolation_partial_tight
std::vector< double > m_TOB_isolation_partial_tight
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:88
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
GlobalSim::cTauMultiplicity::m_TOB_isolation_partial_loose
std::vector< double > m_TOB_isolation_partial_loose
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:86
cTauMultiplicity.h
TCS::cTauTOB::phi
unsigned int phi() const
Definition: cTauTOB.h:35
GlobalSim::cTauMultiplicity::cTauMatching
bool cTauMatching(const TCS::cTauTOB *etauCand, const TCS::cTauTOB *jtauCand) const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:201
ReadTripsProbsFromCool.denominator
denominator
Definition: ReadTripsProbsFromCool.py:96
GlobalSim::cTauMultiplicity::m_isoFW_CTAU_jTAUCoreScale
std::map< std::string, int > m_isoFW_CTAU_jTAUCoreScale
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:95
TCS::cTauTOB::eta
int eta() const
Definition: cTauTOB.h:34
GlobalSim::cTauMultiplicity::convertIsoToBit
static unsigned int convertIsoToBit(const std::map< std::string, int > &isoFW_CTAU, const std::map< std::string, int > &isoFW_CTAU_jTAUCoreScale, const float jTauCoreEt, const float jTauIso, const float eTauEt)
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:240
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
threshold
Definition: chainparser.cxx:74
GlobalSim::cTauMultiplicity::m_threshold
const TrigConf::L1Threshold_cTAU & m_threshold
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:80
TCS::cTauTOB::Et
unsigned int Et() const
Definition: cTauTOB.h:33
GlobalSim::cTauMultiplicity::m_isoFW_CTAU
std::map< std::string, int > m_isoFW_CTAU
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:94
GlobalSim::cTauMultiplicity::accept_eta
const std::vector< double > & accept_eta() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:303
GlobalSim::cTauMultiplicity::m_TOB_isolation_partial_medium
std::vector< double > m_TOB_isolation_partial_medium
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:87
isocut.h
GlobalSim::cTauMultiplicity::TOB_isoScore
const std::vector< double > & TOB_isoScore() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:298
TCS::ETAU
@ ETAU
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Types.h:22
TCS::JTAU
@ JTAU
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Types.h:13
GlobalSim::cTauMultiplicity::accept_et
const std::vector< double > & accept_et() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:308
GlobalSim::cTauMultiplicity::m_nbits
unsigned int m_nbits
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:77
TCS::cTauTOB
Definition: cTauTOB.h:13
TrigConf::L1Threshold_cTAU::isolation
Selection::WP isolation() const
Definition: L1Threshold.h:262
GlobalSim::isocut
bool isocut(const std::string &threshold, const unsigned int bit)
Definition: isocut.cxx:10
GlobalSim::cTauMultiplicity::TOB_isolation_partial_tight
const std::vector< double > & TOB_isolation_partial_tight() const
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.cxx:293
GlobalSim::cTauMultiplicity::m_TOB_isoScore
std::vector< double > m_TOB_isoScore
Definition: Global/GlobalSimulation/src/L1TopoAlgs/cTauMultiplicity.h:89