4 // Author: I. Hrivnacova
6 // Class AliPrimaryGeneratorMessenger
7 // ----------------------------------
8 // See the class description in the header file.
10 #include "AliPrimaryGeneratorMessenger.h"
11 #include "AliPrimaryGeneratorAction.h"
12 #include "AliGlobals.h"
14 #include <G4UIdirectory.hh>
15 #include <G4UIcmdWithAString.hh>
16 #include <G4UIcmdWithAnInteger.hh>
18 //_____________________________________________________________________________
19 AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger(
20 AliPrimaryGeneratorAction* primaryGenAction)
21 : fPrimaryGenAction(primaryGenAction)
24 fPrimariesDirectory = new G4UIdirectory("/aliGenerator/");
25 fPrimariesDirectory->SetGuidance("AliPrimaryGeneratorAction control commands.");
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);
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);
48 //_____________________________________________________________________________
49 AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger() {
53 //_____________________________________________________________________________
54 AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger(
55 const AliPrimaryGeneratorMessenger& right) {
57 AliGlobals::Exception(
58 "AliPrimaryGeneratorMessenger is protected from copying.");
61 //_____________________________________________________________________________
62 AliPrimaryGeneratorMessenger::~AliPrimaryGeneratorMessenger() {
64 delete fPrimariesDirectory;
66 delete fNofParticlesCmd;
71 //_____________________________________________________________________________
72 AliPrimaryGeneratorMessenger&
73 AliPrimaryGeneratorMessenger::operator=(
74 const AliPrimaryGeneratorMessenger &right)
76 // check assignement to self
77 if (this == &right) return *this;
79 AliGlobals::Exception(
80 "AliPrimaryGeneratorMessenger is protected from assigning.");
87 //_____________________________________________________________________________
88 void AliPrimaryGeneratorMessenger::SetNewValue(G4UIcommand * command,
91 // Applies command to the associated object.
94 if( command == fGeneratorCmd ) {
95 if (newValue == "Gun")
96 fPrimaryGenAction->SetGenerator(kGun);
97 else if (newValue == "Geantino")
98 fPrimaryGenAction->SetGenerator(kGeantino);
99 else if (newValue == "ChargedGeantino")
100 fPrimaryGenAction->SetGenerator(kChargedGeantino);
101 else if (newValue == "AliGenerator")
102 fPrimaryGenAction->SetGenerator(kAliGenerator);
104 else if( command == fNofParticlesCmd ) {
106 ->SetNofGunParticles(fNofParticlesCmd->GetNewIntValue(newValue));