ATLAS Offline Software
TauxAODHelpers.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
9 // ==================================================================
11 {
12  return getLink<xAOD::TruthParticle>(particle, "truthParticleLink", debug);
13 }
14 
15 // ==================================================================
16 std::vector< ElementLink< xAOD::TrackParticleContainer > > xAOD::TauHelpers::allTrackParticleLinks(const xAOD::TauJet* tau){
18  return trackParticleLinksWithMask(tau, mask);
19 }
20 
21 // ==================================================================
22 std::vector< ElementLink< xAOD::TrackParticleContainer > > xAOD::TauHelpers::trackParticleLinks(const xAOD::TauJet* tau, xAOD::TauJetParameters::TauTrackFlag flag/*=xAOD::TauJetParameters::TauTrackFlag::classifiedCharged*/){
24  return trackParticleLinksWithMask(tau, mask);
25 }
26 
27 // ==================================================================
28 std::vector< ElementLink< xAOD::TrackParticleContainer > > xAOD::TauHelpers::trackParticleLinksWithMask(const xAOD::TauJet* tau, xAOD::TauTrack::TrackFlagType mask){
29  std::vector< ElementLink< xAOD::TrackParticleContainer > > links;
30  std::vector< const xAOD::TauTrack* > allTracks = tau->allTracks();
31  for ( const xAOD::TauTrack* trk : allTracks ){
32  if(trk->trackLinks().empty()) continue;
33  if(trk->flagWithMask(mask))
34  links.push_back(trk->trackLinks()[0]);
35  }
36  return links;
37 }
38 
39 
40 // ==================================================================
41 xAOD::TauTrack* xAOD::TauHelpers::tauTrackNonConst( const xAOD::TauJet* tau, xAOD::TauTrackContainer* trackCont, int index, xAOD::TauJetParameters::TauTrackFlag flag/*=xAOD::TauJetParameters::TauTrackFlag::classifiedCharged */){
43  return tauTrackNonConstWithMask(tau, trackCont, index, mask);
44 
45 }
46 
47 // ==================================================================
49  int accepted_track=0;
50  for( const ElementLink< xAOD::TauTrackContainer >& link : tau->allTauTrackLinks() ){
51  const xAOD::TauTrack* c_trk(nullptr);
52  if(link.isValid()) c_trk = *link;
53  if(c_trk==nullptr) continue;
54  if(c_trk->flagWithMask(mask)){
55 
56  if(accepted_track==index) {
57  if(dynamic_cast<const xAOD::TauTrackContainer*> (link.getStorableObjectPointer())!=trackCont){
58  std::cerr << "TauxAODHelpers::tauTrackNonConstWithMask, inconsistent containers given" << std::endl;
59  return nullptr;
60  }
61  return trackCont->at(link.index());
62  }
63  accepted_track++;
64  }
65  }
66  return nullptr;
67 }
68 
69 // ==================================================================
70 std::vector<xAOD::TauTrack*> xAOD::TauHelpers::tauTracksNonConst( const xAOD::TauJet* tau, xAOD::TauTrackContainer* trackCont, xAOD::TauJetParameters::TauTrackFlag flag/*=xAOD::TauJetParameters::TauTrackFlag::classifiedCharged*/ ){
72  return tauTracksNonConstWithMask(tau, trackCont, mask);
73 }
74 
75 // ==================================================================
77  std::vector<xAOD::TauTrack*> v;
78  for( const ElementLink< xAOD::TauTrackContainer >& link : tau->allTauTrackLinks() ){
79  if(link.isValid() && (*link)->flagWithMask(mask) && dynamic_cast<const xAOD::TauTrackContainer*> (link.getStorableObjectPointer()) == trackCont) v.push_back( trackCont->at(link.index()));
80  }
81  return v;
82 }
83 
84 // ==================================================================
85 std::vector<xAOD::TauTrack*> xAOD::TauHelpers::allTauTracksNonConst( const xAOD::TauJet* tau, xAOD::TauTrackContainer* trackCont ){
87  return tauTracksNonConstWithMask(tau, trackCont, mask);
88 }
89 
90 
91 
92 std::vector<const xAOD::IParticle*>
93 xAOD::TauHelpers::clusters(const xAOD::TauJet& tau, double dRMax) {
94  auto vertexedClusterList = xAOD::TauHelpers::vertexedClusters(tau, dRMax);
95 
96  std::vector<const xAOD::IParticle*> clusterList;
97  for (const auto& vertexedCluster : vertexedClusterList) {
98  const xAOD::CaloCluster& cluster = vertexedCluster.clust();
99  clusterList.push_back(&cluster);
100  }
101 
102  return clusterList;
103 }
104 
105 
106 
107 std::vector<xAOD::CaloVertexedTopoCluster>
109  TLorentzVector tauAxis;
110  if (tau.vertexLink().isValid()) {
112  }
113  else {
115  }
116 
117  auto vertexedClusterList = tau.vertexedClusters();
118 
119  std::vector<xAOD::CaloVertexedTopoCluster> selectedList;
120  for (const auto& vertexedCluster : vertexedClusterList) {
121  TLorentzVector clusterP4 = vertexedCluster.p4();
122 
123  double dR = clusterP4.DeltaR(tauAxis);
124  if (dR > dRMax) continue;
125 
126  selectedList.push_back(vertexedCluster);
127  }
128 
129  return selectedList;
130 }
xAOD::TauJetParameters::TauTrackFlag
TauTrackFlag
Enum for tau track flags.
Definition: TauDefs.h:400
xAOD::TauHelpers::tauTrackNonConstWithMask
xAOD::TauTrack * tauTrackNonConstWithMask(const xAOD::TauJet *tau, xAOD::TauTrackContainer *trackCont, int index, xAOD::TauTrack::TrackFlagType mask)
Definition: TauxAODHelpers.cxx:48
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
xAOD::TauJetParameters::IntermediateAxis
@ IntermediateAxis
Definition: TauDefs.h:338
xAOD::TauHelpers::trackParticleLinksWithMask
std::vector< ElementLink< xAOD::TrackParticleContainer > > trackParticleLinksWithMask(const xAOD::TauJet *tau, xAOD::TauTrack::TrackFlagType mask)
Definition: TauxAODHelpers.cxx:28
index
Definition: index.py:1
xAOD::TauHelpers::clusters
std::vector< const xAOD::IParticle * > clusters(const xAOD::TauJet &tau, double dRMax)
Definition: TauxAODHelpers.cxx:93
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
xAOD::TauHelpers::allTauTracksNonConst
std::vector< xAOD::TauTrack * > allTauTracksNonConst(const xAOD::TauJet *tau, xAOD::TauTrackContainer *trackCont)
Definition: TauxAODHelpers.cxx:85
xAOD::TauHelpers::tauTrackNonConst
xAOD::TauTrack * tauTrackNonConst(const xAOD::TauJet *tau, xAOD::TauTrackContainer *trackCont, int index, xAOD::TauJetParameters::TauTrackFlag flag=xAOD::TauJetParameters::TauTrackFlag::classifiedCharged)
Definition: TauxAODHelpers.cxx:41
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
xAOD::TauHelpers::getTruthParticle
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle *, bool debug=false)
return the truthParticle associated to the given IParticle (if any)
Definition: TauxAODHelpers.cxx:10
xAOD::TauHelpers::allTrackParticleLinks
std::vector< ElementLink< xAOD::TrackParticleContainer > > allTrackParticleLinks(const xAOD::TauJet *tau)
Definition: TauxAODHelpers.cxx:16
xAOD::TauJet_v3::allTauTrackLinks
const TauTrackLinks_t & allTauTrackLinks() const
Definition: TauJet_v3.cxx:420
TruthLink_t
ElementLink< xAOD::TruthParticleContainer > TruthLink_t
Definition: TauxAODHelpers.cxx:7
DMTest::links
links
Definition: CLinks_v1.cxx:22
TauxAODHelpers.h
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
master.flag
bool flag
Definition: master.py:29
xAOD::TauHelpers::trackParticleLinks
std::vector< ElementLink< xAOD::TrackParticleContainer > > trackParticleLinks(const xAOD::TauJet *tau, xAOD::TauJetParameters::TauTrackFlag flag=xAOD::TauJetParameters::TauTrackFlag::classifiedCharged)
Definition: TauxAODHelpers.cxx:22
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::TauTrack_v1::flagWithMask
bool flagWithMask(unsigned int) const
Definition: TauTrack_v1.cxx:81
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
xAOD::TauTrack_v1::TrackFlagType
uint16_t TrackFlagType
Definition: TauTrack_v1.h:61
xAOD::TauJet_v3::vertexedClusters
std::vector< xAOD::CaloVertexedTopoCluster > vertexedClusters() const
Definition: TauJet_v3.cxx:626
xAOD::TauHelpers::tauTracksNonConst
std::vector< xAOD::TauTrack * > tauTracksNonConst(const xAOD::TauJet *tau, xAOD::TauTrackContainer *trackCont, xAOD::TauJetParameters::TauTrackFlag flag=xAOD::TauJetParameters::TauTrackFlag::classifiedCharged)
Definition: TauxAODHelpers.cxx:70
xAOD::TauHelpers::tauTracksNonConstWithMask
std::vector< xAOD::TauTrack * > tauTracksNonConstWithMask(const xAOD::TauJet *tau, xAOD::TauTrackContainer *trackCont, xAOD::TauTrack::TrackFlagType mask)
Definition: TauxAODHelpers.cxx:76
python.PyAthena.v
v
Definition: PyAthena.py:154
xAOD::TauTrack_v1
Definition: TauTrack_v1.h:27
xAOD::TauJet_v3::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: TauJet_v3.cxx:97
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
xAOD::TauJetParameters::DetectorAxis
@ DetectorAxis
Definition: TauDefs.h:337
xAOD::TauJet_v3::allTracks
std::vector< const TauTrack * > allTracks() const
Get the v<const pointer> to all tracks associated with this tau, regardless of classification.
Definition: TauJet_v3.cxx:514
xAOD::TauJet_v3::vertexLink
const VertexLink_t & vertexLink() const
xAOD::TauHelpers::vertexedClusters
std::vector< xAOD::CaloVertexedTopoCluster > vertexedClusters(const xAOD::TauJet &tau, double dRMax)
Definition: TauxAODHelpers.cxx:108