Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 //--------------------------------------------------------------------------- 27 // ClassName: G4FTFTuningsMessenger 28 // Author: Alberto Ribon 29 // Date: August 2022 30 //--------------------------------------------------------------------------- 31 32 #include "G4FTFTuningsMessenger.hh" 33 #include "G4UIcommand.hh" 34 #include "G4UIcmdWithAnInteger.hh" 35 #include "G4UIcmdWithAString.hh" 36 #include "G4FTFTunings.hh" 37 38 39 G4FTFTuningsMessenger::G4FTFTuningsMessenger() { 40 // These two commands select an alternative set of FTF parameters (called "tune"): 41 // either via its integer index 42 theFTFTuneIndexCmd = new G4UIcmdWithAnInteger( "/process/had/models/ftf/selectTuneByIndex", this ); 43 theFTFTuneIndexCmd->SetGuidance( "Select one FTF set of parameters (tune) via its index: 0 (default), 1, 2, ..." ); 44 theFTFTuneIndexCmd->SetParameterName( "indexFTFTune", true ); 45 theFTFTuneIndexCmd->SetDefaultValue( 0 ); 46 theFTFTuneIndexCmd->SetRange( "indexFTFTune>=0" ); 47 theFTFTuneIndexCmd->AvailableForStates( G4State_PreInit ); 48 // or via its string name 49 theFTFTuneNameCmd = new G4UIcmdWithAString( "/process/had/models/ftf/selectTuneByName", this ); 50 theFTFTuneNameCmd->SetGuidance( "Select one FTF set of parametes (tune) via its name (string)." ); 51 theFTFTuneNameCmd->SetGuidance( " (default) is the default." ); 52 theFTFTuneNameCmd->SetParameterName( "nameFTFTune", true ); 53 theFTFTuneNameCmd->SetDefaultValue( "default" ); 54 theFTFTuneNameCmd->AvailableForStates( G4State_PreInit ); 55 } 56 57 58 G4FTFTuningsMessenger::~G4FTFTuningsMessenger() { 59 delete theFTFTuneIndexCmd; 60 delete theFTFTuneNameCmd; 61 } 62 63 64 void G4FTFTuningsMessenger::SetNewValue( G4UIcommand *command, G4String newValues ) { 65 if ( command == theFTFTuneIndexCmd || command == theFTFTuneNameCmd ) { 66 G4int index = -999; 67 if ( command == theFTFTuneIndexCmd ) { 68 G4int value = theFTFTuneIndexCmd->GetNewIntValue( newValues ); 69 if ( value >= 0 && value < G4FTFTunings::sNumberOfTunes ) { 70 index = value; 71 } else { 72 G4ExceptionDescription ed; 73 ed << "The FTF tune index=" << value << " value is wrong!"; 74 command->CommandFailed( ed ); 75 } 76 } else { 77 for ( G4int i = 0; i < G4FTFTunings::sNumberOfTunes; ++i ) { 78 if ( newValues == G4FTFTunings::Instance()->GetTuneName(i) ) { 79 index = i; 80 break; 81 } 82 } 83 if ( index < 0 ) { 84 G4ExceptionDescription ed; 85 ed << "The FTF tune name=" << newValues << " is not found!"; 86 command->CommandFailed( ed ); 87 } 88 } 89 if ( index >= 0 ) { 90 // Tune applicability state: 0 means switched off; 1 means switched on. 91 G4FTFTunings::Instance()->SetTuneApplicabilityState(index, 1); 92 } 93 } 94 } 95