]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4G3ControlVector.cxx
added comment lines separating methods
[u/mrichter/AliRoot.git] / TGeant4 / TG4G3ControlVector.cxx
CommitLineData
ae542d51 1// $Id$
2// Category: global
3//
4// See the class description in the header file.
5
6#include "TG4G3ControlVector.h"
7#include "TG4G3Defaults.h"
8#include "TG4Globals.h"
9
10#include <G4VProcess.hh>
11
12#include <math.h>
13
72095f7c 14//_____________________________________________________________________________
ae542d51 15TG4G3ControlVector::TG4G3ControlVector()
16{
17 // initialize fControlVector
18 fControlVector = new TG4ControlValueVector;
19 for (G4int i=0; i<kNoG3Controls; i++) fControlVector->insert(kUnset);
20}
21
72095f7c 22//_____________________________________________________________________________
ae542d51 23TG4G3ControlVector::TG4G3ControlVector(const TG4G3ControlVector& right)
24{
58c0119e 25 // allocation
ae542d51 26 fControlVector = new TG4ControlValueVector;
58c0119e 27
28 // copy stuff
29 *this = right;
ae542d51 30}
31
72095f7c 32//_____________________________________________________________________________
ae542d51 33TG4G3ControlVector::~TG4G3ControlVector() {
34//
35 delete fControlVector;
36}
37
38// operators
39
72095f7c 40//_____________________________________________________________________________
ae542d51 41TG4G3ControlVector& TG4G3ControlVector::operator=(
42 const TG4G3ControlVector& right)
43{
44 // check assignement to self
45 if (this == &right) return *this;
46
47 // initialize fControlVector
58c0119e 48 fControlVector->clear();;
ae542d51 49 for (G4int i=0; i<kNoG3Controls; i++) {
50 fControlVector->insert((*right.fControlVector)[i]);
51 }
52
53 return *this;
54}
55
72095f7c 56//_____________________________________________________________________________
ae542d51 57G4double TG4G3ControlVector::operator[](G4int index) const
58{
59//
60 if (index < kNoG3Controls)
61 return (*fControlVector)[index];
62 else {
63 TG4Globals::Exception(
64 "TG4G3ControlVector::operator[]: index out of the vector scope");
65 return 0.;
66 }
67}
68
69// public methods
70
72095f7c 71//_____________________________________________________________________________
ae542d51 72void TG4G3ControlVector::SetG3Control(TG4G3Control control,
73 G4double controlValue)
74{
75// Sets the controlValue for the specified process control.
76// ---
77
78 if (control<kNoG3Controls) {
79 // conversion G4double -> G3ControlValue
80 if (abs(controlValue - kUnset) < 0.01) {
81 (*fControlVector)[control] = kUnset ;
82 }
83 else if (abs(controlValue - kInActivate) < 0.01) {
84 (*fControlVector)[control] = kInActivate;
85 }
86 else if (abs(controlValue - kActivate) < 0.01) {
87 (*fControlVector)[control] = kActivate;
88 }
89 else if (abs(controlValue - kActivate2) < 0.01) {
90 (*fControlVector)[control] = kActivate2;
91 }
92 else {
93 G4String text = "TG4G3ControlVector::SetG3Control:\n ";
94 text = text + "Inconsistent/Not-yet-implemented control has been ignored.";
95 TG4Globals::Warning(text);
96 }
97 }
98}
99
72095f7c 100//_____________________________________________________________________________
ae542d51 101void TG4G3ControlVector::SetG3Defaults()
102{
103// Sets G3 default values for all controls.
104// ---
105
106 for (G4int i=0; i<kNoG3Controls; i++) {
107 (*fControlVector)[i] = TG4G3Defaults::ControlValue(i);
108 }
109}
110
72095f7c 111//_____________________________________________________________________________
ae542d51 112G4int TG4G3ControlVector::GetControl(G4VProcess* process) const
113{
114// Returns the control value for the particle associated with
115// the specified process.
116// ---
117
118 G4String name = process->GetProcessName();
119 if (name == "conv") return (*fControlVector)(kPAIR);
120 else if (name == "compt") return (*fControlVector)(kCOMP);
121 else if (name == "phot") return (*fControlVector)(kPHOT);
122 // else if (name == "??") return (*fControlVector)(kPFIS);
123 else if ((name == "eIoni") ||
124 (name == "IeIoni") ||
125 (name == "eIoni+") ||
126 (name == "MuIoni") ||
127 (name == "IMuIonisation") ||
128 (name == "hIoni") ||
129 (name == "IhIoni"))
130 return (*fControlVector)(kDRAY);
131 else if (name == "annihil") return (*fControlVector)(kANNI);
132 else if ((name == "eBrem") ||
133 (name == "eBrem+") ||
134 (name == "IeBrems") ||
135 (name == "MuBrems") ||
136 (name == "IMuBremsstrahlung"))
137 return (*fControlVector)(kBREM);
138 // else if (name == "??") return (*fControlVector)(kHADR);
139 else if (name == "MuNucl") return (*fControlVector)(kMUNU);
140 else if (name == "Decay") return (*fControlVector)(kDCAY);
141 // else if (name == "??") return (*fControlVector)(kLOSS);
142 // !!! not yet implemented
143 else if ((name == "msc") ||
144 (name == "Imsc")) return (*fControlVector)(kMULS);
145 else return kUnset;
146}