Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ProductionCuts.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4ProductionCuts class implementation
27//
28// Author: H.Kurashige, 17 September 2002 - First implementation
29// --------------------------------------------------------------------
30
31#include "G4ProductionCuts.hh"
33
34#include <iomanip>
35
36G4ThreadLocal G4ParticleDefinition* G4ProductionCuts::gammaDef = nullptr;
37G4ThreadLocal G4ParticleDefinition* G4ProductionCuts::electDef = nullptr;
38G4ThreadLocal G4ParticleDefinition* G4ProductionCuts::positDef = nullptr;
39G4ThreadLocal G4ParticleDefinition* G4ProductionCuts::protonDef = nullptr;
40
42{
43 for (G4int i=0; i< NumberOfG4CutIndex; ++i)
44 {
45 fRangeCuts.push_back(0.0);
46 }
47}
48
50{
51 for (G4int i=0; i< NumberOfG4CutIndex; ++i)
52 {
53 fRangeCuts.push_back(0.0);
54 }
55 *this = right;
56}
57
59{
60 fRangeCuts.clear();
61}
62
64{
65 if (&right==this) return *this;
66
67 for (G4int i=0; i< NumberOfG4CutIndex; ++i)
68 {
69 fRangeCuts[i] = right.fRangeCuts[i];
70 }
71 isModified = right.isModified;
72 return *this;
73}
74
76{
77 return (this == &right);
78}
79
80
82{
83 return (this != &right);
84}
85
87{
88 static const G4String gamma ("gamma");
89 static const G4String electron("e-");
90 static const G4String positron("e+");
91 static const G4String proton("proton");
92
93 G4int index;
94 if ( name == gamma ) { index = 0; }
95 else if ( name == electron ) { index = 1; }
96 else if ( name == positron ) { index = 2; }
97 else if ( name == proton ) { index = 3; }
98 else { index = -1; }
99
100 return index;
101}
102
103
105{
106 if(!ptcl) return -1;
107
108 // In the first call, pointers are set
109 if(gammaDef==nullptr && ptcl->GetParticleName()=="gamma")
110 { gammaDef = (G4ParticleDefinition*) ptcl; }
111 if(electDef==nullptr && ptcl->GetParticleName()=="e-")
112 { electDef = (G4ParticleDefinition*) ptcl; }
113 if(positDef==nullptr && ptcl->GetParticleName()=="e+")
114 { positDef = (G4ParticleDefinition*) ptcl; }
115 if(protonDef==nullptr && ptcl->GetParticleName()=="proton")
116 { protonDef = (G4ParticleDefinition*) ptcl; }
117
118 G4int index;
119 if(ptcl==(const G4ParticleDefinition*) gammaDef) { index = 0; }
120 else if(ptcl==(const G4ParticleDefinition*) electDef) { index = 1; }
121 else if(ptcl==(const G4ParticleDefinition*) positDef) { index = 2; }
122 else if(ptcl==(const G4ParticleDefinition*) protonDef) { index = 3; }
123 else { index = -1; }
124
125 return index;
126}
127
128void G4ProductionCuts::SetProductionCuts(std::vector<G4double>& cut)
129{
130 G4int vSize = cut.size();
131 if (vSize != NumberOfG4CutIndex)
132 {
133#ifdef G4VERBOSE
134 if ( G4ProductionCutsTable::GetProductionCutsTable()->GetVerboseLevel()>1)
135 {
136 G4cerr << "G4ProductionCuts::SetProductionCuts ";
137 G4cerr << " The size of given cut value vector [=" << vSize << "] "
138 << " is not consistent with number of CutIndex [="
140 }
141#endif
142 G4Exception( "G4ProductionCuts::SetProductionCuts ",
143 "ProcCuts108",
144 JustWarning, "Given vector size is inconsistent ");
145 if (NumberOfG4CutIndex<vSize) { vSize = NumberOfG4CutIndex; }
146 }
147 for(G4int i = 0; (i<vSize ); ++i)
148 {
149 fRangeCuts[i] = cut[i];
150 }
151 isModified = true;
152}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
@ NumberOfG4CutIndex
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetParticleName() const
static G4ProductionCutsTable * GetProductionCutsTable()
G4bool operator!=(const G4ProductionCuts &right) const
G4ProductionCuts & operator=(const G4ProductionCuts &right)
std::vector< G4double > fRangeCuts
static G4int GetIndex(const G4String &name)
virtual ~G4ProductionCuts()
void SetProductionCuts(std::vector< G4double > &)
G4bool operator==(const G4ProductionCuts &right) const
#define G4ThreadLocal
Definition: tls.hh:77