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

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 loizides 1.33 // $Id: Particle.h,v 1.32 2009/05/18 06:28:49 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 loizides 1.33 #include "MitAna/DataTree/interface/Types.h"
19 loizides 1.9
20 loizides 1.1 namespace mithep
21     {
22 loizides 1.3 class Particle : public DataObject
23 loizides 1.1 {
24     public:
25     Particle() {}
26 loizides 1.11
27 loizides 1.27 Double_t AbsEta() const { return TMath::Abs(Eta()); }
28     Double_t Charge() const;
29 loizides 1.24 Int_t Compare(const TObject *o) const;
30 loizides 1.27 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 bendavid 1.28 const FourVectorM &Mom() const;
37 loizides 1.24 EObjType ObjType() const { return kParticle; }
38 loizides 1.27 Double_t Phi() const { return Mom().Phi(); }
39 loizides 1.24 Double_t PhiDeg() const { return Phi() * 180 /TMath::Pi(); }
40 loizides 1.32 void Print(Option_t *opt="") const;
41 loizides 1.27 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 loizides 1.31 Double_t Rapidity() const { return Mom().Rapidity(); }
47 loizides 1.27 Double_t Theta() const { return Mom().Theta(); }
48     Double_t TMass() const;
49 loizides 1.11
50 bendavid 1.26 protected:
51 bendavid 1.28 void ClearCharge() const { fCacheQFlag.ClearCache(); }
52     void ClearMom() const { fCacheMomFlag.ClearCache(); }
53 loizides 1.27 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 loizides 1.12 ClassDef(Particle, 1) // Generic particle class
63 loizides 1.1 };
64 loizides 1.8 }
65 loizides 1.24
66     //--------------------------------------------------------------------------------------------------
67 loizides 1.27 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 loizides 1.24 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 loizides 1.25 return E()*Pt()/P();
105     }
106    
107     //--------------------------------------------------------------------------------------------------
108 bendavid 1.28 inline const mithep::FourVectorM &mithep::Particle::Mom() const
109 loizides 1.27 {
110     // Return cached momentum value.
111    
112     if (!fCacheMomFlag.IsValid()) {
113     GetMom();
114     fCacheMomFlag.SetValid();
115     }
116    
117     return fCachedMom;
118     }
119    
120     //--------------------------------------------------------------------------------------------------
121 loizides 1.25 inline Double_t mithep::Particle::TMass() const
122     {
123     // Return transverse mass.
124    
125     return Mass()*Pt()/P();
126 loizides 1.24 }
127 loizides 1.8 #endif