Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:17:05

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 //
0028 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0030 
0031 #include "RunActionMessenger.hh"
0032 
0033 #include "G4Tokenizer.hh"
0034 #include "G4UIcmdWithABool.hh"
0035 #include "G4UIcmdWithAnInteger.hh"
0036 #include "G4UIdirectory.hh"
0037 
0038 #include "RunAction.hh"
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 RunActionMessenger::RunActionMessenger(RunAction* runAction)
0043   : G4UImessenger(), fRunAction(runAction), fRunDir(nullptr), fScanParamsCmd(nullptr)
0044 {
0045   fRunDir = new G4UIdirectory("/tomography/run/");
0046   fRunDir->SetGuidance("run control");
0047 
0048   fScanParamsCmd = new G4UIcommand("/tomography/run/scanParameters", this);
0049   fScanParamsCmd->SetGuidance("Set scan parameters: number of projections, slices and pixels");
0050 
0051   auto nbProjections = new G4UIparameter("NbProjections", 'i', false);
0052   nbProjections->SetGuidance("number of scan projections");
0053   nbProjections->SetParameterRange("NbProjections>=1");
0054   fScanParamsCmd->SetParameter(nbProjections);
0055   //
0056   auto nbSlices = new G4UIparameter("NbSlices", 'i', false);
0057   nbSlices->SetGuidance("number of scan slices");
0058   nbSlices->SetParameterRange("NbSlices>=1");
0059   fScanParamsCmd->SetParameter(nbSlices);
0060   //
0061   auto nbPixels = new G4UIparameter("NbPixels", 'i', false);
0062   nbPixels->SetGuidance("number of scan pixels");
0063   nbPixels->SetParameterRange("NbPixels>=1");
0064   fScanParamsCmd->SetParameter(nbPixels);
0065   fScanParamsCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0066 
0067   resumeCmd = new G4UIcmdWithABool("/tomography/run/resumeSimulation", this);
0068   resumeCmd->SetGuidance("Resume the simulation after an interruption");
0069   resumeCmd->SetParameterName("interruptionFlag", true);
0070   resumeCmd->SetDefaultValue(false);
0071   resumeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0072 
0073   resumeProjectionIndexCmd =
0074     new G4UIcmdWithAnInteger("/tomography/run/resumeProjectionIndex", this);
0075   resumeProjectionIndexCmd->SetGuidance("Set the index of projection to resume the simulation");
0076   resumeProjectionIndexCmd->SetParameterName("ProjectionIndex", true);
0077   resumeProjectionIndexCmd->SetDefaultValue(0);
0078   resumeProjectionIndexCmd->SetRange("ProjectionIndex >=0");
0079   resumeProjectionIndexCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0080 }
0081 
0082 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0083 
0084 RunActionMessenger::~RunActionMessenger()
0085 {
0086   delete fRunDir;
0087   delete fScanParamsCmd;
0088   delete resumeCmd;
0089   delete resumeProjectionIndexCmd;
0090 }
0091 
0092 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0093 
0094 void RunActionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0095 {
0096   if (command == fScanParamsCmd) {
0097     G4Tokenizer next(newValue);
0098     G4int nbProjections = StoI(next());
0099     G4int nbSlices = StoI(next());
0100     G4int nbPixels = StoI(next());
0101     fRunAction->SetScanParameters(nbProjections, nbSlices, nbPixels);
0102   }
0103   else if (command == resumeCmd) {
0104     fRunAction->SetInterruptionFlag(resumeCmd->GetNewBoolValue(newValue));
0105   }
0106   else if (command == resumeProjectionIndexCmd) {
0107     fRunAction->SetResumeProjectionIndex(resumeProjectionIndexCmd->GetNewIntValue(newValue));
0108   }
0109 }
0110 
0111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......