Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FTFTuningsMessenger.cc
Go to the documentation of this file.
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
33#include "G4UIcommand.hh"
35#include "G4UIcmdWithAString.hh"
36#include "G4FTFTunings.hh"
37
38
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
59 delete theFTFTuneIndexCmd;
60 delete theFTFTuneNameCmd;
61}
62
63
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 {
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 ) {
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.
92 }
93 }
94}
@ G4State_PreInit
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
int G4int
Definition: G4Types.hh:85
void SetNewValue(G4UIcommand *command, G4String newValues) override
static const G4int sNumberOfTunes
void SetTuneApplicabilityState(const G4int index, const G4int state)
static G4FTFTunings * Instance()
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
void SetDefaultValue(G4int defVal)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:157
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:179
void SetRange(const char *rs)
Definition: G4UIcommand.hh:121
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:287