ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleShallowClone.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5*/
6
7// ParticleShallowClone.h
8// @author: Karsten Koeneke - February 2013
10#ifndef PARTICLEEVENT_PARTICLESHALLOWCLONE_H
11#define PARTICLEEVENT_PARTICLESHALLOWCLONE_H 1
12
13#include "AthLinks/ElementLink.h"
16#include "FourMom/P4PxPyPzE.h"
17
18// VxVertex includes
21#include "VxVertex/RecVertex.h"
22
23
24/* OPEN QUESTIONS:
25 I could template this class with two template arguemnts:
26 One being the type of 4Momentum (P4PxPyPzE, P4PtEtaPhiM,...)
27 and the other being the type of the master particle (egamma, Muon, TauJet,...)
28 I could then implement the specific methods for each particle as well,
29 i.e., forward them to the original master. And the underlying 4Momentum
30 implementation would be identical to the one of the master.
31 However, I could still not dynamic_cast to the type of the master particle
32 nor could I use the containers of this and the master interchangably.
33 So it may not be worth the effort? Too little benefit?
34*/
35
36
37
38// Typedefs
43
45
46namespace Analysis
47{
48
50 virtual public IParticle
51 {
52
53 // Public typedefs
54 public:
57
58
59 public:
60
63 P4Momentum_t ( ),
64 m_masterLink ( ),
65 m_originLink ( ),
66 m_hasCharge ( false ),
67 m_charge ( 0.0 )
68 {
69 }
70
71
75 explicit ParticleShallowClone( const MasterLink_t& theMasterLink ) :
76 P4Momentum_t ( *theMasterLink ),
77 m_originLink ( (*theMasterLink)->originLink() ),
78 m_hasCharge ( (*theMasterLink)->hasCharge() ),
79 m_charge ( (*theMasterLink)->charge() )
80 {
81 // Assign the ElementLink to the original master particle,
82 // including searching until we don't have a ParticleShallowClone any more
83 const ParticleShallowClone* pscPtr = dynamic_cast<const ParticleShallowClone*>(*theMasterLink);
84 m_masterLink = pscPtr ? pscPtr->getMasterLink() : theMasterLink;
85 }
86
87
92 ParticleShallowClone( const MasterLink_t& theMasterLink,
93 const I4Momentum* the4Mom,
94 const ChargeType theCharge = std::numeric_limits<ChargeType>::quiet_NaN(),
95 const ElementLink<VxContainer>* theOriginLink = 0 ) :
96 P4Momentum_t ( the4Mom )
97 {
98 // Assign the ElementLink to the original master particle,
99 // including searching until we don't have a ParticleShallowClone any more
100 const ParticleShallowClone* pscPtr = dynamic_cast<const ParticleShallowClone*>(*theMasterLink);
101 m_masterLink = pscPtr ? pscPtr->getMasterLink() : theMasterLink;
102
103 // Check if a charge was given. Is so, use it. If not, get the one from the orignal master particle
104 if ( std::isnan(theCharge) )
105 {
106 m_hasCharge = (*theMasterLink)->hasCharge();
107 m_charge = (*theMasterLink)->charge();
108 }
109 else
110 {
111 m_hasCharge = true;
112 m_charge = theCharge;
113 }
114
115 // Check if an origin was given. Is so, use it. If not, get the one from the orignal master particle
116 if ( theOriginLink )
117 {
118 m_originLink = *theOriginLink;
119 }
120 else
121 {
122 m_originLink = (*theMasterLink)->originLink();
123 }
124 }
125
126
127
129 // Use default.
130
131
132
134 //~ParticleShallowClone( );
135
136
137
139 public:
140
142 const MasterLink_t& getMasterLink() const;
143
145 const Master_t* getMasterPtr() const;
146
147
148
149
150 // All public methods that come from IAthenaBarCode
151 // QUESTION: Should the ParticleShallowClone own a new barcode? For now, no.
152 public:
153
155 virtual AthenaBarCode_t getAthenaBarCode() const;
156
158 virtual bool hasSameAthenaBarCode(const IAthenaBarCode &/*obj*/) const;
159
161 virtual bool hasSameAthenaBarCodeExceptVersion(const IAthenaBarCode &/*obj*/) const;
162
164 virtual AthenaBarCodeVersion_t getVersion() const;
165
166 /* These setters are not implemented! Users should get the master particle and modify its barcode directly...
168 virtual void setAthenaBarCode(AthenaBarCode_t id);
169
171 virtual void newVersion();
172
174 virtual void setVersion(AthenaBarCodeVersion_t newversion);
175 */
176
177
178
179 // All public methods that come from INavigable
180 public:
181
183 virtual void fillToken(INavigationToken&) const;
184
186 virtual void fillToken(INavigationToken&, const std::any&) const;
187
188
189
190 // All public methods that come from IParticle
191 public:
192
197 virtual ParticleDataType::DataType dataType() const;
198
201 virtual const Trk::RecVertex* origin() const;
202
205 virtual const ElementLink<VxContainer>& originLink() const ; // FIXME: WHY NOT RETURN A REFERENCE???
206
209 virtual bool hasCharge() const;
210
215 virtual ChargeType charge() const;
216
219 virtual bool hasPdgId() const;
220
223 virtual int pdgId() const;
224
225
226 // Set functions (for IParticle)
227
229 virtual void set_charge( ChargeType theCharge );
230
232 virtual void set_origin( const VxContainer* theContainer, int index );
233
235 virtual void set_origin( const VxContainer* theContainer,
236 const Trk::VxCandidate * vertex );
237
238 /* These setters are not implemented!
239 Users should get the master particle and modify its PDG_ID or ParticleDataType directly... */
240 //virtual void set_dataType( ParticleDataType::DataType x );
241 //virtual void set_pdgId( int x );
242
243
244
246 const momentum_type& momentumBase() const;
248
249
250
251 public:
252 /* Need to implement this as the union of all others
253 virtual std::ostream& dump(std::ostream&) const; // FIXME: Need to actually re-implement it here for full correctness!
254 */
255
256
257
258 // All private data memebers that this class needs on top of the ones inherited
259 private:
260 friend class ::ParticleShallowCloneCnv_p1;
261
264
267
270
275
276
277 };
278
279} // End of namespace Analysis
280
281
283// Inline methods:
285inline
290
291
292inline
294{
295 if ( m_masterLink.isValid() )
296 {
297 return *m_masterLink;
298 }
299 else
300 {
301 //ATH_MSG_ERROR ( "You tried to implicitly cast from an ParticleShallowClone to a INavigable4Momentum, but the pointed-at INavigable4Momentum doesn't exist! Returning NULL..." );
302 return 0;
303 }
304}
305
306
307// Implementations for methods comming from IAthenaBarCode
308inline
310{
311 return (*m_masterLink)->getAthenaBarCode();
312}
313
314inline
316{
317 return (*m_masterLink)->hasSameAthenaBarCode(obj);
318}
319
320inline
322{
323 return (*m_masterLink)->hasSameAthenaBarCodeExceptVersion(obj);
324}
325
326inline
328{
329 return (*m_masterLink)->getVersion();
330}
331
332
333// Implementations for methods comming from INavigable
334inline
336{
337 (*m_masterLink)->fillToken(theToken);
338 return;
339}
340
341inline
342void Analysis::ParticleShallowClone::fillToken(INavigationToken& theToken, const std::any& theOther) const
343{
344 (*m_masterLink)->fillToken(theToken, theOther);
345 return;
346}
347
348
349// Implementations for methods comming from IParticle
350inline
352{
353 return (*m_masterLink)->dataType();
354}
355
356inline
358{
359 return (!m_originLink.isValid())
360 ? 0
361 : &(**m_originLink).recVertex();
362}
363
364inline
369
370inline
375
376inline
381
382inline
384{
385 return (*m_masterLink)->hasPdgId();
386}
387
388inline
390{
391 return (*m_masterLink)->pdgId();
392}
393
394inline
396{
397 m_charge = theCharge;
398 m_hasCharge = true;
399 return;
400}
401
402inline
404{
406 return;
407}
408
409inline
411 const Trk::VxCandidate * vertex )
412{
414 ( vertex,*theContainer );
415 return;
416}
417
418inline
423
424inline
429
430
431
432/*
433inline
434std::ostream& Analysis::ParticleShallowClone::dump(std::ostream& val) const
435{
436 return (*m_masterLink)->dump(val);
437}
438*/
439
440#endif // PARTICLEEVENT_PARTICLESHALLOWCLONE_H
uint64_t AthenaBarCode_t
barcode for all INav4Mom classes
AthenaBarCode_t AthenaBarCodeVersion_t
double ChargeType
typedef ChargeType used to anticipate changes here
DataVector< IParticle > IParticleContainer
IParticle Master_t
IParticleContainer MasterContainer_t
P4PxPyPzE P4Momentum_t
ElementLink< MasterContainer_t > MasterLink_t
virtual ParticleDataType::DataType dataType() const
Return enum indicating real data, fast, or full simulation Return Type has a DataType enum with the f...
virtual const Trk::RecVertex * origin() const
Return a RecVertex corresponding to particle's Origin (used directly from this shallow clone particle...
ElementLink< VxContainer > m_originLink
Persistent pointer (ElementLink) to the origin of this particle.
virtual AthenaBarCodeVersion_t getVersion() const
Comparing & Versioning Control.
P4PxPyPzE momentum_type
publish the type of the base class (ie: 'traits-itize' it)
virtual void fillToken(INavigationToken &) const
Implement method from INavigable (forwareded to the orignal "master" particle)
virtual int pdgId() const
Return particle id (forwareded to the orignal "master" particle)
virtual bool hasSameAthenaBarCode(const IAthenaBarCode &) const
Comparing & Versioning Control.
virtual AthenaBarCode_t getAthenaBarCode() const
Public getter.
ParticleShallowClone(const MasterLink_t &theMasterLink, const I4Momentum *the4Mom, const ChargeType theCharge=std::numeric_limits< ChargeType >::quiet_NaN(), const ElementLink< VxContainer > *theOriginLink=0)
Standard constructor with an ElementLink to the original particle and all other parameters explicitly...
const momentum_type & momentumBase() const
access to underlying base type (I4Momentum-like)
virtual const ElementLink< VxContainer > & originLink() const
Return an ElementLink corresponding to particle's Origin (used directly from this shallow clone parti...
virtual bool hasCharge() const
method to check if charge information is available (used directly from this shallow clone particle)
ChargeType m_charge
Value of the charge of the particle (this has real meaning, only if hasCharge() returns true)
bool m_hasCharge
Switch to tell if this particle has a charge.
virtual void set_origin(const VxContainer *theContainer, int index)
Set method to set the charge of this shallow clone particle (the original "master" particle remains u...
const Master_t * getMasterPtr() const
Get a const pointer to the original "master" particle.
ParticleShallowClone()
The default constructor.
MasterLink_t m_masterLink
The persistent pointer (ElementLink) to the original "master" particle.
virtual bool hasSameAthenaBarCodeExceptVersion(const IAthenaBarCode &) const
Comparing & Versioning Control.
virtual ChargeType charge() const
returns charge as a typedef ChargeType currently Charge Type is a double for jets this may be changed...
virtual void set_charge(ChargeType theCharge)
Set method to set the charge of this shallow clone particle (the original "master" particle remains u...
virtual bool hasPdgId() const
method to check if particle id information is available (forwareded to the orignal "master" particle)
const MasterLink_t & getMasterLink() const
Copy constructor.
ParticleShallowClone(const MasterLink_t &theMasterLink)
Standard constructor with an ElementLink to the original particle.
I4Momentum is an abstract base class providing 4-momentum behavior.
Definition I4Momentum.h:31
P4PxPyPzE is a class with 4-momentum behavior, for which Px, Py, Pz and M are data members.
Definition P4PxPyPzE.h:29
P4PxPyPzE(const double px, const double py, const double pz, const double e)
constructor with all data members
Definition P4PxPyPzE.h:104
Trk::RecVertex inherits from Trk::Vertex.
Definition RecVertex.h:44
The namespace of all packages in PhysicsAnalysis/JetTagging.
Definition index.py:1