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