ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/MCParticle.h
Revision: 1.6
Committed: Wed Nov 5 12:15:39 2008 UTC (16 years, 6 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_006
Changes since 1.5: +6 -6 lines
Log Message:
Switched to Double32 for position and momentum, switch FourVector to PtEtaPhiMass version

File Contents

# User Rev Content
1 bendavid 1.1 //--------------------------------------------------------------------------------------------------
2 bendavid 1.6 // $Id: MCParticle.h,v 1.5 2008/10/06 15:55:17 ceballos Exp $
3 bendavid 1.1 //
4     // MCParticle
5     //
6     // Stores MC information for both gen and sim level
7     //
8     // Authors: C.Loizides, J.Bendavid...
9     //--------------------------------------------------------------------------------------------------
10    
11 loizides 1.3 #ifndef MITANA_DATATREE_MCPARTICLE_H
12     #define MITANA_DATATREE_MCPARTICLE_H
13 bendavid 1.1
14     #include <TRef.h>
15     #include <TDatabasePDG.h>
16     #include <TParticlePDG.h>
17     #include "MitAna/DataTree/interface/CompositeParticle.h"
18    
19     namespace mithep
20     {
21     class MCParticle : public CompositeParticle
22     {
23     public:
24     MCParticle() : fIsGenerated(kFALSE), fIsSimulated(kFALSE) {}
25     MCParticle(Double_t px, Double_t py, Double_t pz, Double_t e, Int_t id, Int_t s) :
26     fPdgId(id), fStatus(s),
27 bendavid 1.6 fFourVector(FourVector(px,py,pz,e)), fDecayVertex(0,0,0),
28 bendavid 1.1 fIsGenerated(kFALSE), fIsSimulated(kFALSE) {}
29     ~MCParticle() {}
30    
31 loizides 1.3 Int_t AbsPdgId() const { return (fPdgId<0 ? -fPdgId:fPdgId); }
32     void AddDaughter(MCParticle *p) { fDaughters.Add(p); }
33     Double_t Charge() const;
34     const ThreeVector &DecayVertex() const { return fDecayVertex; }
35     const MCParticle *Daughter(UInt_t i) const;
36 bendavid 1.4 const MCParticle *DistinctMother() const;
37 loizides 1.3 Bool_t HasMother() const { return fMother.IsValid(); }
38     Bool_t IsGenerated() const { return fIsGenerated; }
39     Bool_t IsSimulated() const { return fIsSimulated; }
40     Bool_t IsNeutrino() const;
41     const MCParticle *Mother() const;
42 bendavid 1.6 FourVector Mom() const { return FourVector(fFourVector); }
43 bendavid 1.1 void SetIsGenerated(Bool_t t=kTRUE) { fIsGenerated = t; }
44     void SetIsSimulated(Bool_t t=kTRUE) { fIsSimulated = t; }
45 loizides 1.3 TParticlePDG *PdgEntry() const;
46     Int_t PdgId() const { return fPdgId; }
47 bendavid 1.1 void SetMom(Double_t px, Double_t py, Double_t pz, Double_t e);
48 loizides 1.3 void SetMother(MCParticle *p) { fMother = p; }
49     void SetStatus(Int_t s) { fStatus = s; }
50 bendavid 1.2 void SetVertex(Double_t x, Double_t y, Double_t z);
51 ceballos 1.5 void SetPdgId(Int_t s) { fPdgId = s; }
52 loizides 1.3 Int_t Status() const { return fStatus; }
53     void Print(Option_t *opt="") const;
54 bendavid 1.1
55     enum EPartType {
56     kUnknown=0,
57     kEl=11, kMu=13, kTau=15,
58     kElNu=12, kMuNu=14, kTauNu=16,
59     kGlu=21, kGamma=22
60     };
61    
62     protected:
63     Int_t fPdgId; //pdg identifier
64     Int_t fStatus; //status flag of generator or simulation
65 bendavid 1.6 FourVectorM32 fFourVector; //four momentum vector
66     ThreeVector32 fDecayVertex; //gen decay vertex
67 bendavid 1.1 TRef fMother; //reference to mother
68 loizides 1.3 Bool_t fIsGenerated; //=true if generated particle
69     Bool_t fIsSimulated; //=true if simulated particle
70 bendavid 1.1
71 bendavid 1.6 ClassDef(MCParticle,3) // Generated particle class
72 bendavid 1.1 };
73     }
74    
75     //--------------------------------------------------------------------------------------------------
76     inline const mithep::MCParticle *mithep::MCParticle::Daughter(UInt_t i) const
77     {
78     // Return daughter corresponding to given index.
79    
80     return static_cast<const MCParticle*>(fDaughters.At(i));
81     }
82    
83     //--------------------------------------------------------------------------------------------------
84 bendavid 1.4 inline const mithep::MCParticle *mithep::MCParticle::DistinctMother() const
85     {
86     // Return mother, walking up the tree until a particle with a different pdg from this one
87     // is found.
88    
89     const mithep::MCParticle *mother = Mother();
90    
91     if (!mother) return 0;
92    
93     while (mother->PdgId()==fPdgId)
94     mother = mother->Mother();
95    
96     return mother;
97     }
98    
99     //--------------------------------------------------------------------------------------------------
100 bendavid 1.1 inline const mithep::MCParticle *mithep::MCParticle::Mother() const
101     {
102     // Return mother.
103    
104     return static_cast<const MCParticle*>(fMother.GetObject());
105     }
106    
107     //--------------------------------------------------------------------------------------------------
108     inline Bool_t mithep::MCParticle::IsNeutrino() const
109     {
110     // Return true if particle is neutrino.
111    
112     Int_t ap = AbsPdgId();
113     if ((ap==kElNu) ||
114     (ap==kMuNu) ||
115     (ap==kTauNu))
116     return kTRUE;
117    
118     return kFALSE;
119     }
120    
121     //--------------------------------------------------------------------------------------------------
122     inline TParticlePDG *mithep::MCParticle::PdgEntry() const
123     {
124     // Return entry to pdg database.
125    
126     return TDatabasePDG::Instance()->GetParticle(fPdgId);
127     }
128    
129     //--------------------------------------------------------------------------------------------------
130     inline void mithep::MCParticle::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
131     {
132     // Set four vector.
133    
134     fFourVector.SetXYZT(px, py, pz, e);
135     }
136    
137     //--------------------------------------------------------------------------------------------------
138     inline void mithep::MCParticle::SetVertex(Double_t x, Double_t y, Double_t z)
139     {
140     // Set decay vertex.
141    
142     fDecayVertex.SetXYZ(x,y,z);
143     }
144     #endif