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