ATLAS Offline Software
OfflineObjectDecorHelper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
13 #include "TrackParametersHelper.h"
14 
15 namespace IDTPM {
16 
19  const std::string& quality ) {
20  std::string decoName = "LinkedElectron_" + quality;
21  return getLinkedObject< xAOD::ElectronContainer >( track, decoName );
22  }
23 
24 
27  const std::string& quality ) {
28  std::string decoName = "LinkedMuon_" + quality;
29  return getLinkedObject< xAOD::MuonContainer >( track, decoName );
30  }
31 
32 
35  const int requiredNtracks,
36  const std::string& type,
37  const std::string& quality ) {
38  std::string decoName = "LinkedTau" + type +
39  std::to_string( requiredNtracks ) + "_" + quality;
40  return getLinkedObject< xAOD::TauJetContainer >( track, decoName );
41  }
42 
43 
46  const xAOD::TruthParticle* truth = getLinkedObject< xAOD::TruthParticleContainer >(
47  track, "truthParticleLink" );
48  return ( truth == nullptr );
49  }
50 
51 
54  static const SG::ConstAccessor< float > truthMatchProbabilityAcc( "truthMatchProbability" );
55  return truthMatchProbabilityAcc.withDefault( track, -1 );
56  }
57 
60  const float truthProbCut ) {
61  float prob = getTruthMatchProb( track );
62  if( std::isnan(prob) ) return nullptr;
63  if( prob <= truthProbCut ) return nullptr;
64 
65  return getLinkedObject< xAOD::TruthParticleContainer >(
66  track, "truthParticleLink" );
67  }
68 
70  bool isFakeTruth( const xAOD::TrackParticle& track, const float truthProbCut, const bool unlinkedAsFakes )
71  {
73  if( unlinkedAsFakes and isUnlinkedTruth( track ) ) return true;
74  float prob = getTruthMatchProb( track );
77  return ( prob < truthProbCut );
78  }
79 
81  bool isReconstructable( const xAOD::TruthParticle& truth, const std::vector<unsigned int>& minSilHits, const std::vector<float>& etaBins)
82  {
83  // Get eta bin
84  float absEta = std::abs(truth.eta());
85  absEta = std::clamp(absEta, etaBins.front(), etaBins.back());
86  const auto pVal = std::lower_bound(etaBins.begin(), etaBins.end(), absEta);
87  const unsigned int bin = std::distance(etaBins.begin(), pVal) - 1;
88  return ( nSiHits(truth) >= minSilHits.at( bin ) );
89  }
90 
91 } // namespace IDTPM
IDTPM::getTruthMatchProb
float getTruthMatchProb(const xAOD::TrackParticle &track)
getTruthMatchProb
Definition: OfflineObjectDecorHelper.cxx:53
IDTPM::getLinkedTau
const xAOD::TauJet * getLinkedTau(const xAOD::TrackParticle &track, const int requiredNtracks, const std::string &type, const std::string &quality)
getLinkedTau
Definition: OfflineObjectDecorHelper.cxx:34
IDTPM::getLinkedTruth
const xAOD::TruthParticle * getLinkedTruth(const xAOD::TrackParticle &track, const float truthProbCut)
getLinkedTruth
Definition: OfflineObjectDecorHelper.cxx:59
ConvertOldUJHistosToNewHistos.etaBins
list etaBins
Definition: ConvertOldUJHistosToNewHistos.py:145
bin
Definition: BinsDiffFromStripMedian.h:43
IDTPM::getLinkedElectron
const xAOD::Electron * getLinkedElectron(const xAOD::TrackParticle &track, const std::string &quality)
getLinkedElectron
Definition: OfflineObjectDecorHelper.cxx:18
SG::ConstAccessor< float >
covarianceTool.prob
prob
Definition: covarianceTool.py:678
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
TrackParametersHelper.h
Utility methods to access track/truth particles parmeters in a consitent way in this package.
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
IDTPM::getLinkedMuon
const xAOD::Muon * getLinkedMuon(const xAOD::TrackParticle &track, const std::string &quality)
getLinkedMuon
Definition: OfflineObjectDecorHelper.cxx:26
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
xAOD::TruthParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TruthParticle_v1.cxx:174
xAOD::Electron_v1
Definition: Electron_v1.h:34
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TauGNNUtils::Variables::absEta
bool absEta(const xAOD::TauJet &tau, double &out)
Definition: TauGNNUtils.cxx:234
IDTPM::isReconstructable
bool isReconstructable(const xAOD::TruthParticle &truth, const std::vector< unsigned int > &minSilHits, const std::vector< float > &etaBins)
isReconstructable
Definition: OfflineObjectDecorHelper.cxx:81
IDTPM::isFakeTruth
bool isFakeTruth(const xAOD::TrackParticle &track, const float truthProbCut, const bool unlinkedAsFakes)
isFake
Definition: OfflineObjectDecorHelper.cxx:70
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
OfflineObjectDecorHelper.h
Utility methods to access offline object decorations.
IDTPM
Athena include(s).
Definition: IPlotsDefinitionSvc.h:25
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
IDTPM::isUnlinkedTruth
bool isUnlinkedTruth(const xAOD::TrackParticle &track)
isUnlinkedTruth
Definition: OfflineObjectDecorHelper.cxx:45
IDTPM::nSiHits
float nSiHits(const U &p)
Definition: TrackParametersHelper.h:399
SG::ConstAccessor::withDefault
const_reference_type withDefault(const ELT &e, const T &deflt) const
Fetch the variable for one element, as a const reference, with a default.