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