Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 08:29:55

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