source: trunk/source/geometry/magneticfield/test/NTST/src/NTSTPrimaryGeneratorMessenger.cc@ 1207

Last change on this file since 1207 was 1199, checked in by garnier, 16 years ago

nvx fichiers dans CVS

File size: 4.4 KB
Line 
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// $Id: NTSTPrimaryGeneratorMessenger.cc,v 1.3 2006/06/29 18:26:29 gunter Exp $
27//
28
29//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
31
32#include "NTSTPrimaryGeneratorMessenger.hh"
33#include "G4UIcmdWithAString.hh"
34#include "G4UIcmdWithABool.hh"
35#include "G4UIdirectory.hh"
36
37//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
38
39NTSTPrimaryGeneratorMessenger::NTSTPrimaryGeneratorMessenger()
40 : ChooseCmd(0), PrintCmd(0), generator(0), print(0)
41{ // set the available commands
42 GenDir = new G4UIdirectory("/gen/");
43 GenDir->SetGuidance("NTST generator control");
44 ChooseCmd = new G4UIcmdWithAString("/gen/choose",this);
45 ChooseCmd->SetGuidance("Choose the generator to use.");
46 ChooseCmd->SetDefaultValue("gun");
47 G4String Names("gun evt");
48 // ChooseCmd->SetCandidates(Names);
49 // ChooseCmd->AvailableForStates(PreInit,Idle);
50 SetNewValue(ChooseCmd, "gun");
51
52 // (en,dis)able printing
53 PrintCmd = new G4UIcmdWithABool("/gen/print", this);
54 G4cout << "### Instantiated /gen/print cmd" << G4endl;
55 PrintCmd->SetGuidance("print events (true) or not (false).");
56 G4cout << "### SetGuidance for /gen/print" << G4endl;
57 PrintCmd->SetDefaultValue(false);
58 G4cout << "### Set default value for /gen/print cmd" << G4endl;
59}
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
62
63NTSTPrimaryGeneratorMessenger::~NTSTPrimaryGeneratorMessenger()
64{
65 delete ChooseCmd;
66 delete PrintCmd;
67 delete generator;
68}
69
70//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
71
72#include "NTSTGunGenerator.hh"
73#include "NTSTBabarEvtReadGenerator.hh"
74
75void
76NTSTPrimaryGeneratorMessenger::
77SetNewValue(G4UIcommand* command, G4String newValue)
78{
79 if( command == ChooseCmd ) {
80 if (newValue == "gun") {
81 Choice = GUN;
82 delete generator;
83 generator = new NTSTGunGenerator();
84 G4cout << "### instantiated " << newValue << " generator" << G4endl;
85 Name = newValue;
86 } else if (newValue == "evt") {
87 Choice = EVT;
88 delete generator;
89 generator = new NTSTBabarEvtReadGenerator("babarevt.out");
90 G4cout << "### instantiated " << newValue << " generator" << G4endl;
91 Name = newValue;
92 } else {
93 G4cerr << "!!! Illegal choice of generator: \"" << newValue
94 << "\"" << G4endl;
95 G4cerr << "!!! Valid choices are " << GetNames() << G4endl;
96 G4cerr << "!!! Old generator: \"" << GetName() << "\" retained"
97 << G4endl;
98 }
99 } else if ( command == PrintCmd ) {
100 if (newValue == "0" || newValue == "false") DisablePrinting();
101 else if (newValue == "1" || newValue == "true") EnablePrinting();
102 else G4cerr << "PrintCmd \"" << newValue << "\" not understood" << G4endl;
103 }
104}
105
106
107
108
Note: See TracBrowser for help on using the repository browser.