ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/UHHAnalysis/NtupleWriter/Objects/GenParticle.h
(Generate patch)

Comparing UserCode/UHHAnalysis/NtupleWriter/Objects/GenParticle.h (file contents):
Revision 1.3 by peiffer, Wed May 30 13:20:09 2012 UTC vs.
Revision 1.6 by rkogler, Fri Jun 14 15:00:45 2013 UTC

# Line 2 | Line 2
2   #define GenParticle_H
3  
4   #include "Particle.h"
5 + #include <iomanip>
6 + #include <iostream>
7 + #include <string>
8 + #include <sstream>
9 +
10 + /**
11 + *  @short generator particle class
12 + *  @author Thomas Peiffer
13 + */
14  
15   class GenParticle : public Particle{
16   public:
# Line 13 | Line 22 | class GenParticle : public Particle{
22      m_mother2=0;
23      m_daughter1=0;
24      m_daughter2=0;
25 +    m_spin=0;
26    };
27    ~GenParticle(){
28    };
# Line 24 | Line 34 | class GenParticle : public Particle{
34    int mother2() const{return m_mother2;}
35    int daughter1() const{return m_daughter1;}
36    int daughter2() const{return m_daughter2;}
37 +  int spin() const{return m_spin;}
38  
39    //return mother 1 or 2 (ind<=1 or ind>=2)
40 <  GenParticle* mother(std::vector<GenParticle> *gplist, int ind=1){
40 >  GenParticle* mother(std::vector<GenParticle> *gplist, int ind=1) const {
41      for(unsigned int i=0; i< gplist->size(); ++i){
42        if(ind<=1){
43          if(this->m_mother1 == gplist->at(i).index()){
# Line 42 | Line 53 | class GenParticle : public Particle{
53      //std::cout << "WARNING: Mother " << ind << " not found in list of GenParticles" << std::endl;
54      return 0;
55    }
56 +
57    //return daughter 1 or 2 (ind<=1 or ind>=2)
58 <  GenParticle* daughter(std::vector<GenParticle> *gplist, int ind=1){
58 >  GenParticle* daughter(std::vector<GenParticle> *gplist, int ind=1) const {
59      for(unsigned int i=0; i< gplist->size(); ++i){
60        if(ind<=1){
61          if(this->m_daughter1 == gplist->at(i).index()){
# Line 59 | Line 71 | class GenParticle : public Particle{
71      //std::cout << "WARNING: Daughter " << ind << " not found in list of GenParticles" << std::endl;
72      return 0;
73    }
74 +  
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  
118    void set_pdgId(int x){  m_pdgId=x;}
119    void set_status(int x){  m_status=x;}
# Line 67 | Line 122 | class GenParticle : public Particle{
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 +  void set_spin(int x){  m_spin=x;}
126  
127   private:
128    int m_pdgId;
# Line 77 | Line 133 | class GenParticle : public Particle{
133    int m_mother2;
134    int m_daughter1;
135    int m_daughter2;
136 +  int m_spin;
137  
138  
139   };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines