ATLAS Offline Software
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
14 constexpr 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() );
41 
43 
44  return StatusCode::SUCCESS;
45 }
46 
47 
48 //**********************************************************************
49 
50 StatusCode 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 
75 std::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){
81  auto pvs = SG::makeHandle(m_vertexContainer_key, ctx);
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 
109 std::vector<fastjet::PseudoJet>
111 #ifndef GENERATIONBASE
114 #endif
116 }
117 
118 #ifndef GENERATIONBASE
119 std::vector<fastjet::PseudoJet>
122 }
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 //**********************************************************************
PseudoJetAlgorithm::m_negEnergyAsGhosts
Gaudi::Property< bool > m_negEnergyAsGhosts
Flag indicating to treat objects with E<0 as ghosts (useful for HI)
Definition: PseudoJetAlgorithm.h:79
WriteHandle.h
Handle class for recording to StoreGate.
PseudoJetAlgorithm::m_ufo
bool m_ufo
True if inputs are PFlow.
Definition: PseudoJetAlgorithm.h:103
PseudoJetGetter::PFlowsToPJs
std::vector< fastjet::PseudoJet > PFlowsToPJs(const xAOD::IParticleContainer &ips, bool skipNegativeEnergy, bool useChargedPFOs, bool useNeutralPFOs, bool useChargedPV, bool useChargedPUsideband, bool isUFO)
Definition: PseudoJetGetter.h:193
PseudoJetAlgorithm::m_skipNegativeEnergy
Gaudi::Property< bool > m_skipNegativeEnergy
Flag indicating to skip objects with E<0.
Definition: PseudoJetAlgorithm.h:76
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
PseudoJetAlgorithm::m_isGhost
bool m_isGhost
Internal steering flags Set in initialize()
Definition: PseudoJetAlgorithm.h:100
PseudoJetAlgorithm::m_vertexContainer_key
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
Definition: PseudoJetAlgorithm.h:96
PseudoJetAlgorithm::m_useChargedPUsideband
Gaudi::Property< bool > m_useChargedPUsideband
Flag for PFlow sideband definition.
Definition: PseudoJetAlgorithm.h:91
PseudoJetAlgorithm::print
virtual void print() const
Dump to properties to the log.
Definition: PseudoJetAlgorithm.cxx:127
PseudoJetGetter.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
PseudoJetAlgorithm::createPJContainer
virtual std::unique_ptr< PseudoJetContainer > createPJContainer(const xAOD::IParticleContainer &cont, const EventContext &ctx) const
Method to construct the PseudoJetContainer and record in StoreGate.
Definition: PseudoJetAlgorithm.cxx:75
PseudoJetAlgorithm::createPseudoJets
std::vector< fastjet::PseudoJet > createPseudoJets(const xAOD::IParticleContainer &) const
Definition: PseudoJetAlgorithm.cxx:110
PseudoJetAlgorithm::initialize
virtual StatusCode initialize() override final
Athena algorithm's Hooks.
Definition: PseudoJetAlgorithm.cxx:18
PseudoJetAlgorithm::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: PseudoJetAlgorithm.cxx:50
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
PseudoJetAlgorithm::m_useCharged
Gaudi::Property< bool > m_useCharged
Flag to define if charged PFOs / FEs should be considered.
Definition: PseudoJetAlgorithm.h:82
PseudoJetAlgorithm::m_useNeutral
Gaudi::Property< bool > m_useNeutral
Flag to define if neutral PFOs / FEs should be considered.
Definition: PseudoJetAlgorithm.h:85
PseudoJetAlgorithm.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PseudoJetGetter::EMToposToPJs
std::vector< fastjet::PseudoJet > EMToposToPJs(const xAOD::IParticleContainer &ips, bool skipNegativeEnergy)
Definition: PseudoJetGetter.h:88
ghostscale
constexpr float ghostscale
Definition: PseudoJetAlgorithm.cxx:14
PseudoJetGetter::ByVertexPFlowsToPJs
std::vector< fastjet::PseudoJet > ByVertexPFlowsToPJs(const xAOD::IParticleContainer &ips, const xAOD::VertexContainer *pvs, bool skipNegativeEnergy, bool useChargedPFOs, bool useNeutralPFOs, bool isUFO)
Definition: PseudoJetGetter.h:217
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
PseudoJetAlgorithm::m_outcoll
SG::WriteHandleKey< PseudoJetContainer > m_outcoll
Output collection name.
Definition: PseudoJetAlgorithm.h:70
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PseudoJetAlgorithm::m_byVertex
Gaudi::Property< bool > m_byVertex
Flag for by-vertex jet reconstruction.
Definition: PseudoJetAlgorithm.h:94
PseudoJetAlgorithm::m_pflow
bool m_pflow
True if inputs are EM-scale topo clusters.
Definition: PseudoJetAlgorithm.h:102
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
PseudoJetAlgorithm::m_label
Gaudi::Property< std::string > m_label
Label for the collection.
Definition: PseudoJetAlgorithm.h:73
PseudoJetAlgorithm::m_emtopo
bool m_emtopo
Determines whether the PJs should be made ghosts.
Definition: PseudoJetAlgorithm.h:101
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ReadHandle.h
Handle class for reading from StoreGate.
PseudoJetAlgorithm::m_incoll
SG::ReadHandleKey< xAOD::IParticleContainer > m_incoll
Input collection name.
Definition: PseudoJetAlgorithm.h:67
PseudoJetGetter::IParticlesToPJs
std::vector< fastjet::PseudoJet > IParticlesToPJs(const xAOD::IParticleContainer &ips, bool skipNegativeEnergy)
Definition: PseudoJetGetter.h:51
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
PseudoJetContainer::size
std::size_t size() const
Definition: PseudoJetContainer.cxx:440
PseudoJetAlgorithm::m_useChargedPV
Gaudi::Property< bool > m_useChargedPV
Flag to define if charged PFOs / FEs should be matched to PV.
Definition: PseudoJetAlgorithm.h:88
IParticleExtractor.h