ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/UHHAnalysis/NtupleWriter/Objects/GenParticle.h
Revision: 1.6
Committed: Fri Jun 14 15:00:45 2013 UTC (11 years, 11 months ago) by rkogler
Content type: text/plain
Branch: MAIN
Changes since 1.5: +50 -2 lines
Log Message:
print list of generator particles, implemented by Mehdi Hamoudi

File Contents

# User Rev Content
1 peiffer 1.1 #ifndef GenParticle_H
2     #define GenParticle_H
3    
4     #include "Particle.h"
5 rkogler 1.6 #include <iomanip>
6     #include <iostream>
7     #include <string>
8     #include <sstream>
9 peiffer 1.1
10 peiffer 1.4 /**
11     * @short generator particle class
12     * @author Thomas Peiffer
13     */
14    
15 peiffer 1.1 class GenParticle : public Particle{
16     public:
17     GenParticle(){
18     m_pdgId=0;
19     m_status=0;
20     m_index=0;
21     m_mother1=0;
22     m_mother2=0;
23     m_daughter1=0;
24     m_daughter2=0;
25 peiffer 1.5 m_spin=0;
26 peiffer 1.1 };
27     ~GenParticle(){
28     };
29    
30 peiffer 1.2 int pdgId() const{return m_pdgId;}
31     int status() const{return m_status;}
32     int index() const{return m_index;}
33 peiffer 1.3 int mother1() const{return m_mother1;}
34     int mother2() const{return m_mother2;}
35     int daughter1() const{return m_daughter1;}
36     int daughter2() const{return m_daughter2;}
37 peiffer 1.5 int spin() const{return m_spin;}
38 peiffer 1.1
39     //return mother 1 or 2 (ind<=1 or ind>=2)
40 rkogler 1.6 GenParticle* mother(std::vector<GenParticle> *gplist, int ind=1) const {
41 peiffer 1.1 for(unsigned int i=0; i< gplist->size(); ++i){
42     if(ind<=1){
43     if(this->m_mother1 == gplist->at(i).index()){
44     return &(gplist->at(i));
45     }
46     }
47     else{
48     if(this->m_mother2 == gplist->at(i).index()){
49     return &(gplist->at(i));
50     }
51     }
52     }
53     //std::cout << "WARNING: Mother " << ind << " not found in list of GenParticles" << std::endl;
54     return 0;
55     }
56 rkogler 1.6
57 peiffer 1.1 //return daughter 1 or 2 (ind<=1 or ind>=2)
58 rkogler 1.6 GenParticle* daughter(std::vector<GenParticle> *gplist, int ind=1) const {
59 peiffer 1.1 for(unsigned int i=0; i< gplist->size(); ++i){
60     if(ind<=1){
61     if(this->m_daughter1 == gplist->at(i).index()){
62     return &(gplist->at(i));
63     }
64     }
65     else{
66     if(this->m_daughter2 == gplist->at(i).index()){
67     return &(gplist->at(i));
68     }
69     }
70     }
71     //std::cout << "WARNING: Daughter " << ind << " not found in list of GenParticles" << std::endl;
72     return 0;
73     }
74 rkogler 1.6
75     //print list of particles in one event with their characteristics
76     void Print(std::vector<GenParticle> *gplist) const{
77     std::cout << std::setw(10) << this->m_index << '|';
78     std::cout << std::setw(10) << this->m_pdgId << '|';
79     std::cout << std::setw(10) << this->m_status << '|';
80     if(this->mother(gplist, 1)){
81     std::ostringstream convert1;
82     convert1 << "id:" << this->mother(gplist, 1)->pdgId() << ", ind:" << this->m_mother1;
83     std::cout << std::setw(20) << convert1.str() << '|';
84     }
85     else{std::cout << std::setw(20) << "none" << '|';}
86     if(this->mother(gplist, 2)){
87     std::ostringstream convert2;
88     convert2 << "id:" << this->mother(gplist, 2)->pdgId() << ", ind:" << this->m_mother2;
89     std::cout << std::setw(20) << convert2.str() << '|';
90     }
91     else{std::cout << std::setw(20) << "none" << '|';}
92     if(this->daughter(gplist, 1)){
93     std::ostringstream convert3;
94     convert3 << "id:" << this->daughter(gplist, 1)->pdgId() << ", ind:" << this->m_daughter1;
95     std::cout << std::setw(20) << convert3.str() << '|';
96     }
97     else{std::cout << std::setw(20) << "none" << '|';}
98     if(this->daughter(gplist, 2)){
99     std::ostringstream convert4;
100     convert4 << "id:" << this->daughter(gplist, 2)->pdgId() << ", ind:" << this->m_daughter2;
101     std::cout << std::setw(20) << convert4.str() << '|';
102     }
103     else{std::cout << std::setw(20) << "none" << '|';}
104     std::cout << std::setw(10) << this->v4().Px() << '|';
105     std::cout << std::setw(10) << this->v4().Py() << '|';
106     std::cout << std::setw(10) << this->v4().Pz() << '|';
107     std::cout << std::setw(10) << this->energy() << '|';
108     std::cout << std::setw(10) << this->pt() << '|';
109     double m2 = this->v4().M2();
110     double m;
111     if (m2>0) m = sqrt(m2);
112     else m = (-1)*sqrt((-1)*m2);
113     std::cout << std::setw(10) << m << std::endl;
114     return;
115     }
116    
117 peiffer 1.1
118     void set_pdgId(int x){ m_pdgId=x;}
119     void set_status(int x){ m_status=x;}
120     void set_index(int x){ m_index=x;}
121     void set_mother1(int x){ m_mother1=x;}
122     void set_mother2(int x){ m_mother2=x;}
123     void set_daughter1(int x){ m_daughter1=x;}
124     void set_daughter2(int x){ m_daughter2=x;}
125 peiffer 1.5 void set_spin(int x){ m_spin=x;}
126 peiffer 1.1
127     private:
128     int m_pdgId;
129     int m_status;
130     int m_index;
131    
132     int m_mother1;
133     int m_mother2;
134     int m_daughter1;
135     int m_daughter2;
136 peiffer 1.5 int m_spin;
137 peiffer 1.1
138    
139     };
140    
141     #endif