Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:15:17

0001 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0002   Implementation of Particle class. See Particle.hxx
0003   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
0004 
0005 #include "Particle.hxx"
0006 #include "TVector3.h"
0007 #include "TMath.h"
0008 
0009 #include <iostream>
0010 #include <stdio.h>
0011 #include <string.h>
0012 
0013 using namespace TMath;
0014 
0015 int Particle::GetPid()
0016 {
0017   return pid;
0018 }
0019 void Particle::SetPid(int x)
0020 {
0021   pid = x;
0022 }
0023 int Particle::GetCharge()
0024 {
0025   return charge;
0026 }
0027 void Particle::SetCharge(int x)
0028 {
0029   charge = x;
0030 }
0031 double Particle::GetMass()
0032 {
0033   return proper_mass;
0034 }
0035 void Particle::SetMass(double x)
0036 {
0037   proper_mass = x;
0038 }
0039 double Particle::GetVx()
0040 {
0041   return vx;
0042 }
0043 double Particle::GetVy()
0044 {
0045   return vy;
0046 }
0047 double Particle::GetVz()
0048 {
0049   return vz;
0050 }
0051 void Particle::SetVx(double x)
0052 {
0053   vx = x;
0054 }
0055 void Particle::SetVy(double x)
0056 {
0057   vy = x;
0058 }
0059 void Particle::SetVz(double x)
0060 {
0061   vz = x;
0062 }
0063 
0064 int Particle::Complete(Particle a, Particle b)
0065 {
0066   TVector3 pa = a.Vect();
0067   TVector3 pb = b.Vect();
0068   TVector3 p0(0,0,0);
0069   TVector3 pthis = p0 - (pa+pb);
0070   SetVectM(pthis, proper_mass);
0071 }
0072 
0073 Particle::Particle(double m, double px, double py, double pz)
0074 {
0075   TVector3 v(px,py,pz);
0076   SetVectM(v, m);
0077   proper_mass = m;
0078 }
0079 
0080 Particle::Particle(double m, TVector3& v)
0081 {
0082   SetVectM(v,m);
0083   proper_mass = m;
0084 }
0085 
0086 Particle::Particle(double m, Particle a, Particle b)
0087 {
0088   proper_mass = m;
0089   Complete(a,b);
0090 }
0091 
0092 Particle Particle::operator + (const Particle& q)
0093 {
0094   Particle result;
0095   double Eresult = this->E() + q.E();
0096   TVector3 Presult = this->Vect()+q.Vect();
0097   result.SetE(Eresult);
0098   result.SetVect(Presult);
0099   return result;
0100 }
0101 
0102 Particle Particle::operator - (const Particle& q)
0103 {
0104   Particle result;
0105   double Eresult = this->E() - q.E();
0106   TVector3 Presult = this->Vect()-q.Vect();
0107   result.SetE(Eresult);
0108   result.SetVect(Presult);
0109   return result;
0110 }
0111 
0112 Particle Particle::operator -()
0113 {
0114   Particle result;
0115   result.SetVect(-this->Vect());
0116   return result;
0117 }
0118 
0119 // PID and Proper_should not change
0120 // This operator overload makes sure these things stay
0121 // the same as new particles are generated, and that
0122 // the memory allocation remains persistant
0123 Particle Particle::operator = (const Particle& q)
0124 {
0125   this->SetPxPyPzE(q.Px(),q.Py(),q.Pz(),q.E());
0126   return *this;
0127 }
0128 
0129 double Particle::Pmag()
0130 {
0131   return this->Vect().Mag();
0132 }
0133 
0134 char * Particle::GetName()
0135 {
0136   return identifier;
0137 }
0138 
0139 void Particle::SetName(char * name)
0140 {
0141   strcpy(identifier, name);
0142 }
0143 
0144 void Particle::SetThetaPhiE(double theta, double phi, double E)
0145 {
0146   TVector3* P = new TVector3(0,0,1);
0147   P->SetTheta(theta);
0148   P->SetPhi(phi);
0149   double Pmag = Sqrt(E*E - proper_mass*proper_mass);
0150   P->SetMag(Pmag);
0151 
0152   this->SetVectM(*P,proper_mass);
0153 
0154   delete P;
0155 }
0156 
0157 void Particle::SetThetaPhiP(double theta, double phi, double P)
0158 {
0159   TVector3* Pvec = new TVector3(0,0,1);
0160   Pvec->SetTheta(theta);
0161   Pvec->SetPhi(phi);
0162   double Pmag = P;
0163   Pvec->SetMag(Pmag);
0164 
0165   this->SetVectM(*Pvec,proper_mass);
0166 
0167   delete Pvec;
0168 }
0169 
0170 
0171 Particle::Particle(double m, const char* name, int pid_in)
0172 {
0173   proper_mass = m;
0174   pid = pid_in;
0175   strcpy(identifier, name);
0176   this->SetPxPyPzE(0, 0, 0, m);
0177 }