38 return static_cast<float>(roi->
et());
42inline std::vector<std::string>
48inline std::vector<std::string>
50 const std::vector<std::string>& bitToName)
52 std::vector<std::string>
passed;
53 static const SG::AuxElement::ConstAccessor<uint64_t>
54 thrPatternsAcc(
"thresholdPatterns");
55 if (!thrPatternsAcc.isAvailable(*roi))
return passed;
57 passed.reserve(bitToName.size());
58 for (
size_t b = 0;
b < bitToName.size(); ++
b) {
59 if (((pat >> b) & 1ULL) && !bitToName[b].
empty()) {
60 passed.push_back(bitToName[b]);
79inline std::vector<L1LegToken> parseL1LegTokens(
const std::string& l1Name) {
80 static const std::regex l1NameParser(
81 "(\\d*)(j?J)(\\d*)((p|\\.)(\\d*)ETA(\\d*))?");
82 static const std::regex dashToUnderscore(
"-");
84 std::vector<L1LegToken>
tokens;
85 std::stringstream
ss(std::regex_replace(l1Name, dashToUnderscore,
"_"));
88 while (getline(
ss, legName,
'_')) {
89 if (std::regex_match(legName,
match, l1NameParser)) {
90 std::string legName_noMultiplicity =
99template <
typename RoI,
typename Container,
typename ThrAccessor>
100std::tuple<float, float, float, float, std::vector<int>> matchL1Container(
102 const std::vector<L1LegToken>& l1LegTokens,
float drMax) {
103 const RoI* bestL1 =
nullptr;
104 float minDRL1 = drMax;
105 std::set<int> L1Thresholds;
107 for (
const RoI* l1_jet : container) {
108 TLorentzVector l1_jet_p4;
109 l1_jet_p4.SetPtEtaPhiM(
110 getL1JetEt(l1_jet), l1_jet->eta(), l1_jet->phi(), 0.);
111 const float dR =
static_cast<float>(
jet->p4().
DeltaR(l1_jet_p4));
116 L1Thresholds.clear();
117 const std::vector<std::string> thrNames = thrAccessor(l1_jet);
118 for (
const L1LegToken& tok : l1LegTokens) {
119 for (
const auto& thr : thrNames) {
120 if (thr == tok.name) {
121 L1Thresholds.insert(tok.threshold);
129 bestL1 ? getL1JetEt(bestL1) : -99.f,
130 bestL1 ? bestL1->
eta() : -99.f,
131 bestL1 ? bestL1->
phi() : -99.f,
179 return StatusCode::SUCCESS;
183 const EventContext& ctx) {
187 }
catch (
const std::exception&
e) {
190 <<
". The Phase-I jFEX threshold table "
191 "cannot be built. Ensure TrigConf::xAODConfigSvc has "
192 "loaded the L1 menu for this input file.");
193 return StatusCode::FAILURE;
197 return StatusCode::SUCCESS;
202 <<
"' — rebuilding jFEX threshold table");
205 if (thresholds.empty()) {
207 <<
"' has no thresholds of type '"
209 return StatusCode::FAILURE;
212 for (
const auto& thr : thresholds) {
213 const unsigned int bit = thr->mapping();
219 <<
" jFEX threshold names from L1 menu '"
220 << l1menu->name() <<
"'");
223 return StatusCode::SUCCESS;
253 std::unordered_map<std::string,
254 std::vector<std::pair<const xAOD::Jet*, bool>>>
261 .getChainConfigurationDetails(
m_trigger);
263 const std::vector<L1LegToken> l1LegTokens = parseL1LegTokens(l1Name);
278 float minDRL1 =
m_l1dR.value();
279 std::vector<int> l1ThresholdsVec;
284 std::tie(l1Et, l1Eta, l1Phi, minDRL1, l1ThresholdsVec) =
285 matchL1Container<xAOD::jFexSRJetRoI>(
288 return getL1JetThresholds(
r, jfexNames);
290 l1LegTokens,
m_l1dR.value());
293 std::tie(l1Et, l1Eta, l1Phi, minDRL1, l1ThresholdsVec) =
294 matchL1Container<xAOD::JetRoI>(
297 return getL1JetThresholds(
r);
299 l1LegTokens,
m_l1dR.value());
316 float minDRHLT =
m_hltDR.value();
317 std::set<int> HLTThresholds = {};
323 if (legInfo.signature ==
"j") {
325 <<
" " << legInfo.legName() <<
" "
326 << legInfo.type() <<
" "
327 << legInfo.signature <<
" "
328 << legInfo.threshold);
330 int legThreshold = legInfo.threshold;
332 if (legInfo.legName().find(
"gsc") != std::string::npos) {
333 for (
const std::string& part : legInfo.legParts) {
334 if (part.find(
"gsc") != std::string::npos) {
335 legThreshold = std::stoi(part.substr(3));
348 auto hlt_emulated_jets =
349 emulatedJets[legInfo.legName()];
352 << legInfo.legName() <<
": "
353 << hlt_emulated_jets.size());
355 for (
const auto& [hlt_jet, passBtag] : hlt_emulated_jets) {
356 float dR =
jet->p4().DeltaR(hlt_jet->p4());
358 <<
" eta: " << hlt_jet->eta()
359 <<
" phi: " << hlt_jet->phi()
362 if (bestHLT &&
isSameJet(bestHLT, hlt_jet))
363 HLTThresholds.insert(legThreshold);
364 else if (dR < minDRHLT) {
367 HLTThresholds.clear();
368 HLTThresholds.insert(legThreshold);
379 auto hlt_jetsFromtrigDec =
382 std::vector<const xAOD::IParticle*> allHLTJets;
384 for (
const auto& hlt_jet_link : hlt_jetsFromtrigDec) {
387 if (!hlt_jetFromtrigDec)
389 allHLTJets.push_back(hlt_jetFromtrigDec);
395 for (
const xAOD::Jet* jetFromCont : *hltJetsFromCont) {
396 bool alreadyIn =
false;
406 allHLTJets.push_back(jetFromCont);
409 <<
" eta=" << jetFromCont->eta()
410 <<
" phi=" << jetFromCont->phi());
415 float dR =
jet->p4().DeltaR(hlt_jet->p4());
416 bool fromtrigDec =
false;
417 for (
const auto& hlt_jet_link : hlt_jetsFromtrigDec) {
418 if (*hlt_jet_link.link == hlt_jet) {
425 " pt: " << hlt_jet->pt() <<
" eta: " << hlt_jet->eta()
426 <<
" phi: " << hlt_jet->phi() <<
" dR: " << dR
427 <<
" (fromContainer=" << !fromtrigDec <<
")");
429 if (bestHLT &&
isSameJet(bestHLT, hlt_jet))
430 HLTThresholds.insert(legThreshold);
431 else if (dR < minDRHLT) {
434 HLTThresholds.clear();
435 HLTThresholds.insert(legThreshold);
450 std::vector<int> hltThresh;
452 hltThresh = std::vector<int>(HLTThresholds.begin(),
453 HLTThresholds.end());
457 <<
" Trigger: " <<
m_trigger <<
" bestHLT pT: "
458 << (bestHLT ? bestHLT->
pt() : -99.));
462 return StatusCode::SUCCESS;
468 return (jet1->
p4().DeltaR(jet2->
p4()) < 0.01) && (std::abs(jet1->
pt() - jet2->
pt()) < 100);
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Helper class to provide constant type-safe access to aux data.
static const Attributes_t empty
SysListHandle m_systematicsList
the systematics list we run
ToolHandle< TrigConf::ITrigConfigTool > m_trigConfigTool
Gaudi::Property< bool > m_doHLTMatching
Gaudi::Property< float > m_l1dR
JetTriggerDecoratorAlg(const std::string &name, ISvcLocator *svcLoc=nullptr)
Gaudi::Property< bool > m_useEmulationTool
Gaudi::Property< bool > m_usePhaseIL1
CP::SysWriteDecorHandle< std::vector< int > > m_L1Threshold_decor
CP::SysWriteDecorHandle< float > m_HLTPt_decor
CP::SysWriteDecorHandle< float > m_HLTPhi_decor
CP::SysWriteDecorHandle< std::vector< int > > m_HLTThreshold_decor
ToolHandle< Trig::ITrigBtagEmulationTool > m_emulationTool
bool isSameJet(const xAOD::IParticle *jet1, const xAOD::IParticle *jet2) const
SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer > m_L1JetsPhaseIInKey
Gaudi::Property< std::vector< std::string > > m_triggerNavBug
CP::SysWriteDecorHandle< float > m_L1Eta_decor
Gaudi::Property< float > m_hltDR
CP::SysWriteDecorHandle< float > m_L1DR_decor
StatusCode rebuildJfexThresholdTable(const EventContext &ctx)
PublicToolHandle< Trig::TrigDecisionTool > m_trigDecisionTool
CP::SysReadHandle< xAOD::JetContainer > m_jetsHandle
SG::ReadHandleKey< xAOD::JetContainer > m_HLTJetsInKey
CP::SysWriteDecorHandle< float > m_HLTEta_decor
Gaudi::Property< std::string > m_trigger
std::vector< std::string > m_jfexThresholdNames
CP::SysWriteDecorHandle< float > m_HLTDR_decor
CP::SysWriteDecorHandle< float > m_L1Et_decor
SG::ReadHandleKey< xAOD::JetRoIContainer > m_L1JetsInKey
Gaudi::Property< std::string > m_l1ThresholdType
StatusCode initialize() override
Gaudi::Property< bool > m_doL1Matching
CP::SysWriteDecorHandle< float > m_L1Phi_decor
bool m_thresholdNamesLoaded
std::string m_cachedL1MenuName
Helper class that provides access to information about individual legs.
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
virtual::StatusCode execute()
execute this algorithm
storage of the time histories of all the cells
virtual bool isValid() override final
Can the handle be successfully dereferenced?
HLT chain configuration information.
const std::string & lower_chain_name() const
FeatureRequestDescriptor & setChainGroup(const std::string &chainGroupName)
Set the desired Chain or Chain Group.
FeatureRequestDescriptor & setRestrictRequestToLeg(const int restrictToLegIndex)
Set to -1 by default, indicating that all legs of multi-leg chains are searched.
Class providing the definition of the 4-vector interface.
virtual double eta() const =0
The pseudorapidity ( ) of the particle.
virtual FourMom_t p4() const =0
The full 4-momentum of the particle.
virtual double pt() const =0
The transverse momentum ( ) of the particle.
virtual double phi() const =0
The azimuthal angle ( ) of the particle.
float et8x8() const
The energy deposited in a 0.8x0.8 area around the RoI.
const std::vector< std::string > & thrNames() const
The names of the thresholds passed by jet candidate.
unsigned int et() const
Methods that require combining results or applying scales.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Select isolated Photons, Electrons and Muons.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
legName(chainName, legCounter)
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
jFexSRJetRoI_v1 jFexSRJetRoI
Define the latest version of the jFexSRJetRoI class.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Struct containing information on each leg of a chain.