42{
46 return false;
47 }
48 }
49
50 G4ThreeVector
pos = aStep->GetTrack()->GetPosition();
51 G4ThreeVector
momentum = aStep->GetPreStepPoint()->GetMomentum();
52
53
54
55
56 if (aStep->GetTrack()->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition()){
57 return true;
58 }
59
60
61
62
63
65 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
66 return true;
67 }
68
69
70
71
72
73 G4StepPoint *endPoint = aStep->GetPostStepPoint();
74 if (endPoint->GetStepStatus() != fGeomBoundary)
75 return true;
76
77
78
79
80
81
82
83
84 G4MaterialPropertiesTable *MPT = aStep->GetPreStepPoint()->GetMaterial()->GetMaterialPropertiesTable();
85 if (!MPT)
86 return true;
87 G4MaterialPropertyVector *RindexMPV = MPT->GetProperty(kRINDEX);
88 if (!RindexMPV)
89 return true;
90
91 G4double Rindex;
93 double photonEnergy = aStep->GetTrack()->GetDynamicParticle()->GetTotalMomentum();
94 Rindex = RindexMPV->Value(photonEnergy, index);
95
96
97 G4ThreeVector momDir = aStep->GetPreStepPoint()->GetMomentumDirection();
98 G4double angleFromY =
atan(sqrt(1 -
pow(momDir.y(), 2.0)) / momDir.y());
99
100
101
102 if (angleFromY > asin(1.0 / Rindex)){
103 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
104 return true;
105 }
106
107
108
109
110
111
112 G4bool isTIR = false;
113 G4ProcessVector *postStepDoItVector = G4OpticalPhoton::OpticalPhotonDefinition()->GetProcessManager()->GetPostStepProcessVector(typeDoIt);
114 G4int n_proc = postStepDoItVector->entries();
115 for (G4int i = 0;
i < n_proc; ++
i){
116 G4OpBoundaryProcess *opProc =
dynamic_cast<G4OpBoundaryProcess *
>((*postStepDoItVector)[
i]);
117 if (opProc && opProc->GetStatus() == TotalInternalReflection){
118 isTIR = true;
119 break;
120 }
121 }
122
123 if(!isTIR){
124 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
125 return true;
126 }
127
128
129
130
131
132
133 G4MaterialPropertyVector *AbsMPV = MPT->GetProperty(kABSLENGTH);
134 G4double Absorption = AbsMPV->Value(aStep->GetTrack()->GetDynamicParticle()->GetTotalMomentum(), index);
135
137 G4double absChance = 1 -
exp(-pathLength / Absorption);
138
139
140 if (CLHEP::RandFlat::shoot(0.0, 1.0) < absChance){
141 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
142 return true;
143 }
144
145
146
147
148
150 id = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo();
152
153
154
155
156 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
157 return true;
158}