Geant4  10.00.p02
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 //
27 // $Id: G4ProductionCuts.cc 73044 2013-08-15 09:44:11Z gcosmo $
28 // GEANT4 tag $Name: geant4-09-04-ref-00 $
29 //
30 //
31 // --------------------------------------------------------------
32 // GEANT 4 class implementation file/ History:
33 // 18 Sep. 2002, H.Kuirashige : Structure created based on object model
34 // --------------------------------------------------------------
35 
36 #include "G4ProductionCuts.hh"
37 #include "G4ProductionCutsTable.hh"
38 #include <iomanip>
39 
44 
46  isModified(true)
47 {
48  for (G4int i=0; i< NumberOfG4CutIndex; i++) {
49  fRangeCuts.push_back(0.0);
50  }
51 }
52 
54  : isModified(true)
55 {
56  for (G4int i=0; i< NumberOfG4CutIndex; i++) {
57  fRangeCuts.push_back(0.0);
58  }
59  *this = right;
60 }
61 
63 {
64  fRangeCuts.clear();
65 }
66 
68 {
69  if (&right==this) return *this;
70 
71  for (G4int i=0; i< NumberOfG4CutIndex; i++) {
72  fRangeCuts[i] = right.fRangeCuts[i];
73  }
74  isModified = right.isModified;
75  return *this;
76 }
77 
78 
79 
81 {
82  return (this == &right);
83 }
84 
85 
87 {
88  return (this != &right);
89 }
90 
91 
93 {
94  static const G4String gamma ("gamma");
95  static const G4String electron("e-");
96  static const G4String positron("e+");
97  static const G4String proton("proton");
98 
99  G4int index;
100  if ( name == gamma ) { index = 0; }
101  else if ( name == electron ) { index = 1; }
102  else if ( name == positron ) { index = 2; }
103  else if ( name == proton ) { index = 3; }
104  else { index = -1; }
105 
106  return index;
107 }
108 
109 
111 {
112  if(!ptcl) return -1;
113  // In the first call, pointers are set
114  if(gammaDef==0 && ptcl->GetParticleName()=="gamma") { gammaDef = (G4ParticleDefinition*) ptcl; }
115  if(electDef==0 && ptcl->GetParticleName()=="e-") { electDef = (G4ParticleDefinition*) ptcl; }
116  if(positDef==0 && ptcl->GetParticleName()=="e+") { positDef = (G4ParticleDefinition*) ptcl; }
117  if(protonDef==0 && ptcl->GetParticleName()=="proton") { protonDef = (G4ParticleDefinition*) ptcl; }
118 
119  G4int index;
120  if(ptcl==(const G4ParticleDefinition*) gammaDef) { index = 0; }
121  else if(ptcl==(const G4ParticleDefinition*) electDef) { index = 1; }
122  else if(ptcl==(const G4ParticleDefinition*) positDef) { index = 2; }
123  else if(ptcl==(const G4ParticleDefinition*) protonDef) { index = 3; }
124  else { index = -1; }
125 
126  return index;
127 }
128 
129 
130 void G4ProductionCuts::SetProductionCuts(std::vector<G4double>& cut)
131 {
132  G4int vSize = cut.size();
133  if (vSize != NumberOfG4CutIndex) {
134 #ifdef G4VERBOSE
135  if ( G4ProductionCutsTable::GetProductionCutsTable()->GetVerboseLevel()>1) {
136  G4cerr << "G4ProductionCuts::SetProductionCuts ";
137  G4cerr << " The size of given cut value vector [=" << vSize << "] "
138  << " is not consitent with number of CutIndex [="
140  }
141 #endif
142  G4Exception( "G4ProductionCuts::SetProductionCuts ",
143  "ProcCuts108",
144  JustWarning, "Given vector size is inconsitent ");
145  if (NumberOfG4CutIndex<vSize) vSize = NumberOfG4CutIndex;
146  }
147  for(G4int i = 0; (i<vSize ); i++) {
148  fRangeCuts[i] = cut[i];
149  }
150  isModified = true;
151 }
static G4int GetIndex(const G4String &name)
std::vector< G4double > fRangeCuts
static G4ThreadLocal G4ParticleDefinition * gammaDef
G4int operator!=(const G4ProductionCuts &right) const
G4String name
Definition: TRTMaterials.hh:40
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4int operator==(const G4ProductionCuts &right) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4ProductionCutsTable * GetProductionCutsTable()
virtual ~G4ProductionCuts()
#define G4endl
Definition: G4ios.hh:61
static G4ThreadLocal G4ParticleDefinition * positDef
static G4ThreadLocal G4ParticleDefinition * electDef
G4ProductionCuts & operator=(const G4ProductionCuts &right)
void SetProductionCuts(std::vector< G4double > &)
static G4ThreadLocal G4ParticleDefinition * protonDef
G4GLOB_DLL std::ostream G4cerr