• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/Users/jmonk/Physics/ForIA/src/TruthParticle.cxx

Go to the documentation of this file.
00001 #include "ForIA/TruthParticle.hh"
00002 
00003 #include <cmath>
00004 #include <stdexcept>
00005 
00006 namespace ForIA{
00007  
00008   TruthParticle::TruthParticle(): IFourMomentum(), 
00009   m_gotpx(false), m_gotpy(false), m_gotpz(false),
00010   m_haveTheta(false), 
00011   m_haveEta(false), m_haveET(false), m_haveE(false), m_haveMass(false),
00012   m_haveMotherPdgId(false){
00013     
00014   }
00015   
00016   double TruthParticle::eta() const{
00017     
00018     if(!m_haveEta){
00019       if(!m_haveTheta){
00020         throw std::runtime_error("TruthParticle was asked for eta, but neither eta nor theta is set.");
00021       }
00022       
00023       m_haveEta = true;
00024       
00025       m_eta = -log(tan(0.5 * m_theta));
00026     }
00027     return m_eta;
00028   }
00029   
00030   double TruthParticle::theta() const{
00031    
00032     if(!m_haveTheta){
00033       if(!m_haveEta){
00034         throw std::runtime_error("TruthParticle was asked for theta, but neither eta nor theta is set.");
00035       }
00036       
00037       m_haveTheta = true;
00038       m_theta = 2. * atan(exp(-m_eta));
00039     }
00040     return m_theta;
00041   }
00042  
00043   double TruthParticle::phi()const{
00044     return m_phi;
00045   }
00046   
00047   double TruthParticle::ET()const{
00048     
00049     if(!m_haveET){
00050       if(!m_haveE){
00051         throw std::runtime_error("TruthParticle was asked for ET, but neither energy nor transverse energy is set.");
00052       }
00053       
00054       //m_et = m_e * cos(theta());
00055       m_et = m_e * fabs(sin(theta()));
00056       m_haveET = true;
00057     }
00058     
00059     return m_et;
00060   }
00061   
00062   double TruthParticle::PT()const{
00063     return m_pt;
00064   }
00065   
00066   double TruthParticle::E()const{
00067     if(!m_haveE){
00068       if(!m_haveET){
00069         throw std::runtime_error("TruthParticle was asked for energy, but neither energy nor transverse energy is set.");
00070       }
00071       //m_e = m_et / cos(theta());
00072       m_e = m_et / sin(theta());
00073     }
00074     
00075     return m_e;
00076   }
00077   
00078   double TruthParticle::m()const{
00079     if(!m_haveMass){
00080       throw std::runtime_error("TruthParticle was asked for mass, but has not been set");
00081     }
00082     return m_mass;
00083   }
00084   
00085   double TruthParticle::px()const{
00086     if(m_gotpx) return m_px;
00087     m_px = PT() * sin(phi());
00088     m_gotpx = true;
00089     return m_px;
00090   }
00091 
00092   double TruthParticle::py()const{
00093     if(m_gotpy) return m_py;
00094     m_py = PT() * cos(phi());
00095     m_gotpy = true;
00096     return m_py;
00097   }
00098   
00099   double TruthParticle::pz()const{
00100     if(m_gotpz) return m_pz;
00101     double tanp = tan(theta());
00102     if(fabs(tanp) < 1.e-12){
00103       m_pz = sqrt(E()*E() - m()*m());
00104     }else{
00105       m_pz = PT() / tanp;
00106     }
00107     m_gotpz = true;
00108     return m_pz;
00109   }
00110   
00111   int TruthParticle::pdgId()const{
00112     return m_pdg;
00113   }
00114   
00115   double TruthParticle::charge()const{
00116     return m_charge;
00117   }
00118   
00119   int TruthParticle::barcode()const{
00120     return m_barcode;
00121   }
00122   
00123   int TruthParticle::status()const{
00124     return m_status;
00125   }
00126   
00127   int TruthParticle::motherPdgId()const{
00128     if(!m_haveMotherPdgId) throw std::runtime_error("TruthParticle was asked for mother PDG ID, but has not been set");
00129     return m_motherPdg;
00130   }
00131   
00132 }

Generated on Mon Jul 30 2012 16:56:35 for ForIA by  doxygen 1.7.2