ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
ElectronPhotonID
PhotonVertexSelection
src
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
7
#include "
PhotonVertexSelectionAlg.h
"
8
#include "
xAODEgamma/PhotonContainer.h
"
9
#include "
xAODTracking/VertexContainer.h
"
10
#include "
xAODTracking/VertexAuxContainer.h
"
11
#include "
AthContainers/ConstDataVector.h
"
12
#include "
PhotonVertexSelection/IPhotonVertexSelectionTool.h
"
13
14
namespace
CP
{
15
16
using
std::string;
17
using namespace
xAOD;
18
19
//**********************************************************************
20
21
PhotonVertexSelectionAlg::PhotonVertexSelectionAlg
(
const
string
&
name
,
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
35
PhotonVertexSelectionAlg::~PhotonVertexSelectionAlg
() =
default
;
36
37
//**********************************************************************
38
39
StatusCode
PhotonVertexSelectionAlg::initialize
() {
40
ATH_MSG_INFO
(
"Initializing "
<<
name
() <<
"..."
);
41
42
return
StatusCode::SUCCESS;
43
}
44
45
//**********************************************************************
46
47
StatusCode
PhotonVertexSelectionAlg::finalize
() {
48
ATH_MSG_INFO
(
"Finalizing "
<<
name
() <<
"..."
);
49
50
return
StatusCode::SUCCESS;
51
}
52
53
//**********************************************************************
54
55
StatusCode
PhotonVertexSelectionAlg::execute
(
const
EventContext&
/*ctx*/
) {
56
ATH_MSG_VERBOSE
(
"Executing "
<<
name
() <<
"..."
);
57
58
VertexContainer
* vxOut(
new
VertexContainer
);
59
VertexAuxContainer
* vxOutAux(
new
VertexAuxContainer
);
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
70
ConstDataVector<PhotonContainer>
photons_presel(
SG::VIEW_ELEMENTS
);
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
78
vxOut->
front
()->
setVertexType
(
VxType::PriVtx
);
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
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
PhotonContainer.h
IPhotonVertexSelectionTool.h
PhotonVertexSelectionAlg.h
VertexAuxContainer.h
VertexContainer.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
CP::PhotonVertexSelectionAlg::finalize
StatusCode finalize()
Definition
PhotonVertexSelectionAlg.cxx:47
CP::PhotonVertexSelectionAlg::~PhotonVertexSelectionAlg
~PhotonVertexSelectionAlg()
Destructor:
CP::PhotonVertexSelectionAlg::m_inVxColl
std::string m_inVxColl
Definition
PhotonVertexSelectionAlg.h:41
CP::PhotonVertexSelectionAlg::m_inGamColl
std::string m_inGamColl
Definition
PhotonVertexSelectionAlg.h:42
CP::PhotonVertexSelectionAlg::m_vxSelTool
ToolHandle< CP::IPhotonVertexSelectionTool > m_vxSelTool
Definition
PhotonVertexSelectionAlg.h:45
CP::PhotonVertexSelectionAlg::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
PhotonVertexSelectionAlg.cxx:55
CP::PhotonVertexSelectionAlg::m_outVxColl
std::string m_outVxColl
Definition
PhotonVertexSelectionAlg.h:43
CP::PhotonVertexSelectionAlg::initialize
StatusCode initialize()
Athena algorithm's Hooks.
Definition
PhotonVertexSelectionAlg.cxx:39
CP::PhotonVertexSelectionAlg::PhotonVertexSelectionAlg
PhotonVertexSelectionAlg()
Default constructor:
CP::PhotonVertexSelectionAlg::acceptPhoton
static bool acceptPhoton(const xAOD::Photon &gam)
Definition
PhotonVertexSelectionAlg.cxx:94
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition
ConstDataVector.h:76
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
xAOD::Vertex_v1::setVertexType
void setVertexType(VxType::VertexType vType)
Set the type of the vertex.
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition
TrackingPrimitives.h:590
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::VertexAuxContainer
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
Definition
VertexAuxContainer.h:19
xAOD::PhotonContainer
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/PhotonContainer.h:17
xAOD::VertexContainer
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Definition
VertexContainer.h:14
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition
Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
Generated on
for ATLAS Offline Software by
1.17.0