ATLAS Offline Software
Loading...
Searching...
No Matches
OverlapRemovalTestAlg.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// EDM includes
6
7// Local includes
11
12namespace
13{
15 const float GeV = 1000.;
16 const float invGeV = 1./GeV;
17}
18
19//-----------------------------------------------------------------------------
20// Constructor
21//-----------------------------------------------------------------------------
23 ISvcLocator* svcLoc)
24 : AthAlgorithm(name, svcLoc),
25 m_orTool("OverlapRemovalTool", this)
26{
27 declareProperty("OverlapRemovalTool", m_orTool);
28 declareProperty("SelectionLabel", m_selectionLabel="selected",
29 "Input label for the OverlapRemovalTool");
30 declareProperty("OverlapLabel", m_overlapLabel="overlaps",
31 "Output label for the OverlapRemovalTool");
32 declareProperty("BJetLabel", m_bJetLabel="isBJet",
33 "Input label for b-tagged jets");
34}
35
36//-----------------------------------------------------------------------------
37// Initialize
38//-----------------------------------------------------------------------------
40{
41 ATH_MSG_INFO("Initialize");
42
43 // Try to retrieve the tool
44 ATH_CHECK( m_orTool.retrieve() );
45
46 return StatusCode::SUCCESS;
47}
48
49//-----------------------------------------------------------------------------
50// Execute
51//-----------------------------------------------------------------------------
53{
54 // Electrons
55 const xAOD::ElectronContainer* electrons = 0;
56 ATH_CHECK( evtStore()->retrieve(electrons, "Electrons") );
57 applySelection(*electrons);
58 // Muons
59 const xAOD::MuonContainer* muons = 0;
60 ATH_CHECK( evtStore()->retrieve(muons, "Muons") );
61 applySelection(*muons);
62 // Taus
63 const xAOD::TauJetContainer* taus = 0;
64 ATH_CHECK( evtStore()->retrieve(taus, "TauJets") );
66 // Jets
67 const xAOD::JetContainer* jets = 0;
68 ATH_CHECK( evtStore()->retrieve(jets, "AntiKt4EMTopoJets") );
69 applySelection(*jets);
70 // Photons
71 const xAOD::PhotonContainer* photons = 0;
72 ATH_CHECK( evtStore()->retrieve(photons, "Photons") );
73 applySelection(*photons);
74
75 // Apply the overlap removal
76 ATH_CHECK( m_orTool->removeOverlaps(electrons, muons, jets, taus, photons) );
77
78 // Dump the objects
79 ATH_MSG_DEBUG("Dumping results");
80 printObjects(*electrons, "ele");
81 printObjects(*muons, "muo");
82 printObjects(*taus, "tau");
83 printObjects(*jets, "jet");
84 printObjects(*photons, "pho");
85
86 return StatusCode::SUCCESS;
87}
88
89//-----------------------------------------------------------------------------
90// Apply selection to a container
91//-----------------------------------------------------------------------------
92template<class ContainerType>
94{
95 const static ort::inputDecorator_t selDec(m_selectionLabel);
96 for(auto obj : container){
97 selDec(*obj) = selectObject(*obj);
98 }
99}
100//-----------------------------------------------------------------------------
101template<class ObjType>
103{
104 if(obj.pt() < 10.*GeV) return false;
105 if(std::abs(obj.eta()) > 2.5) return false;
106 return true;
107}
108//-----------------------------------------------------------------------------
109template<>
111{
112 // Label bjets
113 const static ort::inputDecorator_t bJetDec(m_bJetLabel);
114 bJetDec(jet) = false;
115 double mv2c10 = 0.;
117 if(btag && btag->MVx_discriminant("MV2c10", mv2c10)){
118 if(mv2c10 > -0.1416) bJetDec(jet) = true;
119 }
120 else ATH_MSG_WARNING("BTag info unavailable!");
121 if(jet.pt() < 20.*GeV) return false;
122 if(std::abs(jet.eta()) > 2.5) return false;
123 return true;
124}
125//-----------------------------------------------------------------------------
126template<>
128{
129 if(obj.pt() < 20.*GeV) return false;
130 if(std::abs(obj.eta()) > 2.5) return false;
131 return true;
132}
133
134
135//-----------------------------------------------------------------------------
136// Print object
137//-----------------------------------------------------------------------------
139 const std::string& type)
140{
143 for(auto obj : container){
144 if(selectAcc(*obj)){
145 bool overlaps = overlapAcc(*obj);
146 ATH_MSG_DEBUG(" " << type << " pt " << obj->pt()*invGeV
147 << " eta " << obj->eta() << " phi " << obj->phi()
148 << " overlaps " << overlaps);
149 }
150 }
151}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t taus
const ort::inputDecorator_t bJetDec(bJetLabel)
const ort::outputAccessor_t overlapAcc(outputLabel)
const ort::inputAccessor_t selectAcc(inputLabel)
constexpr float invGeV
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode execute()
Execute the algorithm.
virtual StatusCode initialize()
Initialize the algorithm.
std::string m_selectionLabel
Configuration.
void applySelection(const ContainerType &container)
Simple object selection.
OverlapRemovalTestAlg(const std::string &name, ISvcLocator *svcLoc)
Standard algorithm constructor.
ToolHandle< ORUtils::IOverlapRemovalTool > m_orTool
Handle to the tool.
bool selectObject(const ObjType &obj)
Simple object selection.
void printObjects(const xAOD::IParticleContainer &container, const std::string &type)
Print object info.
SG::AuxElement::ConstAccessor< inputFlag_t > inputAccessor_t
Input object accessor.
SG::AuxElement::Decorator< inputFlag_t > inputDecorator_t
Input object decorator (for convenience if users want it)
SG::AuxElement::ConstAccessor< outputFlag_t > outputAccessor_t
Output object accessor (for convenience)
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".
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".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.