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