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 // << 27 #include "G4VITProcess.hh" 26 #include "G4VITProcess.hh" 28 << 29 #include "G4IT.hh" 27 #include "G4IT.hh" 30 #include "G4SystemOfUnits.hh" << 31 #include "G4TrackingInformation.hh" << 32 << 33 #include <memory> << 34 28 35 /*G4ThreadLocal*/size_t *G4VITProcess::fNbProc << 29 G4int G4VITProcess::fNbProcess = 0; 36 30 37 G4VITProcess::G4VITProcess(const G4String& nam 31 G4VITProcess::G4VITProcess(const G4String& name, G4ProcessType type) : 38 G4VProcess(name, type) << 32 G4VProcess( name, type ), 39 // fpState (0)//, << 33 fState (0), 40 //fProcessID(fNbProcess) << 34 fProcessID(fNbProcess) 41 { << 35 { 42 fpState.reset(); << 36 fNbProcess++; 43 if(fNbProcess == nullptr) fNbProcess = new s << 37 SetInstantiateProcessState(true); 44 fProcessID = *fNbProcess; << 38 currentInteractionLength = 0; 45 (*fNbProcess)++; << 39 theInteractionTimeLeft = 0; 46 SetInstantiateProcessState(true); << 40 theNumberOfInteractionLengthLeft = 0; 47 currentInteractionLength = nullptr; << 48 theInteractionTimeLeft = nullptr; << 49 theNumberOfInteractionLengthLeft = nullptr; << 50 fProposesTimeStep = false; << 51 } 41 } 52 42 53 G4VITProcess::G4ProcessState::G4ProcessState() 43 G4VITProcess::G4ProcessState::G4ProcessState() 54 { 44 { 55 theNumberOfInteractionLengthLeft = -1.0; << 45 theNumberOfInteractionLengthLeft = -1.0 ; 56 theInteractionTimeLeft = -1.0; << 46 theInteractionTimeLeft = -1.0 ; 57 currentInteractionLength = -1.0; << 47 currentInteractionLength = -1.0 ; 58 } 48 } 59 49 60 G4VITProcess::G4ProcessState::~G4ProcessState( 50 G4VITProcess::G4ProcessState::~G4ProcessState() 61 = default; << 51 {;} 62 52 63 G4VITProcess::~G4VITProcess() 53 G4VITProcess::~G4VITProcess() 64 = default; << 54 { >> 55 //dtor >> 56 // As the owner, G4IT should delete fProcessState >> 57 } 65 58 66 G4VITProcess::G4VITProcess(const G4VITProcess& << 59 G4VITProcess::G4VITProcess(const G4VITProcess& other) : G4VProcess(other), fProcessID(other.fProcessID) 67 G4VProcess(other), fProcessID(other.fProce << 68 { 60 { 69 //copy ctor << 61 //copy ctor 70 //fpState = 0 ; << 62 fState = 0 ; 71 currentInteractionLength = nullpt << 63 currentInteractionLength = 0; 72 theInteractionTimeLeft = nullpt << 64 theInteractionTimeLeft = 0; 73 theNumberOfInteractionLengthLeft = nullpt << 65 theNumberOfInteractionLengthLeft = 0; 74 fInstantiateProcessState = other. << 75 fProposesTimeStep = other. << 76 } 66 } 77 67 78 G4VITProcess& G4VITProcess::operator=(const G4 68 G4VITProcess& G4VITProcess::operator=(const G4VITProcess& rhs) 79 { 69 { 80 if (this == &rhs) return *this; // handle se << 70 if (this == &rhs) return *this; // handle self assignment 81 //assignment operator << 71 //assignment operator 82 return *this; << 72 return *this; 83 } 73 } 84 74 85 void G4VITProcess::StartTracking(G4Track* trac 75 void G4VITProcess::StartTracking(G4Track* track) 86 { 76 { 87 G4TrackingInformation* trackingInfo = GetIT( << 77 G4TrackingInformation* trackingInfo = GetIT(track)->GetTrackingInfo(); 88 if(InstantiateProcessState()) << 78 if(InstantiateProcessState()) 89 { << 79 { 90 // fpState = new G4ProcessState(); << 80 fState = new G4ProcessState(); 91 fpState = std::make_shared<G4ProcessState> << 81 } 92 } << 82 93 << 83 theNumberOfInteractionLengthLeft = &(fState->theNumberOfInteractionLengthLeft ); 94 theNumberOfInteractionLengthLeft = &(fpSt << 84 theInteractionTimeLeft = &(fState->theInteractionTimeLeft ); 95 theInteractionTimeLeft = &(fpSt << 85 currentInteractionLength = &(fState->currentInteractionLength ); 96 currentInteractionLength = &(fpSt << 86 trackingInfo->RecordProcessState(fState,fProcessID); 97 trackingInfo->RecordProcessState(fpState,fPr << 87 fState = 0; 98 // fpState = 0; << 99 fpState.reset(); << 100 } 88 } 101 89 >> 90 void G4VITProcess::SubtractNumberOfInteractionLengthLeft( >> 91 G4double previousStepSize ) >> 92 { >> 93 if (fState->currentInteractionLength>0.0) { >> 94 fState->theNumberOfInteractionLengthLeft -= previousStepSize/(fState->currentInteractionLength); >> 95 if(fState->theNumberOfInteractionLengthLeft<0.) { >> 96 fState->theNumberOfInteractionLengthLeft=perMillion; >> 97 } >> 98 >> 99 } else { >> 100 #ifdef G4VERBOSE >> 101 if (verboseLevel>0) { >> 102 G4cerr << "G4VProcess::SubtractNumberOfInteractionLengthLeft()"; >> 103 G4cerr << " [" << theProcessName << "]" <<G4endl; >> 104 G4cerr << " currentInteractionLength = " << *currentInteractionLength/cm << " [cm]"; >> 105 G4cerr << " previousStepSize = " << previousStepSize/cm << " [cm]"; >> 106 G4cerr << G4endl; >> 107 } >> 108 #endif >> 109 G4Exception("G4VProcess::SubtractNumberOfInteractionLengthLeft()", >> 110 "Negative currentInteractionLength",EventMustBeAborted,theProcessName); >> 111 } >> 112 } 102 113