ATLAS Offline Software
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 
11 namespace
12 {
14  const float GeV = 1000.;
15 }
16 
17 //-----------------------------------------------------------------------------
18 // Constructor
19 //-----------------------------------------------------------------------------
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
45 
46  return StatusCode::SUCCESS;
47 }
48 
49 //-----------------------------------------------------------------------------
50 // Execute the algorithm
51 //-----------------------------------------------------------------------------
53 {
54  ATH_MSG_INFO( "Executing " << name() );
55 
56  // Electrons
58  ATH_CHECK( evtStore()->retrieve(electrons, "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") );
67  applySelection(*taus);
68  // Jets
69  const xAOD::JetContainer* jets = 0;
70  ATH_CHECK( evtStore()->retrieve(jets, "AntiKt4EMTopoJets") );
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 //-----------------------------------------------------------------------------
86 template<class ContainerType>
87 void ORToolBoxTestAlg::applySelection(const ContainerType& container)
88 {
89  const static ort::inputDecorator_t selDec(m_flags.inputLabel);
90  for(auto obj : container){
91  selDec(*obj) = selectObject(*obj);
92  }
93 }
94 //-----------------------------------------------------------------------------
95 template<class ObjType>
96 bool 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 //-----------------------------------------------------------------------------
103 template<>
104 bool ORToolBoxTestAlg::selectObject<xAOD::Jet>(const xAOD::Jet& jet)
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 //-----------------------------------------------------------------------------
120 template<>
121 bool ORToolBoxTestAlg::selectObject<xAOD::TauJet>(const xAOD::TauJet& obj)
122 {
123  if(obj.pt() < 20.*GeV) return false;
124  if(std::abs(obj.eta()) > 2.5) return false;
125  return true;
126 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
BTaggingUtilities.h
ORToolBoxTestAlg.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ORToolBoxTestAlg::applySelection
void applySelection(const ContainerType &container)
Simple object selection.
Definition: ORToolBoxTestAlg.cxx:87
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ORToolBoxTestAlg::execute
virtual StatusCode execute()
Execute the algorithm.
Definition: ORToolBoxTestAlg.cxx:52
ORUtils::recommendedTools
StatusCode recommendedTools(const ORFlags &flags, ToolBox &toolBox)
Pre-configured standard recommended OR tools.
Definition: OverlapRemovalInit.cxx:50
ORToolBoxTestAlg::m_flags
ORUtils::ORFlags m_flags
The overlap removal tools' configuration flags.
Definition: ORToolBoxTestAlg.h:57
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
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:58
ORToolBoxTestAlg::ORToolBoxTestAlg
ORToolBoxTestAlg(const std::string &name, ISvcLocator *svcLoc)
Standard algorithm constructor.
Definition: ORToolBoxTestAlg.cxx:20
ORToolBoxTestAlg::selectObject
bool selectObject(const ObjType &obj)
Simple object selection.
Definition: ORToolBoxTestAlg.cxx:96
bJetDec
const ort::inputDecorator_t bJetDec(bJetLabel)
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ORUtils::ORFlags::bJetLabel
std::string bJetLabel
B-jet decoration.
Definition: OverlapRemovalInit.h:43
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
ORUtils::ToolBox::initialize
StatusCode initialize()
Attach and initialize all tools.
Definition: ToolBox.cxx:35
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgorithm
Definition: AthAlgorithm.h:47
BTaggingContainer.h
OverlapRemovalInit.h
Defines helper functions for initializing the OR tools in C++.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ORUtils::ORFlags::outputLabel
std::string outputLabel
Output decoration.
Definition: OverlapRemovalInit.h:40
ORToolBoxTestAlg::initialize
virtual StatusCode initialize()
Initialize the algorithm.
Definition: ORToolBoxTestAlg.cxx:36
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
ORUtils::ToolBox::masterTool
MasterHandle_t masterTool
Master overlap removal tool handle.
Definition: ToolBox.h:64
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
OverlapRemovalDefs.h
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
ORToolBoxTestAlg::m_toolBox
ORUtils::ToolBox m_toolBox
The overlap removal tools' toolbox.
Definition: ORToolBoxTestAlg.h:54
python.PyAthena.obj
obj
Definition: PyAthena.py:135
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
ORUtils::ORFlags::inputLabel
std::string inputLabel
Input object decoration.
Definition: OverlapRemovalInit.h:38
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
xAOD::BTagging_v1::MVx_discriminant
bool MVx_discriminant(const std::string &taggername, double &value) const
Definition: BTagging_v1.cxx:381