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$ 29 // - 2 December 1995, G.Cosmo - First implemen << 28 // 30 // - 18 December 1996, H.Kurashige - New Physi << 29 // 31 // ------------------------------------------- << 30 // -------------------------------------------------------------- >> 31 // GEANT 4 class implementation file >> 32 // >> 33 // History: first implementation, based on object model of >> 34 // 2nd December 1995, G.Cosmo >> 35 // -------------------------------------------------------------- >> 36 // New Physics scheme 8 Jan. 1997 H.Kurahige >> 37 // ------------------------------------------------------------ >> 38 // removed thePhysicsTable 02 Aug. 1998 H.Kurashige >> 39 // Modified DumpInfo 15 Aug. 1998 H.Kurashige 32 40 33 #include "G4VProcess.hh" 41 #include "G4VProcess.hh" 34 42 35 #include "G4PhysicalConstants.hh" 43 #include "G4PhysicalConstants.hh" 36 #include "G4SystemOfUnits.hh" 44 #include "G4SystemOfUnits.hh" 37 45 38 #include "G4ProcessTable.hh" << 39 #include "G4PhysicsTable.hh" 46 #include "G4PhysicsTable.hh" 40 #include "G4MaterialTable.hh" 47 #include "G4MaterialTable.hh" 41 #include "G4ElementTable.hh" 48 #include "G4ElementTable.hh" 42 #include "G4ElementVector.hh" 49 #include "G4ElementVector.hh" 43 #include "G4Log.hh" << 44 50 45 // ------------------------------------------- << 51 G4VProcess::G4VProcess(const G4String& aName, G4ProcessType aType ) 46 G4VProcess::G4VProcess(const G4String& aName, << 52 : aProcessManager(0), 47 : theProcessName(aName), theProcessType(aTyp << 53 pParticleChange(0), 48 { << 54 theNumberOfInteractionLengthLeft(-1.0), 49 pParticleChange = &aParticleChange; << 55 currentInteractionLength(-1.0), 50 fProcessTable = G4ProcessTable::GetProcessTa << 56 theInitialNumberOfInteractionLength(-1.0), 51 fProcessTable->RegisterProcess(this); << 57 theProcessName(aName), 52 } << 58 theProcessType(aType), >> 59 theProcessSubType(-1), >> 60 thePILfactor(1.0), >> 61 enableAtRestDoIt(true), >> 62 enableAlongStepDoIt(true), >> 63 enablePostStepDoIt(true), >> 64 verboseLevel(0) 53 65 54 // ------------------------------------------- << 55 G4VProcess::G4VProcess() << 56 { 66 { >> 67 pParticleChange = &aParticleChange; 57 } 68 } 58 69 59 // ------------------------------------------- << 60 G4VProcess::~G4VProcess() 70 G4VProcess::~G4VProcess() 61 { 71 { 62 fProcessTable->DeRegisterProcess(this); << 63 } 72 } 64 73 65 // ------------------------------------------- << 66 G4VProcess::G4VProcess(const G4VProcess& right 74 G4VProcess::G4VProcess(const G4VProcess& right) 67 : theProcessName(right.theProcessName), << 75 : aProcessManager(0), 68 theProcessType(right.theProcessType), << 76 pParticleChange(0), 69 theProcessSubType(right.theProcessSubType) << 77 theNumberOfInteractionLengthLeft(-1.0), 70 verboseLevel(right.verboseLevel), << 78 currentInteractionLength(-1.0), 71 enableAtRestDoIt(right.enableAtRestDoIt), << 79 theInitialNumberOfInteractionLength(-1.0), 72 enableAlongStepDoIt(right.enableAlongStepD << 80 theProcessName(right.theProcessName), 73 enablePostStepDoIt(right.enablePostStepDoI << 81 theProcessType(right.theProcessType), 74 masterProcessShadow(right.masterProcessSha << 82 theProcessSubType(right.theProcessSubType), 75 fProcessTable(right.fProcessTable) << 83 thePILfactor(1.0), >> 84 enableAtRestDoIt(right.enableAtRestDoIt), >> 85 enableAlongStepDoIt(right.enableAlongStepDoIt), >> 86 enablePostStepDoIt(right.enablePostStepDoIt), >> 87 verboseLevel(right.verboseLevel) 76 { 88 { 77 } 89 } 78 90 79 // ------------------------------------------- << 91 80 void G4VProcess::ResetNumberOfInteractionLengt 92 void G4VProcess::ResetNumberOfInteractionLengthLeft() 81 { 93 { 82 theNumberOfInteractionLengthLeft = -1.*G4Lo << 94 theNumberOfInteractionLengthLeft = -std::log( G4UniformRand() ); 83 theInitialNumberOfInteractionLength = theNum 95 theInitialNumberOfInteractionLength = theNumberOfInteractionLengthLeft; 84 } 96 } 85 97 86 // ------------------------------------------- << 98 void G4VProcess::SubtractNumberOfInteractionLengthLeft( >> 99 G4double previousStepSize ) >> 100 { >> 101 if (currentInteractionLength>0.0) { >> 102 theNumberOfInteractionLengthLeft -= previousStepSize/currentInteractionLength; >> 103 if(theNumberOfInteractionLengthLeft<0.) { >> 104 theNumberOfInteractionLengthLeft=perMillion; >> 105 } >> 106 >> 107 } else { >> 108 #ifdef G4VERBOSE >> 109 if (verboseLevel>0) { >> 110 G4cerr << "G4VProcess::SubtractNumberOfInteractionLengthLeft()"; >> 111 G4cerr << " [" << theProcessName << "]" <<G4endl; >> 112 G4cerr << " currentInteractionLength = " << currentInteractionLength/cm << " [cm]"; >> 113 G4cerr << " previousStepSize = " << previousStepSize/cm << " [cm]"; >> 114 G4cerr << G4endl; >> 115 } >> 116 #endif >> 117 G4String msg = "Negative currentInteractionLength for "; >> 118 msg += theProcessName; >> 119 G4Exception("G4VProcess::SubtractNumberOfInteractionLengthLeft()", >> 120 "ProcMan201",EventMustBeAborted, >> 121 msg); >> 122 } >> 123 } >> 124 87 void G4VProcess::StartTracking(G4Track*) 125 void G4VProcess::StartTracking(G4Track*) 88 { 126 { 89 currentInteractionLength = -1.0; 127 currentInteractionLength = -1.0; 90 theNumberOfInteractionLengthLeft = -1.0; 128 theNumberOfInteractionLengthLeft = -1.0; 91 theInitialNumberOfInteractionLength = -1.0; << 129 theInitialNumberOfInteractionLength=-1.0; 92 #ifdef G4VERBOSE 130 #ifdef G4VERBOSE 93 if (verboseLevel>2) << 131 if (verboseLevel>2) { 94 { << 132 G4cout << "G4VProcess::StartTracking() [" << theProcessName << "]" <<G4endl; 95 G4cout << "G4VProcess::StartTracking() - [ << 96 << G4endl; << 97 } 133 } 98 #endif 134 #endif 99 } 135 } 100 136 101 // ------------------------------------------- << 102 void G4VProcess::EndTracking() 137 void G4VProcess::EndTracking() 103 { 138 { 104 #ifdef G4VERBOSE 139 #ifdef G4VERBOSE 105 if (verboseLevel>2) << 140 if (verboseLevel>2) { 106 { << 141 G4cout << "G4VProcess::EndTracking() [" << theProcessName << "]" <<G4endl; 107 G4cout << "G4VProcess::EndTracking() - [" << 108 << G4endl; << 109 } 142 } 110 #endif 143 #endif 111 theNumberOfInteractionLengthLeft = -1.0; 144 theNumberOfInteractionLengthLeft = -1.0; 112 currentInteractionLength = -1.0; 145 currentInteractionLength = -1.0; 113 theInitialNumberOfInteractionLength=-1.0; 146 theInitialNumberOfInteractionLength=-1.0; 114 } 147 } 115 148 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 149 133 // ------------------------------------------- << 134 const G4String& G4VProcess::GetProcessTypeName 150 const G4String& G4VProcess::GetProcessTypeName(G4ProcessType aType ) 135 { 151 { 136 switch (aType) << 152 static G4String typeNotDefined= "NotDefined"; 137 { << 153 static G4String typeTransportation = "Transportation"; 138 case fNotDefined: return typeNotDe << 154 static G4String typeElectromagnetic = "Electromagnetic"; 139 case fTransportation: return typeTrans << 155 static G4String typeOptical = "Optical"; 140 case fElectromagnetic: return typeElect << 156 static G4String typeHadronic = "Hadronic"; 141 case fOptical: return typeOptic << 157 static G4String typePhotolepton_hadron = "Photolepton_hadron"; 142 case fHadronic: return typeHadro << 158 static G4String typeDecay = "Decay"; 143 case fPhotolepton_hadron: return typePhoto << 159 static G4String typeGeneral = "General"; 144 case fDecay: return typeDecay << 160 static G4String typeParameterisation = "Parameterisation"; 145 case fGeneral: return typeGener << 161 static G4String typeUserDefined = "UserDefined"; 146 case fParameterisation: return typeParam << 162 static G4String noType = "------"; // Do not modify this !!!! 147 case fUserDefined: return typeUserD << 163 148 case fPhonon: return typePhono << 164 if (aType == fNotDefined) { 149 default: ; << 165 return typeNotDefined; >> 166 } else if (aType == fTransportation ) { >> 167 return typeTransportation; >> 168 } else if (aType == fElectromagnetic ) { >> 169 return typeElectromagnetic; >> 170 } else if (aType == fOptical ) { >> 171 return typeOptical; >> 172 } else if (aType == fHadronic ) { >> 173 return typeHadronic; >> 174 } else if (aType == fPhotolepton_hadron ) { >> 175 return typePhotolepton_hadron; >> 176 } else if (aType == fDecay ) { >> 177 return typeDecay; >> 178 } else if (aType == fGeneral ) { >> 179 return typeGeneral; >> 180 } else if (aType == fParameterisation ) { >> 181 return typeParameterisation; >> 182 } else if (aType == fUserDefined ) { >> 183 return typeUserDefined; >> 184 } else { >> 185 return noType; 150 } 186 } 151 return noType; << 152 } 187 } 153 188 154 // ------------------------------------------- << 189 G4VProcess & G4VProcess::operator=(const G4VProcess &) 155 const G4VProcess* G4VProcess::GetCreatorProces << 156 { 190 { 157 return this; << 191 G4Exception("G4VProcess::operator=","ProcMan101", >> 192 JustWarning,"Assignment operator is called but NO effect"); >> 193 return *this; 158 } 194 } 159 195 160 // ------------------------------------------- << 196 G4int G4VProcess::operator==(const G4VProcess &right) const 161 G4bool G4VProcess::operator==(const G4VProcess << 162 { 197 { 163 return (this == &right); 198 return (this == &right); 164 } 199 } 165 200 166 // ------------------------------------------- << 201 G4int G4VProcess::operator!=(const G4VProcess &right) const 167 G4bool G4VProcess::operator!=(const G4VProcess << 168 { 202 { 169 return (this != &right); 203 return (this != &right); 170 } 204 } 171 205 172 // ------------------------------------------- << 173 void G4VProcess::DumpInfo() const 206 void G4VProcess::DumpInfo() const 174 { 207 { 175 G4cout << "Process Name " << theProcessName 208 G4cout << "Process Name " << theProcessName ; 176 G4cout << " : Type[" << GetProcessTypeName(t 209 G4cout << " : Type[" << GetProcessTypeName(theProcessType) << "]"; 177 G4cout << " : SubType[" << theProcessSubType 210 G4cout << " : SubType[" << theProcessSubType << "]"<< G4endl; 178 } 211 } 179 212 180 // ------------------------------------------- << 213 181 void G4VProcess::ProcessDescription(std::ostre << 214 const G4String& G4VProcess::GetPhysicsTableFileName(const G4ParticleDefinition* particle, 182 { << 215 const G4String& directory, 183 outFile << "This process has not yet been de << 216 const G4String& tableName, 184 } << 217 G4bool ascii) 185 << 186 // ------------------------------------------- << 187 const G4String& G4VProcess:: << 188 GetPhysicsTableFileName( const G4ParticleDefin << 189 const G4String& direc << 190 const G4String& table << 191 G4bool ascii ) << 192 { 218 { 193 G4String thePhysicsTableFileExt; 219 G4String thePhysicsTableFileExt; 194 if (ascii) thePhysicsTableFileExt = ".asc"; 220 if (ascii) thePhysicsTableFileExt = ".asc"; 195 else thePhysicsTableFileExt = ".dat"; 221 else thePhysicsTableFileExt = ".dat"; 196 222 197 thePhysicsTableFileName = directory + "/"; 223 thePhysicsTableFileName = directory + "/"; 198 thePhysicsTableFileName += tableName + "." + 224 thePhysicsTableFileName += tableName + "." + theProcessName + "."; 199 thePhysicsTableFileName += particle->GetPart << 225 thePhysicsTableFileName += particle->GetParticleName() + thePhysicsTableFileExt; 200 + thePhysicsTableFi << 201 226 202 return thePhysicsTableFileName; 227 return thePhysicsTableFileName; 203 } << 204 << 205 // ------------------------------------------- << 206 void G4VProcess::BuildWorkerPhysicsTable(const << 207 { << 208 BuildPhysicsTable(part); << 209 } << 210 << 211 // ------------------------------------------- << 212 void G4VProcess::PrepareWorkerPhysicsTable(con << 213 { << 214 PreparePhysicsTable(part); << 215 } << 216 << 217 // ------------------------------------------- << 218 void G4VProcess::SetMasterProcess(G4VProcess* << 219 { << 220 masterProcessShadow = masterP; << 221 } 228 } 222 229