Go to the documentation of this file.00001
00002
00003
00004 #include "SimG4Core/GFlash/interface/GflashHadronWrapperProcess.h"
00005
00006 #include "G4Track.hh"
00007 #include "G4VParticleChange.hh"
00008 #include "G4ProcessManager.hh"
00009 #include "G4ProcessVector.hh"
00010 #include "G4VProcess.hh"
00011 #include "G4GPILSelection.hh"
00012
00013 GflashHadronWrapperProcess::GflashHadronWrapperProcess(G4String processName) :
00014 particleChange(0),
00015 pmanager(0),
00016 fProcessVector(0),
00017 fProcess(0)
00018 {
00019 theProcessName = processName;
00020 }
00021
00022 GflashHadronWrapperProcess::~GflashHadronWrapperProcess() {
00023 }
00024
00025 G4VParticleChange* GflashHadronWrapperProcess::PostStepDoIt(const G4Track& track, const G4Step& step)
00026 {
00027
00028
00029 particleChange = pRegProcess->PostStepDoIt(track, step);
00030
00031
00032
00033
00034
00035
00036
00037 particleChange->UpdateStepForPostStep(const_cast<G4Step *> (&step));
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 G4TrackVector* fSecondary = (const_cast<G4Step *> (&step))->GetfSecondary();
00055 G4int nSecondarySave = fSecondary->size();
00056
00057 G4int num2ndaries = particleChange->GetNumberOfSecondaries();
00058 G4Track* tempSecondaryTrack;
00059
00060 for(G4int DSecLoop=0 ; DSecLoop< num2ndaries; DSecLoop++){
00061 tempSecondaryTrack = particleChange->GetSecondary(DSecLoop);
00062
00063
00064 tempSecondaryTrack->SetCreatorProcess( pRegProcess );
00065
00066
00067 fSecondary->push_back( tempSecondaryTrack );
00068
00069 }
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 pmanager = track.GetDefinition()->GetProcessManager();
00085
00086 G4double testGPIL = DBL_MAX;
00087 G4double fStepLength = 0.0;
00088 G4ForceCondition fForceCondition = InActivated;
00089
00090 fStepLength = step.GetStepLength();
00091
00092 fProcessVector = pmanager->GetPostStepProcessVector(typeDoIt);
00093
00094
00095
00096
00097
00098 const G4TrackStatus keepStatus = track.GetTrackStatus();
00099
00100 (const_cast<G4Track *> (&track))->SetTrackStatus(fPostponeToNextEvent);
00101
00102 for(G4int ipm = 0 ; ipm < fProcessVector->entries() ; ipm++) {
00103 fProcess = (*fProcessVector)(ipm);
00104
00105 if ( fProcess->GetProcessType() == fParameterisation ) {
00106
00107
00108 testGPIL = fProcess->PostStepGPIL(track,fStepLength,&fForceCondition );
00109
00110
00111
00112
00113 if( fForceCondition == ExclusivelyForced) {
00114
00115
00116
00117 G4int nsec = particleChange->GetNumberOfSecondaries();
00118 for(G4int DSecLoop=0 ; DSecLoop< nsec ; DSecLoop++){
00119 G4Track* tempSecondaryTrack = particleChange->GetSecondary(DSecLoop);
00120 delete tempSecondaryTrack;
00121 }
00122 particleChange->Clear();
00123
00124
00125
00126
00127 (const_cast<G4Step *> (&step))->SetStepLength(testGPIL);
00128 (const_cast<G4Track *> (&track))->SetStepLength(testGPIL);
00129
00130 step.GetPostStepPoint()->SetStepStatus(fExclusivelyForcedProc);;
00131 step.GetPostStepPoint()->SetProcessDefinedStep(fProcess);
00132 step.GetPostStepPoint()->SetSafety(0.0);
00133
00134
00135 particleChange = fProcess->PostStepDoIt(track,step);
00136
00137
00138 particleChange->UpdateStepForPostStep(const_cast<G4Step *> (&step));
00139
00140
00141 (const_cast<G4Step *> (&step))->UpdateTrack();
00142
00143
00144
00145 step.GetPostStepPoint()->SetSafety(0.0);
00146
00147
00148 (const_cast<G4Track *> (&track))->SetTrackStatus( particleChange->GetTrackStatus() );
00149 }
00150 else {
00151
00152 (const_cast<G4Track *> (&track))->SetTrackStatus(keepStatus);
00153 }
00154
00155 break;
00156 }
00157 }
00158
00159
00160
00161
00162
00163
00164 G4TrackVector::iterator itv = fSecondary->begin();
00165 itv += nSecondarySave;
00166
00167
00168 fSecondary->erase(itv,itv+num2ndaries);
00169
00170
00171
00172 return particleChange;
00173 }
00174
00175 void GflashHadronWrapperProcess::Print(const G4Step& step) {
00176
00177 std::cout << " GflashHadronWrapperProcess ProcessName, PreStepPosition, preStepPoint KE, PostStepPoint KE, DeltaEnergy Nsec \n "
00178 << step.GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() << " "
00179 << step.GetPostStepPoint()->GetPosition() << " "
00180 << step.GetPreStepPoint()->GetKineticEnergy()/GeV << " "
00181 << step.GetPostStepPoint()->GetKineticEnergy()/GeV << " "
00182 << step.GetDeltaEnergy()/GeV << " "
00183 << particleChange->GetNumberOfSecondaries() << std::endl;
00184 }