ATLAS Offline Software
Loading...
Searching...
No Matches
PseudoJetAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// PseudoJetAlgorithm.cxx
6
12
13// Fixed value by which to scale ghost kinematics
14constexpr float ghostscale = 1e-40;
15
16//**********************************************************************
17
19 ATH_MSG_INFO("Initializing " << name() << "...");
20
21 // This is horrible, but still necessary for the time being
22 // PJG needs to know if this is the basic EMTopo cluster collection
23 // in order to change the cluster signal state.
24 if ( m_label == "EMTopo") m_emtopo = true;
25 // PFlow containers need to have PV matching applied
26 if ( std::string(m_label).find("PFlow") != std::string::npos) m_pflow = true;
27 if ( std::string(m_label).find("UFO") != std::string::npos) m_ufo = true;
28
29 // "Ghost" in output collection name? If so is a ghost collection.
30 m_isGhost = (m_outcoll.key()).find("Ghost") != std::string::npos;
31
32 print();
33
34 if(m_incoll.key().empty() || m_outcoll.key().empty()) {
35 ATH_MSG_ERROR("Either input or output collection is empty!");
36 return StatusCode::FAILURE;
37 }
38
39 ATH_CHECK( m_incoll.initialize() );
40 ATH_CHECK( m_outcoll.initialize() );
41
43
44 return StatusCode::SUCCESS;
45}
46
47
48//**********************************************************************
49
50StatusCode PseudoJetAlgorithm::execute(const EventContext& ctx) const {
51 ATH_MSG_VERBOSE("Executing " << name() << "...");
52
53 // build and record the container
54 auto incoll = SG::makeHandle(m_incoll, ctx);
55 if( !incoll.isValid() ) {
56 // Return SUCCESS to avoid crashing T0 jobs
57 ATH_MSG_WARNING("Failed to retrieve " << m_incoll.key() << " for PseudoJet creation!" );
58 return StatusCode::SUCCESS;
59 }
60 ATH_MSG_DEBUG("Retrieved xAOD container " << m_incoll.key() << " of size " << incoll->size()
61 << ", isGhost=" << m_isGhost);
62
63 ATH_MSG_DEBUG("Creating PseudoJetContainer...");
64 std::unique_ptr<PseudoJetContainer> pjcont( createPJContainer(*incoll, ctx) );
65
66 auto outcoll = SG::makeHandle(m_outcoll, ctx);
67 ATH_MSG_DEBUG("Created new PseudoJetContainer \"" << m_outcoll.key() << "\" with size " << pjcont->size());
68
69 ATH_CHECK( outcoll.record(std::move(pjcont)) );
70
71 return StatusCode::SUCCESS;
72}
73
74
75std::unique_ptr<PseudoJetContainer> PseudoJetAlgorithm::createPJContainer(const xAOD::IParticleContainer& cont, const EventContext& ctx) const {
76 // create PseudoJets
77 std::vector<fastjet::PseudoJet> vpj;
78
79 #ifndef GENERATIONBASE
80 if (m_byVertex){
82 vpj = createPseudoJets(cont, pvs.cptr());
83 }
84 else{
85 vpj = createPseudoJets(cont);
86 }
87 #else
88 [[maybe_unused]] const EventContext& unused_ctx = ctx;
89 vpj = createPseudoJets(cont);
90 #endif
91
92 // create an extractor to attach to the PJContainer -- this will be used by clients
93 auto extractor = std::make_unique<IParticleExtractor>(&cont, m_label, m_isGhost);
94 ATH_MSG_DEBUG("Created extractor: " << extractor->toString(0));
95
96 // ghostify the pseudojets if necessary
97 if(m_isGhost){
98 for(fastjet::PseudoJet& pj : vpj) {pj *= ghostscale;}
99 }
100
101 // Put the PseudoJetContainer together
102 auto pjcont = std::make_unique<PseudoJetContainer>(std::move(extractor), vpj);
103 ATH_MSG_DEBUG("New PseudoJetContainer size " << pjcont->size());
104
105 return pjcont;
106}
107
108
109std::vector<fastjet::PseudoJet>
111#ifndef GENERATIONBASE
114#endif
116}
117
118#ifndef GENERATIONBASE
119std::vector<fastjet::PseudoJet>
123#endif
124
125//**********************************************************************
126
128 std::string sskip = m_skipNegativeEnergy ? "true" : "false";
129 // May want to change to DEBUG
130 ATH_MSG_INFO("Properties for PseudoJetGetter " << name());
131 ATH_MSG_INFO(" Label: " << m_label);
132 ATH_MSG_INFO(" Input container: " << m_incoll.key());
133 ATH_MSG_INFO(" Output container: " << m_outcoll.key());
134 ATH_MSG_INFO(" Skip negative E: " << sskip);
135 ATH_MSG_INFO(" Is EMTopo: " << m_emtopo);
136 ATH_MSG_INFO(" Is PFlow: " << m_pflow);
137 ATH_MSG_INFO(" Is UFO: " << m_ufo);
138 ATH_MSG_INFO(" Is ghost: " << m_isGhost);
139 ATH_MSG_INFO(" Treat negative E as ghost: " << m_negEnergyAsGhosts.value());
140 ATH_MSG_INFO(" Running by-vertex reco: " << m_byVertex.value());
141 ATH_MSG_INFO(" Vertex input container: " << m_vertexContainer_key.key());
142
143 if(m_pflow){
144 ATH_MSG_INFO(" Use charged FEs: " << m_useCharged.value());
145 ATH_MSG_INFO(" Use neutral FEs: " << m_useNeutral.value());
146 ATH_MSG_INFO("Use charged PV FEs: " << m_useChargedPV.value());
147 ATH_MSG_INFO(" PU sideband def: " << m_useChargedPUsideband.value());
148 }
149 if(m_ufo){
150 ATH_MSG_INFO(" Use charged UFOs: " << m_useCharged.value());
151 ATH_MSG_INFO(" Use neutral UFOs: " << m_useNeutral.value());
152 }
153}
154
155//**********************************************************************
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
constexpr float ghostscale
Gaudi::Property< bool > m_useNeutral
Flag to define if neutral PFOs / FEs should be considered.
bool m_pflow
True if inputs are EM-scale topo clusters.
Gaudi::Property< bool > m_useChargedPV
Flag to define if charged PFOs / FEs should be matched to PV.
std::vector< fastjet::PseudoJet > createPseudoJets(const xAOD::IParticleContainer &) const
bool m_ufo
True if inputs are PFlow.
Gaudi::Property< std::string > m_label
Label for the collection.
Gaudi::Property< bool > m_useChargedPUsideband
Flag for PFlow sideband definition.
Gaudi::Property< bool > m_useCharged
Flag to define if charged PFOs / FEs should be considered.
SG::WriteHandleKey< PseudoJetContainer > m_outcoll
Output collection name.
bool m_emtopo
Determines whether the PJs should be made ghosts.
bool m_isGhost
Internal steering flags Set in initialize()
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
Gaudi::Property< bool > m_skipNegativeEnergy
Flag indicating to skip objects with E<0.
virtual std::unique_ptr< PseudoJetContainer > createPJContainer(const xAOD::IParticleContainer &cont, const EventContext &ctx) const
Method to construct the PseudoJetContainer and record in StoreGate.
Gaudi::Property< bool > m_byVertex
Flag for by-vertex jet reconstruction.
virtual void print() const
Dump to properties to the log.
virtual StatusCode execute(const EventContext &ctx) const override final
virtual StatusCode initialize() override final
Athena algorithm's Hooks.
Gaudi::Property< bool > m_negEnergyAsGhosts
Flag indicating to treat objects with E<0 as ghosts (useful for HI)
SG::ReadHandleKey< xAOD::IParticleContainer > m_incoll
Input collection name.
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
std::vector< fastjet::PseudoJet > EMToposToPJs(const xAOD::IParticleContainer &ips, bool skipNegativeEnergy)
std::vector< fastjet::PseudoJet > PFlowsToPJs(const xAOD::IParticleContainer &ips, bool skipNegativeEnergy, bool useChargedPFOs, bool useNeutralPFOs, bool useChargedPV, bool useChargedPUsideband, bool isUFO)
std::vector< fastjet::PseudoJet > IParticlesToPJs(const xAOD::IParticleContainer &ips, bool skipNegativeEnergy)
std::vector< fastjet::PseudoJet > ByVertexPFlowsToPJs(const xAOD::IParticleContainer &ips, const xAOD::VertexContainer *pvs, bool skipNegativeEnergy, bool useChargedPFOs, bool useNeutralPFOs, bool isUFO)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.