Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 08:29:43

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 Par04ParallelMessenger.cc
0027 /// \brief Implementation of the Par04ParallelMessenger class
0028 
0029 #include "Par04ParallelMessenger.hh"
0030 
0031 #include "Par04ParallelFullWorld.hh"  // for Par04ParallelFullWorld
0032 
0033 #include "G4UIcmdWithABool.hh"  // for G4UIcmdWithABool
0034 #include "G4UIcmdWithAnInteger.hh"  // for G4UIcmdWithAnInteger
0035 #include "G4UIcmdWithoutParameter.hh"  // for G4UIcmdWithoutParameter
0036 #include "G4UIdirectory.hh"  // for G4UIdirectory
0037 
0038 #include <CLHEP/Units/SystemOfUnits.h>  // for pi
0039 #include <G4ApplicationState.hh>  // for G4State_PreInit, G4State_Idle
0040 #include <G4ThreeVector.hh>  // for G4ThreeVector
0041 #include <G4Types.hh>  // for G4bool, G4double, G4int
0042 #include <G4UIcommand.hh>  // for G4UIcommand
0043 #include <G4UImessenger.hh>  // for G4UImessenger
0044 #include <G4UIparameter.hh>  // for G4UIparameter
0045 #include <istream>  // for basic_istream, basic_istream...
0046 #include <string>  // for operator>>
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 Par04ParallelMessenger::Par04ParallelMessenger(Par04ParallelFullWorld* aParallel)
0051   : G4UImessenger(), fParallel(aParallel)
0052 {
0053   fExampleDir = new G4UIdirectory("/Par04/");
0054   fExampleDir->SetGuidance("UI commands specific to this example");
0055 
0056   fParallelDir = new G4UIdirectory("/Par04/parallel/");
0057   fParallelDir->SetGuidance("Parallel construction UI commands");
0058 
0059   fPrintCmd = new G4UIcmdWithoutParameter("/Par04/parallel/print", this);
0060   fPrintCmd->SetGuidance("Print current settings.");
0061 
0062   fNbSlicesCmd = new G4UIcmdWithAnInteger("/Par04/parallel/setNbOfSlices", this);
0063   fNbSlicesCmd->SetGuidance("Set number of slices.");
0064   fNbSlicesCmd->SetParameterName("NbSlices", false);
0065   fNbSlicesCmd->SetRange("NbSlices>0");
0066   fNbSlicesCmd->AvailableForStates(G4State_PreInit);
0067   fNbSlicesCmd->SetToBeBroadcasted(false);
0068 
0069   fNbRowsCmd = new G4UIcmdWithAnInteger("/Par04/parallel/setNbOfRows", this);
0070   fNbRowsCmd->SetGuidance("Set number of rows.");
0071   fNbRowsCmd->SetParameterName("NbRows", false);
0072   fNbRowsCmd->SetRange("NbRows>0");
0073   fNbRowsCmd->AvailableForStates(G4State_PreInit);
0074   fNbRowsCmd->SetToBeBroadcasted(false);
0075 }
0076 
0077 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0078 
0079 Par04ParallelMessenger::~Par04ParallelMessenger()
0080 {
0081   delete fPrintCmd;
0082   delete fNbSlicesCmd;
0083   delete fNbRowsCmd;
0084   delete fParallelDir;
0085   delete fExampleDir;
0086 }
0087 
0088 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0089 
0090 void Par04ParallelMessenger::SetNewValue(G4UIcommand* aCommand, G4String aNewValue)
0091 {
0092   if (aCommand == fPrintCmd) {
0093     fParallel->Print();
0094   }
0095   else if (aCommand == fNbSlicesCmd) {
0096     fParallel->SetNbOfSlices(fNbSlicesCmd->GetNewIntValue(aNewValue));
0097   }
0098   else if (aCommand == fNbRowsCmd) {
0099     fParallel->SetNbOfRows(fNbRowsCmd->GetNewIntValue(aNewValue));
0100   }
0101 }
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0104 
0105 G4String Par04ParallelMessenger::GetCurrentValue(G4UIcommand* aCommand)
0106 {
0107   G4String cv;
0108 
0109   if (aCommand == fNbSlicesCmd) {
0110     cv = fNbSlicesCmd->ConvertToString(fParallel->GetNbOfSlices());
0111   }
0112   else if (aCommand == fNbRowsCmd) {
0113     cv = fNbRowsCmd->ConvertToString(fParallel->GetNbOfRows());
0114   }
0115   return cv;
0116 }