ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ProductionCuts.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ProductionCuts.cc
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 //
28 //
29 // --------------------------------------------------------------
30 // GEANT 4 class implementation file/ History:
31 // 18 Sep. 2002, H.Kuirashige : Structure created based on object model
32 // --------------------------------------------------------------
33 
34 #include "G4ProductionCuts.hh"
35 #include "G4ProductionCutsTable.hh"
36 #include <iomanip>
37 
42 
44  isModified(true)
45 {
46  for (G4int i=0; i< NumberOfG4CutIndex; i++) {
47  fRangeCuts.push_back(0.0);
48  }
49 }
50 
52  : isModified(true)
53 {
54  for (G4int i=0; i< NumberOfG4CutIndex; i++) {
55  fRangeCuts.push_back(0.0);
56  }
57  *this = right;
58 }
59 
61 {
62  fRangeCuts.clear();
63 }
64 
66 {
67  if (&right==this) return *this;
68 
69  for (G4int i=0; i< NumberOfG4CutIndex; i++) {
70  fRangeCuts[i] = right.fRangeCuts[i];
71  }
72  isModified = right.isModified;
73  return *this;
74 }
75 
76 
77 
79 {
80  return (this == &right);
81 }
82 
83 
85 {
86  return (this != &right);
87 }
88 
89 
91 {
92  static const G4String gamma ("gamma");
93  static const G4String electron("e-");
94  static const G4String positron("e+");
95  static const G4String proton("proton");
96 
97  G4int index;
98  if ( name == gamma ) { index = 0; }
99  else if ( name == electron ) { index = 1; }
100  else if ( name == positron ) { index = 2; }
101  else if ( name == proton ) { index = 3; }
102  else { index = -1; }
103 
104  return index;
105 }
106 
107 
109 {
110  if(!ptcl) return -1;
111  // In the first call, pointers are set
112  if(gammaDef==nullptr && ptcl->GetParticleName()=="gamma") { gammaDef = (G4ParticleDefinition*) ptcl; }
113  if(electDef==nullptr && ptcl->GetParticleName()=="e-") { electDef = (G4ParticleDefinition*) ptcl; }
114  if(positDef==nullptr && ptcl->GetParticleName()=="e+") { positDef = (G4ParticleDefinition*) ptcl; }
115  if(protonDef==nullptr && ptcl->GetParticleName()=="proton") { protonDef = (G4ParticleDefinition*) ptcl; }
116 
117  G4int index;
118  if(ptcl==(const G4ParticleDefinition*) gammaDef) { index = 0; }
119  else if(ptcl==(const G4ParticleDefinition*) electDef) { index = 1; }
120  else if(ptcl==(const G4ParticleDefinition*) positDef) { index = 2; }
121  else if(ptcl==(const G4ParticleDefinition*) protonDef) { index = 3; }
122  else { index = -1; }
123 
124  return index;
125 }
126 
127 
128 void G4ProductionCuts::SetProductionCuts(std::vector<G4double>& cut)
129 {
130  G4int vSize = cut.size();
131  if (vSize != NumberOfG4CutIndex) {
132 #ifdef G4VERBOSE
133  if ( G4ProductionCutsTable::GetProductionCutsTable()->GetVerboseLevel()>1) {
134  G4cerr << "G4ProductionCuts::SetProductionCuts ";
135  G4cerr << " The size of given cut value vector [=" << vSize << "] "
136  << " is not consitent with number of CutIndex [="
138  }
139 #endif
140  G4Exception( "G4ProductionCuts::SetProductionCuts ",
141  "ProcCuts108",
142  JustWarning, "Given vector size is inconsitent ");
143  if (NumberOfG4CutIndex<vSize) vSize = NumberOfG4CutIndex;
144  }
145  for(G4int i = 0; (i<vSize ); i++) {
146  fRangeCuts[i] = cut[i];
147  }
148  isModified = true;
149 }