]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliPrimaryGeneratorMessenger.cxx
First commit
[u/mrichter/AliRoot.git] / AliGeant4 / AliPrimaryGeneratorMessenger.cxx
1 // $Id$
2 // Category: run
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class AliPrimaryGeneratorMessenger
7 // ----------------------------------
8 // See the class description in the header file.
9
10 #include "AliPrimaryGeneratorMessenger.h"
11 #include "AliPrimaryGeneratorAction.h"
12 #include "AliGlobals.h"
13
14 #include <G4UIdirectory.hh>
15 #include <G4UIcmdWithAString.hh>
16 #include <G4UIcmdWithAnInteger.hh>
17
18 //_____________________________________________________________________________
19 AliPrimaryGeneratorMessenger::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
48 //_____________________________________________________________________________
49 AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger() {
50 //
51 }
52
53 //_____________________________________________________________________________
54 AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger(
55                                  const AliPrimaryGeneratorMessenger& right) {
56 //                               
57   AliGlobals::Exception(
58     "AliPrimaryGeneratorMessenger is protected from copying.");
59 }
60
61 //_____________________________________________________________________________
62 AliPrimaryGeneratorMessenger::~AliPrimaryGeneratorMessenger() {
63 //
64   delete fPrimariesDirectory;
65   delete fGeneratorCmd;
66   delete fNofParticlesCmd;
67 }
68
69 // operators
70
71 //_____________________________________________________________________________
72 AliPrimaryGeneratorMessenger& 
73 AliPrimaryGeneratorMessenger::operator=(
74                                 const AliPrimaryGeneratorMessenger &right)
75 {
76   // check assignement to self
77   if (this == &right) return *this;
78   
79   AliGlobals::Exception(
80     "AliPrimaryGeneratorMessenger is protected from assigning.");
81
82   return *this;
83 }
84
85 // public methods
86
87 //_____________________________________________________________________________
88 void AliPrimaryGeneratorMessenger::SetNewValue(G4UIcommand * command,
89        G4String newValue)
90
91 // Applies command to the associated object.
92 // ---
93
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);       
103   }
104   else if( command == fNofParticlesCmd ) { 
105     fPrimaryGenAction
106       ->SetNofGunParticles(fNofParticlesCmd->GetNewIntValue(newValue)); 
107   }   
108 }
109