ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Particle.h
Revision: 1.31
Committed: Mon Apr 6 09:50:49 2009 UTC (16 years, 1 month ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009
Changes since 1.30: +2 -1 lines
Log Message:
Added rapidity.

File Contents

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