ATLAS Offline Software
Loading...
Searching...
No Matches
ORToolBoxTestAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "ORToolBoxTestAlg.h"
10
11namespace
12{
14 const float GeV = 1000.;
15}
16
17//-----------------------------------------------------------------------------
18// Constructor
19//-----------------------------------------------------------------------------
20ORToolBoxTestAlg::ORToolBoxTestAlg(const std::string& name,
21 ISvcLocator* svcLoc)
22 : AthAlgorithm(name, svcLoc),
23 m_toolBox("ORTBox", this)
24{
25 declareProperty("SelectionLabel", m_flags.inputLabel="isSelected",
26 "Input label for the OverlapRemovalTool");
27 declareProperty("OverlapLabel", m_flags.outputLabel="overlaps",
28 "Output label for the OverlapRemovalTool");
29 declareProperty("BJetLabel", m_flags.bJetLabel="isBJet",
30 "Input label for b-tagged jets");
31}
32
33//-----------------------------------------------------------------------------
34// Initialize the algorithm
35//-----------------------------------------------------------------------------
37{
38 ATH_MSG_INFO( "Initializing " << name() );
39
40 // Configuration helper function
42
43 // Initialize the tools
44 ATH_CHECK( m_toolBox.initialize() );
45
46 return StatusCode::SUCCESS;
47}
48
49//-----------------------------------------------------------------------------
50// Execute the algorithm
51//-----------------------------------------------------------------------------
53{
54 ATH_MSG_INFO( "Executing " << name() );
55
56 // Electrons
57 const xAOD::ElectronContainer* electrons = 0;
58 ATH_CHECK( evtStore()->retrieve(electrons, "Electrons") );
59 applySelection(*electrons);
60 // Muons
61 const xAOD::MuonContainer* muons = 0;
62 ATH_CHECK( evtStore()->retrieve(muons, "Muons") );
63 applySelection(*muons);
64 // Taus
65 const xAOD::TauJetContainer* taus = 0;
66 ATH_CHECK( evtStore()->retrieve(taus, "TauJets") );
68 // Jets
69 const xAOD::JetContainer* jets = 0;
70 ATH_CHECK( evtStore()->retrieve(jets, "AntiKt4EMTopoJets") );
71 applySelection(*jets);
72 // Photons
73 const xAOD::PhotonContainer* photons = 0;
74 ATH_CHECK( evtStore()->retrieve(photons, "Photons") );
75 applySelection(*photons);
76
77 // Apply the overlap removal
78 ATH_CHECK( m_toolBox.masterTool->removeOverlaps(electrons, muons, jets, taus, photons) );
79
80 return StatusCode::SUCCESS;
81}
82
83//-----------------------------------------------------------------------------
84// Apply selection to a container
85//-----------------------------------------------------------------------------
86template<class ContainerType>
88{
89 const static ort::inputDecorator_t selDec(m_flags.inputLabel);
90 for(auto obj : container){
91 selDec(*obj) = selectObject(*obj);
92 }
93}
94//-----------------------------------------------------------------------------
95template<class ObjType>
96bool ORToolBoxTestAlg::selectObject(const ObjType& obj)
97{
98 if(obj.pt() < 10.*GeV) return false;
99 if(std::abs(obj.eta()) > 2.5) return false;
100 return true;
101}
102//-----------------------------------------------------------------------------
103template<>
105{
106 // Label bjets
107 const static ort::inputDecorator_t bJetDec(m_flags.bJetLabel);
108 bJetDec(jet) = false;
109 double mv2c10 = 0.;
111 if(btag->MVx_discriminant("MV2c10", mv2c10)){
112 if(mv2c10 > -0.1416) bJetDec(jet) = true;
113 }
114 else ATH_MSG_WARNING("BTag info unavailable!");
115 if(jet.pt() < 20.*GeV) return false;
116 if(std::abs(jet.eta()) > 2.5) return false;
117 return true;
118}
119//-----------------------------------------------------------------------------
120template<>
122{
123 if(obj.pt() < 20.*GeV) return false;
124 if(std::abs(obj.eta()) > 2.5) return false;
125 return true;
126}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
static Double_t taus
Defines helper functions for initializing the OR tools in C++.
const ort::inputDecorator_t bJetDec(bJetLabel)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
void applySelection(const ContainerType &container)
Simple object selection.
ORToolBoxTestAlg(const std::string &name, ISvcLocator *svcLoc)
Standard algorithm constructor.
virtual StatusCode initialize()
Initialize the algorithm.
ORUtils::ToolBox m_toolBox
The overlap removal tools' toolbox.
bool selectObject(const ObjType &obj)
Simple object selection.
ORUtils::ORFlags m_flags
The overlap removal tools' configuration flags.
virtual StatusCode execute()
Execute the algorithm.
bool MVx_discriminant(const std::string &taggername, double &value) const
StatusCode recommendedTools(const ORFlags &flags, ToolBox &toolBox)
Pre-configured standard recommended OR tools.
SG::AuxElement::Decorator< inputFlag_t > inputDecorator_t
Input object decorator (for convenience if users want it)
const BTagging * getBTagging(const SG::AuxElement &part)
Access the default xAOD::BTagging object associated to an object.
Jet_v1 Jet
Definition of the current "jet version".
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
BTagging_v1 BTagging
Definition of the current "BTagging version".
Definition BTagging.h:17
TauJet_v3 TauJet
Definition of the current "tau version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".