Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SkimmingToolEXOT5.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Based on DerivationFramework::SkimmingToolExample
7 // Author: Valentinos Christodoulou (valentinos.christodoulou@cern.ch)
9 
12 #include "xAODJet/JetContainer.h"
14 #include "xAODCore/ShallowCopy.h"
15 
16 struct DescendingPt:std::function<bool(const xAOD::IParticle*, const xAOD::IParticle*)> {
17  bool operator()(const xAOD::IParticle* l, const xAOD::IParticle* r) const {
18  return l->pt() > r->pt();
19  }
20 };
21 
22 template<typename T, typename... Args>
23 std::unique_ptr<T> make_unique(Args&&... args) {
24  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
25 }
26 
28  const std::string& n,
29  const IInterface* p) :
30  base_class(t, n, p),
31  m_ntot(0),
32  m_npass(0)
33 {
34 
35 
36  declareProperty("JetContainer", m_jetSGKey = "AntiKt4EMTopoJets");
37 
38  declareProperty("UncalibMonoJetPtCut", m_uncalibMonoJetPt = 100000.);
39  declareProperty("MonoJetPtCut", m_monoJetPt = 100000.);
40  declareProperty("LeadingJetPtCut", m_leadingJetPt = 40000.);
41  declareProperty("SubleadingJetPtCut", m_subleadingJetPt = 40000.);
42  declareProperty("DiJetMassCut", m_Mjj = 150000.);
43 }
44 
46 }
47 
49 {
50  ATH_MSG_VERBOSE("initialize() ..");
51 
52  m_jetCalibrationTool.setTypeAndName("JetCalibrationTool/EXOT5JESTool");
53  CHECK(m_jetCalibrationTool.retrieve());
54  ATH_MSG_INFO("Retrieved tool: " << m_jetCalibrationTool);
55 
56  return StatusCode::SUCCESS;
57 }
58 
60 {
61  ATH_MSG_VERBOSE("finalize() ...");
62  ATH_MSG_INFO("Processed " << m_ntot << " events, " << m_npass << " events passed filter ");
63 
64  return StatusCode::SUCCESS;
65 
66 }
67 
69 {
70 
71  m_ntot++;
72 
73  const xAOD::EventInfo* eventInfo = nullptr;
74  ATH_CHECK(evtStore()->retrieve(eventInfo), false);
75 
76  const xAOD::JetContainer* jets = nullptr;
77  ATH_CHECK(evtStore()->retrieve(jets, m_jetSGKey), false);
78 
79  bool passUncalibMonojetCut = false;
80  bool passRecoJetCuts = false;
81  bool passTruthJetCuts = false;
82 
83  std::unique_ptr<xAOD::JetContainer> recoJets = make_unique<xAOD::JetContainer>();
84  std::unique_ptr<xAOD::JetAuxContainer> recoJetsAux = make_unique<xAOD::JetAuxContainer>();
85  recoJets->setStore(recoJetsAux.get());
86 
87  std::pair<xAOD::JetContainer*, xAOD::ShallowAuxContainer*> jets_shallowCopy = xAOD::shallowCopyContainer(*jets);
88  for (const auto jet : *jets_shallowCopy.first) {
89  if (jet->pt() > 100000.) passUncalibMonojetCut = true;
90  }
91  if (m_jetCalibrationTool->applyCalibration(*jets_shallowCopy.first).isFailure()) {
92  ATH_MSG_ERROR("Problem applying jet calibration");
93  return false;
94  }
95  for (const auto jet : *jets_shallowCopy.first) {
96  xAOD::Jet* newJet = new xAOD::Jet();
97  newJet->makePrivateStore(*jet);
98  recoJets->push_back(newJet);
99  }
100  delete jets_shallowCopy.first;
101  delete jets_shallowCopy.second;
102 
103  if (recoJets->size() > 1) std::partial_sort(recoJets->begin(), recoJets->begin()+2, recoJets->end(), DescendingPt());
104  float mjj = 0;
105  if (recoJets->size() > 1) {
106  TLorentzVector jet1 = recoJets->at(0)->p4();
107  TLorentzVector jet2 = recoJets->at(1)->p4();
108  auto dijet = jet1 + jet2;
109  mjj = dijet.M();
110  }
111  if ((recoJets->size() > 0 && recoJets->at(0)->pt() > m_monoJetPt) || (recoJets->size() > 1 && recoJets->at(0)->pt() > m_leadingJetPt && recoJets->at(1)->pt() > m_subleadingJetPt && mjj > m_Mjj)) passRecoJetCuts = true;
112 
113  if (eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) {
114  const xAOD::JetContainer* truthJetContainer = nullptr;
115  ATH_CHECK(evtStore()->retrieve(truthJetContainer, "AntiKt4TruthJets"), false);
116 
117  std::unique_ptr<xAOD::JetContainer> truthJets = make_unique<xAOD::JetContainer>();
118  std::unique_ptr<xAOD::JetAuxContainer> truthJetsAux = make_unique<xAOD::JetAuxContainer>();
119  truthJets->setStore(truthJetsAux.get());
120 
121  for (const auto truthJet : *truthJetContainer) {
122  xAOD::Jet* newTruthJet = new xAOD::Jet();
123  newTruthJet->makePrivateStore(*truthJet);
124  truthJets->push_back(newTruthJet);
125  }
126 
127  if (truthJets->size() > 1) std::partial_sort(truthJets->begin(), truthJets->begin()+2, truthJets->end(), DescendingPt());
128  float truthMjj = 0;
129  if (truthJets->size() > 1) {
130  TLorentzVector truthJet1 = truthJets->at(0)->p4();
131  TLorentzVector truthJet2 = truthJets->at(1)->p4();
132  auto truthDijet = truthJet1 + truthJet2;
133  truthMjj = truthDijet.M();
134  }
135  if ((truthJets->size() > 0 && truthJets->at(0)->pt() > m_monoJetPt) || (truthJets->size() > 1 && truthJets->at(0)->pt() > m_leadingJetPt && truthJets->at(1)->pt() > m_subleadingJetPt && truthMjj > m_Mjj)) passTruthJetCuts = true;
136  }
137 
138  bool acceptEvent = passUncalibMonojetCut || passRecoJetCuts || passTruthJetCuts;
139 
140  m_npass++;
141  return acceptEvent;
142 
143 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ShallowCopy.h
beamspotman.r
def r
Definition: beamspotman.py:676
SkimmingToolEXOT5.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
python.CaloAddPedShiftConfig.args
args
Definition: CaloAddPedShiftConfig.py:45
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
DerivationFramework::SkimmingToolEXOT5::eventPassesFilter
virtual bool eventPassesFilter() const override
Definition: SkimmingToolEXOT5.cxx:68
DerivationFramework::SkimmingToolEXOT5::m_Mjj
double m_Mjj
Definition: SkimmingToolEXOT5.h:43
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Args
Definition: test_lwtnn_fastgraph.cxx:12
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
DescendingPt
Definition: SkimmingToolEXOT5.cxx:16
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
DerivationFramework::SkimmingToolEXOT5::m_subleadingJetPt
double m_subleadingJetPt
Definition: SkimmingToolEXOT5.h:42
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DerivationFramework::SkimmingToolEXOT5::finalize
virtual StatusCode finalize() override
Definition: SkimmingToolEXOT5.cxx:59
DerivationFramework::SkimmingToolEXOT5::m_monoJetPt
double m_monoJetPt
Definition: SkimmingToolEXOT5.h:40
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework::SkimmingToolEXOT5::m_jetSGKey
std::string m_jetSGKey
Definition: SkimmingToolEXOT5.h:37
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DescendingPt::operator()
bool operator()(const xAOD::IParticle *l, const xAOD::IParticle *r) const
Definition: SkimmingToolEXOT5.cxx:17
DerivationFramework::SkimmingToolEXOT5::SkimmingToolEXOT5
SkimmingToolEXOT5(const std::string &t, const std::string &n, const IInterface *p)
Definition: SkimmingToolEXOT5.cxx:27
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
DerivationFramework::SkimmingToolEXOT5::m_uncalibMonoJetPt
double m_uncalibMonoJetPt
Definition: SkimmingToolEXOT5.h:39
DerivationFramework::SkimmingToolEXOT5::initialize
virtual StatusCode initialize() override
Definition: SkimmingToolEXOT5.cxx:48
xAOD::shallowCopyContainer
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, [[maybe_unused]] const EventContext &ctx)
Function making a shallow copy of a constant container.
Definition: ShallowCopy.h:110
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
DerivationFramework::SkimmingToolEXOT5::m_leadingJetPt
double m_leadingJetPt
Definition: SkimmingToolEXOT5.h:41
JetContainer.h
JetAuxContainer.h
DerivationFramework::SkimmingToolEXOT5::~SkimmingToolEXOT5
~SkimmingToolEXOT5()
Definition: SkimmingToolEXOT5.cxx:45
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.