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