4 // See the class description in the header file.
6 #include "TG4FlagVector.h"
7 #include "TG4CutVector.h"
8 #include "TG4G3Defaults.h"
9 #include "TG4Globals.h"
11 #include <G4ParticleDefinition.hh>
12 #include <G4VProcess.hh>
16 TG4FlagVector::TG4FlagVector()
18 // initialize fFlagVector
19 fFlagVector = new TG3FlagVector;
20 for (G4int i=0; i<kNoG3Flags; i++) fFlagVector->insert(kUnset);
23 TG4FlagVector::TG4FlagVector(const TG4FlagVector& right)
26 fFlagVector = new TG3FlagVector;
27 for (G4int i=0; i<kNoG3Flags; i++) {
28 fFlagVector->insert((*right.fFlagVector)[i]);
32 TG4FlagVector::~TG4FlagVector() {
39 TG4FlagVector& TG4FlagVector::operator=(const TG4FlagVector& right)
41 // check assignement to self
42 if (this == &right) return *this;
44 // initialize fFlagVector
46 for (G4int i=0; i<kNoG3Flags; i++) {
47 fFlagVector->insert((*right.fFlagVector)[i]);
53 G4double TG4FlagVector::operator[](G4int index) const
56 if (index < kNoG3Flags)
57 return (*fFlagVector)[index];
59 TG4Globals::Exception(
60 "TG4FlagVector::operator[]: index out of the vector scope");
67 void TG4FlagVector::SetG3Flag(TG3Flag g3Flag, G4double flagValue)
69 // Sets the flagValue for the specified flag.
72 if (g3Flag<kNoG3Flags) {
73 // conversion G4double -> G3FlagValue
74 if (abs(flagValue - kUnset) < 0.01) {
75 (*fFlagVector)[g3Flag] = kUnset ;
77 else if (abs(flagValue - kInActivate) < 0.01) {
78 (*fFlagVector)[g3Flag] = kInActivate;
80 else if (abs(flagValue - kActivate) < 0.01) {
81 (*fFlagVector)[g3Flag] = kActivate;
83 else if (abs(flagValue - kActivate2) < 0.01) {
84 (*fFlagVector)[g3Flag] = kActivate2;
87 G4String text = "TG4FlagVector::SetG3Flag:\n ";
88 text = text + "Inconsistent/Not-yet-implemented flag has been ignored.";
89 TG4Globals::Warning(text);
94 void TG4FlagVector::SetG3Defaults()
96 // Sets G3 default values for all flags.
99 for (G4int i=0; i<kNoG3Flags; i++) {
100 (*fFlagVector)[i] = TG4G3Defaults::FlagValue(i);
104 G4int TG4FlagVector::GetFlag(G4VProcess* process) const
106 // Returns the flag value for the particle associated with
107 // the specified process.
110 G4String name = process->GetProcessName();
111 if (name == "conv") return (*fFlagVector)(kPAIR);
112 else if (name == "compt") return (*fFlagVector)(kCOMP);
113 else if (name == "phot") return (*fFlagVector)(kPHOT);
114 // else if (name == "??") return (*fFlagVector)(kPFIS);
115 else if ((name == "eIoni") ||
116 (name == "IeIoni") ||
117 (name == "eIoni+") ||
118 (name == "MuIoni") ||
119 (name == "IMuIonisation") ||
122 return (*fFlagVector)(kDRAY);
123 else if (name == "annihil") return (*fFlagVector)(kANNI);
124 else if ((name == "eBrem") ||
125 (name == "eBrem+") ||
126 (name == "IeBrems") ||
127 (name == "MuBrems") ||
128 (name == "IMuBremsstrahlung"))
129 return (*fFlagVector)(kBREM);
130 // else if (name == "??") return (*fFlagVector)(kHADR);
131 else if (name == "MuNucl") return (*fFlagVector)(kMUNU);
132 else if (name == "Decay") return (*fFlagVector)(kDCAY);
133 // else if (name == "??") return (*fFlagVector)(kLOSS);
134 // !!! not yet implemented
135 else if ((name == "msc") ||
136 (name == "Imsc")) return (*fFlagVector)(kMULS);