ATLAS Offline Software
DiTauJet_v1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id: DiTauJet_v1.cxx 631921 2015-09-23 23:30:59Z dkirchme $
6 
7 
8 // EDM include(s):
10 
11 // Local include(s):
13 // #include "xAODDiTau/versions/TauJetCalibMapper_v1.h"
14 #include "DiTauJetAccessors_v1.h"
15 #include <stdexcept>
16 
17 namespace xAOD {
18 
20  : IParticle() {
21  }
22 
23 
28 
29 
31  FourMom_t p4;
32  p4.SetPtEtaPhiM( pt(), eta(), phi(), m());
33  return p4;
34  }
35 
37  return GenVecFourMom_t(pt(), eta(), phi(), m());
38  }
39 
40  void DiTauJet_v1::setP4(double pt, double eta, double phi, double m) {
41  static const Accessor< float > acc1( "pt" );
42  static const Accessor< float > acc2( "eta" );
43  static const Accessor< float > acc3( "phi" );
44  static const Accessor< float > acc4( "m" );
45  acc1( *this ) = pt;
46  acc2( *this ) = eta;
47  acc3( *this ) = phi;
48  acc4( *this ) = m;
49  }
50 
51 
53  return Type::Jet;
54  }
55 
56 
57  double DiTauJet_v1::rapidity() const {
58  return genvecP4().Rapidity();
59  }
60 
61 
62  double DiTauJet_v1::e() const {
63  return genvecP4().E();
64  }
65 
66 
67  // ----------------------------------------------------------------------------
68  // setter and getter for the seed jet link
69  // ----------------------------------------------------------------------------
72  jetLink,
73  setJetLink )
74 
75  static const SG::AuxElement::Accessor< DiTauJet_v1::JetLink_t > jetAcc( "jetLink" );
76 
77  const Jet* DiTauJet_v1::jet() const {
78  return ( *jetAcc( *this ) );
79  }
80 
81 
82  void DiTauJet_v1::setJet( const xAOD::JetContainer *cont, const xAOD::Jet *jet) {
83  if( jetAcc( *this ).isValid() )
84  jetAcc( *this ).reset();
85  jetAcc( *this ).toContainedElement( *cont, jet );
86  }
87 
88  // ----------------------------------------------------------------------------
89  // getter and setter for subjet 4-mom
90  // ----------------------------------------------------------------------------
91 
92  float DiTauJet_v1::subjetPt(unsigned int numSubjet) const
93  {
94  static const Accessor< std::vector <float > > subjetPtAcc("subjet_pt");
95  const std::vector<float>& vPt = subjetPtAcc(*this);
96  if (vPt.size()<numSubjet+1)
97  return -999.0;
98  else
99  return vPt[numSubjet];
100  }
101 
102  float DiTauJet_v1::subjetEta(unsigned int numSubjet) const
103  {
104  static const Accessor< std::vector <float > > subjetEtaAcc("subjet_eta");
105  const std::vector<float>& vEta = subjetEtaAcc(*this);
106  if (vEta.size()<numSubjet+1)
107  return -999.0;
108  else
109  return vEta[numSubjet];
110  }
111 
112  float DiTauJet_v1::subjetPhi(unsigned int numSubjet) const
113  {
114  static const Accessor< std::vector <float > > subjetPhiAcc("subjet_phi");
115  const std::vector<float>& vPhi = subjetPhiAcc(*this);
116  if (vPhi.size()<numSubjet+1)
117  return -999.0;
118  else
119  return vPhi[numSubjet];
120  }
121 
122  float DiTauJet_v1::subjetE(unsigned int numSubjet) const
123  {
124  static const Accessor< std::vector <float > > subjetEAcc("subjet_e");
125  const std::vector<float>& vE = subjetEAcc(*this);
126  if (vE.size()<numSubjet+1)
127  return -999.0;
128  else
129  return vE[numSubjet];
130  }
131 
132  float DiTauJet_v1::nSubjets() const
133  {
134  static const Accessor < std::vector <float> > subjetPtAcc("subjet_pt");
135  const std::vector<float>& vPt = subjetPtAcc(*this);
136  return vPt.size();
137  }
138 
139  void DiTauJet_v1::setSubjetPtEtaPhiE(unsigned int numSubjet,
140  float pt, float eta, float phi, float e)
141  {
142  static const Accessor< std::vector <float > > subjetPtAcc("subjet_pt");
143  static const Accessor< std::vector <float > > subjetEtaAcc("subjet_eta");
144  static const Accessor< std::vector <float > > subjetPhiAcc("subjet_phi");
145  static const Accessor< std::vector <float > > subjetEAcc("subjet_e");
146  std::vector<float>& vPt = subjetPtAcc(*this);
147  std::vector<float>& vEta = subjetEtaAcc(*this);
148  std::vector<float>& vPhi = subjetPhiAcc(*this);
149  std::vector<float>& vE = subjetEAcc(*this);
150  if (vPt.size()<numSubjet+1)
151  vPt.resize(numSubjet+1);
152  if (vEta.size()<numSubjet+1)
153  vEta.resize(numSubjet+1);
154  if (vPhi.size()<numSubjet+1)
155  vPhi.resize(numSubjet+1);
156  if (vE.size()<numSubjet+1)
157  vE.resize(numSubjet+1);
158 
159  vPt[numSubjet] = pt;
160  vEta[numSubjet] = eta;
161  vPhi[numSubjet] = phi;
162  vE[numSubjet] = e;
163  }
164 
165  // ----------------------------------------------------------------------------
166  // f_core getter and setter
167  // ----------------------------------------------------------------------------
168  float DiTauJet_v1::fCore(unsigned int numSubjet) const
169  {
170  static const Accessor< std::vector <float > > fCoreAcc("subjet_f_core");
171  const std::vector<float>& vec = fCoreAcc(*this);
172  if (vec.size()<numSubjet+1)
173  return -999.0;
174  else
175  return vec[numSubjet];
176  }
177 
178  void DiTauJet_v1::setfCore(unsigned int numSubjet, float fCore)
179  {
180  static const Accessor< std::vector <float > > fCoreAcc("subjet_f_core");
181  std::vector<float>& vec = fCoreAcc(*this);
182  if (vec.size()<numSubjet+1)
183  vec.resize(numSubjet+1);
184 
185  vec[numSubjet] = fCore;
186  }
187 
188 
189  // ----------------------------------------------------------------------------
190  // setter and getter for the primary vertex link
191  // ----------------------------------------------------------------------------
194  vertexLink,
195  setVertexLink )
196 
197  static const SG::AuxElement::Accessor< DiTauJet_v1::VertexLink_t > vertexAcc( "vertexLink" );
198 
199  const Vertex* DiTauJet_v1::vertex() const {
200  return ( *vertexAcc( *this ) );
201  }
202 
203 
205  if( vertexAcc( *this ).isValid() )
206  vertexAcc( *this ).reset();
207  vertexAcc( *this ).toContainedElement( *cont, vertex );
208  }
209 
210  // // ----------------------------------------------------------------------------
211  // // setters and getters for the secondary vertex links
212  // // ----------------------------------------------------------------------------
213  // AUXSTORE_OBJECT_SETTER_AND_GETTER( DiTauJet_v1,
214  // DiTauJet_v1::SecVertexLinks_t,
215  // secVertexLinks,
216  // setSecVertexLinks )
217 
218  // static const SG::AuxElement::Accessor< DiTauJet_v1::SecVertexLinks_t > secVtxAcc( "secVertexLinks" );
219 
220  // const Vertex* DiTauJet_v1::secVertex( size_t i ) const {
221  // return ( *secVtxAcc( *this )[ i ] );
222  // }
223 
224  // size_t DiTauJet_v1::nSecVertex() const {
225  // return secVtxAcc( *this ).size();
226  // }
227 
228  // void DiTauJet_v1::addSecVertex( const xAOD::VertexContainer* pVertexCont,
229  // const xAOD::Vertex* pVertex) {
230  // ElementLink<xAOD::VertexContainer> linkToVertex;
231  // linkToVertex.toContainedElement(*pVertexCont, pVertex);
232 
233  // secVtxAcc( *this ).push_back( linkToVertex );
234 
235  // return;
236  // }
237 
238  // void DiTauJet_v1::clearSecVertexLinks() {
239  // secVtxAcc( *this ).clear();
240  // return;
241  // }
242 
243  // ----------------------------------------------------------------------------
244  // setters and getters for the track links
245  // ----------------------------------------------------------------------------
246  // tacks inside subjets
249  trackLinks,
250  setTrackLinks )
251 
252  static const SG::AuxElement::Accessor< DiTauJet_v1::TrackParticleLinks_t > trackAcc( "trackLinks" );
253 
254  const TrackParticle* DiTauJet_v1::track( size_t i ) const {
255  return ( *trackAcc( *this )[ i ] );
256  }
257 
258  size_t DiTauJet_v1::nTracks() const {
259  return trackAcc( *this ).size();
260  }
261 
262  void DiTauJet_v1::addTrack( const xAOD::TrackParticleContainer* pTrackParticleCont,
263  const xAOD::TrackParticle* pTrackParticle) {
264  ElementLink<xAOD::TrackParticleContainer> linkToTrackParticle;
265  linkToTrackParticle.toContainedElement(*pTrackParticleCont, pTrackParticle);
266 
267  trackAcc( *this ).push_back( linkToTrackParticle );
268 
269  return;
270  }
271 
273  trackAcc( *this ).clear();
274  return;
275  }
276 
277 
278  // tacks inside isolation region
281  isoTrackLinks,
282  setIsoTrackLinks )
283 
284  static const SG::AuxElement::Accessor< DiTauJet_v1::TrackParticleLinks_t > isoTrackAcc( "isoTrackLinks" );
285 
286  const TrackParticle* DiTauJet_v1::isoTrack( size_t i ) const {
287  return ( *isoTrackAcc( *this )[ i ] );
288  }
289 
290  size_t DiTauJet_v1::nIsoTracks() const {
291  return isoTrackAcc( *this ).size();
292  }
293 
294  void DiTauJet_v1::addIsoTrack( const xAOD::TrackParticleContainer* pTrackParticleCont,
295  const xAOD::TrackParticle* pTrackParticle) {
296  ElementLink<xAOD::TrackParticleContainer> linkToIsoTrackParticle;
297  linkToIsoTrackParticle.toContainedElement(*pTrackParticleCont, pTrackParticle);
298 
299  isoTrackAcc( *this ).push_back( linkToIsoTrackParticle );
300 
301  return;
302  }
303 
305  isoTrackAcc( *this ).clear();
306  return;
307  }
308 
309 
310  // tacks in seed jet that do not fulfill quality cuts
313  otherTrackLinks,
314  setOtherTrackLinks )
315 
316  static const SG::AuxElement::Accessor< DiTauJet_v1::TrackParticleLinks_t > otherTrackAcc( "otherTrackLinks" );
317 
318  const TrackParticle* DiTauJet_v1::otherTrack( size_t i ) const {
319  return ( *otherTrackAcc( *this )[ i ] );
320  }
321 
322  size_t DiTauJet_v1::nOtherTracks() const {
323  return otherTrackAcc( *this ).size();
324  }
325 
327  const xAOD::TrackParticle* pTrackParticle) {
328  ElementLink<xAOD::TrackParticleContainer> linkToOtherTrackParticle;
329  linkToOtherTrackParticle.toContainedElement(*pTrackParticleCont, pTrackParticle);
330 
331  otherTrackAcc( *this ).push_back( linkToOtherTrackParticle );
332 
333  return;
334  }
335 
337  otherTrackAcc( *this ).clear();
338  return;
339  }
340 
341 
342  //-------------------------------------------------------------------------
343  // Get int detail via enum
344  //-------------------------------------------------------------------------
346  // Get the detail accessor:
347  const Accessor< int >* acc = xAODDiTau::detailsAccessorV1<int>( detail );
348  if( ! acc ) return false;
349  if( ! acc->isAvailable( *this ) ) return false;
350 
351  // Retrieve the detail value:
352  value = ( *acc )( *this );
353  return true;
354  }
355 
356  //-------------------------------------------------------------------------
357  // Get float detail via enum
358  //-------------------------------------------------------------------------
360  // Get the detail accessor:
361  const Accessor< float >* acc = xAODDiTau::detailsAccessorV1<float>( detail );
362  if( ! acc ) return false;
363  if( ! acc->isAvailable( *this ) ) return false;
364 
365  // Retrieve the detail value:
366  value = ( *acc )( *this );
367  return true;
368  }
369 
370  //-------------------------------------------------------------------------
371  // Set int detail via enum
372  //-------------------------------------------------------------------------
374  const SG::AuxElement::Accessor< int >* acc = xAODDiTau::detailsAccessorV1<int>( detail );
375  if (!acc) {
376  throw std::runtime_error ("DiTauJet_v1::setDetail: bad detail code");
377  }
378  (*acc)(*this) = value;
379  }
380 
381  //-------------------------------------------------------------------------
382  // Set float detail via enum
383  //-------------------------------------------------------------------------
385  const SG::AuxElement::Accessor< float >* acc = xAODDiTau::detailsAccessorV1<float>( detail );
386  if (!acc) {
387  throw std::runtime_error ("DiTauJet_v1::setDetail: bad detail code");
388  }
389  (*acc)(*this) = value;
390  ( *( xAODDiTau::detailsAccessorV1<float>( detail ) ) )( *this ) = value;
391  }
392 
393 
394 
395 } // namespace xAOD
python.CaloBCIDAvgAlgConfig.acc3
def acc3
Definition: CaloBCIDAvgAlgConfig.py:69
xAOD::DiTauJet_v1::m
virtual double m() const
The invariant mass of the particle.
xAOD::DiTauJet_v1::setVertex
void setVertex(const xAOD::VertexContainer *cont, const xAOD::Vertex *vertex)
Definition: DiTauJet_v1.cxx:204
xAOD::DiTauJet_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
xAOD::DiTauJet_v1::TrackParticleLinks_t
std::vector< ElementLink< xAOD::TrackParticleContainer > > TrackParticleLinks_t
Definition: DiTauJet_v1.h:118
xAOD::DiTauJet_v1::clearTrackLinks
void clearTrackLinks()
Definition: DiTauJet_v1.cxx:272
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
xAOD::DiTauJet_v1::fCore
float fCore(unsigned int numSubjet) const
Definition: DiTauJet_v1.cxx:168
xAOD::DiTauJet_v1::setJet
void setJet(const xAOD::JetContainer *cont, const xAOD::Jet *jet)
Definition: DiTauJet_v1.cxx:82
xAOD::DiTauJet_v1::GenVecFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > GenVecFourMom_t
Base 4 Momentum type for taus.
Definition: DiTauJet_v1.h:50
xAOD::DiTauJet_v1::clearIsoTrackLinks
void clearIsoTrackLinks()
Definition: DiTauJet_v1.cxx:304
xAOD::DiTauJet_v1::addOtherTrack
void addOtherTrack(const xAOD::TrackParticleContainer *, const xAOD::TrackParticle *)
Definition: DiTauJet_v1.cxx:326
SG::Accessor< float >
AuxStoreAccessorMacros.h
xAOD::DiTauJet_v1::setDetail
void setDetail(DiTauJetParameters::Detail detail, int value)
Definition: DiTauJet_v1.cxx:373
xAOD::DiTauJet_v1::DiTauJet_v1
DiTauJet_v1()
Default constructor.
Definition: DiTauJet_v1.cxx:19
xAOD::DiTauJet_v1::subjetPhi
float subjetPhi(unsigned int numSubjet) const
Definition: DiTauJet_v1.cxx:112
athena.value
value
Definition: athena.py:124
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
detail
Definition: extract_histogram_tag.cxx:14
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
xAOD::pt
setRcore setEtHad setFside pt
Definition: TrigPhoton_v1.cxx:106
xAOD::DiTauJet_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
xAOD::DiTauJet_v1::setP4
void setP4(double pt, double eta, double phi, double m)
Set methods for IParticle values.
Definition: DiTauJet_v1.cxx:40
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::DiTauJet_v1::nOtherTracks
size_t nOtherTracks() const
Definition: DiTauJet_v1.cxx:322
xAOD::DiTauJet_v1::clearOtherTrackLinks
void clearOtherTrackLinks()
Definition: DiTauJet_v1.cxx:336
xAOD::DiTauJet_v1::nSubjets
float nSubjets() const
Definition: DiTauJet_v1.cxx:132
xAOD::DiTauJet_v1::genvecP4
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : internal taus type.
Definition: DiTauJet_v1.cxx:36
xAOD::DiTauJet_v1::addTrack
void addTrack(const xAOD::TrackParticleContainer *, const xAOD::TrackParticle *)
Definition: DiTauJet_v1.cxx:262
xAOD::DiTauJet_v1::subjetE
float subjetE(unsigned int numSubjet) const
Definition: DiTauJet_v1.cxx:122
xAOD::IParticle::FourMom_t
TLorentzVector FourMom_t
Definition of the 4-momentum type.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:69
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
xAOD::DiTauJet_v1::addIsoTrack
void addIsoTrack(const xAOD::TrackParticleContainer *, const xAOD::TrackParticle *)
Definition: DiTauJet_v1.cxx:294
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
xAOD::DiTauJet_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::DiTauJet_v1::track
const TrackParticle * track(size_t i) const
xAOD::e
setPy e
Definition: CompositeParticle_v1.cxx:166
python.CaloBCIDAvgAlgConfig.acc1
def acc1
Definition: CaloBCIDAvgAlgConfig.py:49
xAOD::AUXSTORE_PRIMITIVE_GETTER_WITH_CAST
AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(Muon_v1, uint8_t, Muon_v1::EnergyLossType, energyLossType) AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(Muon_v1
xAOD::DiTauJet_v1::jet
const Jet * jet() const
xAOD::DiTauJet_v1::type
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
Definition: DiTauJet_v1.cxx:52
python.CaloBCIDAvgAlgConfig.acc2
def acc2
Definition: CaloBCIDAvgAlgConfig.py:59
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
python.LArRecUtilsConfig.acc4
def acc4
Definition: LArRecUtilsConfig.py:196
xAOD::DiTauJet_v1::setfCore
void setfCore(unsigned int numSubjet, float fCore)
Definition: DiTauJet_v1.cxx:178
xAOD::DiTauJet_v1::subjetEta
float subjetEta(unsigned int numSubjet) const
Definition: DiTauJet_v1.cxx:102
xAOD::DiTauJet_v1::nIsoTracks
size_t nIsoTracks() const
Definition: DiTauJet_v1.cxx:290
xAOD::DiTauJet_v1::nTracks
size_t nTracks() const
Definition: DiTauJet_v1.cxx:258
xAOD::DiTauJet_v1::setSubjetPtEtaPhiE
void setSubjetPtEtaPhiE(unsigned int numSubjet, float pt, float eta, float phi, float e)
Definition: DiTauJet_v1.cxx:139
xAOD::DiTauJetParameters::Detail
Detail
Definition: DiTauDefs.h:38
xAOD::DiTauJet_v1::detail
bool detail(DiTauJetParameters::Detail detail, int &value) const
Get and set values of common details variables via enum.
Definition: DiTauJet_v1.cxx:345
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
xAOD::DiTauJet_v1
Definition: DiTauJet_v1.h:31
xAOD::DiTauJet_v1::subjetPt
float subjetPt(unsigned int numSubjet) const
Definition: DiTauJet_v1.cxx:92
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAODType::ObjectType
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition: ObjectType.h:32
xAOD::DiTauJet_v1::otherTrack
const TrackParticle * otherTrack(size_t i) const
xAOD::DiTauJet_v1::rapidity
virtual double rapidity() const
The true rapidity (y) of the particle.
Definition: DiTauJet_v1.cxx:57
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::DiTauJet_v1::isoTrack
const TrackParticle * isoTrack(size_t i) const
xAOD::DiTauJet_v1::vertex
const Vertex * vertex() const
xAOD::DiTauJet_v1::e
virtual double e() const
The total energy of the particle.
Definition: DiTauJet_v1.cxx:62
DiTauJet_v1.h
xAOD::AUXSTORE_OBJECT_SETTER_AND_GETTER
AUXSTORE_OBJECT_SETTER_AND_GETTER(CaloRings_v1, RingSetLinks, ringSetLinks, setRingSetLinks) unsigned CaloRings_v1
Definition: CaloRings_v1.cxx:27
DiTauJetAccessors_v1.h