20 #include "GaudiKernel/EventContext.h"
28 m_emExtrapolationTool(
"EMExtrapolationTools"),
29 m_VertexFitter(
"Trk::TrkVkalVrtFitter"),
30 m_V0Tools(
"Trk::V0Tools"),
33 declareInterface<DerivationFramework::IAugmentationTool>(
this);
49 return StatusCode::FAILURE;
55 return StatusCode::FAILURE;
61 return StatusCode::FAILURE;
69 return StatusCode::SUCCESS;
73 return StatusCode::SUCCESS;
78 const EventContext& ctx = Gaudi::Hive::currentContext();
96 return StatusCode::SUCCESS;
110 const auto *prodVtx = truthPart->
prodVtx();
117 const EventContext& ctx = Gaudi::Hive::currentContext();
118 float etaAtCalo, phiAtCalo;
119 if( m_emExtrapolationTool->getEtaPhiAtCalo ( ctx,
123 trkMatchTrk.push_back( cluster->
etaBE(2) - etaAtCalo );
139 for(
unsigned int i(0);
i<trkMatchTrk.size(); ++
i ){
140 trkMatchTrk[
i] = -999;
143 std::array<double,4> eta = { -999.0, -999.0, -999.0, -999.0 };
144 std::array<double,4> phi = { -999.0, -999.0, -999.0, -999.0 };
145 std::array<double,4>
deltaEta = { -999.0, -999.0, -999.0, -999.0 };
146 std::array<double,4>
deltaPhi = { -999.0, -999.0, -999.0, -999.0 };
148 const EventContext& ctx = Gaudi::Hive::currentContext();
149 std::pair<std::vector<CaloSampling::CaloSample>,
150 std::vector<std::unique_ptr<Trk::Surface>>>
152 m_emExtrapolationTool->getClusterLayerSurfaces(*cluster, *caloDDMgr);
154 if (m_emExtrapolationTool
155 ->getMatchAtCalo(ctx,
158 layersAndSurfaces.first,
159 layersAndSurfaces.second,
173 if (m_emExtrapolationTool
174 ->getMatchAtCalo(ctx,
177 layersAndSurfaces.first,
178 layersAndSurfaces.second,
192 if(m_emExtrapolationTool->getMatchAtCalo ( ctx,
195 layersAndSurfaces.first,
196 layersAndSurfaces.second,
215 return nPix + nPix_DS + nSCT + nSCT_DS;
221 std::vector<float> trkMatchTrkP_dEta1(
el->nTrackParticles(),-999);
222 std::vector<float> trkMatchTrkP_dEta2(
el->nTrackParticles(),-999);
223 std::vector<float> trkMatchTrkP_dPhi1(
el->nTrackParticles(),-999);
224 std::vector<float> trkMatchTrkP_dPhi2(
el->nTrackParticles(),-999);
225 std::vector<float> trkMatchTrkLM_dEta1(
el->nTrackParticles(),-999);
226 std::vector<float> trkMatchTrkLM_dEta2(
el->nTrackParticles(),-999);
227 std::vector<float> trkMatchTrkLM_dPhi1(
el->nTrackParticles(),-999);
228 std::vector<float> trkMatchTrkLM_dPhi2(
el->nTrackParticles(),-999);
229 std::vector<float> trkMatchTrkR_dPhi2(
el->nTrackParticles(),-999);
231 std::vector<float> trueMatch_dEta2(
el->nTrackParticles(),-999);
232 std::vector<float> trueMatch_dPhi2(
el->nTrackParticles(),-999);
234 const auto *caloCluster =
el->caloCluster();
235 if( caloCluster && caloCluster->pt() > m_minET ){
236 std::vector<float> trkMatch(9,-999);
237 for(
unsigned int i(0);
i <
el->nTrackParticles(); ++
i ){
238 const auto *trackParticle =
el->trackParticle(
i );
240 fillMatchDetails( trkMatch, trackParticle, caloCluster);
241 trkMatchTrkP_dEta1[
i] = trkMatch[0];
242 trkMatchTrkP_dEta2[
i] = trkMatch[1];
243 trkMatchTrkP_dPhi1[
i] = trkMatch[2];
244 trkMatchTrkP_dPhi2[
i] = trkMatch[3];
245 trkMatchTrkLM_dEta1[
i] = trkMatch[4];
246 trkMatchTrkLM_dEta2[
i] = trkMatch[5];
247 trkMatchTrkLM_dPhi1[
i] = trkMatch[6];
248 trkMatchTrkLM_dPhi2[
i] = trkMatch[7];
249 trkMatchTrkR_dPhi2[
i] = trkMatch[8];
252 fillTruthDetails( trkMatch, trackParticle, caloCluster );
253 if( trkMatch.size() == 2 ){
254 trueMatch_dEta2[
i] = trkMatch[0];
255 trueMatch_dPhi2[
i] = trkMatch[1];
273 TrackMatchingP_dEta1Dec(*
el) = trkMatchTrkP_dEta1;
274 TrackMatchingP_dEta2Dec(*
el) = trkMatchTrkP_dEta2;
275 TrackMatchingP_dPhi1Dec(*
el) = trkMatchTrkP_dPhi1;
276 TrackMatchingP_dPhi2Dec(*
el) = trkMatchTrkP_dPhi2;
277 TrackMatchingLM_dEta1Dec(*
el) = trkMatchTrkLM_dEta1;
278 TrackMatchingLM_dEta2Dec(*
el) = trkMatchTrkLM_dEta2;
279 TrackMatchingLM_dPhi1Dec(*
el) = trkMatchTrkLM_dPhi1;
280 TrackMatchingLM_dPhi2Dec(*
el) = trkMatchTrkLM_dPhi2;
281 TrackMatchingR_dPhi2Dec(*
el) = trkMatchTrkR_dPhi2;
282 TrackMatchingTrue_dEta2Dec(*
el) = trueMatch_dEta2;
283 TrackMatchingTrue_dPhi2Dec(*
el) = trueMatch_dPhi2;
288 const auto *caloCluster =
el->caloCluster();
290 std::vector<float> subCluster_E;
291 std::vector<float> subCluster_dEta;
292 std::vector<float> subCluster_dPhi;
295 if(caloCluster && clusterLinksAcc.
isAvailable(*caloCluster) ){
296 std::vector<ElementLink<xAOD::CaloClusterContainer> > clusterLinks = clusterLinksAcc(*caloCluster);
297 for(
const auto& link : clusterLinks){
298 if( link.isValid() ){
299 subCluster_E.push_back( (*link)->e() );
300 subCluster_dEta.push_back( caloCluster->eta() - (*link)->eta() );
302 subCluster_dPhi.push_back(dphi);
309 SubCluster_EDec(*
el) = subCluster_E;
310 SubCluster_dEtaDec(*
el) = subCluster_dEta;
311 SubCluster_dPhiDec(*
el) = subCluster_dPhi;
317 const EventContext& ctx = Gaudi::Hive::currentContext();
318 const auto *caloCluster =
el->caloCluster();
324 int vtxTrkParticleIndex1 = -999;
325 int vtxTrkParticleIndex2 = -999;
326 float vtxTrkParticle1_dEta2 = -999;
327 float vtxTrkParticle1_dPhi2 = -999;
328 float vtxTrkParticle2_dEta2 = -999;
329 float vtxTrkParticle2_dPhi2 = -999;
330 float vtxRerr = -999;
331 float vtxZerr = -999;
332 float vtxMerr = -999;
333 float vtxPerr = -999;
334 float vtxChi2 = -999;
336 float vtxdEta = -999;
337 float vtxdPhi = -999;
342 if( caloCluster && caloCluster->pt() > m_minET ){
345 int trkIndex1 = -999;
346 int trkIndex2 = -999;
347 for(
unsigned int i(0);
i <
el->nTrackParticles(); ++
i ){
348 const auto *trackParticle =
el->trackParticle(
i );
350 if ( trk1 ==
nullptr ){
351 trk1 = trackParticle;
353 }
else if( trk2 ==
nullptr ){
354 if( trk1->
charge() == trackParticle->charge() )
356 trk2 = trackParticle;
362 if( trk2 !=
nullptr){
369 std::vector<const xAOD::TrackParticle*> trksToFit;
370 trksToFit.push_back( trk1 );
371 trksToFit.push_back( trk2 );
372 vtxTrkParticleIndex1 = trkIndex1;
373 vtxTrkParticleIndex2 = trkIndex2;
375 std::unique_ptr<xAOD::Vertex> myVertex( m_VertexFitter->fit( trksToFit, startingPoint ) );
379 vtxR = m_V0Tools->rxy( myVertex.get() );
380 vtxRerr = m_V0Tools->rxyError( myVertex.get() );
381 vtxZ = myVertex->
z();
382 vtxZerr = myVertex->covariancePosition()(2,2) > 0 ? sqrt( myVertex->covariancePosition()(2,2) ): myVertex->covariancePosition()(2,2);
384 std::vector<double>
masses = { 0.511e-3, 0.511e-3 };
385 vtxM = m_V0Tools->invariantMass( myVertex.get(),
masses);
386 vtxMerr = m_V0Tools->invariantMassError( myVertex.get(),
masses);
388 vtxP = m_V0Tools->pT( myVertex.get() );
389 vtxPerr = m_V0Tools->pTError( myVertex.get() );
394 m_emExtrapolationTool->getEtaPhiAtCalo( ctx, myVertex.get(), &vtxdEta, &vtxdPhi);
397 vtxdEta -= caloCluster->etaBE(2);
401 vtxPhi = vertex4P.Phi();
402 vtxEta = vertex4P.Eta();
403 double momentumScaleFactor = caloCluster->e() / vtxE;
408 mom *= momentumScaleFactor;
411 float etaAtCalo, phiAtCalo;
412 if( m_emExtrapolationTool->getEtaPhiAtCalo (ctx,
416 vtxTrkParticle1_dEta2 = caloCluster->etaBE(2) - etaAtCalo;
421 pos = perigeeParameters2.position();
422 mom = perigeeParameters2.momentum();
423 mom *= momentumScaleFactor;
426 if( m_emExtrapolationTool->getEtaPhiAtCalo (ctx,
430 vtxTrkParticle2_dEta2 = caloCluster->etaBE(2) - etaAtCalo;
464 vtxRerrDec(*
el) = vtxRerr;
466 vtxZerrDec(*
el) = vtxZerr;
468 vtxMerrDec(*
el) = vtxMerr;
469 vtxPtDec(*
el) = vtxP;
470 vtxPterrDec(*
el)= vtxPerr;
472 vtxEtaDec(*
el) = vtxEta;
473 vtxPhiDec(*
el) = vtxPhi;
474 vtxTrkParticleIndex1Dec(*
el) = vtxTrkParticleIndex1;
475 vtxTrkParticleIndex2Dec(*
el) = vtxTrkParticleIndex2;
476 vtxTrkParticle1_dPhi2Dec(*
el) = vtxTrkParticle1_dPhi2;
477 vtxTrkParticle1_dEta2Dec(*
el) = vtxTrkParticle1_dEta2;
478 vtxTrkParticle2_dPhi2Dec(*
el) = vtxTrkParticle2_dPhi2;
479 vtxTrkParticle2_dEta2Dec(*
el) = vtxTrkParticle2_dEta2;
480 vtxChi2Dec(*
el) = vtxChi2;
481 vtxNdofDec(*
el) = vtxNdof;
482 vtxdEtaDec(*
el) = vtxdEta;
483 vtxdPhiDec(*
el) = vtxdPhi;