Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4VProcess class implementation << 27 // 26 // 28 // Authors: << 27 // $Id: G4VProcess.cc,v 1.15.2.1 2008/04/25 11:47:07 kurasige Exp $ 29 // - 2 December 1995, G.Cosmo - First implemen << 28 // GEANT4 tag $Name: geant4-09-01-patch-03 $ 30 // - 18 December 1996, H.Kurashige - New Physi << 29 // 31 // ------------------------------------------- << 30 // 32 << 31 // -------------------------------------------------------------- 33 #include "G4VProcess.hh" << 32 // GEANT 4 class implementation file 34 << 33 // 35 #include "G4PhysicalConstants.hh" << 34 // History: first implementation, based on object model of 36 #include "G4SystemOfUnits.hh" << 35 // 2nd December 1995, G.Cosmo >> 36 // -------------------------------------------------------------- >> 37 // New Physics scheme 8 Jan. 1997 H.Kurahige >> 38 // ------------------------------------------------------------ >> 39 // removed thePhysicsTable 02 Aug. 1998 H.Kurashige >> 40 // Modified DumpInfo 15 Aug. 1998 H.Kurashige 37 41 38 #include "G4ProcessTable.hh" << 39 #include "G4PhysicsTable.hh" 42 #include "G4PhysicsTable.hh" 40 #include "G4MaterialTable.hh" 43 #include "G4MaterialTable.hh" 41 #include "G4ElementTable.hh" 44 #include "G4ElementTable.hh" 42 #include "G4ElementVector.hh" 45 #include "G4ElementVector.hh" 43 #include "G4Log.hh" << 46 #include "G4VProcess.hh" 44 47 45 // ------------------------------------------- << 48 G4VProcess::G4VProcess(const G4String& aName, G4ProcessType aType ) 46 G4VProcess::G4VProcess(const G4String& aName, << 49 : pParticleChange(0), 47 : theProcessName(aName), theProcessType(aTyp << 50 theNumberOfInteractionLengthLeft(-1.0), >> 51 currentInteractionLength(-1.0), >> 52 theProcessName(aName), >> 53 theProcessType(aType), >> 54 thePILfactor(1.0), >> 55 enableAtRestDoIt(true), >> 56 enableAlongStepDoIt(true), >> 57 enablePostStepDoIt(true), >> 58 verboseLevel(0) 48 { 59 { 49 pParticleChange = &aParticleChange; 60 pParticleChange = &aParticleChange; 50 fProcessTable = G4ProcessTable::GetProcessTa << 51 fProcessTable->RegisterProcess(this); << 52 } << 53 << 54 // ------------------------------------------- << 55 G4VProcess::G4VProcess() << 56 { << 57 } 61 } 58 62 59 // ------------------------------------------- << 60 G4VProcess::~G4VProcess() 63 G4VProcess::~G4VProcess() 61 { 64 { 62 fProcessTable->DeRegisterProcess(this); << 63 } 65 } 64 66 65 // ------------------------------------------- << 66 G4VProcess::G4VProcess(const G4VProcess& right 67 G4VProcess::G4VProcess(const G4VProcess& right) 67 : theProcessName(right.theProcessName), << 68 : pParticleChange(0), 68 theProcessType(right.theProcessType), << 69 theNumberOfInteractionLengthLeft(-1.0), 69 theProcessSubType(right.theProcessSubType) << 70 currentInteractionLength(-1.0), 70 verboseLevel(right.verboseLevel), << 71 theProcessName(right.theProcessName), 71 enableAtRestDoIt(right.enableAtRestDoIt), << 72 theProcessType(right.theProcessType), 72 enableAlongStepDoIt(right.enableAlongStepD << 73 thePILfactor(1.0), 73 enablePostStepDoIt(right.enablePostStepDoI << 74 enableAtRestDoIt(true), 74 masterProcessShadow(right.masterProcessSha << 75 enableAlongStepDoIt(true), 75 fProcessTable(right.fProcessTable) << 76 enablePostStepDoIt(true), >> 77 verboseLevel(right.verboseLevel) 76 { 78 { 77 } 79 } 78 80 79 // ------------------------------------------- << 81 80 void G4VProcess::ResetNumberOfInteractionLengt << 82 void G4VProcess::SubtractNumberOfInteractionLengthLeft( 81 { << 83 G4double previousStepSize ) 82 theNumberOfInteractionLengthLeft = -1.*G4Lo << 84 { 83 theInitialNumberOfInteractionLength = theNum << 85 if (currentInteractionLength>0.0) { >> 86 theNumberOfInteractionLengthLeft -= previousStepSize/currentInteractionLength; >> 87 if(theNumberOfInteractionLengthLeft<0.) { >> 88 theNumberOfInteractionLengthLeft=perMillion; >> 89 } >> 90 >> 91 } else { >> 92 #ifdef G4VERBOSE >> 93 if (verboseLevel>0) { >> 94 G4cerr << "G4VProcess::SubtractNumberOfInteractionLengthLeft()"; >> 95 G4cerr << " [" << theProcessName << "]" <<G4endl; >> 96 G4cerr << " currentInteractionLength = " << currentInteractionLength/cm << " [cm]"; >> 97 G4cerr << " previousStepSize = " << previousStepSize/cm << " [cm]"; >> 98 G4cerr << G4endl; >> 99 } >> 100 #endif >> 101 G4Exception("G4VProcess::SubtractNumberOfInteractionLengthLeft()", >> 102 "Negative currentInteractionLength",EventMustBeAborted,theProcessName); >> 103 } 84 } 104 } 85 105 86 // ------------------------------------------- << 87 void G4VProcess::StartTracking(G4Track*) 106 void G4VProcess::StartTracking(G4Track*) 88 { 107 { 89 currentInteractionLength = -1.0; 108 currentInteractionLength = -1.0; 90 theNumberOfInteractionLengthLeft = -1.0; 109 theNumberOfInteractionLengthLeft = -1.0; 91 theInitialNumberOfInteractionLength = -1.0; << 92 #ifdef G4VERBOSE 110 #ifdef G4VERBOSE 93 if (verboseLevel>2) << 111 if (verboseLevel>2) { 94 { << 112 G4cout << "G4VProcess::StartTracking() [" << theProcessName << "]" <<G4endl; 95 G4cout << "G4VProcess::StartTracking() - [ << 96 << G4endl; << 97 } 113 } 98 #endif 114 #endif 99 } 115 } 100 116 101 // ------------------------------------------- << 102 void G4VProcess::EndTracking() 117 void G4VProcess::EndTracking() 103 { 118 { 104 #ifdef G4VERBOSE 119 #ifdef G4VERBOSE 105 if (verboseLevel>2) << 120 if (verboseLevel>2) { 106 { << 121 G4cout << "G4VProcess::EndTracking() [" << theProcessName << "]" <<G4endl; 107 G4cout << "G4VProcess::EndTracking() - [" << 108 << G4endl; << 109 } 122 } 110 #endif 123 #endif 111 theNumberOfInteractionLengthLeft = -1.0; 124 theNumberOfInteractionLengthLeft = -1.0; 112 currentInteractionLength = -1.0; 125 currentInteractionLength = -1.0; 113 theInitialNumberOfInteractionLength=-1.0; << 114 } 126 } 115 127 116 // ------------------------------------------- << 117 namespace << 118 { << 119 static const G4String typeNotDefined = "NotD << 120 static const G4String typeTransportation = " << 121 static const G4String typeElectromagnetic = << 122 static const G4String typeOptical = "Optical << 123 static const G4String typeHadronic = "Hadron << 124 static const G4String typePhotolepton_hadron << 125 static const G4String typeDecay = "Decay"; << 126 static const G4String typeGeneral = "General << 127 static const G4String typeParameterisation = << 128 static const G4String typeUserDefined = "Use << 129 static const G4String typePhonon = "Phonon"; << 130 static const G4String noType = "------"; << 131 } << 132 128 133 // ------------------------------------------- << 134 const G4String& G4VProcess::GetProcessTypeName 129 const G4String& G4VProcess::GetProcessTypeName(G4ProcessType aType ) 135 { 130 { 136 switch (aType) << 131 static G4String typeNotDefined= "NotDefined"; 137 { << 132 static G4String typeTransportation = "Transportation"; 138 case fNotDefined: return typeNotDe << 133 static G4String typeElectromagnetic = "Electromagnetic"; 139 case fTransportation: return typeTrans << 134 static G4String typeOptical = "Optical"; 140 case fElectromagnetic: return typeElect << 135 static G4String typeHadronic = "Hadronic"; 141 case fOptical: return typeOptic << 136 static G4String typePhotolepton_hadron = "Photolepton_hadron"; 142 case fHadronic: return typeHadro << 137 static G4String typeDecay = "Decay"; 143 case fPhotolepton_hadron: return typePhoto << 138 static G4String typeGeneral = "General"; 144 case fDecay: return typeDecay << 139 static G4String typeParameterisation = "Parameterisation"; 145 case fGeneral: return typeGener << 140 static G4String typeUserDefined = "UserDefined"; 146 case fParameterisation: return typeParam << 141 static G4String noType = "------"; // Do not modify this !!!! 147 case fUserDefined: return typeUserD << 142 148 case fPhonon: return typePhono << 143 if (aType == fNotDefined) { 149 default: ; << 144 return typeNotDefined; >> 145 } else if (aType == fTransportation ) { >> 146 return typeTransportation; >> 147 } else if (aType == fElectromagnetic ) { >> 148 return typeElectromagnetic; >> 149 } else if (aType == fOptical ) { >> 150 return typeOptical; >> 151 } else if (aType == fHadronic ) { >> 152 return typeHadronic; >> 153 } else if (aType == fPhotolepton_hadron ) { >> 154 return typePhotolepton_hadron; >> 155 } else if (aType == fDecay ) { >> 156 return typeDecay; >> 157 } else if (aType == fGeneral ) { >> 158 return typeGeneral; >> 159 } else if (aType == fParameterisation ) { >> 160 return typeParameterisation; >> 161 } else if (aType == fUserDefined ) { >> 162 return typeUserDefined; >> 163 } else { >> 164 return noType; 150 } 165 } 151 return noType; << 152 } 166 } 153 167 154 // ------------------------------------------- << 168 G4VProcess & G4VProcess::operator=(const G4VProcess &) 155 const G4VProcess* G4VProcess::GetCreatorProces << 156 { 169 { 157 return this; << 170 G4Exception("G4VProcess::operator=","Illegal operation", >> 171 JustWarning,"Assignment operator is called"); >> 172 return *this; 158 } 173 } 159 174 160 // ------------------------------------------- << 175 G4int G4VProcess::operator==(const G4VProcess &right) const 161 G4bool G4VProcess::operator==(const G4VProcess << 162 { 176 { 163 return (this == &right); 177 return (this == &right); 164 } 178 } 165 179 166 // ------------------------------------------- << 180 G4int G4VProcess::operator!=(const G4VProcess &right) const 167 G4bool G4VProcess::operator!=(const G4VProcess << 168 { 181 { 169 return (this != &right); 182 return (this != &right); 170 } 183 } 171 184 172 // ------------------------------------------- << 173 void G4VProcess::DumpInfo() const 185 void G4VProcess::DumpInfo() const 174 { 186 { 175 G4cout << "Process Name " << theProcessName 187 G4cout << "Process Name " << theProcessName ; 176 G4cout << " : Type[" << GetProcessTypeName(t << 188 G4cout << " : Type[" << GetProcessTypeName(theProcessType) << "]"<< G4endl; 177 G4cout << " : SubType[" << theProcessSubType << 178 } 189 } 179 190 180 // ------------------------------------------- << 191 181 void G4VProcess::ProcessDescription(std::ostre << 192 const G4String& G4VProcess::GetPhysicsTableFileName(const G4ParticleDefinition* particle, 182 { << 193 const G4String& directory, 183 outFile << "This process has not yet been de << 194 const G4String& tableName, 184 } << 195 G4bool ascii) 185 << 186 // ------------------------------------------- << 187 const G4String& G4VProcess:: << 188 GetPhysicsTableFileName( const G4ParticleDefin << 189 const G4String& direc << 190 const G4String& table << 191 G4bool ascii ) << 192 { 196 { 193 G4String thePhysicsTableFileExt; 197 G4String thePhysicsTableFileExt; 194 if (ascii) thePhysicsTableFileExt = ".asc"; 198 if (ascii) thePhysicsTableFileExt = ".asc"; 195 else thePhysicsTableFileExt = ".dat"; 199 else thePhysicsTableFileExt = ".dat"; 196 200 197 thePhysicsTableFileName = directory + "/"; 201 thePhysicsTableFileName = directory + "/"; 198 thePhysicsTableFileName += tableName + "." + 202 thePhysicsTableFileName += tableName + "." + theProcessName + "."; 199 thePhysicsTableFileName += particle->GetPart << 203 thePhysicsTableFileName += particle->GetParticleName() + thePhysicsTableFileExt; 200 + thePhysicsTableFi << 201 204 202 return thePhysicsTableFileName; 205 return thePhysicsTableFileName; 203 } 206 } 204 207 205 // ------------------------------------------- << 206 void G4VProcess::BuildWorkerPhysicsTable(const << 207 { << 208 BuildPhysicsTable(part); << 209 } << 210 208 211 // ------------------------------------------- << 212 void G4VProcess::PrepareWorkerPhysicsTable(con << 213 { << 214 PreparePhysicsTable(part); << 215 } << 216 209 217 // ------------------------------------------- << 210 218 void G4VProcess::SetMasterProcess(G4VProcess* << 211 219 { << 212 220 masterProcessShadow = masterP; << 213 221 } << 214 >> 215 >> 216 >> 217 222 218