ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Particle.h
Revision: 1.33
Committed: Mon Jul 13 11:00:30 2009 UTC (15 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_020d, TMit_020d, Mit_020c, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, Mit_010
Changes since 1.32: +2 -1 lines
Log Message:
Include files checked.

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: Particle.h,v 1.32 2009/05/18 06:28:49 loizides Exp $
3 //
4 // Particle
5 //
6 // General particle class. It provides an abstract interface to kinematical quantities
7 // computed by derived classes.
8 //
9 // Authors: C.Loizides
10 //--------------------------------------------------------------------------------------------------
11
12 #ifndef MITANA_DATATREE_PARTICLE_H
13 #define MITANA_DATATREE_PARTICLE_H
14
15 #include <TMath.h>
16 #include "MitAna/DataCont/interface/CacheFlag.h"
17 #include "MitAna/DataTree/interface/DataObject.h"
18 #include "MitAna/DataTree/interface/Types.h"
19
20 namespace mithep
21 {
22 class Particle : public DataObject
23 {
24 public:
25 Particle() {}
26
27 Double_t AbsEta() const { return TMath::Abs(Eta()); }
28 Double_t Charge() const;
29 Int_t Compare(const TObject *o) const;
30 Double_t E() const { return Mom().E(); }
31 Double_t Et() const;
32 Double_t Eta() const { return Mom().Eta(); }
33 Bool_t IsSortable() const { return kTRUE; }
34 Double_t Mass() const { return Mom().M(); }
35 Double_t Mt() const { return Mom().Mt(); }
36 const FourVectorM &Mom() const;
37 EObjType ObjType() const { return kParticle; }
38 Double_t Phi() const { return Mom().Phi(); }
39 Double_t PhiDeg() const { return Phi() * 180 /TMath::Pi(); }
40 void Print(Option_t *opt="") const;
41 Double_t Pt() const { return Mom().Pt(); }
42 Double_t Px() const { return Mom().Px(); }
43 Double_t Py() const { return Mom().Py(); }
44 Double_t Pz() const { return Mom().Pz(); }
45 Double_t P() const { return Mom().P(); }
46 Double_t Rapidity() const { return Mom().Rapidity(); }
47 Double_t Theta() const { return Mom().Theta(); }
48 Double_t TMass() const;
49
50 protected:
51 void ClearCharge() const { fCacheQFlag.ClearCache(); }
52 void ClearMom() const { fCacheMomFlag.ClearCache(); }
53 virtual Double_t GetCharge() const { return 0; }
54 virtual Double_t GetMass() const { return 0; }
55 virtual void GetMom() const = 0;
56
57 mutable CacheFlag fCacheMomFlag; //||cache validity flag for momentum
58 mutable CacheFlag fCacheQFlag; //||cache validity flag for charge
59 mutable FourVectorM fCachedMom; //!cached momentum vector (filled by derived classes)
60 mutable Double_t fCachedQ; //!chached charge value (filled by derived classes)
61
62 ClassDef(Particle, 1) // Generic particle class
63 };
64 }
65
66 //--------------------------------------------------------------------------------------------------
67 inline Double_t mithep::Particle::Charge() const
68 {
69 // Return cached charge value.
70
71 if (!fCacheQFlag.IsValid()) {
72 fCachedQ = GetCharge();
73 fCacheQFlag.SetValid();
74 }
75
76 return fCachedQ;
77 }
78
79 //--------------------------------------------------------------------------------------------------
80 inline Int_t mithep::Particle::Compare(const TObject *o) const
81 {
82 // Default compare function for sorting according to transverse momentum.
83 // Returns -1 if this object is smaller than given object, 0 if objects are
84 // equal and 1 if this is larger than given object.
85
86 const mithep::Particle *p = dynamic_cast<const mithep::Particle *>(o);
87 if (!p)
88 return 1;
89
90 Double_t mypt = Pt();
91 Double_t pt = p->Pt();
92 if (mypt>pt)
93 return -1;
94 else if (pt>mypt)
95 return +1;
96 return 0;
97 }
98
99 //--------------------------------------------------------------------------------------------------
100 inline Double_t mithep::Particle::Et() const
101 {
102 // Return transverse energy.
103
104 return E()*Pt()/P();
105 }
106
107 //--------------------------------------------------------------------------------------------------
108 inline const mithep::FourVectorM &mithep::Particle::Mom() const
109 {
110 // Return cached momentum value.
111
112 if (!fCacheMomFlag.IsValid()) {
113 GetMom();
114 fCacheMomFlag.SetValid();
115 }
116
117 return fCachedMom;
118 }
119
120 //--------------------------------------------------------------------------------------------------
121 inline Double_t mithep::Particle::TMass() const
122 {
123 // Return transverse mass.
124
125 return Mass()*Pt()/P();
126 }
127 #endif