ATLAS Offline Software
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
10 #include "OverlapRemovalTestAlg.h"
11 
12 namespace
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
56  ATH_CHECK( evtStore()->retrieve(electrons, "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") );
65  applySelection(*taus);
66  // Jets
67  const xAOD::JetContainer* jets = 0;
68  ATH_CHECK( evtStore()->retrieve(jets, "AntiKt4EMTopoJets") );
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 //-----------------------------------------------------------------------------
92 template<class ContainerType>
93 void OverlapRemovalTestAlg::applySelection(const ContainerType& container)
94 {
95  const static ort::inputDecorator_t selDec(m_selectionLabel);
96  for(auto obj : container){
97  selDec(*obj) = selectObject(*obj);
98  }
99 }
100 //-----------------------------------------------------------------------------
101 template<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 //-----------------------------------------------------------------------------
109 template<>
110 bool OverlapRemovalTestAlg::selectObject<xAOD::Jet>(const xAOD::Jet& jet)
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 //-----------------------------------------------------------------------------
126 template<>
127 bool OverlapRemovalTestAlg::selectObject<xAOD::TauJet>(const xAOD::TauJet& obj)
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
BTaggingUtilities.h
OverlapRemovalTestAlg::selectObject
bool selectObject(const ObjType &obj)
Simple object selection.
Definition: OverlapRemovalTestAlg.cxx:102
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
OverlapRemovalTestAlg::applySelection
void applySelection(const ContainerType &container)
Simple object selection.
Definition: OverlapRemovalTestAlg.cxx:93
OverlapRemovalTestAlg::m_orTool
ToolHandle< ORUtils::IOverlapRemovalTool > m_orTool
Handle to the tool.
Definition: OverlapRemovalTestAlg.h:51
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
OverlapRemovalTestAlg.h
selectAcc
const ort::inputAccessor_t selectAcc(inputLabel)
OverlapRemovalTestAlg::printObjects
void printObjects(const xAOD::IParticleContainer &container, const std::string &type)
Print object info.
Definition: OverlapRemovalTestAlg.cxx:138
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
OverlapRemovalTestAlg::m_overlapLabel
std::string m_overlapLabel
Definition: OverlapRemovalTestAlg.h:55
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:58
bJetDec
const ort::inputDecorator_t bJetDec(bJetLabel)
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
OverlapRemovalTestAlg::execute
virtual StatusCode execute()
Execute the algorithm.
Definition: OverlapRemovalTestAlg.cxx:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
OverlapRemovalTestAlg::initialize
virtual StatusCode initialize()
Initialize the algorithm.
Definition: OverlapRemovalTestAlg.cxx:39
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::BTaggingUtilities::getBTagging
const BTagging * getBTagging(const SG::AuxElement &part)
Access the default xAOD::BTagging object associated to an object.
Definition: BTaggingUtilities.cxx:37
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
OverlapRemovalDefs.h
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
OverlapRemovalTestAlg::m_bJetLabel
std::string m_bJetLabel
Definition: OverlapRemovalTestAlg.h:56
OverlapRemovalTestAlg::m_selectionLabel
std::string m_selectionLabel
Configuration.
Definition: OverlapRemovalTestAlg.h:54
python.PyAthena.obj
obj
Definition: PyAthena.py:135
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
OverlapRemovalTestAlg::OverlapRemovalTestAlg
OverlapRemovalTestAlg(const std::string &name, ISvcLocator *svcLoc)
Standard algorithm constructor.
Definition: OverlapRemovalTestAlg.cxx:22
invGeV
constexpr float invGeV
Definition: PFTrackSelector.cxx:10
overlapAcc
const ort::outputAccessor_t overlapAcc(outputLabel)