15 #include "CLHEP/Units/SystemOfUnits.h"
31 const IInterface*
p) :
35 declareInterface<DerivationFramework::IAugmentationTool>(
this);
53 ATH_CHECK( m_photonVertexSelectionTool.retrieve() );
54 ATH_CHECK( m_primaryVertexKey.initialize() );
56 ATH_CHECK( m_diphotonVertexKey.initialize() );
57 ATH_CHECK( m_FEContainerHandleKey.initialize() );
58 return StatusCode::SUCCESS;
63 return StatusCode::SUCCESS;
73 if (!PV->
empty() && PV->
at(0)) {
74 ATH_MSG_DEBUG(
"Default PV " << PV->
at(0) <<
", type = " << PV->
at(0)->vertexType() <<
" , z = " << PV->
at(0)->z() );
84 if (!PhotonPreselect(ph))
continue;
85 if (not ph1 or ph->
pt() > ph1->
pt())
90 else if (not ph2 or ph->pt() > ph2->pt()) ph2 = ph;
98 ATH_CHECK( m_photonVertexSelectionTool->decorateInputs(*(vertexPhotons.
asDataVector()), &vertexFailType) );
101 std::vector<std::pair<const xAOD::Vertex*, float> > vxResult;
106 for(
const auto *
const fe : *FEHandle) passORDec(*fe) =
true;
110 vxResult = m_photonVertexSelectionTool->getVertex( *( vertexPhotons.
asDataVector()) , m_ignoreConv,
true, &yyvertexVtxType, &vertexFailType );
111 if(!vxResult.empty()) {
112 newPV = vxResult[0].first;
114 ATH_CHECK(matchFlowElement(ph1,&*FEHandle));
115 ATH_CHECK(matchFlowElement(ph2,&*FEHandle));
119 ATH_MSG_DEBUG(
"PhotonVertexSelection returns vertex " << newPV <<
" " << (newPV? Form(
" with z = %g", newPV->
z()) :
"") );
122 HggPV.second->setShallowIO(
false);
126 std::unique_ptr< xAOD::ShallowAuxContainer >(HggPV.second)));
137 for (
unsigned int iPV=0; iPV<PV->
size(); iPV++) {
138 const auto *vx = PV->
at(iPV);
139 auto yyvx = (HggPV.first)->at(iPV);
149 for (
const auto& vxR: vxResult) {
151 if ( vx == vxR.first ) {
152 vertexScoreAcc(*yyvx) = vxR.second;
153 vertexFailTypeAcc(*yyvx) = vertexFailType;
154 vertexCaseAcc(*yyvx) = yyvertexVtxType;
155 leadingPhotonLinkAcc(*yyvx) =
phlink_t(*photons, ph1->
index());
156 subleadingPhotonLinkAcc(*yyvx) =
phlink_t(*photons, ph2->index());
166 for(yyvx_itr = (HggPV.first)->begin(); yyvx_itr != yyvx_end; ++yyvx_itr ) {
168 vertexScoreAcc(**yyvx_itr) = -9999;
169 vertexFailTypeAcc(**yyvx_itr) = vertexFailType;
170 vertexCaseAcc(**yyvx_itr) = yyvertexVtxType;
171 leadingPhotonLinkAcc(**yyvx_itr) = (
phlink_t()) ;
172 subleadingPhotonLinkAcc(**yyvx_itr) = (
phlink_t());
179 ATH_MSG_WARNING(
"Unable to find transient xAOD::VertexContainer, \"" << m_diphotonVertexKey.key() <<
"\"");
182 return StatusCode::SUCCESS;
188 if (!ph)
return false;
190 if (!ph->
isGoodOQ(34214))
return false;
198 val =
static_cast<bool>(DFCommonPhotonsIsEMLooseAcc(*ph));
204 if(!defined || !
val)
return false;
211 double eta = std::abs(caloCluster->
etaBE(2));
213 if (eta > m_maxEta)
return false;
214 if (m_removeCrack && 1.37 <= eta && eta <= 1.52)
return false;
216 if (ph->
pt() < m_minPhotonPt)
return false;
226 std::vector<const xAOD::FlowElement*> nearbyFE;
227 nearbyFE.reserve(20);
228 for(
const auto *
const fe : *feCont) {
230 if( ( !fe->isCharged() && fe->e() > FLT_MIN )) nearbyFE.push_back(fe);
236 double eg_cl_e = swclus->
e();
240 std::sort(nearbyFE.begin(),nearbyFE.end(),greaterPtFlowElement);
241 for(
const auto& fe : nearbyFE) {
244 double fe_e = fe->e();
246 if(fe_e>m_tcMatch_maxRat*eg_cl_e) {
247 ATH_MSG_VERBOSE(
"Reject topocluster in sum. Ratio vs eg cluster: " << (fe_e/eg_cl_e));
248 if( !bestbadmatch || (std::abs(fe_e/eg_cl_e-1.) < std::abs(bestbadmatch->
e()/eg_cl_e-1.)) ) bestbadmatch = fe;
252 ATH_MSG_VERBOSE(
"E match with new nFE: " << std::abs(sumE_fe+fe_e - eg_cl_e) / eg_cl_e);
253 if( (doSum = std::abs(sumE_fe+fe_e-eg_cl_e) < std::abs(sumE_fe - eg_cl_e)) ) {
254 passORDec(*fe) =
false;
259 if(sumE_fe<FLT_MIN && bestbadmatch) {
260 passORDec(*bestbadmatch) =
false;
263 return StatusCode::SUCCESS;