17#include "GaudiKernel/EventContext.h"
29 return StatusCode::FAILURE;
35 return StatusCode::FAILURE;
41 return StatusCode::FAILURE;
49 return StatusCode::SUCCESS;
66 for(
const auto *
const el : *electrons ){
72 return StatusCode::SUCCESS;
77 std::vector<float>& trkMatchTrk,
87 const auto *prodVtx = truthPart->
prodVtx();
89 Amg::Vector3D pos( prodVtx->x(), prodVtx->y(), prodVtx->z() );
94 float etaAtCalo, phiAtCalo;
99 trkMatchTrk.push_back( cluster->
etaBE(2) - etaAtCalo );
108 std::vector<float>& trkMatchTrk,
116 for(
unsigned int i(0); i<trkMatchTrk.size(); ++i ){
117 trkMatchTrk[i] = -999;
120 std::array<double,4>
eta = { -999.0, -999.0, -999.0, -999.0 };
121 std::array<double,4>
phi = { -999.0, -999.0, -999.0, -999.0 };
122 std::array<double,4> deltaEta = { -999.0, -999.0, -999.0, -999.0 };
123 std::array<double,4>
deltaPhi = { -999.0, -999.0, -999.0, -999.0 };
125 std::pair<std::vector<CaloSampling::CaloSample>,
126 std::vector<std::unique_ptr<Trk::Surface>>>
131 ->getMatchAtCalo(ctx,
134 layersAndSurfaces.first,
135 layersAndSurfaces.second,
143 trkMatchTrk[0] = deltaEta[1];
144 trkMatchTrk[1] = deltaEta[2];
150 ->getMatchAtCalo(ctx,
153 layersAndSurfaces.first,
154 layersAndSurfaces.second,
162 trkMatchTrk[4] = deltaEta[1];
163 trkMatchTrk[5] = deltaEta[2];
171 layersAndSurfaces.first,
172 layersAndSurfaces.second,
191 return nPix + nPix_DS + nSCT + nSCT_DS;
197 std::vector<float> trkMatchTrkP_dEta1(el->nTrackParticles(),-999);
198 std::vector<float> trkMatchTrkP_dEta2(el->nTrackParticles(),-999);
199 std::vector<float> trkMatchTrkP_dPhi1(el->nTrackParticles(),-999);
200 std::vector<float> trkMatchTrkP_dPhi2(el->nTrackParticles(),-999);
201 std::vector<float> trkMatchTrkLM_dEta1(el->nTrackParticles(),-999);
202 std::vector<float> trkMatchTrkLM_dEta2(el->nTrackParticles(),-999);
203 std::vector<float> trkMatchTrkLM_dPhi1(el->nTrackParticles(),-999);
204 std::vector<float> trkMatchTrkLM_dPhi2(el->nTrackParticles(),-999);
205 std::vector<float> trkMatchTrkR_dPhi2(el->nTrackParticles(),-999);
207 std::vector<float> trueMatch_dEta2(el->nTrackParticles(),-999);
208 std::vector<float> trueMatch_dPhi2(el->nTrackParticles(),-999);
210 const auto *caloCluster = el->caloCluster();
211 if( caloCluster && caloCluster->pt() >
m_minET ){
212 std::vector<float> trkMatch(9,-999);
213 for(
unsigned int i(0); i < el->nTrackParticles(); ++i ){
214 const auto *trackParticle = el->trackParticle( i );
217 trkMatchTrkP_dEta1[i] = trkMatch[0];
218 trkMatchTrkP_dEta2[i] = trkMatch[1];
219 trkMatchTrkP_dPhi1[i] = trkMatch[2];
220 trkMatchTrkP_dPhi2[i] = trkMatch[3];
221 trkMatchTrkLM_dEta1[i] = trkMatch[4];
222 trkMatchTrkLM_dEta2[i] = trkMatch[5];
223 trkMatchTrkLM_dPhi1[i] = trkMatch[6];
224 trkMatchTrkLM_dPhi2[i] = trkMatch[7];
225 trkMatchTrkR_dPhi2[i] = trkMatch[8];
229 if( trkMatch.size() == 2 ){
230 trueMatch_dEta2[i] = trkMatch[0];
231 trueMatch_dPhi2[i] = trkMatch[1];
249 TrackMatchingP_dEta1Dec(*el) = trkMatchTrkP_dEta1;
250 TrackMatchingP_dEta2Dec(*el) = trkMatchTrkP_dEta2;
251 TrackMatchingP_dPhi1Dec(*el) = trkMatchTrkP_dPhi1;
252 TrackMatchingP_dPhi2Dec(*el) = trkMatchTrkP_dPhi2;
253 TrackMatchingLM_dEta1Dec(*el) = trkMatchTrkLM_dEta1;
254 TrackMatchingLM_dEta2Dec(*el) = trkMatchTrkLM_dEta2;
255 TrackMatchingLM_dPhi1Dec(*el) = trkMatchTrkLM_dPhi1;
256 TrackMatchingLM_dPhi2Dec(*el) = trkMatchTrkLM_dPhi2;
257 TrackMatchingR_dPhi2Dec(*el) = trkMatchTrkR_dPhi2;
258 TrackMatchingTrue_dEta2Dec(*el) = trueMatch_dEta2;
259 TrackMatchingTrue_dPhi2Dec(*el) = trueMatch_dPhi2;
264 const auto *caloCluster = el->caloCluster();
266 std::vector<float> subCluster_E;
267 std::vector<float> subCluster_dEta;
268 std::vector<float> subCluster_dPhi;
271 if(caloCluster && clusterLinksAcc.
isAvailable(*caloCluster) ){
272 std::vector<ElementLink<xAOD::CaloClusterContainer> > clusterLinks = clusterLinksAcc(*caloCluster);
273 for(
const auto& link : clusterLinks){
274 if( link.isValid() ){
275 subCluster_E.push_back( (*link)->e() );
276 subCluster_dEta.push_back( caloCluster->eta() - (*link)->eta() );
278 subCluster_dPhi.push_back(dphi);
285 SubCluster_EDec(*el) = subCluster_E;
286 SubCluster_dEtaDec(*el) = subCluster_dEta;
287 SubCluster_dPhiDec(*el) = subCluster_dPhi;
293 const auto *caloCluster = el->caloCluster();
299 int vtxTrkParticleIndex1 = -999;
300 int vtxTrkParticleIndex2 = -999;
301 float vtxTrkParticle1_dEta2 = -999;
302 float vtxTrkParticle1_dPhi2 = -999;
303 float vtxTrkParticle2_dEta2 = -999;
304 float vtxTrkParticle2_dPhi2 = -999;
305 float vtxRerr = -999;
306 float vtxZerr = -999;
307 float vtxMerr = -999;
308 float vtxPerr = -999;
309 float vtxChi2 = -999;
311 float vtxdEta = -999;
312 float vtxdPhi = -999;
317 if( caloCluster && caloCluster->pt() >
m_minET ){
320 int trkIndex1 = -999;
321 int trkIndex2 = -999;
322 for(
unsigned int i(0); i < el->nTrackParticles(); ++i ){
323 const auto *trackParticle = el->trackParticle( i );
325 if ( trk1 ==
nullptr ){
326 trk1 = trackParticle;
328 }
else if( trk2 ==
nullptr ){
329 if( trk1->
charge() == trackParticle->charge() )
331 trk2 = trackParticle;
337 if( trk2 !=
nullptr){
344 std::vector<const xAOD::TrackParticle*> trksToFit;
345 trksToFit.push_back( trk1 );
346 trksToFit.push_back( trk2 );
347 vtxTrkParticleIndex1 = trkIndex1;
348 vtxTrkParticleIndex2 = trkIndex2;
350 std::unique_ptr<xAOD::Vertex> myVertex(
m_VertexFitter->fit( ctx, trksToFit, startingPoint ) );
355 vtxRerr =
m_V0Tools->rxyError( myVertex.get() );
356 vtxZ = myVertex->z();
357 vtxZerr = myVertex->covariancePosition()(2,2) > 0 ? sqrt( myVertex->covariancePosition()(2,2) ): myVertex->covariancePosition()(2,2);
359 std::vector<double> masses = { 0.511e-3, 0.511e-3 };
360 vtxM =
m_V0Tools->invariantMass( myVertex.get(), masses);
361 vtxMerr =
m_V0Tools->invariantMassError( myVertex.get(), masses);
364 vtxPerr =
m_V0Tools->pTError( myVertex.get() );
366 vtxChi2 = myVertex->chiSquared();
367 vtxNdof = myVertex->numberDoF();
372 vtxdEta -= caloCluster->etaBE(2);
376 vtxPhi = vertex4P.Phi();
377 vtxEta = vertex4P.Eta();
378 double momentumScaleFactor = caloCluster->e() / vtxE;
383 mom *= momentumScaleFactor;
386 float etaAtCalo, phiAtCalo;
391 vtxTrkParticle1_dEta2 = caloCluster->etaBE(2) - etaAtCalo;
396 pos = perigeeParameters2.position();
397 mom = perigeeParameters2.momentum();
398 mom *= momentumScaleFactor;
405 vtxTrkParticle2_dEta2 = caloCluster->etaBE(2) - etaAtCalo;
439 vtxRerrDec(*el) = vtxRerr;
441 vtxZerrDec(*el) = vtxZerr;
443 vtxMerrDec(*el) = vtxMerr;
444 vtxPtDec(*el) = vtxP;
445 vtxPterrDec(*el)= vtxPerr;
447 vtxEtaDec(*el) = vtxEta;
448 vtxPhiDec(*el) = vtxPhi;
449 vtxTrkParticleIndex1Dec(*el) = vtxTrkParticleIndex1;
450 vtxTrkParticleIndex2Dec(*el) = vtxTrkParticleIndex2;
451 vtxTrkParticle1_dPhi2Dec(*el) = vtxTrkParticle1_dPhi2;
452 vtxTrkParticle1_dEta2Dec(*el) = vtxTrkParticle1_dEta2;
453 vtxTrkParticle2_dPhi2Dec(*el) = vtxTrkParticle2_dPhi2;
454 vtxTrkParticle2_dEta2Dec(*el) = vtxTrkParticle2_dEta2;
455 vtxChi2Dec(*el) = vtxChi2;
456 vtxNdofDec(*el) = vtxNdof;
457 vtxdEtaDec(*el) = vtxdEta;
458 vtxdPhiDec(*el) = vtxdPhi;
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
Helper class to provide type-safe access to aux data.
This class provides the client interface for accessing the detector description information common to...
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
static void fillClusterDetails(const xAOD::Electron *el)
void fillTrackDetails(const EventContext &ctx, const xAOD::Electron *el, bool isMC) const
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
PublicToolHandle< IEMExtrapolationTools > m_emExtrapolationTool
void fillTruthDetails(const EventContext &ctx, std::vector< float > &trkMatchTrk, const xAOD::TrackParticle *tp, const xAOD::CaloCluster *cluster) const
PublicToolHandle< Trk::V0Tools > m_V0Tools
static int nSiHits(const xAOD::TrackParticle *tp)
PublicToolHandle< Trk::IVertexFitter > m_VertexFitter
Gaudi::Property< float > m_minET
virtual StatusCode addBranches(const EventContext &ctx) const override final
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronKey
virtual StatusCode initialize() override final
void fillMatchDetails(const EventContext &ctx, std::vector< float > &trkMatchTrk, const xAOD::TrackParticle *tp, const xAOD::CaloCluster *cluster) const
void fillVertexDetails(const EventContext &ctx, const xAOD::Electron *el) const
Helper class to provide type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
float phiBE(const unsigned layer) const
Get the phi in one layer of the EM Calo.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
@ IS_SIMULATION
true: simulation, false: data
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.
bool summaryValue(uint8_t &value, const SummaryType &information) const
Accessor for TrackSummary values.
float charge() const
Returns the charge.
bool hasProdVtx() const
Check for a production vertex on this particle.
float px() const
The x component of the particle's momentum.
const TruthVertex_v1 * prodVtx() const
The production vertex of this particle.
float py() const
The y component of the particle's momentum.
double charge() const
Physical charge.
float pz() const
The z component of the particle's momentum.
Eigen::Matrix< double, 3, 1 > Vector3D
bool passBLayerRequirement(const xAOD::TrackParticle &tp)
return true if effective number of BL hits + outliers is at least one
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
constexpr double electronMassInMeV
the mass of the electron (in MeV)
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
@ numberOfSCTDeadSensors
number of dead SCT sensors crossed [unit8_t].
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
@ numberOfPixelDeadSensors
number of dead pixel sensors crossed [unit8_t].
Electron_v1 Electron
Definition of the current "egamma version".