ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/MCParticle.h
Revision: 1.2
Committed: Tue Jul 29 12:29:47 2008 UTC (16 years, 9 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: MITHEP_2_0_x
Changes since 1.1: +4 -4 lines
Log Message:
Revamped implementation of decay tree classes, started to remove use of Vertex and FitVertex to prepare for removal of these classes

File Contents

# User Rev Content
1 bendavid 1.1 //--------------------------------------------------------------------------------------------------
2 bendavid 1.2 // $Id: MCParticle.h,v 1.1 2008/07/25 11:32:45 bendavid 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     #ifndef DATATREE_MCPARTICLE_H
12     #define DATATREE_MCPARTICLE_H
13    
14     #include <TRef.h>
15     #include <TDatabasePDG.h>
16     #include <TParticlePDG.h>
17     #include "MitAna/DataTree/interface/CompositeParticle.h"
18     #include "MitAna/DataTree/interface/Vertex.h"
19    
20     namespace mithep
21     {
22     class MCParticle : public CompositeParticle
23     {
24     public:
25     MCParticle() : fIsGenerated(kFALSE), fIsSimulated(kFALSE) {}
26     MCParticle(Double_t px, Double_t py, Double_t pz, Double_t e, Int_t id, Int_t s) :
27     fPdgId(id), fStatus(s),
28     fFourVector(px,py,pz,e), fDecayVertex(0,0,0),
29     fIsGenerated(kFALSE), fIsSimulated(kFALSE) {}
30     ~MCParticle() {}
31    
32     Int_t AbsPdgId() const { return (fPdgId<0 ? -fPdgId:fPdgId); }
33     void AddDaughter(MCParticle *p) { fDaughters.Add(p); }
34     Double_t Charge() const;
35 bendavid 1.2 const ThreeVector &DecayVertex() const { return fDecayVertex; }
36 bendavid 1.1 const MCParticle *Daughter(UInt_t i) const;
37     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     void SetIsGenerated(Bool_t t=kTRUE) { fIsGenerated = t; }
44     void SetIsSimulated(Bool_t t=kTRUE) { fIsSimulated = t; }
45     TParticlePDG *PdgEntry() const;
46     Int_t PdgId() const { return fPdgId; }
47     void SetMom(Double_t px, Double_t py, Double_t pz, Double_t e);
48     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 bendavid 1.1 Int_t Status() const { return fStatus; }
52     void Print(Option_t *opt="") const;
53    
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     Bool_t fIsGenerated;
68     Bool_t fIsSimulated;
69    
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     inline const mithep::MCParticle *mithep::MCParticle::Mother() const
84     {
85     // Return mother.
86    
87     return static_cast<const MCParticle*>(fMother.GetObject());
88     }
89    
90     //--------------------------------------------------------------------------------------------------
91     inline Bool_t mithep::MCParticle::IsNeutrino() const
92     {
93     // Return true if particle is neutrino.
94    
95     Int_t ap = AbsPdgId();
96     if ((ap==kElNu) ||
97     (ap==kMuNu) ||
98     (ap==kTauNu))
99     return kTRUE;
100    
101     return kFALSE;
102     }
103    
104     //--------------------------------------------------------------------------------------------------
105     inline TParticlePDG *mithep::MCParticle::PdgEntry() const
106     {
107     // Return entry to pdg database.
108    
109     return TDatabasePDG::Instance()->GetParticle(fPdgId);
110     }
111    
112     //--------------------------------------------------------------------------------------------------
113     inline void mithep::MCParticle::SetMom(Double_t px, Double_t py, Double_t pz, Double_t e)
114     {
115     // Set four vector.
116    
117     fFourVector.SetXYZT(px, py, pz, e);
118     }
119    
120     //--------------------------------------------------------------------------------------------------
121     inline void mithep::MCParticle::SetVertex(Double_t x, Double_t y, Double_t z)
122     {
123     // Set decay vertex.
124    
125     fDecayVertex.SetXYZ(x,y,z);
126     }
127     #endif