ATLAS Offline Software
Loading...
Searching...
No Matches
GepJetAlg.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#include "./GepJetAlg.h"
7
8// Interface to jet reconstruction objects
9#include "./IJetMaker.h"
10
11// concrete jet reconstruction classes.
12#include "./ModAntikTJetMaker.h"
13#include "./ConeJetMaker.h"
14#include "./WTAConeJetMaker.h"
15
16// input and output types
17#include "./Cluster.h"
18#include "./Jet.h"
19
22
23GepJetAlg::GepJetAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
24 AthReentrantAlgorithm( name, pSvcLocator ){
25
26}
27
28
30 ATH_MSG_INFO ("Initializing " << name() << "...");
31 ATH_MSG_INFO ("Jet alg " << m_jetAlgName);
32
33 // Initialize data access keys
34 CHECK(m_caloClustersKey.initialize());
35 CHECK(m_jFexSRJetsKey.initialize());
36 CHECK(m_outputGepJetsKey.initialize());
37
38 return StatusCode::SUCCESS;
39}
40
41
42StatusCode GepJetAlg::execute(const EventContext& context) const {
43 ATH_MSG_DEBUG ("Executing " << name() << "...");
44
45
47 h_outputJets = SG::makeHandle(m_outputGepJetsKey, context);
48
49
50 CHECK(h_outputJets.record(std::make_unique<xAOD::JetContainer>(),
51 std::make_unique<xAOD::JetAuxContainer>()));
52
53 // read in clusters
54 auto h_caloClusters = SG::makeHandle(m_caloClustersKey, context);
55 CHECK(h_caloClusters.isValid());
56 ATH_MSG_DEBUG("Read in " << h_caloClusters->size() << " clusters");
57
58 const auto& clusters = *h_caloClusters;
59
60
61
62 std::vector<Gep::Cluster> gepClusters;
63 std::transform(clusters.cbegin(),
64 clusters.cend(),
65 std::back_inserter(gepClusters),
66 [](const auto& cluster){
67 return Gep::Cluster(cluster->p4());});
68
69
70
71 // create a jet maker
72 std::unique_ptr<Gep::IJetMaker> jetMaker{};
73
74
75 if ( m_jetAlgName=="ModAntikT" ) {
76 jetMaker.reset(new Gep::ModAntikTJetMaker());
77 }
78
79 else if ( m_jetAlgName=="Cone" ) {
80
81 // Use jJFexSR RoIs as seeds
82 auto h_seeds = SG::makeHandle(m_jFexSRJetsKey, context);
83 CHECK(h_seeds.isValid());
84 ATH_MSG_DEBUG("No of seeds "<< h_seeds->size());
85 jetMaker.reset(new Gep::ConeJetMaker(0.4, *h_seeds));
86
87 } else if(m_jetAlgName=="WTACone"){ // Large block for the WTACone
88
89 auto WTAConeJetMaker = std::make_unique<Gep::WTAConeJetMaker>(); // Default parameters for now
90
91 WTAConeJetMaker->m_GEPWTAParameters.SetConstEtCut(m_WTAConstEtCut * Athena::Units::GeV); // Set ConstEtCut to 2GeV
92 WTAConeJetMaker->m_GEPWTAParameters.SetSeedEtCut(m_WTASeedEtCut * Athena::Units::GeV); // Set SeedEtCut to 5GeV by default
93 WTAConeJetMaker->m_GEPWTAParameters.SetJet_dR2(m_WTAJet_dR2);
94 WTAConeJetMaker->m_GEPWTAParameters.SetIso_dR2(m_WTAJet_dR2); // Default is Jet_dR2 = Iso_dR2
95 WTAConeJetMaker->m_GEPWTAParameters.SetMaxConstN(m_WTAMaxConstN);
96 WTAConeJetMaker->m_GEPWTAParameters.SetMaxSeedSortingN(m_WTAMaxSeedSortingN);
97 WTAConeJetMaker->SetBlockN(m_WTABlockN);
98
99 WTAConeJetMaker->SetSeedCleaningAlgo(0); // 0 = Baseline
100 if(m_WTASeedCleaningName=="TwoPass")WTAConeJetMaker->SetSeedCleaningAlgo(1); // 1 = TwoPass
101
102 jetMaker = std::move(WTAConeJetMaker);
103 } // WTACone loop, will be updated as the WTAConeJets
104 else {
105 ATH_MSG_ERROR( "Unknown JetMaker " << m_jetAlgName);
106 return StatusCode::FAILURE;
107 }
108
109 ATH_MSG_DEBUG( "jet maker: " << jetMaker->toString());
110
111 std::vector<Gep::Jet> gepJets = jetMaker->makeJets( gepClusters );
112
113 ATH_MSG_DEBUG("Number of jets found for " <<
114 m_jetAlgName << " " <<gepJets.size());
115
116 // if no jets were found, skip event
117 if( gepJets.empty() ){
118 return StatusCode::SUCCESS;
119 }
120
121 // store gep jets in athena format
122 for(const auto& gjet: gepJets){
123
124 std::unique_ptr<xAOD::Jet> xAODJet{new xAOD::Jet()};
125 xAOD::Jet* p_xAODJet = xAODJet.get();
126
127 // store the xAOD::Jet in the output container to prepare the Aux container
128 // The move invalids the unique_ptr, but we still have the bare pointer
129 // which allows the updating of the xAODJet from the gep jet data.
130 h_outputJets->push_back(std::move(xAODJet));
131
133 p4.SetPt(gjet.vec.Pt());
134 p4.SetEta(gjet.vec.Eta());
135 p4.SetPhi(gjet.vec.Phi());
136 p4.SetM(gjet.vec.M());
137
138 p_xAODJet->setJetP4(p4);
139
140 p_xAODJet->setAttribute("RCut", gjet.radius);
141 p_xAODJet->setAttribute("SeedEta", gjet.seedEta); // < gep attributes
142 p_xAODJet->setAttribute("SeedPhi", gjet.seedPhi); //
143 p_xAODJet->setAttribute("SeedEt", gjet.seedEt); //
144
145 for (const auto& i: gjet.constituentsIndices) {
146 p_xAODJet->addConstituent(clusters.at(i));
147 }
148
149 }
150
151 return StatusCode::SUCCESS;
152}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer > m_jFexSRJetsKey
Definition GepJetAlg.h:48
Gaudi::Property< float > m_WTASeedEtCut
Definition GepJetAlg.h:59
Gaudi::Property< float > m_WTAConstEtCut
Definition GepJetAlg.h:56
Gaudi::Property< std::string > m_jetAlgName
Definition GepJetAlg.h:42
virtual StatusCode initialize() override
Definition GepJetAlg.cxx:29
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClustersKey
Definition GepJetAlg.h:45
virtual StatusCode execute(const EventContext &) const override
Definition GepJetAlg.cxx:42
Gaudi::Property< std::string > m_WTASeedCleaningName
Definition GepJetAlg.h:74
Gaudi::Property< unsigned int > m_WTABlockN
Definition GepJetAlg.h:71
Gaudi::Property< float > m_WTAJet_dR2
Definition GepJetAlg.h:62
Gaudi::Property< unsigned int > m_WTAMaxConstN
Definition GepJetAlg.h:65
Gaudi::Property< unsigned int > m_WTAMaxSeedSortingN
Definition GepJetAlg.h:68
SG::WriteHandleKey< xAOD::JetContainer > m_outputGepJetsKey
Definition GepJetAlg.h:51
GepJetAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition GepJetAlg.cxx:23
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void setAttribute(const std::string &name, const T &v)
void addConstituent(const ElementLink< IParticleContainer > &link, float weight=1.0)
Add a constituent directly in the ElementLink format.
Definition Jet_v1.cxx:111
void setJetP4(const JetFourMom_t &p4)
Definition Jet_v1.cxx:171
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Jet_v1 Jet
Definition of the current "jet version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17