ATLAS Offline Software
JetRecAlg.cxx
Go to the documentation of this file.
1 
2 /*
3  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 // JetRecAlg.cxx
7 
8 #include <memory>
9 #include "JetRec/JetRecAlg.h"
12 
13 #if !defined (GENERATIONBASE) && !defined (XAOD_ANALYSIS)
15 #include "GaudiKernel/SystemOfUnits.h"
16 #endif
17 
18 using std::string;
19 
20 //**********************************************************************
21 
23 
24  ATH_CHECK(m_output.initialize());
25 
26  ATH_CHECK(m_jetprovider.retrieve());
27  // Some providers (e.g. copy) need the output WriteHandle
28  // to be provided during initialisation
29  ATH_CHECK(m_jetprovider->initWithOutput(m_output));
30 
31  ATH_MSG_INFO("Initialized IJetProvider : "<< m_jetprovider->name());
32 
33  ATH_MSG_INFO("Initialize .... List of modifiers: ");
34  ATH_CHECK(m_modifiers.retrieve());
35  for(const ToolHandle<IJetModifier>& t : m_modifiers){
36  ATH_MSG_INFO(" --> : "<< t->name());
37  }
38 
39  ATH_CHECK(m_output.initialize());
40 
41 #if !defined (GENERATIONBASE) && !defined (XAOD_ANALYSIS)
42  if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
43 #endif
44 
45  return StatusCode::SUCCESS;
46 }
47 
48 //**********************************************************************
49 
50 #if !defined (GENERATIONBASE) && !defined (XAOD_ANALYSIS)
51 #define DOMONITORING
52 #endif
53 
54 StatusCode JetRecAlg::execute(const EventContext& ctx) const {
55  // Get JetContainer by running fastjet, grooming or copying existing jets...
56  // Pass in the WriteHandle so that the provider can do the record, and we
57  // needn't know the type of the jet aux container
58  // We can subsequently access the jets from the handle and don't have to
59  // worry about memory management.
60 
61 #ifdef DOMONITORING
62  auto t_total = Monitored::Timer<std::chrono::milliseconds>( "TIME_jetreco" );
63  auto t_jpv = Monitored::Timer<std::chrono::milliseconds>( "TIME_jetprovider" );
64  auto t_mod = Monitored::Timer<std::chrono::milliseconds>( "TIME_jetmod" );
65 #endif
66 
68 
69  // Define a scope to ease monitoring of the JetProvider action
70  {
71 #ifdef DOMONITORING
72  Monitored::ScopedTimer time_provider(t_jpv);
73 #endif
74  ATH_CHECK( m_jetprovider->getAndRecordJets(jetContHandle) );
75  ATH_MSG_DEBUG("Created jet container of size "<< (*jetContHandle).size() << " | writing to "<< m_output.key() );
76  }
77 
78  // Define a scope to ease monitoring of the JetModifier action
79  {
80 #ifdef DOMONITORING
81  Monitored::ScopedTimer time_modifiers(t_mod);
82 #endif
83  ATH_MSG_DEBUG("Applying jet modifiers to " << m_output.key());
84  // Calculate moments, calibrate, sort, filter... -----------
85  for(const ToolHandle<IJetModifier>& t : m_modifiers){
86  ATH_MSG_DEBUG("Running " << t.name());
87  ATH_CHECK(t->modify(*jetContHandle));
88  }
89  }
90 
91 #ifdef DOMONITORING
92  // monitor jet multiplicity and basic jet kinematics
93  auto njets = Monitored::Scalar<int>("JET_n");
94  njets = jetContHandle->size();
95  constexpr float invGeV = 1./Gaudi::Units::GeV;
96  auto pt = Monitored::Collection("JET_pt", *jetContHandle, [c=invGeV]( const xAOD::Jet* jet ) { return jet->pt()*c; });
97  auto et = Monitored::Collection("JET_et", *jetContHandle, [c=invGeV]( const xAOD::Jet* jet ) { return jet->p4().Et()*c; });
98  auto mass = Monitored::Collection("JET_m", *jetContHandle, [c=invGeV]( const xAOD::Jet* jet ) { return jet->m()*c; });
99  auto eta = Monitored::Collection("JET_eta", *jetContHandle, []( const xAOD::Jet* jet ) { return jet->eta(); });
100  auto phi = Monitored::Collection("JET_phi", *jetContHandle, []( const xAOD::Jet* jet ) { return jet->phi(); });
101 
102  auto mon = Monitored::Group(m_monTool,t_total,t_jpv,t_mod,njets,pt,et,mass,eta,phi);
103 #endif
104 
105 
106  return StatusCode::SUCCESS;
107 
108 }
109 
110 //**********************************************************************
111 
et
Extra patterns decribing particle interation process.
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
JetRecAlg::initialize
StatusCode initialize() override
Athena algorithm's Hooks.
Definition: JetRecAlg.cxx:22
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
JetRecAlg::m_modifiers
ToolHandleArray< IJetModifier > m_modifiers
Definition: JetRecAlg.h:47
JetRecAlg::m_jetprovider
ToolHandle< IJetProvider > m_jetprovider
Athena configured tools.
Definition: JetRecAlg.h:46
test_pyathena.pt
pt
Definition: test_pyathena.py:11
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
JetRecAlg::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: JetRecAlg.h:50
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
IJetExecuteTool.h
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
JetRecAlg::m_output
SG::WriteHandleKey< xAOD::JetContainer > m_output
Definition: JetRecAlg.h:48
JetRecAlg.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
plotBeamSpotMon.mon
mon
Definition: plotBeamSpotMon.py:67
JetAuxContainer.h
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
Monitored::ScopedTimer
Helper class to create a scoped timer.
Definition: MonitoredTimer.h:95
JetRecAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: JetRecAlg.cxx:54
python.compressB64.c
def c
Definition: compressB64.py:93
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32
invGeV
constexpr float invGeV
Definition: PFTrackSelector.cxx:10