]>
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" | |
8 | #include "AliPrimaryGenerator.h" | |
9 | #include "AliGlobals.h" | |
10 | ||
11 | #include <G4UIdirectory.hh> | |
12 | #include <G4UIcmdWithAString.hh> | |
13 | #include <G4UIcmdWithAnInteger.hh> | |
14 | ||
15 | AliPrimaryGeneratorMessenger::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 | ||
51 | AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger() { | |
52 | // | |
53 | } | |
54 | ||
55 | AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger( | |
56 | const AliPrimaryGeneratorMessenger& right) { | |
57 | // | |
58 | AliGlobals::Exception( | |
59 | "AliPrimaryGeneratorMessenger is protected from copying."); | |
60 | } | |
61 | ||
62 | AliPrimaryGeneratorMessenger::~AliPrimaryGeneratorMessenger() { | |
63 | // | |
64 | delete fPrimariesDirectory; | |
65 | delete fGeneratorCmd; | |
66 | delete fNofParticlesCmd; | |
67 | delete fVerboseCmd; | |
68 | } | |
69 | ||
70 | // operators | |
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 | void AliPrimaryGeneratorMessenger::SetNewValue(G4UIcommand * command, | |
88 | G4String newValue) | |
89 | { | |
90 | // Applies command to the associated object. | |
91 | // --- | |
92 | ||
93 | if( command == fGeneratorCmd ) { | |
94 | if (newValue == "Gun") | |
95 | fPrimaryGenAction->SetGenerator(kGun); | |
96 | else if (newValue == "Geantino") | |
97 | fPrimaryGenAction->SetGenerator(kGeantino); | |
98 | else if (newValue == "ChargedGeantino") | |
99 | fPrimaryGenAction->SetGenerator(kChargedGeantino); | |
100 | else if (newValue == "AliGenerator") | |
101 | fPrimaryGenAction->SetGenerator(kAliGenerator); | |
102 | } | |
103 | else if( command == fNofParticlesCmd ) { | |
104 | fPrimaryGenAction | |
105 | ->SetNofGunParticles(fNofParticlesCmd->GetNewIntValue(newValue)); | |
106 | } | |
107 | else if(command == fVerboseCmd) { | |
108 | fPrimaryGenAction | |
109 | ->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue)); | |
110 | } | |
111 | } | |
112 |