Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:30:33

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/HepMC/HepMCEx02/include/H02PrimaryGeneratorAction.hh
0027 /// \brief Definition of the H02PrimaryGeneratorAction class
0028 //
0029 // ====================================================================
0030 //
0031 //   H02PrimaryGeneratorAction.hh
0032 //
0033 // ====================================================================
0034 #ifndef H02_PRIMARY_GENERATOR_ACTION_H
0035 #define H02_PRIMARY_GENERATOR_ACTION_H
0036 
0037 #include "G4VUserPrimaryGeneratorAction.hh"
0038 #include "globals.hh"
0039 
0040 #include <map>
0041 
0042 class G4Event;
0043 class G4VPrimaryGenerator;
0044 class H02PrimaryGeneratorMessenger;
0045 
0046 class H02PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
0047 {
0048   public:
0049     H02PrimaryGeneratorAction();
0050     ~H02PrimaryGeneratorAction();
0051 
0052     virtual void GeneratePrimaries(G4Event* anEvent);
0053 
0054     void SetGenerator(G4VPrimaryGenerator* gen);
0055     void SetGenerator(G4String genname);
0056 
0057     G4VPrimaryGenerator* GetGenerator() const;
0058     G4String GetGeneratorName() const;
0059 
0060   private:
0061     G4VPrimaryGenerator* fParticleGun;
0062     G4VPrimaryGenerator* fHepmcAscii;
0063     G4VPrimaryGenerator* fPythiaGen;
0064 
0065     G4VPrimaryGenerator* fCurrentGenerator;
0066     G4String fCurrentGeneratorName;
0067     std::map<G4String, G4VPrimaryGenerator*> fGentypeMap;
0068 
0069     H02PrimaryGeneratorMessenger* fMessenger;
0070 };
0071 
0072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0073 inline void H02PrimaryGeneratorAction::SetGenerator(G4VPrimaryGenerator* gen)
0074 {
0075   fCurrentGenerator = gen;
0076 }
0077 
0078 inline void H02PrimaryGeneratorAction::SetGenerator(G4String genname)
0079 {
0080   std::map<G4String, G4VPrimaryGenerator*>::iterator pos = fGentypeMap.find(genname);
0081   if (pos != fGentypeMap.end()) {
0082     fCurrentGenerator = pos->second;
0083     fCurrentGeneratorName = genname;
0084   }
0085 }
0086 
0087 inline G4VPrimaryGenerator* H02PrimaryGeneratorAction::GetGenerator() const
0088 {
0089   return fCurrentGenerator;
0090 }
0091 
0092 inline G4String H02PrimaryGeneratorAction::GetGeneratorName() const
0093 {
0094   return fCurrentGeneratorName;
0095 }
0096 
0097 #endif