Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-03 07:52:20

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 G4BlinePrimaryGeneratorAction.cc
0027 /// \brief Implementation of the G4BlinePrimaryGeneratorAction class
0028 
0029 // --------------------------------------------------------------------
0030 //
0031 // G4BlinePrimaryGeneratorAction implementation
0032 //
0033 // --------------------------------------------------------------------
0034 // Author: Laurent Desorgher (desorgher@phim.unibe.ch)
0035 //         Created - 2003-10-06
0036 // --------------------------------------------------------------------
0037 
0038 #include "G4BlinePrimaryGeneratorAction.hh"
0039 
0040 #include "G4ChargedGeantino.hh"
0041 #include "G4Event.hh"
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4Types.hh"
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 
0047 void G4BlinePrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
0048 {
0049   if (!fUserPrimaryAction) {
0050     G4Exception("G4BlinePrimaryGeneratorAction::GeneratePrimaries()", "NullPointer", JustWarning,
0051                 "Primary generator action not defined !");
0052     return;
0053   }
0054 
0055   // For the first part of a bline the start position and time are defined
0056   // by using the USER primary action while for the second part the previous
0057   // values are taken.
0058 
0059   if (fFirstPartOfBline) {
0060     // set the position and time defined by using the USER primary action
0061 
0062     auto tmpEvent = new G4Event();
0063     fUserPrimaryAction->GeneratePrimaries(tmpEvent);
0064     fBlineStartPosition = tmpEvent->GetPrimaryVertex()->GetPosition();
0065     fT0 = tmpEvent->GetPrimaryVertex()->GetT0();
0066     delete tmpEvent;
0067   }
0068   fFirstPartOfBline = false;
0069 
0070   auto primary_vertex = new G4PrimaryVertex(fBlineStartPosition, fT0);
0071 
0072   // Define the particle to be tracked as Charged Geantino
0073 
0074   G4ChargedGeantino* pdef = G4ChargedGeantino::ChargedGeantino();
0075 
0076   G4double mass = pdef->GetPDGMass();
0077   G4double energy = 10000. * MeV + mass;
0078   G4double pmom = std::sqrt(energy * energy - mass * mass);
0079 
0080   // The momentum direction and energy do not have an effect in tracing of
0081   // bline but still need to be defined.
0082 
0083   G4double px = 0.;
0084   G4double py = 0.;
0085   G4double pz = pmom;
0086 
0087   auto particle = new G4PrimaryParticle(pdef, px, py, pz);
0088   particle->SetMass(mass);
0089   particle->SetCharge(pdef->GetPDGCharge());
0090   primary_vertex->SetPrimary(particle);
0091 
0092   anEvent->AddPrimaryVertex(primary_vertex);
0093 }