ATLAS Offline Software
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 
15 // input and output types
16 #include "./Cluster.h"
17 #include "./Jet.h"
18 
21 
22 GepJetAlg::GepJetAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
23  AthReentrantAlgorithm( name, pSvcLocator ){
24 
25 }
26 
27 
29  ATH_MSG_INFO ("Initializing " << name() << "...");
30  ATH_MSG_INFO ("Jet alg " << m_jetAlgName);
31 
32  // Initialize data access keys
34  CHECK(m_jFexSRJetsKey.initialize());
35  CHECK(m_outputGepJetsKey.initialize());
36 
37  return StatusCode::SUCCESS;
38 }
39 
40 
41 StatusCode GepJetAlg::execute(const EventContext& context) const {
42  ATH_MSG_DEBUG ("Executing " << name() << "...");
43 
44 
46  h_outputJets = SG::makeHandle(m_outputGepJetsKey, context);
47 
48 
49  CHECK(h_outputJets.record(std::make_unique<xAOD::JetContainer>(),
50  std::make_unique<xAOD::JetAuxContainer>()));
51 
52  // read in clusters
53  auto h_caloClusters = SG::makeHandle(m_caloClustersKey, context);
54  CHECK(h_caloClusters.isValid());
55  ATH_MSG_DEBUG("Read in " << h_caloClusters->size() << " clusters");
56 
57  const auto& clusters = *h_caloClusters;
58 
59 
60 
61  std::vector<Gep::Cluster> gepClusters;
62  std::transform(clusters.cbegin(),
63  clusters.cend(),
64  std::back_inserter(gepClusters),
65  [](const auto& cluster){
66  return Gep::Cluster(cluster->p4());});
67 
68 
69 
70  // create a jet maker
71  std::unique_ptr<Gep::IJetMaker> jetMaker{};
72 
73 
74  if ( m_jetAlgName=="ModAntikT" ) {
75  jetMaker.reset(new Gep::ModAntikTJetMaker());
76  }
77 
78  else if ( m_jetAlgName=="Cone" ) {
79 
80  // Use jJFexSR RoIs as seeds
81  auto h_seeds = SG::makeHandle(m_jFexSRJetsKey, context);
82  CHECK(h_seeds.isValid());
83  ATH_MSG_DEBUG("No of seeds "<< h_seeds->size());
84  jetMaker.reset(new Gep::ConeJetMaker(0.4, *h_seeds));
85 
86  } else {
87  ATH_MSG_ERROR( "Unknown JetMaker " << m_jetAlgName);
88  return StatusCode::FAILURE;
89  }
90 
91  ATH_MSG_DEBUG( "jet maker: " << jetMaker->toString());
92 
93  std::vector<Gep::Jet> gepJets = jetMaker->makeJets( gepClusters );
94 
95  ATH_MSG_DEBUG("Number of jets found for " <<
96  m_jetAlgName << " " <<gepJets.size());
97 
98  // if no jets were found, skip event
99  if( gepJets.empty() ){
100  return StatusCode::SUCCESS;
101  }
102 
103  // store gep jets in athena format
104  for(const auto& gjet: gepJets){
105 
106  std::unique_ptr<xAOD::Jet> xAODJet{new xAOD::Jet()};
107  xAOD::Jet* p_xAODJet = xAODJet.get();
108 
109  // store the xAOD::Jet in the output container to prepare the Aux container
110  // The move invalids the unique_ptr, but we still have the bare pointer
111  // which allows the updating of the xAODJet from the gep jet data.
112  h_outputJets->push_back(std::move(xAODJet));
113 
115  p4.SetPt(gjet.vec.Pt());
116  p4.SetEta(gjet.vec.Eta());
117  p4.SetPhi(gjet.vec.Phi());
118  p4.SetM(gjet.vec.M());
119 
120  p_xAODJet->setJetP4(p4);
121 
122  p_xAODJet->setAttribute("RCut", gjet.radius);
123  p_xAODJet->setAttribute("SeedEta", gjet.seedEta); // < gep attributes
124  p_xAODJet->setAttribute("SeedPhi", gjet.seedPhi); //
125  p_xAODJet->setAttribute("SeedEt", gjet.seedEt); //
126 
127  for (const auto& i: gjet.constituentsIndices) {
128  p_xAODJet->addConstituent(clusters.at(i));
129  }
130 
131  }
132 
133  return StatusCode::SUCCESS;
134 }
GepJetAlg::m_jFexSRJetsKey
SG::ReadHandleKey< xAOD::jFexSRJetRoIContainer > m_jFexSRJetsKey
Definition: GepJetAlg.h:45
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
GepJetAlg.h
GepJetAlg::GepJetAlg
GepJetAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GepJetAlg.cxx:22
Jet.h
Gep::ConeJetMaker
Definition: ConeJetMaker.h:23
GepJetAlg::m_outputGepJetsKey
SG::WriteHandleKey< xAOD::JetContainer > m_outputGepJetsKey
Definition: GepJetAlg.h:48
Gep::ModAntikTJetMaker
Definition: ModAntikTJetMaker.h:15
GepJetAlg::initialize
virtual StatusCode initialize() override
Definition: GepJetAlg.cxx:28
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
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:270
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
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:41
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:195
ModAntikTJetMaker.h
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:42
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
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_jetAlgName
Gaudi::Property< std::string > m_jetAlgName
Definition: GepJetAlg.h:39
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17