40{
42
44
45 if (!PV->empty() && PV->at(0)) {
46 ATH_MSG_DEBUG(
"Default PV " << PV->at(0) <<
", type = " << PV->at(0)->vertexType() <<
" , z = " << PV->at(0)->z() );
47 }
48
49
50
51 SG::ReadHandle<xAOD::PhotonContainer> photons (
m_photonKey, ctx);
53
55 {
57 if (not ph1 or ph->pt() > ph1->
pt())
58 {
59 ph2 = ph1;
60 ph1 = ph;
61 }
62 else if (not ph2 or ph->pt() > ph2->pt()) ph2 = ph;
63 }
64
65 const ConstDataVector< xAOD::PhotonContainer > vertexPhotons = {ph1, ph2};
66
69
71
72
73 std::vector<std::pair<const xAOD::Vertex*, float> > vxResult;
75
78 for(const auto *const fe : *FEHandle) passORDec(*fe) = true;
79
80 if (ph1 and ph2)
81 {
83 if(!vxResult.empty()) {
84 newPV = vxResult[0].first;
85 }
88 }
89
90
91 ATH_MSG_DEBUG(
"PhotonVertexSelection returns vertex " << newPV <<
" " << (newPV? Form(
" with z = %g", newPV->
z()) :
"") );
92
95 HggPV.second->setShallowIO(false);
96
98 ATH_CHECK(vertexContainer.recordNonConst(std::move(HggPV.first),
99 std::move(HggPV.second)));
100
101
102 static const SG::Accessor<float> vertexScoreAcc("vertexScore");
103 static const SG::Accessor<int> vertexFailTypeAcc("vertexFailType");
104 static const SG::Accessor<int> vertexCaseAcc("vertexCase");
107
108 if (newPV) {
109
110 for (unsigned int iPV=0; iPV<PV->size(); iPV++) {
111 const auto *vx = PV->at(iPV);
112 auto yyvx = vertexContainer->at(iPV);
113
114 if (vx == newPV) {
115
118
120 }
121
122 for (const auto& vxR: vxResult) {
123
124 if ( vx == vxR.first ) {
125 vertexScoreAcc(*yyvx) = vxR.second;
126 vertexFailTypeAcc(*yyvx) = vertexFailType;
127 vertexCaseAcc(*yyvx) = yyvertexVtxType;
128 leadingPhotonLinkAcc(*yyvx) =
phlink_t(*photons, ph1->index());
129 subleadingPhotonLinkAcc(*yyvx) =
phlink_t(*photons, ph2->index());
130 break;
131 }
132 }
133 }
134 }
135 else {
136
139 for(yyvx_itr = vertexContainer->begin(); yyvx_itr != yyvx_end; ++yyvx_itr ) {
141 vertexScoreAcc(**yyvx_itr) = -9999;
142 vertexFailTypeAcc(**yyvx_itr) = vertexFailType;
143 vertexCaseAcc(**yyvx_itr) = yyvertexVtxType;
144 leadingPhotonLinkAcc(**yyvx_itr) = (
phlink_t()) ;
145 subleadingPhotonLinkAcc(**yyvx_itr) = (
phlink_t());
146 }
147 }
148 }
149
150
151 if( !evtStore()->transientContains< xAOD::VertexContainer >(
m_diphotonVertexKey.key() ) ){
153 }
154
155 return StatusCode::SUCCESS;
156}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
ElementLink< xAOD::PhotonContainer > phlink_t
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
DataModel_detail::iterator< DataVector > iterator
SG::ReadHandleKey< xAOD::PhotonContainer > m_photonKey
bool PhotonPreselect(const xAOD::Photon *ph) const
SG::ReadHandleKey< xAOD::FlowElementContainer > m_FEContainerHandleKey
SG::WriteHandleKey< xAOD::VertexContainer > m_diphotonVertexKey
Gaudi::Property< bool > m_ignoreConv
SG::ReadHandleKey< xAOD::VertexContainer > m_primaryVertexKey
ToolHandle< CP::IPhotonVertexSelectionTool > m_photonVertexSelectionTool
StatusCode matchFlowElement(const xAOD::Photon *eg, const xAOD::FlowElementContainer *pfoCont) const
virtual double pt() const override final
The transverse momentum ( ) of the particle.
float z() const
Returns the z position.
SG::Accessor< T, ALLOC > Accessor
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
typename ShallowCopyResult< T >::type ShallowCopyResult_t
Return type of xAOD::shallowCopy.
Vertex_v1 Vertex
Define the latest version of the vertex class.
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
Photon_v1 Photon
Definition of the current "egamma version".