4 // See the class description in the header file.
6 #include "TG4CutVector.h"
7 #include "TG4G3Defaults.h"
10 #include <G4ParticleDefinition.hh>
11 #include <G4VProcess.hh>
13 TG4CutVector::TG4CutVector()
15 // initialize fCutVector
16 fCutVector = new TG4doubleVector;
17 for (G4int i=0; i<kNoG3Cuts; i++) fCutVector->insert(0.);
20 TG4CutVector::TG4CutVector(const TG4CutVector& right)
23 fCutVector = new TG4doubleVector;
24 for (G4int i=0; i<kNoG3Cuts; i++) {
25 fCutVector->insert((*right.fCutVector)[i]);
29 TG4CutVector::~TG4CutVector() {
36 TG4CutVector& TG4CutVector::operator=(const TG4CutVector& right)
38 // check assignement to self
39 if (this == &right) return *this;
41 // initialize fCutVector
43 for (G4int i=0; i<kNoG3Cuts; i++) {
44 fCutVector->insert((*right.fCutVector)[i]);
50 G4double TG4CutVector::operator[](G4int index) const
53 if (index < kNoG3Cuts)
54 return (*fCutVector)[index];
56 TG4Globals::Exception(
57 "TG4CutVector::operator[]: index out of the vector scope");
64 void TG4CutVector::SetG3Cut(TG3Cut g3Cut, G4double cutValue)
66 // Sets the cutValue for the specified cut.
69 if (g3Cut<kNoG3Cuts) {
70 (*fCutVector)[g3Cut] = cutValue;
73 TG4Globals::Exception(
74 "TG4CutVector::SetG3Cut: Inconsistent cut.");
78 void TG4CutVector::SetG3Defaults()
80 // Sets G3 default values for all cuts.
83 for (G4int i=0; i<kNoG3Cuts; i++) {
84 (*fCutVector)[i] = TG4G3Defaults::CutValue(i);
88 G4double TG4CutVector::GetMinEkine(const G4Track& track) const
90 // Returns the cut value for the particle associated with
94 G4ParticleDefinition* particle = track.GetDefinition();
95 G4String particleName = particle->GetParticleName();
97 if (particleName == "gamma") {
98 return GetMinEkineForGamma(track);
100 else if (particleName == "e-") {
101 return GetMinEkineForElectron(track);
103 else if ((particle->GetParticleType() == "baryon") ||
104 (particle->GetParticleType() == "meson") ||
105 (particle->GetParticleType() == "nucleus")) {
106 if (particle->GetPDGCharge() == 0)
107 return GetMinEkineForHadron(track);
109 return GetMinEkineForNeutralHadron(track);
111 else if ((particleName == "mu-") || (particleName == "mu+")) {
112 return GetMinEkineForMuon(track);
115 G4String text = "TG4CutVector::GetMinEkine: \n";
116 text = text + " The kinetic energy cut for " + particleName;
117 text = text + " is not defined.";
118 TG4Globals::Warning(text);
123 G4double TG4CutVector::GetMinEkineForGamma(const G4Track& track) const
125 // Returns the cut value for gamma.
126 // (Cut is not applied for "opticalphoton"
127 // as it is treated in G4 as a particle different
128 // from "gamma" in G4.)
131 G4cout << "TG4CutVector::GetMinEkineForGamma start" << endl;
132 const G4VProcess* kpCreatorProcess = track.GetCreatorProcess();
133 G4String processName = "";
134 if (kpCreatorProcess) processName = kpCreatorProcess->GetProcessName();
136 if ((processName == "eBrem") || (processName == "IeBrem")) {
137 return (*fCutVector)[kBCUTE];
139 else if ((processName == "MuBrems") || (processName == "IMuBrems") ||
140 (processName == "//hBrems")|| (processName == "//IhBrems")) {
141 // hadron Brehmstrahlung is not defined in G4
142 return (*fCutVector)[kBCUTM];
145 return (*fCutVector)[kCUTGAM];
149 G4double TG4CutVector::GetMinEkineForElectron(const G4Track& track) const
151 // Returns the cut value for e-.
152 // Should these cuts be applied to e+ too ??
155 const G4VProcess* kpCreatorProcess = track.GetCreatorProcess();
156 G4String processName = "";
157 if (kpCreatorProcess) processName = kpCreatorProcess->GetProcessName();
159 if ((processName == "eIoni") || (processName == "IeIoni")) {
160 // !! Geant4 treats delta rays + continuous energy loss
161 // within one process
162 return (*fCutVector)[kDCUTE];
164 else if ((processName == "MuIoni") || (processName == "IMuIoni")) {
165 // !! Geant4 treats delta rays + continuous energy loss
166 // within one process
167 return (*fCutVector)[kDCUTM];
170 return (*fCutVector)[kCUTELE];
174 G4double TG4CutVector::GetMinEkineForHadron(const G4Track& track) const
176 // Returns the cut value for charged hadron.
179 return (*fCutVector)[kCUTHAD];
182 G4double TG4CutVector::GetMinEkineForNeutralHadron(const G4Track& track) const
184 // Returns the cut value for neutral hadron.
187 return (*fCutVector)[kCUTNEU];
190 G4double TG4CutVector::GetMinEkineForMuon(const G4Track& track) const
192 // Returns the cut value for neutral muon.
195 return (*fCutVector)[kCUTMUO];
198 G4double TG4CutVector::GetMinEkineForOther(const G4Track& track) const