52 #ifndef LARG4_OPBOUNDARYPROCESSSIMPLE_CXX 53 #define LARG4_OPBOUNDARYPROCESSSIMPLE_CXX 1 58 #include "Geant4/G4ios.hh" 59 #include "Geant4/G4OpProcessSubType.hh" 60 #include "Geant4/G4GeometryTolerance.hh" 75 : G4VDiscreteProcess(processName, type)
78 G4cout << GetProcessName() <<
" is created " << G4endl;
82 SetProcessSubType(fOpBoundary);
87 ->GetSurfaceTolerance();
117 aParticleChange.Initialize(aTrack);
120 G4StepPoint* pPreStepPoint = aStep.GetPreStepPoint();
121 G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
124 if (pPostStepPoint->GetStepStatus() != fGeomBoundary){
126 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
130 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
133 G4Material* Material1 = pPreStepPoint -> GetMaterial();
134 G4Material* Material2 = pPostStepPoint -> GetMaterial();
137 if(Material1 != Material2)
146 G4double thePhotonMomentum;
148 G4ThreeVector OldMomentum;
149 G4ThreeVector OldPolarization;
151 G4ThreeVector NewMomentum;
152 G4ThreeVector NewPolarization;
154 G4ThreeVector theGlobalNormal;
155 G4ThreeVector theFacetNormal;
157 std::string Material1Name = Material1->GetName();
158 std::string Material2Name = Material2->GetName();
160 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
163 thePhotonMomentum = aParticle->GetTotalMomentum();
164 OldMomentum = aParticle->GetMomentumDirection();
165 OldPolarization = aParticle->GetPolarization();
169 if (
fVerbosity>9) std::cout<<
"OpBoundaryProcessSimple Debug: Photon " <<aTrack.GetTrackID() <<
" momentum "<<thePhotonMomentum <<
" Material1 " << Material1Name.c_str() <<
" Material 2 " << Material2Name.c_str() << std::endl;
171 G4ThreeVector theGlobalPoint = pPostStepPoint->GetPosition();
173 G4Navigator* theNavigator =
174 G4TransportationManager::GetTransportationManager()->
175 GetNavigatorForTracking();
177 G4ThreeVector theLocalPoint = theNavigator->
178 GetGlobalToLocalTransform().
179 TransformPoint(theGlobalPoint);
181 G4ThreeVector theLocalNormal;
184 theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
187 theLocalNormal = -theLocalNormal;
190 G4cerr <<
" OpBoundaryProcessSimple/PostStepDoIt(): " 191 <<
" The Navigator reports that it returned an invalid normal" 195 theGlobalNormal = theNavigator->GetLocalToGlobalTransform().
196 TransformAxis(theLocalNormal);
198 if (OldMomentum * theGlobalNormal > 0.0) {
199 #ifdef G4DEBUG_OPTICAL 200 G4cerr <<
" OpBoundaryProcessSimple/PostStepDoIt(): " 201 <<
" theGlobalNormal points the wrong direction " 204 theGlobalNormal = -theGlobalNormal;
207 G4MaterialPropertiesTable* aMaterialPropertiesTable;
208 G4MaterialPropertyVector* Reflectance;
209 G4MaterialPropertyVector* DiffuseReflectanceFraction;
212 aMaterialPropertiesTable = Material1->GetMaterialPropertiesTable();
215 if (aMaterialPropertiesTable) {
217 std::stringstream PropertyName;
218 PropertyName<<
"REFLECTANCE_"<<Material2Name.c_str();
219 Reflectance = aMaterialPropertiesTable->GetProperty(PropertyName.str().c_str());
221 PropertyName.str(
"");
222 PropertyName<<
"DIFFUSE_REFLECTANCE_FRACTION_"<<Material2Name.c_str();
223 DiffuseReflectanceFraction=aMaterialPropertiesTable->GetProperty(PropertyName.str().c_str());
227 double theReflectance = Reflectance->Value(thePhotonMomentum);
230 if(DiffuseReflectanceFraction)
232 double theDiffuseReflectanceFraction = DiffuseReflectanceFraction->Value(thePhotonMomentum);
265 NewMomentum = G4LambertianRand(theGlobalNormal);
266 theFacetNormal = (NewMomentum - OldMomentum).unit();
270 theFacetNormal = theGlobalNormal;
271 G4double PdotN = OldMomentum * theFacetNormal;
272 NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
276 aParticleChange.ProposeTrackStatus(fStopAndKill);
281 NewMomentum=OldMomentum;
283 else aParticleChange.ProposeTrackStatus(fStopAndKill);
285 NewMomentum = NewMomentum.unit();
286 aParticleChange.ProposeMomentumDirection(NewMomentum);
288 return G4VDiscreteProcess::PostStepDoIt(aTrack,aStep);
299 G4ForceCondition* condition)
Store parameters for running LArG4.
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep)
~OpBoundaryProcessSimple()
OpBoundaryProcessSimpleStatus fTheStatus
G4bool G4BooleanRand(const G4double prob) const
G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition)
OpBoundaryProcessSimple(const G4String &processName="OpBoundary", G4ProcessType type=fOptical)