Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:09

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 /// \file eventgenerator/particleGun/src/PrimaryGeneratorAction.cc
0027 /// \brief Implementation of the PrimaryGeneratorAction class
0028 //
0029 //
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 #include "PrimaryGeneratorAction.hh"
0035 
0036 #include "PrimaryGeneratorAction0.hh"
0037 #include "PrimaryGeneratorAction1.hh"
0038 #include "PrimaryGeneratorAction2.hh"
0039 #include "PrimaryGeneratorAction3.hh"
0040 #include "PrimaryGeneratorAction4.hh"
0041 #include "PrimaryGeneratorMessenger.hh"
0042 
0043 #include "G4Event.hh"
0044 #include "G4ParticleDefinition.hh"
0045 #include "G4ParticleGun.hh"
0046 #include "G4ParticleTable.hh"
0047 #include "Randomize.hh"
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 
0051 PrimaryGeneratorAction::PrimaryGeneratorAction()
0052 {
0053   // default particle kinematic
0054   //
0055   G4int n_particle = 1;
0056   fParticleGun = new G4ParticleGun(n_particle);
0057 
0058   G4ParticleDefinition* particle = G4ParticleTable::GetParticleTable()->FindParticle("geantino");
0059   fParticleGun->SetParticleDefinition(particle);
0060 
0061   fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., 0.));
0062 
0063   fAction0 = new PrimaryGeneratorAction0(fParticleGun);
0064   fAction1 = new PrimaryGeneratorAction1(fParticleGun);
0065   fAction2 = new PrimaryGeneratorAction2(fParticleGun);
0066   fAction3 = new PrimaryGeneratorAction3(fParticleGun);
0067   fAction4 = new PrimaryGeneratorAction4(fParticleGun);
0068 
0069   // create a messenger for this class
0070   fGunMessenger = new PrimaryGeneratorMessenger(this);
0071 }
0072 
0073 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0074 
0075 PrimaryGeneratorAction::~PrimaryGeneratorAction()
0076 {
0077   delete fAction0;
0078   delete fAction1;
0079   delete fAction2;
0080   delete fAction3;
0081   delete fAction4;
0082   delete fParticleGun;
0083   delete fGunMessenger;
0084 }
0085 
0086 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0087 
0088 void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
0089 {
0090   switch (fSelectedAction) {
0091     case 0:
0092       fAction0->GeneratePrimaries(anEvent);
0093       break;
0094     case 1:
0095       fAction1->GeneratePrimaries(anEvent);
0096       break;
0097     case 2:
0098       fAction2->GeneratePrimaries(anEvent);
0099       break;
0100     case 3:
0101       fAction3->GeneratePrimaries(anEvent);
0102       break;
0103     case 4:
0104       fAction4->GeneratePrimaries(anEvent);
0105       break;
0106     default:
0107       G4cerr << "Invalid generator fAction" << G4endl;
0108   }
0109 }
0110 
0111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......