]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliPrimaryGeneratorMessenger.cxx
Initial version
[u/mrichter/AliRoot.git] / AliGeant4 / AliPrimaryGeneratorMessenger.cxx
CommitLineData
676fb573 1// $Id$
2// Category: run
3//
4// See the class description in the header file.
5
6#include "AliPrimaryGeneratorMessenger.h"
7#include "AliPrimaryGeneratorAction.h"
676fb573 8#include "AliGlobals.h"
9
10#include <G4UIdirectory.hh>
11#include <G4UIcmdWithAString.hh>
12#include <G4UIcmdWithAnInteger.hh>
13
78ca1e9c 14//_____________________________________________________________________________
676fb573 15AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger(
16 AliPrimaryGeneratorAction* primaryGenAction)
17 : fPrimaryGenAction(primaryGenAction)
18{
19//
20 fPrimariesDirectory = new G4UIdirectory("/aliGenerator/");
21 fPrimariesDirectory->SetGuidance("AliPrimaryGeneratorAction control commands.");
22
23 fGeneratorCmd = new G4UIcmdWithAString("/aliGenerator/set", this);
24 G4String guidance = "Set one of the defined primary generators:\n";
25 guidance = guidance + " Gun: particle gun (default)\n";
26 guidance = guidance + " Geantino: geantino with random momentum(default)\n";
27 guidance = guidance + " ChargedGeantino: chargedgeantino with random momentum\n";
28 guidance = guidance + " AliGenerator: standard aliroot generator";
29 fGeneratorCmd->SetGuidance(guidance);
30 fGeneratorCmd->SetParameterName("Generator", true);
31 fGeneratorCmd->SetCandidates("Gun Geantino ChargedGeantino AliGenerator");
32 fGeneratorCmd->SetDefaultValue("AliGenerator");
33 fGeneratorCmd->AvailableForStates(PreInit,Idle);
34
35 fNofParticlesCmd = new G4UIcmdWithAnInteger("/aliGenerator/nofParticles", this);
36 fNofParticlesCmd->SetGuidance("Give number of primary particles:");
37 fNofParticlesCmd->SetGuidance("It is applied only to \"gun\" type generators.");
38 fNofParticlesCmd->SetParameterName("NofParticles", true);
39 fNofParticlesCmd->SetDefaultValue(1);
40 fNofParticlesCmd->SetRange("NofParticles >= 0");
41 fNofParticlesCmd->AvailableForStates(PreInit,Idle);
42
43 fVerboseCmd = new G4UIcmdWithAnInteger("/aliGenerator/verbose", this);
44 fVerboseCmd->SetGuidance("Set verbose level for AliPrimaryGeneratorAction");
45 fVerboseCmd->SetParameterName("VerboseLevel", true);
46 fVerboseCmd->SetDefaultValue(0);
47 fVerboseCmd->SetRange("VerboseLevel >= 0 && VerboseLevel <= 2");
48 fVerboseCmd->AvailableForStates(Idle);
49}
50
78ca1e9c 51//_____________________________________________________________________________
676fb573 52AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger() {
53//
54}
55
78ca1e9c 56//_____________________________________________________________________________
676fb573 57AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger(
58 const AliPrimaryGeneratorMessenger& right) {
59//
60 AliGlobals::Exception(
61 "AliPrimaryGeneratorMessenger is protected from copying.");
62}
63
78ca1e9c 64//_____________________________________________________________________________
676fb573 65AliPrimaryGeneratorMessenger::~AliPrimaryGeneratorMessenger() {
66//
67 delete fPrimariesDirectory;
68 delete fGeneratorCmd;
69 delete fNofParticlesCmd;
70 delete fVerboseCmd;
71}
72
73// operators
74
78ca1e9c 75//_____________________________________________________________________________
676fb573 76AliPrimaryGeneratorMessenger&
77AliPrimaryGeneratorMessenger::operator=(
78 const AliPrimaryGeneratorMessenger &right)
79{
80 // check assignement to self
81 if (this == &right) return *this;
82
83 AliGlobals::Exception(
84 "AliPrimaryGeneratorMessenger is protected from assigning.");
85
86 return *this;
87}
88
89// public methods
90
78ca1e9c 91//_____________________________________________________________________________
676fb573 92void AliPrimaryGeneratorMessenger::SetNewValue(G4UIcommand * command,
93 G4String newValue)
94{
95// Applies command to the associated object.
96// ---
97
98 if( command == fGeneratorCmd ) {
99 if (newValue == "Gun")
100 fPrimaryGenAction->SetGenerator(kGun);
101 else if (newValue == "Geantino")
102 fPrimaryGenAction->SetGenerator(kGeantino);
103 else if (newValue == "ChargedGeantino")
104 fPrimaryGenAction->SetGenerator(kChargedGeantino);
105 else if (newValue == "AliGenerator")
106 fPrimaryGenAction->SetGenerator(kAliGenerator);
107 }
108 else if( command == fNofParticlesCmd ) {
109 fPrimaryGenAction
110 ->SetNofGunParticles(fNofParticlesCmd->GetNewIntValue(newValue));
111 }
112 else if(command == fVerboseCmd) {
113 fPrimaryGenAction
114 ->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue));
115 }
116}
117