ATLAS Offline Software
Loading...
Searching...
No Matches
PhotonVertexSelectionAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// PhotonVertexSelectionAlg.cxx
6
13
14namespace CP {
15
16 using std::string;
17 using namespace xAOD;
18
19 //**********************************************************************
20
22 ISvcLocator* pSvcLocator )
23 : ::AthAlgorithm( name, pSvcLocator ),
24 m_vxSelTool("CP::PhotonVertexSelectionTool/PhotonVtxSel")
25 {
26 declareProperty( "InputVertices", m_inVxColl ="PrimaryVertices" );
27 declareProperty( "InputPhotons", m_inGamColl="Photons" );
28 declareProperty( "OutputVertices", m_outVxColl="HggPrimaryVertices" );
29 declareProperty( "VxSelTool", m_vxSelTool );
30
31 }
32
33 //**********************************************************************
34
36
37 //**********************************************************************
38
40 ATH_MSG_INFO("Initializing " << name() << "...");
41
42 return StatusCode::SUCCESS;
43 }
44
45 //**********************************************************************
46
48 ATH_MSG_INFO ("Finalizing " << name() << "...");
49
50 return StatusCode::SUCCESS;
51 }
52
53 //**********************************************************************
54
56 ATH_MSG_VERBOSE("Executing " << name() << "...");
57
60 vxOut->setStore(vxOutAux);
61 vxOut->push_back(new Vertex);
62 // Immediately add one vertex, because we will always want one in the container.
63 // Strictly speaking, if the event has no vertex, this could wind up being a dummy.
64 ATH_CHECK( evtStore()->record(vxOut, m_outVxColl) );
65 ATH_CHECK( evtStore()->record(vxOutAux, m_outVxColl+"Aux.") );
66
67 const PhotonContainer* photons(nullptr);
68 ATH_CHECK( evtStore()->retrieve(photons, m_inGamColl) );
69
71 for(const auto *const ph : *photons) {
72 if(acceptPhoton(*ph)) photons_presel.push_back( ph );
73 }
74
75 const Vertex* photonVx(nullptr);
76 if( m_vxSelTool->getVertex(*photons_presel.asDataVector(), photonVx).isSuccess() && photonVx) {
77 *vxOut->front() = *photonVx; // deep copy of photon vertex, to record
79 } else {
80 const VertexContainer* vxIn(nullptr);
81 ATH_CHECK( evtStore()->retrieve(vxIn, m_inVxColl) );
82 for(const auto *const vx : *vxIn) {
83 if(vx->vertexType()==VxType::PriVtx) *vxOut->front() = *vx;
84 }
85 }
86
87 return StatusCode::SUCCESS;
88 }
89
90 //**********************************************************************
91
92 // add some reasonable preselection here a la
93 // https://svnweb.cern.ch/trac/atlasoff/browser/PhysicsAnalysis/HiggsPhys/Run2/HGamma/xAOD/HGamAnalysisFramework/trunk/Root/PhotonHandler.cxx#L511
94 bool PhotonVertexSelectionAlg::acceptPhoton(const xAOD::Photon& /*gam*/) {return true;}
95
96}
97
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
DataVector adapter that acts like it holds const pointers.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
~PhotonVertexSelectionAlg()
Destructor:
ToolHandle< CP::IPhotonVertexSelectionTool > m_vxSelTool
StatusCode initialize()
Athena algorithm's Hooks.
PhotonVertexSelectionAlg()
Default constructor:
static bool acceptPhoton(const xAOD::Photon &gam)
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const T * front() const
Access the first element in the collection as an rvalue.
void setVertexType(VxType::VertexType vType)
Set the type of the vertex.
Select isolated Photons, Electrons and Muons.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
@ PriVtx
Primary vertex.
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
Photon_v1 Photon
Definition of the current "egamma version".