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

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 ceballos 1.34 // $Id: Particle.h,v 1.33 2009/07/13 11:00:30 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 ceballos 1.34 Particle() : fIsFakeable(0) {}
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 ceballos 1.34 Bool_t IsFakeable() const { return fIsFakeable; }
50     void SetIsFakeable(Bool_t b) { fIsFakeable = b; }
51 loizides 1.11
52 bendavid 1.26 protected:
53 bendavid 1.28 void ClearCharge() const { fCacheQFlag.ClearCache(); }
54     void ClearMom() const { fCacheMomFlag.ClearCache(); }
55 loizides 1.27 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 ceballos 1.34 Bool_t fIsFakeable; //set to true if the lepton is a fakeable object
64 loizides 1.27
65 loizides 1.12 ClassDef(Particle, 1) // Generic particle class
66 loizides 1.1 };
67 loizides 1.8 }
68 loizides 1.24
69     //--------------------------------------------------------------------------------------------------
70 loizides 1.27 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 loizides 1.24 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 loizides 1.25 return E()*Pt()/P();
108     }
109    
110     //--------------------------------------------------------------------------------------------------
111 bendavid 1.28 inline const mithep::FourVectorM &mithep::Particle::Mom() const
112 loizides 1.27 {
113     // Return cached momentum value.
114    
115     if (!fCacheMomFlag.IsValid()) {
116     GetMom();
117     fCacheMomFlag.SetValid();
118     }
119    
120     return fCachedMom;
121     }
122    
123     //--------------------------------------------------------------------------------------------------
124 loizides 1.25 inline Double_t mithep::Particle::TMass() const
125     {
126     // Return transverse mass.
127    
128     return Mass()*Pt()/P();
129 loizides 1.24 }
130 loizides 1.8 #endif