ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/MCParticle.h
Revision: 1.4
Committed: Mon Sep 22 10:40:07 2008 UTC (16 years, 7 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_004
Changes since 1.3: +18 -1 lines
Log Message:
Added DistinctMother accessor

File Contents

# User Rev Content
1 bendavid 1.1 //--------------------------------------------------------------------------------------------------
2 bendavid 1.4 // $Id: MCParticle.h,v 1.3 2008/09/10 03:33:27 loizides 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     fFourVector(px,py,pz,e), fDecayVertex(0,0,0),
28     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     FourVector Mom() const { return 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 loizides 1.3 Int_t Status() const { return fStatus; }
52     void Print(Option_t *opt="") const;
53 bendavid 1.1
54     enum EPartType {
55     kUnknown=0,
56     kEl=11, kMu=13, kTau=15,
57     kElNu=12, kMuNu=14, kTauNu=16,
58     kGlu=21, kGamma=22
59     };
60    
61     protected:
62     Int_t fPdgId; //pdg identifier
63     Int_t fStatus; //status flag of generator or simulation
64     FourVector fFourVector; //four momentum vector
65 bendavid 1.2 ThreeVector fDecayVertex; //gen decay vertex
66 bendavid 1.1 TRef fMother; //reference to mother
67 loizides 1.3 Bool_t fIsGenerated; //=true if generated particle
68     Bool_t fIsSimulated; //=true if simulated particle
69 bendavid 1.1
70     ClassDef(MCParticle,2) // Generated particle class
71     };
72     }
73    
74     //--------------------------------------------------------------------------------------------------
75     inline const mithep::MCParticle *mithep::MCParticle::Daughter(UInt_t i) const
76     {
77     // Return daughter corresponding to given index.
78    
79     return static_cast<const MCParticle*>(fDaughters.At(i));
80     }
81    
82     //--------------------------------------------------------------------------------------------------
83 bendavid 1.4 inline const mithep::MCParticle *mithep::MCParticle::DistinctMother() const
84     {
85     // Return mother, walking up the tree until a particle with a different pdg from this one
86     // is found.
87    
88     const mithep::MCParticle *mother = Mother();
89    
90     if (!mother) return 0;
91    
92     while (mother->PdgId()==fPdgId)
93     mother = mother->Mother();
94    
95     return mother;
96     }
97    
98     //--------------------------------------------------------------------------------------------------
99 bendavid 1.1 inline const mithep::MCParticle *mithep::MCParticle::Mother() const
100     {
101     // Return mother.
102    
103     return static_cast<const MCParticle*>(fMother.GetObject());
104     }
105    
106     //--------------------------------------------------------------------------------------------------
107     inline Bool_t mithep::MCParticle::IsNeutrino() const
108     {
109     // Return true if particle is neutrino.
110    
111     Int_t ap = AbsPdgId();
112     if ((ap==kElNu) ||
113     (ap==kMuNu) ||
114     (ap==kTauNu))
115     return kTRUE;
116    
117     return kFALSE;
118     }
119    
120     //--------------------------------------------------------------------------------------------------
121     inline TParticlePDG *mithep::MCParticle::PdgEntry() const
122     {
123     // Return entry to pdg database.
124    
125     return TDatabasePDG::Instance()->GetParticle(fPdgId);
126     }
127    
128     //--------------------------------------------------------------------------------------------------
129     inline void mithep::MCParticle::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
130     {
131     // Set four vector.
132    
133     fFourVector.SetXYZT(px, py, pz, e);
134     }
135    
136     //--------------------------------------------------------------------------------------------------
137     inline void mithep::MCParticle::SetVertex(Double_t x, Double_t y, Double_t z)
138     {
139     // Set decay vertex.
140    
141     fDecayVertex.SetXYZ(x,y,z);
142     }
143     #endif