ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Particle.h
Revision: 1.34
Committed: Mon May 16 18:22:18 2011 UTC (13 years, 11 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_021, HEAD
Branch point for: Mit_025c_branch
Changes since 1.33: +5 -2 lines
Log Message:
new variable

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: Particle.h,v 1.33 2009/07/13 11:00:30 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() : fIsFakeable(0) {}
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 Bool_t IsFakeable() const { return fIsFakeable; }
50 void SetIsFakeable(Bool_t b) { fIsFakeable = b; }
51
52 protected:
53 void ClearCharge() const { fCacheQFlag.ClearCache(); }
54 void ClearMom() const { fCacheMomFlag.ClearCache(); }
55 virtual Double_t GetCharge() const { return 0; }
56 virtual Double_t GetMass() const { return 0; }
57 virtual void GetMom() const = 0;
58
59 mutable CacheFlag fCacheMomFlag; //||cache validity flag for momentum
60 mutable CacheFlag fCacheQFlag; //||cache validity flag for charge
61 mutable FourVectorM fCachedMom; //!cached momentum vector (filled by derived classes)
62 mutable Double_t fCachedQ; //!chached charge value (filled by derived classes)
63 Bool_t fIsFakeable; //set to true if the lepton is a fakeable object
64
65 ClassDef(Particle, 1) // Generic particle class
66 };
67 }
68
69 //--------------------------------------------------------------------------------------------------
70 inline Double_t mithep::Particle::Charge() const
71 {
72 // Return cached charge value.
73
74 if (!fCacheQFlag.IsValid()) {
75 fCachedQ = GetCharge();
76 fCacheQFlag.SetValid();
77 }
78
79 return fCachedQ;
80 }
81
82 //--------------------------------------------------------------------------------------------------
83 inline Int_t mithep::Particle::Compare(const TObject *o) const
84 {
85 // Default compare function for sorting according to transverse momentum.
86 // Returns -1 if this object is smaller than given object, 0 if objects are
87 // equal and 1 if this is larger than given object.
88
89 const mithep::Particle *p = dynamic_cast<const mithep::Particle *>(o);
90 if (!p)
91 return 1;
92
93 Double_t mypt = Pt();
94 Double_t pt = p->Pt();
95 if (mypt>pt)
96 return -1;
97 else if (pt>mypt)
98 return +1;
99 return 0;
100 }
101
102 //--------------------------------------------------------------------------------------------------
103 inline Double_t mithep::Particle::Et() const
104 {
105 // Return transverse energy.
106
107 return E()*Pt()/P();
108 }
109
110 //--------------------------------------------------------------------------------------------------
111 inline const mithep::FourVectorM &mithep::Particle::Mom() const
112 {
113 // Return cached momentum value.
114
115 if (!fCacheMomFlag.IsValid()) {
116 GetMom();
117 fCacheMomFlag.SetValid();
118 }
119
120 return fCachedMom;
121 }
122
123 //--------------------------------------------------------------------------------------------------
124 inline Double_t mithep::Particle::TMass() const
125 {
126 // Return transverse mass.
127
128 return Mass()*Pt()/P();
129 }
130 #endif