15 #include "CLHEP/Units/SystemOfUnits.h"
31 const IInterface*
p) :
37 declareProperty(
"MaxEta",
m_maxEta = 2.37);
39 declareProperty(
"IgnoreConvPointing",
m_ignoreConv =
false);
52 ATH_CHECK( m_photonVertexSelectionTool.retrieve() );
53 ATH_CHECK( m_primaryVertexKey.initialize() );
55 ATH_CHECK( m_diphotonVertexKey.initialize() );
56 ATH_CHECK( m_FEContainerHandleKey.initialize() );
57 return StatusCode::SUCCESS;
62 return StatusCode::SUCCESS;
72 if (!PV->
empty() && PV->
at(0)) {
73 ATH_MSG_DEBUG(
"Default PV " << PV->
at(0) <<
", type = " << PV->
at(0)->vertexType() <<
" , z = " << PV->
at(0)->z() );
83 if (!PhotonPreselect(ph))
continue;
84 if (not ph1 or ph->
pt() > ph1->
pt())
89 else if (not ph2 or ph->pt() > ph2->pt()) ph2 = ph;
97 ATH_CHECK( m_photonVertexSelectionTool->decorateInputs(*(vertexPhotons.
asDataVector()), &vertexFailType) );
100 std::vector<std::pair<const xAOD::Vertex*, float> > vxResult;
105 for(
const auto *
const fe : *FEHandle) passORDec(*fe) =
true;
109 vxResult = m_photonVertexSelectionTool->getVertex( *( vertexPhotons.
asDataVector()) , m_ignoreConv,
true, &yyvertexVtxType, &vertexFailType );
110 if(!vxResult.empty()) {
111 newPV = vxResult[0].first;
113 ATH_CHECK(matchFlowElement(ph1,&*FEHandle));
114 ATH_CHECK(matchFlowElement(ph2,&*FEHandle));
118 ATH_MSG_DEBUG(
"PhotonVertexSelection returns vertex " << newPV <<
" " << (newPV? Form(
" with z = %g", newPV->
z()) :
"") );
121 HggPV.second->setShallowIO(
false);
125 std::unique_ptr< xAOD::ShallowAuxContainer >(HggPV.second)));
136 for (
unsigned int iPV=0; iPV<PV->
size(); iPV++) {
137 const auto *vx = PV->
at(iPV);
138 auto yyvx = (HggPV.first)->at(iPV);
148 for (
const auto& vxR: vxResult) {
150 if ( vx == vxR.first ) {
151 vertexScoreAcc(*yyvx) = vxR.second;
152 vertexFailTypeAcc(*yyvx) = vertexFailType;
153 vertexCaseAcc(*yyvx) = yyvertexVtxType;
154 leadingPhotonLinkAcc(*yyvx) =
phlink_t(*photons, ph1->
index());
155 subleadingPhotonLinkAcc(*yyvx) =
phlink_t(*photons, ph2->index());
165 for(yyvx_itr = (HggPV.first)->begin(); yyvx_itr != yyvx_end; ++yyvx_itr ) {
167 vertexScoreAcc(**yyvx_itr) = -9999;
168 vertexFailTypeAcc(**yyvx_itr) = vertexFailType;
169 vertexCaseAcc(**yyvx_itr) = yyvertexVtxType;
170 leadingPhotonLinkAcc(**yyvx_itr) = (
phlink_t()) ;
171 subleadingPhotonLinkAcc(**yyvx_itr) = (
phlink_t());
178 ATH_MSG_WARNING(
"Unable to find transient xAOD::VertexContainer, \"" << m_diphotonVertexKey.key() <<
"\"");
181 return StatusCode::SUCCESS;
187 if (!ph)
return false;
189 if (!ph->
isGoodOQ(34214))
return false;
197 val =
static_cast<bool>(DFCommonPhotonsIsEMLooseAcc(*ph));
203 if(!defined || !
val)
return false;
210 double eta = std::abs(caloCluster->
etaBE(2));
212 if (eta > m_maxEta)
return false;
213 if (m_removeCrack && 1.37 <= eta && eta <= 1.52)
return false;
215 if (ph->
pt() < m_minPhotonPt)
return false;
225 std::vector<const xAOD::FlowElement*> nearbyFE;
226 nearbyFE.reserve(20);
227 for(
const auto *
const fe : *feCont) {
229 if( ( !fe->isCharged() && fe->e() > FLT_MIN )) nearbyFE.push_back(fe);
235 double eg_cl_e = swclus->
e();
239 std::sort(nearbyFE.begin(),nearbyFE.end(),greaterPtFlowElement);
240 for(
const auto& fe : nearbyFE) {
243 double fe_e = fe->e();
245 if(fe_e>m_tcMatch_maxRat*eg_cl_e) {
246 ATH_MSG_VERBOSE(
"Reject topocluster in sum. Ratio vs eg cluster: " << (fe_e/eg_cl_e));
247 if( !bestbadmatch || (std::abs(fe_e/eg_cl_e-1.) < std::abs(bestbadmatch->
e()/eg_cl_e-1.)) ) bestbadmatch = fe;
251 ATH_MSG_VERBOSE(
"E match with new nFE: " << std::abs(sumE_fe+fe_e - eg_cl_e) / eg_cl_e);
252 if( (doSum = std::abs(sumE_fe+fe_e-eg_cl_e) < std::abs(sumE_fe - eg_cl_e)) ) {
253 passORDec(*fe) =
false;
258 if(sumE_fe<FLT_MIN && bestbadmatch) {
259 passORDec(*bestbadmatch) =
false;
262 return StatusCode::SUCCESS;