Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-18 09:32: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 //
0027 /// \file field/field04/src/F04RunActionMessenger.cc
0028 /// \brief Implementation of the F04RunActionMessenger class
0029 //
0030 
0031 #include "F04RunActionMessenger.hh"
0032 
0033 #include "F04RunAction.hh"
0034 
0035 #include "G4UIcmdWithABool.hh"
0036 #include "G4UIcmdWithAString.hh"
0037 #include "G4UIcmdWithAnInteger.hh"
0038 #include "G4UIdirectory.hh"
0039 #include "Randomize.hh"
0040 #include "globals.hh"
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 F04RunActionMessenger::F04RunActionMessenger(F04RunAction* runAction) : fRunAction(runAction)
0045 {
0046   fRndmDir = new G4UIdirectory("/rndm/");
0047   fRndmDir->SetGuidance("Rndm status control.");
0048 
0049   fRndmSaveCmd = new G4UIcmdWithAnInteger("/rndm/save", this);
0050   fRndmSaveCmd->SetGuidance("set frequency to save rndm status on external files.");
0051   fRndmSaveCmd->SetGuidance("freq = 0 not saved");
0052   fRndmSaveCmd->SetGuidance("freq > 0 saved on: beginOfRun.rndm");
0053   fRndmSaveCmd->SetGuidance("freq = 1 saved on:   endOfRun.rndm");
0054   fRndmSaveCmd->SetGuidance("freq = 2 saved on: endOfEvent.rndm");
0055   fRndmSaveCmd->SetParameterName("frequency", false);
0056   fRndmSaveCmd->SetRange("frequency>=0 && frequency<=2");
0057   fRndmSaveCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0058 
0059   fRndmReadCmd = new G4UIcmdWithAString("/rndm/read", this);
0060   fRndmReadCmd->SetGuidance("get rndm status from an external file.");
0061   fRndmReadCmd->SetParameterName("fileName", true);
0062   fRndmReadCmd->SetDefaultValue("beginOfRun.rndm");
0063   fRndmReadCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0064 
0065   fSetAutoSeedCmd = new G4UIcmdWithABool("/rndm/autoSeed", this);
0066   fSetAutoSeedCmd->SetGuidance("Switch on/off time-based random seeds");
0067   fSetAutoSeedCmd->SetGuidance(" true: run seeds determined by system time");
0068   fSetAutoSeedCmd->SetGuidance("false: use command 'random/resetEngineFrom'");
0069   fSetAutoSeedCmd->SetGuidance("Default = false");
0070   fSetAutoSeedCmd->SetParameterName("autoSeed", false);
0071   fSetAutoSeedCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0072 }
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0075 
0076 F04RunActionMessenger::~F04RunActionMessenger()
0077 {
0078   delete fRndmDir;
0079   delete fRndmSaveCmd;
0080   delete fRndmReadCmd;
0081   delete fSetAutoSeedCmd;
0082 }
0083 
0084 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0085 
0086 void F04RunActionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0087 {
0088   if (command == fRndmSaveCmd) fRunAction->SetRndmFreq(fRndmSaveCmd->GetNewIntValue(newValue));
0089 
0090   if (command == fRndmReadCmd) {
0091     G4cout << "\n---> rndm status restored from file: " << newValue << G4endl;
0092     G4Random::restoreEngineStatus(newValue);
0093     G4Random::showEngineStatus();
0094   }
0095 
0096   if (command == fSetAutoSeedCmd)
0097     fRunAction->SetAutoSeed(fSetAutoSeedCmd->GetNewBoolValue(newValue));
0098 }