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 #ifdef FLOATING_POINT_SIMULATION
92 WTAConeJetMaker->m_GEPWTAParameters.SetConstEtCut(m_WTAConstEtCut * Athena::Units::GeV); // Set ConstEtCut to 2GeV
93 WTAConeJetMaker->m_GEPWTAParameters.SetSeedEtCut(m_WTASeedEtCut * Athena::Units::GeV); // Set SeedEtCut to 5GeV by default
94 WTAConeJetMaker->m_GEPWTAParameters.SetJet_dR(m_WTAJet_dR);
95 WTAConeJetMaker->m_GEPWTAParameters.SetIso_dR(m_WTAJet_dR); // Default is Jet_dR = Iso_dR
96 #else
97 // float to int/bitwise conversion
98 WTAConeJetMaker->m_GEPWTAParameters.SetConstEtCut(static_cast<unsigned int>(m_WTAConstEtCut * Athena::Units::GeV / LSB)); // Set ConstEtCut to 8 bits, LSB = 250 MeV
99 WTAConeJetMaker->m_GEPWTAParameters.SetSeedEtCut(static_cast<unsigned int>(m_WTASeedEtCut * Athena::Units::GeV / LSB)); // Set SeedEtCut to 20 bits by default
100 WTAConeJetMaker->m_GEPWTAParameters.SetJet_dR(static_cast<unsigned int>(m_WTAJet_dR * 10));
101 WTAConeJetMaker->m_GEPWTAParameters.SetIso_dR(static_cast<unsigned int>(m_WTAJet_dR * 10));
102 #endif
103
104 WTAConeJetMaker->m_GEPWTAParameters.SetMaxConstN(m_WTAMaxConstN);
105 WTAConeJetMaker->m_GEPWTAParameters.SetMaxSeedSortingN(m_WTAMaxSeedSortingN);
106 WTAConeJetMaker->SetBlockN(m_WTABlockN);
107
108 WTAConeJetMaker->SetSeedCleaningAlgo(0); // 0 = Baseline
109 if(m_WTASeedCleaningName=="TwoPass")WTAConeJetMaker->SetSeedCleaningAlgo(1); // 1 = TwoPass
110
111 jetMaker = std::move(WTAConeJetMaker);
112 } // WTACone loop, will be updated as the WTAConeJets
113 else {
114 ATH_MSG_ERROR( "Unknown JetMaker " << m_jetAlgName);
115 return StatusCode::FAILURE;
116 }
117
118 ATH_MSG_DEBUG( "jet maker: " << jetMaker->toString());
119
120 std::vector<Gep::Jet> gepJets = jetMaker->makeJets( gepClusters );
121
122 ATH_MSG_DEBUG("Number of jets found for " <<
123 m_jetAlgName << " " <<gepJets.size());
124
125 // if no jets were found, skip event
126 if( gepJets.empty() ){
127 return StatusCode::SUCCESS;
128 }
129
130 // store gep jets in athena format
131 for(const auto& gjet: gepJets){
132
133 std::unique_ptr<xAOD::Jet> xAODJet{new xAOD::Jet()};
134 xAOD::Jet* p_xAODJet = xAODJet.get();
135
136 // store the xAOD::Jet in the output container to prepare the Aux container
137 // The move invalids the unique_ptr, but we still have the bare pointer
138 // which allows the updating of the xAODJet from the gep jet data.
139 h_outputJets->push_back(std::move(xAODJet));
140
142 p4.SetPt(gjet.vec.Pt());
143 p4.SetEta(gjet.vec.Eta());
144 p4.SetPhi(gjet.vec.Phi());
145 p4.SetM(gjet.vec.M());
146
147 p_xAODJet->setJetP4(p4);
148
149 p_xAODJet->setAttribute("RCut", gjet.radius);
150 p_xAODJet->setAttribute("SeedEta", gjet.seedEta); // < gep attributes
151 p_xAODJet->setAttribute("SeedPhi", gjet.seedPhi); //
152 p_xAODJet->setAttribute("SeedEt", gjet.seedEt); //
153 p_xAODJet->setAttribute("Ring0_Et", gjet.ring0_Et);
154 p_xAODJet->setAttribute("Ring1_Et", gjet.ring1_Et);
155 p_xAODJet->setAttribute("Ring2_Et", gjet.ring2_Et);
156 p_xAODJet->setAttribute("Ring3_Et", gjet.ring3_Et);
157 p_xAODJet->setAttribute("Ring4_Et", gjet.ring4_Et);
158 p_xAODJet->setAttribute("Total_TobN", gjet.total_TobN);
159 p_xAODJet->setAttribute("Ring0_TobN", gjet.ring0_TobN);
160 p_xAODJet->setAttribute("Ring1_TobN", gjet.ring1_TobN);
161 p_xAODJet->setAttribute("Ring2_TobN", gjet.ring2_TobN);
162 p_xAODJet->setAttribute("Ring3_TobN", gjet.ring3_TobN);
163 p_xAODJet->setAttribute("Ring4_TobN", gjet.ring4_TobN);
164
165 for (const auto& i: gjet.constituentsIndices) {
166 p_xAODJet->addConstituent(clusters.at(i));
167 }
168
169 }
170
171 return StatusCode::SUCCESS;
172}
#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.
Gaudi::Property< float > m_WTAJet_dR
Definition GepJetAlg.h:62
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< 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:113
void setJetP4(const JetFourMom_t &p4)
Definition Jet_v1.cxx:182
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