Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:03

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 
0029 #include "FlashPrimaryGeneratorAction.hh"
0030 #include "G4SystemOfUnits.hh"
0031 
0032 #include "G4Event.hh"
0033 #include "G4GeneralParticleSource.hh"
0034 #include "G4ParticleDefinition.hh"
0035 #include "G4ParticleGun.hh"
0036 #include "G4ParticleTable.hh"
0037 #include "Randomize.hh"
0038 #include "globals.hh"
0039 
0040 FlashPrimaryGeneratorAction::FlashPrimaryGeneratorAction() {
0041 
0042   particleGun = new G4GeneralParticleSource();
0043 
0044   SetDefaultPrimaryParticle();
0045 }
0046 
0047 FlashPrimaryGeneratorAction::~FlashPrimaryGeneratorAction() {
0048   delete particleGun;
0049 }
0050 
0051 void FlashPrimaryGeneratorAction::SetDefaultPrimaryParticle() {
0052   
0053   G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable();
0054   G4ParticleDefinition *particle = particleTable->FindParticle("e-");
0055   particleGun->SetParticleDefinition(particle);
0056 
0057 
0058   G4double defaultX0 = -113 * cm; //the beam propagates in the x direction from x=-100cm
0059 
0060   X0 = defaultX0;
0061 
0062   G4double defaultY0 = 0.0 * mm;
0063   Y0 = defaultY0;
0064 
0065   G4double defaultZ0 = 0.0 * mm;
0066   Z0 = defaultZ0;
0067 
0068   G4double defaultsigmaY = 2.5*mm;
0069 
0070   sigmaY = defaultsigmaY;
0071 
0072   G4double defaultsigmaZ = 2.5*mm;
0073 
0074   sigmaZ = defaultsigmaZ;
0075 
0076   G4double defaultTheta = 2 * deg;
0077 
0078   Theta = defaultTheta;
0079 }
0080 
0081 void FlashPrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent) {
0082 
0083   //Energy is defined in 9MeVEF.mac and 7MeVEF.mac for the 9 MeV and 7 MeV spectrum respectively
0084 
0085   G4double x = X0;//the beam has a gaussian shape
0086   G4double y = Y0;
0087   G4double z = Z0;
0088 
0089   if (sigmaY > 0.0) {
0090     y += G4RandGauss::shoot(Y0, sigmaY);
0091   }
0092 
0093   if (sigmaZ > 0.0) {
0094     z += G4RandGauss::shoot(Z0, sigmaZ);
0095   }
0096 
0097   particleGun->GetCurrentSource()->GetPosDist()->SetCentreCoords(G4ThreeVector(x, y, z));
0098 
0099       particleGun->GetCurrentSource()->GetAngDist()->SetAngDistType("beam2d"); //define angular divergence
0100         particleGun->GetCurrentSource()->GetAngDist()->DefineAngRefAxes("angref1", G4ThreeVector( 0, 0,1.));//define reference axis for divergence
0101         
0102         particleGun->GetCurrentSource()->GetAngDist()->SetBeamSigmaInAngX(Theta);//set planar divergence
0103         particleGun->GetCurrentSource()->GetAngDist()->SetBeamSigmaInAngY(Theta);//set planar divergence
0104         particleGun->GetCurrentSource()->GetAngDist()->SetParticleMomentumDirection(G4ThreeVector(1,0,0));//beam propagates in the x direction
0105 
0106   particleGun->GeneratePrimaryVertex(anEvent);
0107 }