ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Particle.h
Revision: 1.29
Committed: Sat Mar 7 08:31:36 2009 UTC (16 years, 2 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.28: +2 -2 lines
Log Message:
Cosmetics

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.29 // $Id: Particle.h,v 1.28 2009/02/26 17:06:24 bendavid 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.29 #include "MitAna/DataTree/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     Double_t Theta() const { return Mom().Theta(); }
45     Double_t TMass() const;
46 loizides 1.24 void Print(Option_t *opt="") const;
47 loizides 1.11
48 bendavid 1.26 protected:
49 bendavid 1.28 void ClearCharge() const { fCacheQFlag.ClearCache(); }
50     void ClearMom() const { fCacheMomFlag.ClearCache(); }
51 loizides 1.27 virtual Double_t GetCharge() const { return 0; }
52     virtual Double_t GetMass() const { return 0; }
53     virtual void GetMom() const = 0;
54    
55     mutable CacheFlag fCacheMomFlag; //||cache validity flag for momentum
56     mutable CacheFlag fCacheQFlag; //||cache validity flag for charge
57     mutable FourVectorM fCachedMom; //!cached momentum vector (filled by derived classes)
58     mutable Double_t fCachedQ; //!chached charge value (filled by derived classes)
59    
60 loizides 1.12 ClassDef(Particle, 1) // Generic particle class
61 loizides 1.1 };
62 loizides 1.8 }
63 loizides 1.24
64     //--------------------------------------------------------------------------------------------------
65 loizides 1.27 inline Double_t mithep::Particle::Charge() const
66     {
67     // Return cached charge value.
68    
69     if (!fCacheQFlag.IsValid()) {
70     fCachedQ = GetCharge();
71     fCacheQFlag.SetValid();
72     }
73    
74     return fCachedQ;
75     }
76    
77     //--------------------------------------------------------------------------------------------------
78 loizides 1.24 inline Int_t mithep::Particle::Compare(const TObject *o) const
79     {
80     // Default compare function for sorting according to transverse momentum.
81     // Returns -1 if this object is smaller than given object, 0 if objects are
82     // equal and 1 if this is larger than given object.
83    
84     const mithep::Particle *p = dynamic_cast<const mithep::Particle *>(o);
85     if (!p)
86     return 1;
87    
88     Double_t mypt = Pt();
89     Double_t pt = p->Pt();
90     if (mypt>pt)
91     return -1;
92     else if (pt>mypt)
93     return +1;
94     return 0;
95     }
96    
97     //--------------------------------------------------------------------------------------------------
98     inline Double_t mithep::Particle::Et() const
99     {
100     // Return transverse energy.
101    
102 loizides 1.25 return E()*Pt()/P();
103     }
104    
105     //--------------------------------------------------------------------------------------------------
106 bendavid 1.28 inline const mithep::FourVectorM &mithep::Particle::Mom() const
107 loizides 1.27 {
108     // Return cached momentum value.
109    
110     if (!fCacheMomFlag.IsValid()) {
111     GetMom();
112     fCacheMomFlag.SetValid();
113     }
114    
115     return fCachedMom;
116     }
117    
118     //--------------------------------------------------------------------------------------------------
119 loizides 1.25 inline Double_t mithep::Particle::TMass() const
120     {
121     // Return transverse mass.
122    
123     return Mass()*Pt()/P();
124 loizides 1.24 }
125 loizides 1.8 #endif