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