]>
Commit | Line | Data |
---|---|---|
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 | 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"; | |
b9d0a01d | 32 | guidance = guidance + " Stack: standard generator from MC stack"; |
676fb573 | 33 | fGeneratorCmd->SetGuidance(guidance); |
34 | fGeneratorCmd->SetParameterName("Generator", true); | |
b9d0a01d | 35 | fGeneratorCmd->SetCandidates("Gun Geantino ChargedGeantino Stack"); |
36 | fGeneratorCmd->SetDefaultValue("Stack"); | |
676fb573 | 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); | |
676fb573 | 46 | } |
47 | ||
78ca1e9c | 48 | //_____________________________________________________________________________ |
676fb573 | 49 | AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger() { |
50 | // | |
51 | } | |
52 | ||
78ca1e9c | 53 | //_____________________________________________________________________________ |
676fb573 | 54 | AliPrimaryGeneratorMessenger::AliPrimaryGeneratorMessenger( |
55 | const AliPrimaryGeneratorMessenger& right) { | |
56 | // | |
57 | AliGlobals::Exception( | |
58 | "AliPrimaryGeneratorMessenger is protected from copying."); | |
59 | } | |
60 | ||
78ca1e9c | 61 | //_____________________________________________________________________________ |
676fb573 | 62 | AliPrimaryGeneratorMessenger::~AliPrimaryGeneratorMessenger() { |
63 | // | |
64 | delete fPrimariesDirectory; | |
65 | delete fGeneratorCmd; | |
66 | delete fNofParticlesCmd; | |
676fb573 | 67 | } |
68 | ||
69 | // operators | |
70 | ||
78ca1e9c | 71 | //_____________________________________________________________________________ |
676fb573 | 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 | ||
78ca1e9c | 87 | //_____________________________________________________________________________ |
676fb573 | 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); | |
b9d0a01d | 101 | else if (newValue == "Stack") |
102 | fPrimaryGenAction->SetGenerator(kStack); | |
676fb573 | 103 | } |
104 | else if( command == fNofParticlesCmd ) { | |
105 | fPrimaryGenAction | |
106 | ->SetNofGunParticles(fNofParticlesCmd->GetNewIntValue(newValue)); | |
107 | } | |
676fb573 | 108 | } |
109 |