]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4G3ControlVector.cxx
added comment lines separating methods
[u/mrichter/AliRoot.git] / TGeant4 / TG4G3ControlVector.cxx
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
14 //_____________________________________________________________________________
15 TG4G3ControlVector::TG4G3ControlVector()
16 {
17   // initialize fControlVector 
18   fControlVector = new TG4ControlValueVector;
19   for (G4int i=0; i<kNoG3Controls; i++) fControlVector->insert(kUnset); 
20 }
21
22 //_____________________________________________________________________________
23 TG4G3ControlVector::TG4G3ControlVector(const TG4G3ControlVector& right)
24 {
25   // allocation
26   fControlVector = new TG4ControlValueVector;
27   
28   // copy stuff
29   *this = right;  
30 }
31
32 //_____________________________________________________________________________
33 TG4G3ControlVector::~TG4G3ControlVector() {
34 //
35   delete fControlVector;
36 }
37
38 // operators
39
40 //_____________________________________________________________________________
41 TG4G3ControlVector& TG4G3ControlVector::operator=(
42                                           const TG4G3ControlVector& right)
43 {
44   // check assignement to self
45   if (this == &right) return *this;
46
47   // initialize fControlVector 
48   fControlVector->clear();;
49   for (G4int i=0; i<kNoG3Controls; i++) {
50     fControlVector->insert((*right.fControlVector)[i]);
51   }
52   
53   return *this;   
54 }  
55
56 //_____________________________________________________________________________
57 G4double 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
71 //_____________________________________________________________________________
72 void 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
100 //_____________________________________________________________________________
101 void 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
111 //_____________________________________________________________________________
112 G4int 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 }