Back to home page

EIC code displayed by LXR

 
 

    


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

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 PrimaryGenerator.cc
0027 /// \brief Implementation of the PrimaryGenerator1 class
0028 //
0029 //
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "PrimaryGenerator.hh"
0034 
0035 #include "G4Event.hh"
0036 #include "G4ParticleDefinition.hh"
0037 #include "G4ParticleTable.hh"
0038 #include "G4PhysicalConstants.hh"
0039 #include "G4PrimaryParticle.hh"
0040 #include "G4PrimaryVertex.hh"
0041 #include "G4SystemOfUnits.hh"
0042 #include "Randomize.hh"
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 void PrimaryGenerator::GeneratePrimaryVertex(G4Event* event)
0047 {
0048   // vertex A uniform on a cylinder
0049   //
0050   const G4double r = 2 * mm;
0051   const G4double zmax = 8 * mm;
0052   //
0053   G4double alpha = twopi * G4UniformRand();  // alpha uniform in (0, 2*pi)
0054   G4double ux = std::cos(alpha);
0055   G4double uy = std::sin(alpha);
0056   G4double z = zmax * (2 * G4UniformRand() - 1);  // z uniform in (-zmax, +zmax)
0057   G4ThreeVector positionA(r * ux, r * uy, z);
0058   G4double timeA = 0 * s;
0059   //
0060   G4PrimaryVertex* vertexA = new G4PrimaryVertex(positionA, timeA);
0061 
0062   // particle 1 at vertex A
0063   //
0064   G4ParticleDefinition* particleDefinition =
0065     G4ParticleTable::GetParticleTable()->FindParticle("geantino");
0066   G4PrimaryParticle* particle1 = new G4PrimaryParticle(particleDefinition);
0067   particle1->SetMomentumDirection(G4ThreeVector(ux, uy, 0));
0068   particle1->SetKineticEnergy(1 * MeV);
0069   //
0070   vertexA->SetPrimary(particle1);
0071   event->AddPrimaryVertex(vertexA);
0072 
0073   // vertex (B) symetric to vertex A
0074   //
0075   alpha += pi;
0076   ux = std::cos(alpha);
0077   uy = std::sin(alpha);
0078   G4ThreeVector positionB(r * ux, r * uy, z);
0079   G4double timeB = 1 * s;
0080   //
0081   G4PrimaryVertex* vertexB = new G4PrimaryVertex(positionB, timeB);
0082 
0083   // particles 2 and 3 at vertex B
0084   //
0085   const G4double dalpha = 10 * deg;
0086   ux = std::cos(alpha + dalpha);
0087   uy = std::sin(alpha + dalpha);
0088   G4PrimaryParticle* particle2 = new G4PrimaryParticle(particleDefinition);
0089   particle2->SetMomentumDirection(G4ThreeVector(ux, uy, 0));
0090   particle2->SetKineticEnergy(1 * keV);
0091   //
0092   ux = std::cos(alpha - dalpha);
0093   uy = std::sin(alpha - dalpha);
0094   G4PrimaryParticle* particle3 = new G4PrimaryParticle(particleDefinition);
0095   particle3->SetMomentumDirection(G4ThreeVector(ux, uy, 0));
0096   particle3->SetKineticEnergy(1 * GeV);
0097   //
0098   vertexB->SetPrimary(particle2);
0099   vertexB->SetPrimary(particle3);
0100   event->AddPrimaryVertex(vertexB);
0101 }
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......