Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
23 GepJetAlg::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
35  CHECK(m_jFexSRJetsKey.initialize());
37 
38  return StatusCode::SUCCESS;
39 }
40 
41 
42 StatusCode 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 }
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
GepJetAlg::m_jFexSRJetsKey
SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer > m_jFexSRJetsKey
Definition: GepJetAlg.h:48
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
GepJetAlg.h
WTAConeJetMaker.h
GepJetAlg::m_WTAJet_dR2
Gaudi::Property< float > m_WTAJet_dR2
Definition: GepJetAlg.h:62
GepJetAlg::m_WTAMaxSeedSortingN
Gaudi::Property< unsigned int > m_WTAMaxSeedSortingN
Definition: GepJetAlg.h:68
GepJetAlg::GepJetAlg
GepJetAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GepJetAlg.cxx:23
Jet.h
Gep::ConeJetMaker
Definition: ConeJetMaker.h:23
GepJetAlg::m_outputGepJetsKey
SG::WriteHandleKey< xAOD::JetContainer > m_outputGepJetsKey
Definition: GepJetAlg.h:51
Gep::ModAntikTJetMaker
Definition: ModAntikTJetMaker.h:15
GepJetAlg::initialize
virtual StatusCode initialize() override
Definition: GepJetAlg.cxx:29
GepJetAlg::m_WTASeedCleaningName
Gaudi::Property< std::string > m_WTASeedCleaningName
Definition: GepJetAlg.h:74
GepJetAlg::m_WTAMaxConstN
Gaudi::Property< unsigned int > m_WTAMaxConstN
Definition: GepJetAlg.h:65
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
GepJetAlg::m_WTABlockN
Gaudi::Property< unsigned int > m_WTABlockN
Definition: GepJetAlg.h:71
xAOD::Jet_v1::setJetP4
void setJetP4(const JetFourMom_t &p4)
Definition: Jet_v1.cxx:171
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
GepJetAlg::execute
virtual StatusCode execute(const EventContext &) const override
Definition: GepJetAlg.cxx:42
Cluster.h
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::Jet_v1::addConstituent
void addConstituent(const ElementLink< IParticleContainer > &link, float weight=1.0)
Add a constituent directly in the ElementLink format.
Definition: Jet_v1.cxx:111
xAOD::Jet_v1::setAttribute
void setAttribute(const std::string &name, const T &v)
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ModAntikTJetMaker.h
GepJetAlg::m_WTAConstEtCut
Gaudi::Property< float > m_WTAConstEtCut
Definition: GepJetAlg.h:56
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
IJetMaker.h
EventInfo.h
GepJetAlg::m_caloClustersKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClustersKey
Definition: GepJetAlg.h:45
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
ConeJetMaker.h
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
JetAuxContainer.h
GepJetAlg::m_WTASeedEtCut
Gaudi::Property< float > m_WTASeedEtCut
Definition: GepJetAlg.h:59
GepJetAlg::m_jetAlgName
Gaudi::Property< std::string > m_jetAlgName
Definition: GepJetAlg.h:42
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17