Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #include "Particle.hxx"
0002 #include "CustomRand.hxx"
0003 
0004 #include "TRandom2.h"
0005 #include "TMath.h"
0006 
0007 #include "TargetGen.hxx"
0008 
0009 using namespace TMath;
0010 
0011 TargetGen::TargetGen(double mass_in, bool fermi_in)
0012 {
0013   mass = mass_in;
0014   char fname[100] = "TargetParticle";
0015   double ERange[2] = {0,300};
0016   double ThetaRange[2] = {0, Pi()};
0017   double PhiRange[2] = {0, 2*Pi()};
0018   Rand = new CustomRand(fname, ERange, ThetaRange, PhiRange);
0019 
0020   fermi = fermi_in;
0021 
0022   TargetParticle = new Particle();
0023   TargetParticle -> SetMass(mass);
0024 
0025   fRandom = new TRandom2(0);
0026 
0027   for(int i=0; i<300; i++) fProb[i]/=2;
0028 
0029 }
0030 
0031 double TargetGen::FermiMomentum()
0032 {
0033   fMom;
0034   kFermi = true;
0035   while ( kFermi ) {
0036     fProton_Rand_Mom_Col      = fRandom->Uniform( 0, 300.0);
0037     fProton_Rand_Mom_Col_Prob = fRandom->Uniform( fProb[299], fProb[0] );
0038     fProton_Mom_Int           = std::ceil( fProton_Rand_Mom_Col );
0039     f3He_Value                = fProb[ fProton_Mom_Int - 1 ];
0040 
0041     if ( fProton_Rand_Mom_Col_Prob <= f3He_Value ) {
0042       fMom = fProton_Rand_Mom_Col;
0043       kFermi = false;
0044     }
0045   }
0046 
0047   return fMom;
0048 }
0049 
0050 Particle* TargetGen::GetParticle()
0051 {
0052   TargetParticle -> SetPxPyPzE(0,0,0,mass);
0053 
0054   if(fermi){
0055     TargetParticle -> SetThetaPhiP(Rand->Theta(),
0056                                    Rand->Phi(),
0057                                    FermiMomentum()
0058                                    );
0059   }
0060 
0061   return TargetParticle;
0062 }