MollerPrimaryGenAction.cc
Go to the documentation of this file.00001 #include "MollerPrimaryGenAction.hh"
00002 #include "MollerPrimaryGeneratorMessenger.hh"
00003
00004 #include "G4Event.hh"
00005 #include "G4ParticleGun.hh"
00006 #include "G4ParticleTable.hh"
00007 #include "G4ParticleDefinition.hh"
00008 #include "G4Electron.hh"
00009 #include "globals.hh"
00010 #include "TRandom2.h"
00011
00012
00013 MollerPrimaryGenAction::MollerPrimaryGenAction() : ebeam(11.000), mp(0.9382796), bremcut(1.0e-6), me(0.511E-3)
00014 {
00015
00016
00017 gunMessenger = new MollerPrimaryGeneratorMessenger(this);
00018
00019 eventnumber=0;
00020
00021 G4int n_particle = 1;
00022 particleGun = new G4ParticleGun(n_particle);
00023
00024
00025
00026 G4ParticleDefinition* particle = G4Electron::ElectronDefinition();
00027
00028 G4cout << "Electron gun created!!\n" << G4endl;
00029
00030 particleGun->SetParticleDefinition(particle);
00031 particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
00032 particleGun->SetParticleEnergy(11.0*GeV);
00033 particleGun->SetParticlePosition(G4ThreeVector(0.*cm, 0.*cm, -125.*cm));
00034 }
00035
00036 MollerPrimaryGenAction::~MollerPrimaryGenAction()
00037 {
00038 delete particleGun;
00039 delete gunMessenger;
00040 }
00041
00042 void MollerPrimaryGenAction::GeneratePrimaries(G4Event* anEvent)
00043 {
00044 if(anEvent->GetEventID()==0){
00045 TRandom2 *random_num = new TRandom2(0);
00046 long particle_seed = (long) random_num->GetSeed();
00047 particle_seed += time(0);
00048
00049 if (!fSetSeedConst) {
00050 G4cout<<"Setting the seed to a random value..."<<anEvent->GetEventID()<<G4endl;
00051 CLHEP::HepRandom::setTheSeed(particle_seed);
00052 }
00053 if (fSetSeedConst) {
00054 G4cout<<"Setting the seed to a constant value..."<<anEvent->GetEventID()<<G4endl;
00055
00056
00057 CLHEP::HepRandom::setTheSeed(94528347598798);
00058 }
00059
00060 }
00061
00062
00063
00064
00065 switch(GeneratorNumber) {
00066 case 0:
00067 GeneratePrimaries_moller_dustin(anEvent);
00068 break;
00069 case 1:
00070 GeneratePrimaries_elasticep_dustin(anEvent);
00071 break;
00072 case 2:
00073 GeneratePrimaries_inelasticep_dustin(anEvent);
00074 break;
00075 case 3:
00076 GeneratePrimaries_phasespace_mollers(anEvent);
00077 break;
00078 case 4:
00079 GeneratePrimaries_phasespace_motts(anEvent);
00080 break;
00081 default:
00082 G4cerr << "Generator number " << GeneratorNumber << " does not exist!\n";
00083 G4cerr << "Choose which generator to use.\n";
00084 G4cerr << " Choice : 0. Moller electrons (Dustin) [default]\n";
00085 G4cerr << " 1. Elastic ep electrons (Dustin)\n";
00086 G4cerr << " 2. Inelastic ep electrons (Dustin)\n";
00087 G4cerr << " 3. Optics rays electrons (Moller scattering)\n";
00088 G4cerr << " 4. Optics rays electrons (Mott scattering)\n";
00089 G4cerr << "Running with default.\n";
00090 GeneratePrimaries_moller_dustin(anEvent);
00091 break;
00092 }
00093 }
00094
00095 double MollerPrimaryGenAction::RadProfile(double eloss, double btt){
00096 double Ekin = ebeam - me;
00097 return 1./eloss*(1.-eloss/Ekin+0.75*pow(eloss/Ekin,2))*pow(eloss/Ekin,btt);
00098 }
00099
00100
00101 double MollerPrimaryGenAction::EnergNumInt(double btt, double a0, double b0)
00102 {
00103
00104 double sum = 0.0;
00105
00106 int j;
00107 double boolc[5] = {7.0, 32.0, 12.0, 32.0, 7.0};
00108
00109 double a, b, thissum;
00110
00111 for(int i =0;i<nbin;i++) {
00112
00113 a = bremcut*pow(b0/a0, (((double) i)/nbin));
00114 b = bremcut*pow(b0/a0, (((double) i+1.0)/nbin));
00115
00116
00117 thissum = 0.0;
00118 for( j = 0; j < 5; j++ ){
00119 thissum += boolc[j]*RadProfile( (b-a)*j*0.25 + a, btt);
00120 }
00121 sum += thissum*(b-a)/90.0;
00122 }
00123
00124 return sum;
00125 }
00126