ATLAS Offline Software
Loading...
Searching...
No Matches
cTauMultiplicity.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4// TopoCore
5//
6
7
8
13
17
18#include <cmath>
19
20
21REGISTER_ALG_TCS(cTauMultiplicity)
22
24 setNumberOutputBits(12); //To-Do: Make this flexible to adapt to the menu. Each counting requires more than one bit
25}
26
27
29 m_threshold = dynamic_cast<const TrigConf::L1Threshold_cTAU*>(getThreshold());
30 if (not m_threshold){
31 TRG_MSG_ERROR("Dynamic cast failed in TCS::cTauMultiplicity::initialize");
33 }
34
35 m_extraInfo = m_threshold->getExtraInfo();
36
37 // Book monitoring histograms
38 bookHistMult(m_histAccept, "cTauMultiplicity_accept_EtaPt_"+m_threshold->name(), "Mult_"+m_threshold->name(), "#eta#times40", "E_{t} [GeV]", 200, -200, 200, 100, 0, 100);
39 bookHistMult(m_histAccept, "cTauMultiplicity_accept_counts_"+m_threshold->name(), "Mult_"+m_threshold->name(), "counts", 15, 0, 15);
40
41 // cTau TOB monitoring histograms
42 bookHistMult(m_histcTauEt, "cTauTOBEt", "Matched cTau TOB Et", "E_{t} [GeV]", 200, 0, 400);
43 bookHistMult(m_histcTauPhiEta, "cTauTOBPhiEta", "Matched cTau TOB location", "#eta#times40", "#phi#times20", 200, -200, 200, 128, 0, 128);
44 bookHistMult(m_histcTauEtEta, "cTauTOBEtEta", "Matched cTau TOB Et vs eta", "#eta#times40", "E_{t} [GeV]", 200, -200, 200, 200, 0, 400);
45
46 const std::string wp_name = m_threshold->isolation() != WP::NONE ? TrigConf::Selection::wpToString(m_threshold->isolation()) : "NoIso";
47 bookHistMult(m_histcTauIsoFraction, "cTauTOBIsoFraction", std::string("Matched cTAU ") + wp_name + " isolation fraction", wp_name + " isolation fraction", 200, 0, 10);
48
49 bookHistMult(m_histcTauIsoMatchedPass, "cTauTOBIsoMatchedPass", "Matched cTau isolation pass", "isolation pass", 2, 0, 2);
50
52}
53
54
55// To be implemented
60
61
63{
64 const cTauTOBArray& cTaus = dynamic_cast<const cTauTOBArray&>(input);
65
66 int counting = 0;
67 // Loop over eTau candidates
68 for(cTauTOBArray::const_iterator etauCand = cTaus.begin(); etauCand != cTaus.end(); ++etauCand) {
69 if((*etauCand)->tobType() != TCS::ETAU) continue;
70
71 bool accept = false; // accept = (isMatched==true && isIsolated==true) || (isMatched==false)
72 bool isMatched = false; // Is the eTau matched to a jTau?
73 bool isIsolated = false; // If matched: does the resulting cTau pass the isolation cut?
74 float isolation_fraction = 0; // cTAU isolation fraction
75
76 // Loop over jTau candidates
77 for(cTauTOBArray::const_iterator jtauCand = cTaus.begin(); jtauCand != cTaus.end(); ++jtauCand) {
78 if((*jtauCand)->tobType() != TCS::JTAU) continue;
79
80 isMatched = cTauMatching(*etauCand, *jtauCand);
81
82 if(isMatched) {
83 float etauCand_et = static_cast<float>((*etauCand)->Et());
84 float etauCand_eta = static_cast<float>((*etauCand)->etaDouble());
85 float jtauCand_et = static_cast<float>((*jtauCand)->Et());
86 float jtauCand_etIso = static_cast<float>((*jtauCand)->EtIso());
87
88 // Updated isolation condition, WP-dependent (ATR-28641)
89 // I = (E_T^{jTAU Iso} + jTAUCoreScale * (E_T^{jTAU Core} - E_T^{eTAU})) / E_T^{eTAU}
90 if(m_threshold->isolation() != WP::NONE) {
91 isolation_fraction = (jtauCand_etIso + m_extraInfo->isolation(m_threshold->isolation(), etauCand_eta).isolation_jTAUCoreScale_d() * (jtauCand_et - etauCand_et)) / etauCand_et;
92 }
93 // Old isolation condition coded as in firmware: https://indico.cern.ch/event/1079697/contributions/4541419/attachments/2315137/3940824/cTAU_FirmwareAlgoProposal.pdf page 8
94
95 // Check the isolation WP
96 isIsolated = checkIsolationWP(*etauCand, *jtauCand);
97
98 break; // Break loop when a match is found
99 }
100
101 } // End of jTau loop
102
103 // Fill cTau TOB histograms before threshold cuts (matched cTaus only)
104 if(isMatched) {
105 fillHist1D(m_histcTauEt[0], (*etauCand)->EtDouble());
106 fillHist2D(m_histcTauPhiEta[0], (*etauCand)->eta(), (*etauCand)->phi());
107 fillHist2D(m_histcTauEtEta[0], (*etauCand)->eta(), (*etauCand)->EtDouble());
108 fillHist1D(m_histcTauIsoFraction[0], isolation_fraction);
109 fillHist1D(m_histcTauIsoMatchedPass[0], isMatched && isIsolated);
110 }
111
112 if(isMatched && isIsolated) accept = true; // This is a good matched cTau
113 if(!isMatched) accept = true; // This is a non-matched eTau
114
115 if(!checkeTAUWP(*etauCand)) accept = false; // Check eTAU rCore/BDT and rHad WP
116
117 // Menu threshold uses 0.1 eta granularity but eFex objects have 0.025 eta granularity
118 // eFex eta is calculated as 4*eta_tower (0.1 gran.) + seed (0.025 gran.), eta from -25 to 24
119 int eta_thr;
120 if((*etauCand)->eta()%4 >= 0) eta_thr = (*etauCand)->eta() - (*etauCand)->eta()%4;
121 else eta_thr = (*etauCand)->eta() - (*etauCand)->eta()%4 - 4;
122
123 accept = accept && (*etauCand)->Et() > m_threshold->thrValue100MeV(eta_thr/4); // Convert eta_thr to units of 0.1 to pass as an argument
124
125 if(accept) {
126 counting++;
127 fillHist2D(m_histAccept[0], (*etauCand)->eta(), (*etauCand)->EtDouble());
128 }
129
130 } // End of eTau loop
131
132 fillHist1D(m_histAccept[1], counting);
133
134 // Pass counting to TCS::Count object - output bits are composed there
135 count.setSizeCount(counting);
136
138}
139
140
141bool TCS::cTauMultiplicity::checkIsolationWP(const TCS::cTauTOB* etauCand, const TCS::cTauTOB* jtauCand) const {
142 if(m_threshold->isolation() == WP::NONE) return true;
143 auto iso_wp = m_extraInfo->isolation(m_threshold->isolation(), etauCand->etaDouble());
144 return jtauCand->EtIso()*1024 + jtauCand->Et()*iso_wp.isolation_jTAUCoreScale_fw() < etauCand->Et()*iso_wp.isolation_fw();
145}
146
147
149 if(m_threshold->isolation() == WP::NONE) return true;
150 auto iso_wp = m_extraInfo->isolation(m_threshold->isolation(), etauCand->etaDouble());
151 return etauCand->RCore() >= iso_wp.eTAU_rCoreMin_WP_fw() && etauCand->RHad() >= iso_wp.eTAU_rHadMin_WP_fw();
152}
153
154
155bool TCS::cTauMultiplicity::cTauMatching(const TCS::cTauTOB* etauCand, const TCS::cTauTOB* jtauCand) const {
156
157 bool matching = false;
158
159 // Matching is done comparing eta_tower and phi_tower (granularity = 0.1)
160 // These coordinates represent the lower edge of the towers (both for eFEX and jFEX)
161
162 // eTau eta = 4*eta_tower + seed, eta from -25 to 24
163 int eTauEtaTower;
164 if(etauCand->eta()%4 >= 0 ) eTauEtaTower = etauCand->eta() - etauCand->eta()%4;
165 else eTauEtaTower = etauCand->eta() - etauCand->eta()%4 - 4;
166 int jTauEtaTower;
167 if (jtauCand->eta()%4 >= 0 ) jTauEtaTower = jtauCand->eta() - jtauCand->eta()%4;
168 else jTauEtaTower = jtauCand->eta() - jtauCand->eta()%4 - 4;
169
170 //int jTauEtaTower = jtauCand->eta(); // jTau eta = 4*eta_tower
171 unsigned int eTauPhiTower = etauCand->phi() >> 1; // eTau phi = 2*phi_tower
172 unsigned int jTauPhiTower = jtauCand->phi() >> 1; // jTau phi = 2*phi_tower + 1 (jTau coordinates are at center of tower)
173
174 matching = (eTauEtaTower == jTauEtaTower) && (eTauPhiTower == jTauPhiTower);
175
176 return matching;
177
178}
179
180// Functions used by the HLT seeding
181
182#ifndef TRIGCONF_STANDALONE
184
185 // Return the index of the matched jTau if existent (otherwise return std::numeric_limits<size_t>::max())
186 size_t i_matched{std::numeric_limits<size_t>::max()};
187 size_t i_jTau{0};
188
189 int eTauEtaTower;
190 if(eTau.iEtaTopo()%4 >= 0 ) eTauEtaTower = eTau.iEtaTopo() - eTau.iEtaTopo()%4;
191 else eTauEtaTower = eTau.iEtaTopo() - eTau.iEtaTopo()%4 - 4;
192
193 for(const xAOD::jFexTauRoI* jTau : jTauRoIs) {
194
195 // eFEX: etaTower = iEta, phiTower = iPhi
196 // jFEX: etaTower = globalEta, phiTower = globalPhi
197
198 int jTauEtaTopo = TSU::toTopoEta(jTau->eta());
199 int jTauEtaTower;
200 if(jTauEtaTopo%4 >= 0 ) jTauEtaTower = jTauEtaTopo - jTauEtaTopo%4;
201 else jTauEtaTower = jTauEtaTopo - jTauEtaTopo%4 - 4;
202
203 unsigned int jTauPhiTower = TSU::toTopoPhi(jTau->phi()) >> 1; //ignore lowest bit as jTau coordinates are taken at tower center
204 unsigned int eTauPhiTower = static_cast<unsigned int>(eTau.iPhiTopo()) >> 1; //shift eTau location in the same way to stay consistent
205 bool matching = ( eTauEtaTower == jTauEtaTower ) && ( eTauPhiTower == jTauPhiTower );
206
207 if(matching) {
208 i_matched = i_jTau;
209 break; // Break the loop when a match is found
210 }
211 ++i_jTau;
212 }
213
214 return i_matched;
215
216}
217
218
220
221 // eFEX: etaTower = iEta, phiTower = iPhi
222 // jFEX: etaTower = globalEta, phiTower = globalPhi
223
224 int eTauEtaTower;
225 if(eTau.iEtaTopo()%4 >= 0 ) eTauEtaTower = eTau.iEtaTopo() - eTau.iEtaTopo()%4;
226 else eTauEtaTower = eTau.iEtaTopo() - eTau.iEtaTopo()%4 - 4;
227
228 int jTauEtaTopo = TSU::toTopoEta(jTau.eta());
229 int jTauEtaTower;
230 if(jTauEtaTopo%4 >= 0 ) jTauEtaTower = jTauEtaTopo - jTauEtaTopo%4;
231 else jTauEtaTower = jTauEtaTopo - jTauEtaTopo%4 - 4;
232
233 unsigned int jTauPhiTower = TSU::toTopoPhi(jTau.phi()) >> 1; //ignore lowest bit as jTau coordinates are taken at tower center
234 unsigned int eTauPhiTower = static_cast<unsigned int>(eTau.iPhiTopo()) >> 1; //shift eTau location in the same way to stay consistent
235
236 bool matching = ( eTauEtaTower == jTauEtaTower ) && ( eTauPhiTower == jTauPhiTower );
237 return matching;
238
239}
240
241
243 if(thr.isolation() == WP::NONE) return true;
244 auto iso_wp = thr.getExtraInfo()->isolation(thr.isolation(), eTau.eta());
245 return jTau.tobIso()*2*1024 + jTau.tobEt()*2*iso_wp.isolation_jTAUCoreScale_fw() < eTau.etTOB()*iso_wp.isolation_fw();
246}
247
248
250 if(thr.isolation() == WP::NONE) return true;
251 auto iso_wp = thr.getExtraInfo()->isolation(thr.isolation(), eTau.eta());
252 return eTau.tauOneThresholds() >= iso_wp.eTAU_rCoreMin_WP_fw() && eTau.tauTwoThresholds() >= iso_wp.eTAU_rHadMin_WP_fw();
253}
254
255#endif
#define REGISTER_ALG_TCS(CLASS)
Definition AlgFactory.h:62
const std::string & name() const
void fillHist1D(const std::string &histName, double x)
void bookHistMult(std::vector< std::string > &regName, const std::string &name, const std::string &title, const std::string &xtitle, const int binx, const int xmin, const int xmax)
void fillHist2D(const std::string &histName, double x, double y)
const TrigConf::L1Threshold * getThreshold()
Definition CountingAlg.h:47
std::vector< std::string > m_histAccept
Definition CountingAlg.h:51
CountingAlg(const std::string &name)
Definition CountingAlg.h:28
void setNumberOutputBits(unsigned int numberOutputBits)
Definition CountingAlg.h:41
data_t::const_iterator const_iterator
static size_t cTauMatching(const xAOD::eFexTauRoI &eTau, const xAOD::jFexTauRoIContainer &jTauRoIs)
static bool checkeTAUWP(const xAOD::eFexTauRoI &eTau, const TrigConf::L1Threshold_cTAU &thr)
static bool checkIsolationWP(const xAOD::eFexTauRoI &eTau, const xAOD::jFexTauRoI &jTau, const TrigConf::L1Threshold_cTAU &thr)
std::vector< std::string > m_histcTauPhiEta
cTauMultiplicity(const std::string &name)
std::shared_ptr< TrigConf::L1ThrExtraInfo_cTAU > m_extraInfo
std::vector< std::string > m_histcTauEtEta
std::vector< std::string > m_histcTauEt
virtual StatusCode processBitCorrect(const TCS::InputTOBArray &input, Count &count) override final
virtual StatusCode process(const TCS::InputTOBArray &input, Count &count) override final
std::vector< std::string > m_histcTauIsoMatchedPass
std::vector< std::string > m_histcTauIsoFraction
const TrigConf::L1Threshold_cTAU * m_threshold
virtual StatusCode initialize() override
unsigned int RCore() const
Definition cTauTOB.h:41
int eta() const
Definition cTauTOB.h:34
unsigned int Et() const
Definition cTauTOB.h:33
unsigned int EtIso() const
Definition cTauTOB.h:44
double etaDouble() const
Definition cTauTOB.h:38
unsigned int phi() const
Definition cTauTOB.h:35
unsigned int RHad() const
Definition cTauTOB.h:42
static std::string wpToString(WP)
int iPhiTopo() const
Return phi index in the range used by L1Topo (0->127)
unsigned int tauOneThresholds() const
Tau Condition 1 (generic) results.
unsigned int etTOB() const
Cluster ET (TOB ET scale, 100 MeV/count)
float eta() const
setter for the above
int iEtaTopo() const
Getter for integer phi index (0-63)
unsigned int tauTwoThresholds() const
Tau Condition 2 (generic) results.
uint16_t tobIso() const
float phi() const
uint16_t tobEt() const
float eta() const
const std::string process
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
int toTopoEta(float eta)
unsigned int toTopoPhi(float phi)
STL namespace.
jFexTauRoIContainer_v1 jFexTauRoIContainer
jFexTauRoI_v1 jFexTauRoI
Define the latest version of the jFexSRJetRoI class.
Definition jFexTauRoI.h:13
eFexTauRoI_v1 eFexTauRoI
Define the latest version of the eFexTauRoI class.
Definition eFexTauRoI.h:16