35{
37
38
39 if(clean_trigger.size() > 3 && clean_trigger.rfind("L1_", 0) == 0) {
40 clean_trigger = "L1" + clean_trigger.substr(3);
41 }
42
43 std::vector<std::string> sections;
44 for (
auto&& subrange : std::views::split(
m_trigger,
'_')) sections.emplace_back(subrange.begin(), subrange.end());
45
46 std::regex tau_rgx("^(\\d*)tau(\\d+)$");
47 std::regex elec_rgx("^(\\d*)e(\\d+)$");
48 std::regex muon_rgx("^(\\d*)mu(\\d+)$");
49 std::regex gamma_rgx("^(\\d*)g(\\d+)$");
50 std::regex jet_rgx("^(\\d*)j(\\d+)$");
51 std::regex met_rgx("^xe(\\d+)$");
52 std::regex noalg_rgx("^noalg$");
53 std::regex l1_rgx("^L1.*$");
54 std::regex l1_tau_rgx("(\\d*)(e|j|c|)TAU(\\d+)(L|M|T|HL|HM|HT|H|IM|I|)");
55 std::regex l1_toposeparate_rgx("^(\\d{0,2})(DETA|DPHI)(\\d{0,2})$");
56 std::regex topo_rgx("^.*(invm|dR|deta|dphi)AB.*$");
57 std::regex ditauomni_rgx("^ditauOmni(\\d)+Trk(\\d)+$");
58 std::vector<std::regex*> all_regexes = {&tau_rgx, &elec_rgx, &muon_rgx, &gamma_rgx, &jet_rgx, &met_rgx, &l1_rgx, &ditauomni_rgx};
59
60 std::regex tau_type_rgx("^(ptonly|tracktwoMVA|tracktwoLLP|trackLRT)$");
61 std::regex tau_ID_rgx("^(idperf|noperf|perfcore|perfiso|perf|veryloose.*|loose.*|medium.*|tight.*)$");
62 std::regex tau_HitZ_rgx("^(([\\dp]*mmX[\\dp]*mm)?HitZ.*)$");
63 std::regex tau_CHPreselID_rgx("^(idperfCHP|veryloose.*CHP.*|loose.*CHP.*|medium.*CHP.*|tight.*CHP.*)$");
64
66 std::regex_token_iterator<std::string::iterator> rend;
67
68 std::vector<bool> is_tau_probe_leg;
69
70
71 int hlt_leg_idx = -1;
72 std::vector<std::string>
leg;
73 for(
size_t i = 0;
i < sections.size();
i++) {
74 leg.push_back(sections[i]);
75
76 if(i == sections.size() - 1 || (std::any_of(all_regexes.begin(), all_regexes.end(), [§ions, i](const std::regex* rgx) { return std::regex_match(sections[i+1], *rgx); }))) {
77
78 if(std::regex_match(leg[0],
match, tau_rgx)) {
79 hlt_leg_idx++;
80
81 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
83
84
85 auto itr = find_if(
leg.begin(),
leg.end(), [tau_type_rgx](
const std::string& s) { return std::regex_match(s, tau_type_rgx); });
86 std::string
type = itr !=
leg.end() ? *itr :
"tracktwoMVA";
87
88
89 itr = find_if(
leg.begin(),
leg.end(), [tau_ID_rgx](
const std::string& s) { return std::regex_match(s, tau_ID_rgx); });
90 std::string tau_id = itr !=
leg.end() ? *itr :
"";
91 if(tau_id.starts_with("veryloose")) tau_id = tau_id.substr(9);
92 else if(tau_id.starts_with("loose")) tau_id = tau_id.substr(5);
93 else if(tau_id.starts_with("medium")) tau_id = tau_id.substr(6);
94 else if(tau_id.starts_with("tight")) tau_id = tau_id.substr(5);
95
96
97 if(tau_id.starts_with("var")) {
99
100
101 while(i < tau_id.size() && std::isdigit(
static_cast<unsigned char>(tau_id[i])))
i++;
102
103 tau_id = tau_id.substr(i);
104 }
105
106
107 if(tau_id.starts_with("perfcore")) tau_id = tau_id.substr(8);
108 else if(tau_id.starts_with("perfiso")) tau_id = tau_id.substr(7);
109 else if(tau_id.starts_with("noperf")) tau_id = tau_id.substr(6);
110
111
112 if(tau_id == "RNN") {
113 if(type == "tracktwoMVA") tau_id = "DeepSet";
114 if(type == "tracktwoLLP" || type == "trackLRT") tau_id = "RNNLLP";
115 }
116
117
118 if(tau_id == "DS") tau_id = "DeepSet";
119 else if(tau_id == "GNT") tau_id = "GNTau";
120
121
122 itr = find_if(
leg.begin(),
leg.end(), [tau_HitZ_rgx](
const std::string& s) { return std::regex_match(s, tau_HitZ_rgx); });
123 std::string tau_hitz = itr !=
leg.end() ? *itr :
"";
124 std::string tau_hitz_alg = tau_hitz;
125 if(!tau_hitz_alg.empty()) {
126
127 size_t pos = tau_hitz_alg.rfind(
"mm");
128 if(pos != std::string::npos) {
129 tau_hitz_alg = tau_hitz_alg.substr(pos + 2);
130 }
131 }
132
133
134 itr = find_if(
leg.begin(),
leg.end(), [tau_CHPreselID_rgx](
const std::string& s) { return std::regex_match(s, tau_CHPreselID_rgx); });
135 std::string tau_chpresel_id = itr !=
leg.end() ? *itr :
"";
136 if(tau_chpresel_id.starts_with("veryloose")) tau_chpresel_id = tau_chpresel_id.substr(9);
137 else if(tau_chpresel_id.starts_with("loose")) tau_chpresel_id = tau_chpresel_id.substr(5);
138 else if(tau_chpresel_id.starts_with("medium")) tau_chpresel_id = tau_chpresel_id.substr(6);
139 else if(tau_chpresel_id.starts_with("tight")) tau_chpresel_id = tau_chpresel_id.substr(5);
140
141
142 if(tau_chpresel_id.starts_with("var")) {
144
145
146 while(i < tau_chpresel_id.size() && std::isdigit(
static_cast<unsigned char>(tau_chpresel_id[i])))
i++;
147
148 tau_chpresel_id = tau_chpresel_id.substr(i);
149 }
150
151
152 std::string tau_jet_container_sfx =
type;
153
154 if(type == "ptonly") tau_jet_container_sfx = "CaloMVAOnly";
155 else if(tau_jet_container_sfx.starts_with("tracktwo")) tau_jet_container_sfx = tau_jet_container_sfx.substr(8);
156 else if(tau_jet_container_sfx.starts_with("track")) tau_jet_container_sfx = tau_jet_container_sfx.substr(5);
157
158
159 const bool is_probe_leg = std::find(
leg.begin(),
leg.end(),
"probe") !=
leg.end();
160
161 for(
size_t j = 0;
j < multiplicity;
j++) {
168
171
172 is_tau_probe_leg.push_back(is_probe_leg);
173 }
174 }
else if(std::regex_match(leg[0],
match, elec_rgx)) {
175 hlt_leg_idx++;
176 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
178 for(
size_t j = 0;
j < multiplicity;
j++)
m_HLTElecThr.push_back(threshold);
179 }
else if(std::regex_match(leg[0],
match, muon_rgx)) {
180 hlt_leg_idx++;
181 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
183 for(
size_t j = 0;
j < multiplicity;
j++)
m_HLTMuonThr.push_back(threshold);
184 }
else if(std::regex_match(leg[0],
match, gamma_rgx)) {
185 hlt_leg_idx++;
186 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
188 for(
size_t j = 0;
j < multiplicity;
j++)
m_HLTGammaThr.push_back(threshold);
189 }
else if(std::regex_match(leg[0],
match, jet_rgx)) {
190 hlt_leg_idx++;
191 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
193 for(
size_t j = 0;
j < multiplicity;
j++)
m_HLTJetThr.push_back(threshold);
194 }
else if(std::regex_match(leg[0],
match, met_rgx)) {
195 hlt_leg_idx++;
198 }
else if(std::regex_match(leg[0],
match, noalg_rgx)) {
199 hlt_leg_idx++;
201 }
else if (std::regex_match(leg[0],
match, ditauomni_rgx)) {
202 hlt_leg_idx++;
204 } else if(std::regex_match(leg[0], l1_rgx)){
205 for(
size_t j = 0;
j <
leg.size();
j++) {
206 if(std::regex_match(leg[j], topo_rgx)) continue;
207
208
209 if(leg[j].
find(
'-') != std::string::npos || std::regex_match(leg[j], l1_toposeparate_rgx)) {
210
211
212 if(leg[0] ==
"L1TAU60" && leg[j] ==
"DR-TAU12ITAU12I")
leg[
j] =
"TAU12IM";
213 else if(
leg.size() == 1 && (leg[0] ==
"L1DR-TAU20ITAU12I" || leg[0] ==
"L1DR-TAU20ITAU12I-J25")) {
214
215 leg[0] =
"L1TAU20IM";
216 leg.push_back(
"TAU12IM");
217
218 }
219 else continue;
220 }
221
222 m_L1Items.push_back(j == 0 ? leg[j].substr(2, leg[j].size()) : leg[j]);
223 }
224 }
225
226
228 }
229 }
230
231
232
233 std::map<float, std::pair<std::vector<size_t>, std::vector<size_t>>> tau_n_tag_probes;
235 if(tau_n_tag_probes.find(
m_HLTThr.at(i)) == tau_n_tag_probes.end()) tau_n_tag_probes[
m_HLTThr.at(i)] = {{}, {}};
236
237 if(is_tau_probe_leg.at(i)) tau_n_tag_probes[
m_HLTThr.at(i)].second.push_back(i);
238 else tau_n_tag_probes[
m_HLTThr.at(i)].first.push_back(i);
239 }
240
241 for(auto it = tau_n_tag_probes.begin(); it != tau_n_tag_probes.end(); ) {
242 if(
it->second.first.size() !=
it->second.second.size())
it = tau_n_tag_probes.erase(it);
244 }
245
246
247 std::vector<size_t> legs_to_remove;
248 for(const auto& [thr, n_tag_probe] : tau_n_tag_probes) {
249 legs_to_remove.insert(legs_to_remove.end(), n_tag_probe.first.begin(), n_tag_probe.first.end());
250 }
252
253 std::sort(legs_to_remove.begin(), legs_to_remove.end(), std::greater<size_t>());
254
255 for(size_t i : legs_to_remove) {
262
265
266 is_tau_probe_leg.erase(is_tau_probe_leg.begin() + i);
267 }
268
269
271
274
275
276 std::regex_token_iterator<std::string::iterator> rgx_iter(
m_L1Item.begin(),
m_L1Item.end(), l1_tau_rgx);
277 while(rgx_iter != rend) {
278 const std::string &
s = *rgx_iter;
279 if (std::regex_match(s,
match, l1_tau_rgx)){
280 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
281 std::string item_type =
match[2].str();
283 std::string item_isolation =
match[4].str();
284
285
286 if(remove_L1_phase1_thresholds && (item_type ==
"e" || item_type ==
"j" || item_type ==
"c"))
threshold = -1;
287
288 for(
size_t j = 0;
j < multiplicity;
j++) {
294 }
295 }
296 rgx_iter++;
297 }
298
300 }
301}
std::string find(const std::string &s)
return a remapped string
bool match(std::string s1, std::string s2)
match the individual directories of two strings
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.