Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:35

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