39 if(clean_trigger.size() > 3 && clean_trigger.rfind(
"L1_", 0) == 0) {
40 clean_trigger =
"L1" + clean_trigger.substr(3);
43 std::vector<std::string> sections;
44 for (
auto&& subrange : std::views::split(
m_trigger,
'_')) sections.emplace_back(subrange.begin(), subrange.end());
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};
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.*)$");
66 std::regex_token_iterator<std::string::iterator> rend;
68 std::vector<bool> is_tau_probe_leg;
72 std::vector<std::string> leg;
73 for(
size_t i = 0; i < sections.size(); i++) {
74 leg.push_back(sections[i]);
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); }))) {
78 if(std::regex_match(leg[0],
match, tau_rgx)) {
81 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
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";
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);
97 if(tau_id.starts_with(
"var")) {
101 while(i < tau_id.size() && std::isdigit(
static_cast<unsigned char>(tau_id[i]))) i++;
103 tau_id = tau_id.substr(i);
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);
112 if(tau_id ==
"RNN") {
113 if(
type ==
"tracktwoMVA") tau_id =
"DeepSet";
114 if(
type ==
"tracktwoLLP" ||
type ==
"trackLRT") tau_id =
"RNNLLP";
118 if(tau_id ==
"DS") tau_id =
"DeepSet";
119 else if(tau_id ==
"GNT") tau_id =
"GNTau";
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()) {
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);
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);
142 if(tau_chpresel_id.starts_with(
"var")) {
146 while(i < tau_chpresel_id.size() && std::isdigit(
static_cast<unsigned char>(tau_chpresel_id[i]))) i++;
148 tau_chpresel_id = tau_chpresel_id.substr(i);
152 std::string tau_jet_container_sfx =
type;
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);
159 const bool is_probe_leg = std::find(leg.begin(), leg.end(),
"probe") != leg.end();
161 for(
size_t j = 0; j < multiplicity; j++) {
172 is_tau_probe_leg.push_back(is_probe_leg);
174 }
else if(std::regex_match(leg[0],
match, elec_rgx)) {
176 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
179 }
else if(std::regex_match(leg[0],
match, muon_rgx)) {
181 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
184 }
else if(std::regex_match(leg[0],
match, gamma_rgx)) {
186 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
189 }
else if(std::regex_match(leg[0],
match, jet_rgx)) {
191 size_t multiplicity =
match[1].str() ==
"" ? 1 : std::stoi(
match[1].
str());
194 }
else if(std::regex_match(leg[0],
match, met_rgx)) {
198 }
else if(std::regex_match(leg[0],
match, noalg_rgx)) {
201 }
else if (std::regex_match(leg[0],
match, ditauomni_rgx)) {
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;
209 if(leg[j].
find(
'-') != std::string::npos || std::regex_match(leg[j], l1_toposeparate_rgx)) {
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")) {
215 leg[0] =
"L1TAU20IM";
216 leg.push_back(
"TAU12IM");
222 m_L1Items.push_back(j == 0 ? leg[j].substr(2, leg[j].
size()) : leg[j]);
233 std::map<float, std::pair<std::vector<size_t>, std::vector<size_t>>> tau_n_tag_probes;
234 for(
size_t i = 0; i <
m_HLTThr.size(); i++) {
235 if(tau_n_tag_probes.find(
m_HLTThr.at(i)) == tau_n_tag_probes.end()) tau_n_tag_probes[
m_HLTThr.at(i)] = {{}, {}};
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);
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);
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());
253 std::sort(legs_to_remove.begin(), legs_to_remove.end(), std::greater<size_t>());
255 for(
size_t i : legs_to_remove) {
266 is_tau_probe_leg.erase(is_tau_probe_leg.begin() + i);
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();
286 if(remove_L1_phase1_thresholds && (item_type ==
"e" || item_type ==
"j" || item_type ==
"c"))
threshold = -1;
288 for(
size_t j = 0; j < multiplicity; j++) {