Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
WLSSteppingAction Class Reference

#include <WLSSteppingAction.hh>

Inheritance diagram for WLSSteppingAction:
G4UserSteppingAction

Public Member Functions

 WLSSteppingAction (WLSDetectorConstruction *)
 
virtual ~WLSSteppingAction ()
 
virtual void UserSteppingAction (const G4Step *)
 
void SetBounceLimit (G4int)
 
G4int GetNumberOfBounces ()
 
G4int GetNumberOfClad1Bounces ()
 
G4int GetNumberOfClad2Bounces ()
 
G4int GetNumberOfWLSBounces ()
 
G4int ResetSuccessCounter ()
 
- Public Member Functions inherited from G4UserSteppingAction
 G4UserSteppingAction ()
 
virtual ~G4UserSteppingAction ()
 
void SetSteppingManagerPointer (G4SteppingManager *pValue)
 

Additional Inherited Members

- Protected Attributes inherited from G4UserSteppingAction
G4SteppingManagerfpSteppingManager
 

Detailed Description

Definition at line 48 of file WLSSteppingAction.hh.

Constructor & Destructor Documentation

WLSSteppingAction::WLSSteppingAction ( WLSDetectorConstruction detector)

Definition at line 69 of file WLSSteppingAction.cc.

70  : fDetector(detector)
71 {
72  fSteppingMessenger = new WLSSteppingActionMessenger(this);
73 
74  fCounterEnd = 0;
75  fCounterMid = 0;
76  fBounceLimit = 100000;
77 
78  fOpProcess = NULL;
79 
80  ResetCounters();
81 }
WLSSteppingAction::~WLSSteppingAction ( )
virtual

Definition at line 85 of file WLSSteppingAction.cc.

86 {
87  delete fSteppingMessenger;
88 }

Member Function Documentation

G4int WLSSteppingAction::GetNumberOfBounces ( )

Definition at line 96 of file WLSSteppingAction.cc.

96 {return fCounterBounce;}
G4int WLSSteppingAction::GetNumberOfClad1Bounces ( )

Definition at line 100 of file WLSSteppingAction.cc.

100 {return fCounterClad1Bounce;}
G4int WLSSteppingAction::GetNumberOfClad2Bounces ( )

Definition at line 104 of file WLSSteppingAction.cc.

104 {return fCounterClad2Bounce;}
G4int WLSSteppingAction::GetNumberOfWLSBounces ( )

Definition at line 108 of file WLSSteppingAction.cc.

108 {return fCounterWLSBounce;}
G4int WLSSteppingAction::ResetSuccessCounter ( )

Definition at line 112 of file WLSSteppingAction.cc.

112  {
113  G4int temp = fCounterEnd; fCounterEnd = 0; return temp;
114 }
int G4int
Definition: G4Types.hh:78
void WLSSteppingAction::SetBounceLimit ( G4int  i)

Definition at line 92 of file WLSSteppingAction.cc.

92 {fBounceLimit = i;}
void WLSSteppingAction::UserSteppingAction ( const G4Step theStep)
virtual

Reimplemented from G4UserSteppingAction.

Definition at line 146 of file WLSSteppingAction.cc.

References WLSUserTrackInformation::AddStatusFlag(), python.hepunit::deg, Detection, G4ProcessVector::entries(), EscapedFromReadOut, EscapedFromSide, fAlive, G4SDManager::FindSensitiveDetector(), FresnelReflection, FresnelRefraction, fStopAndKill, G4cout, G4endl, G4Track::GetCurrentStepNumber(), G4VPhysicalVolume::GetName(), G4Track::GetParentID(), G4StepPoint::GetPhysicalVolume(), G4Track::GetPosition(), G4Step::GetPostStepPoint(), G4ProcessManager::GetPostStepProcessVector(), G4Step::GetPreStepPoint(), G4ParticleDefinition::GetProcessManager(), G4SDManager::GetSDMpointer(), G4OpBoundaryProcess::GetStatus(), G4Step::GetTrack(), G4Track::GetTrackStatus(), G4Track::GetUserInformation(), G4Track::GetVertexMomentumDirection(), WLSDetectorConstruction::GetWLSFiberEnd(), InsideOfFiber, WLSDetectorConstruction::IsPerfectFiber(), WLSUserTrackInformation::isStatus(), LambertianReflection, LobeReflection, murderee, G4OpticalPhoton::OpticalPhoton(), OutsideOfFiber, WLSPhotonDetSD::ProcessHits_constStep(), python.hepunit::rad, ReflectedAtMirror, ReflectedAtReadOut, SameMaterial, WLSUserTrackInformation::SetExitPosition(), G4Track::SetTrackStatus(), SpikeReflection, TotalInternalReflection, typeDoIt, Undefined, test::x, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

147 {
148  G4Track* theTrack = theStep->GetTrack();
149  WLSUserTrackInformation* trackInformation
151 
152  G4StepPoint* thePrePoint = theStep->GetPreStepPoint();
153  G4StepPoint* thePostPoint = theStep->GetPostStepPoint();
154 
155  G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
156  G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
157 
158  G4String thePrePVname = " ";
159  G4String thePostPVname = " ";
160 
161  if (thePostPV) {
162  thePrePVname = thePrePV->GetName();
163  thePostPVname = thePostPV->GetName();
164  }
165 
166  //Recording data for start
167  if (theTrack->GetParentID()==0) {
168  //This is a primary track
169  if ( theTrack->GetCurrentStepNumber() == 1 ) {
170 // G4double x = theTrack->GetVertexPosition().x();
171 // G4double y = theTrack->GetVertexPosition().y();
172 // G4double z = theTrack->GetVertexPosition().z();
173 // G4double pz = theTrack->GetVertexMomentumDirection().z();
174 // G4double fInitTheta =
175 // theTrack->GetVertexMomentumDirection().angle(ZHat);
176  }
177  }
178 
179  // Retrieve the status of the photon
181 
182  G4ProcessManager* OpManager =
184 
185  if (OpManager) {
186  G4int MAXofPostStepLoops =
187  OpManager->GetPostStepProcessVector()->entries();
188  G4ProcessVector* fPostStepDoItVector =
190 
191  for ( G4int i=0; i<MAXofPostStepLoops; i++) {
192  G4VProcess* fCurrentProcess = (*fPostStepDoItVector)[i];
193  fOpProcess = dynamic_cast<G4OpBoundaryProcess*>(fCurrentProcess);
194  if (fOpProcess) { theStatus = fOpProcess->GetStatus(); break;}
195  }
196  }
197 
198  // Find the skewness of the ray at first change of boundary
199  if ( fInitGamma == -1 &&
200  (theStatus == TotalInternalReflection
201  || theStatus == FresnelReflection
202  || theStatus == FresnelRefraction)
203  && trackInformation->isStatus(InsideOfFiber) ) {
204 
205  G4double px = theTrack->GetVertexMomentumDirection().x();
206  G4double py = theTrack->GetVertexMomentumDirection().y();
207  G4double x = theTrack->GetPosition().x();
208  G4double y = theTrack->GetPosition().y();
209 
210  fInitGamma = x * px + y * py;
211 
212  fInitGamma =
213  fInitGamma / std::sqrt(px*px + py*py) / std::sqrt(x*x + y*y);
214 
215  fInitGamma = std::acos(fInitGamma*rad);
216 
217  if ( fInitGamma / deg > 90.0) { fInitGamma = 180 * deg - fInitGamma;}
218  }
219  // Record Photons that missed the photon detector but escaped from readout
220  if ( !thePostPV && trackInformation->isStatus(EscapedFromReadOut) ) {
221 // UpdateHistogramSuccess(thePostPoint,theTrack);
222  ResetCounters();
223 
224  return;
225  }
226 
227  // Assumed photons are originated at the fiber OR
228  // the fiber is the first material the photon hits
229  switch (theStatus) {
230 
231  // Exiting the fiber
232  case FresnelRefraction:
233  case SameMaterial:
234 
235  G4bool isFiber;
236  isFiber = thePostPVname == "WLSFiber"
237  || thePostPVname == "Clad1"
238  || thePostPVname == "Clad2";
239 
240  if ( isFiber ) {
241 
242  if (trackInformation->isStatus(OutsideOfFiber))
243  trackInformation->AddStatusFlag(InsideOfFiber);
244 
245  // Set the Exit flag when the photon refracted out of the fiber
246  } else if (trackInformation->isStatus(InsideOfFiber)) {
247 
248  // EscapedFromReadOut if the z position is the same as fiber's end
249  if (theTrack->GetPosition().z() == fDetector->GetWLSFiberEnd())
250  {
251  trackInformation->AddStatusFlag(EscapedFromReadOut);
252  fCounterEnd++;
253  }
254  else // Escaped from side
255  {
256  trackInformation->AddStatusFlag(EscapedFromSide);
257  trackInformation->SetExitPosition(theTrack->GetPosition());
258 
259 // UpdateHistogramEscape(thePostPoint,theTrack);
260 
261  fCounterMid++;
262  ResetCounters();
263  }
264 
265  trackInformation->AddStatusFlag(OutsideOfFiber);
266  trackInformation->SetExitPosition(theTrack->GetPosition());
267 
268  }
269 
270  return;
271 
272  // Internal Reflections
274 
275  // Kill the track if it's number of bounces exceeded the limit
276  if (fBounceLimit > 0 && fCounterBounce >= fBounceLimit)
277  {
278  theTrack->SetTrackStatus(fStopAndKill);
279  trackInformation->AddStatusFlag(murderee);
280  ResetCounters();
281  G4cout << "\n Bounce Limit Exceeded" << G4endl;
282  return;
283  }
284 
285  case FresnelReflection:
286 
287  fCounterBounce++;
288 
289  if ( thePrePVname == "WLSFiber") fCounterWLSBounce++;
290 
291  else if ( thePrePVname == "Clad1") fCounterClad1Bounce++;
292 
293  else if ( thePrePVname == "Clad2") fCounterClad2Bounce++;
294 
295  // Determine if the photon has reflected off the read-out end
296  if (theTrack->GetPosition().z() == fDetector->GetWLSFiberEnd())
297  {
298  if (!trackInformation->isStatus(ReflectedAtReadOut) &&
299  trackInformation->isStatus(InsideOfFiber))
300  {
301  trackInformation->AddStatusFlag(ReflectedAtReadOut);
302 
303  if (fDetector->IsPerfectFiber() &&
304  theStatus == TotalInternalReflection)
305  {
306  theTrack->SetTrackStatus(fStopAndKill);
307  trackInformation->AddStatusFlag(murderee);
308 // UpdateHistogramReflect(thePostPoint,theTrack);
309  ResetCounters();
310  return;
311  }
312  }
313  }
314  return;
315 
316  // Reflection of the mirror
318  case LobeReflection:
319  case SpikeReflection:
320 
321  // Check if it hits the mirror
322  if ( thePostPVname == "Mirror" )
323  trackInformation->AddStatusFlag(ReflectedAtMirror);
324 
325  return;
326 
327  // Detected by a detector
328  case Detection:
329 
330  // Check if the photon hits the detector and process the hit if it does
331  if ( thePostPVname == "PhotonDet" ) {
332 
334  G4String SDname="WLS/PhotonDet";
335  WLSPhotonDetSD* mppcSD =
336  (WLSPhotonDetSD*)SDman->FindSensitiveDetector(SDname);
337 
338  if (mppcSD) mppcSD->ProcessHits_constStep(theStep,NULL);
339 
340  // Record Photons that escaped at the end
341 // if (trackInformation->isStatus(EscapedFromReadOut))
342 // UpdateHistogramSuccess(thePostPoint,theTrack);
343 
344  // Stop Tracking when it hits the detector's surface
345  ResetCounters();
346  theTrack->SetTrackStatus(fStopAndKill);
347 
348  return;
349  }
350 
351  break;
352 
353  default: break;
354 
355  }
356 
357  // Check for absorbed photons
358  if (theTrack->GetTrackStatus() != fAlive &&
359  trackInformation->isStatus(InsideOfFiber))
360  {
361 // UpdateHistogramAbsorb(thePostPoint,theTrack);
362  ResetCounters();
363  return;
364  }
365 
366 }
void SetTrackStatus(const G4TrackStatus aTrackStatus)
G4int GetParentID() const
G4bool AddStatusFlag(TrackStatus s)
double x() const
G4bool ProcessHits_constStep(const G4Step *, G4TouchableHistory *)
void SetExitPosition(const G4ThreeVector &pos)
const G4ThreeVector & GetPosition() const
G4TrackStatus GetTrackStatus() const
G4OpBoundaryProcessStatus
G4OpBoundaryProcessStatus GetStatus() const
G4ProcessManager * GetProcessManager() const
int G4int
Definition: G4Types.hh:78
double z() const
G4VUserTrackInformation * GetUserInformation() const
G4StepPoint * GetPreStepPoint() const
G4int entries() const
G4GLOB_DLL std::ostream G4cout
G4int GetCurrentStepNumber() const
G4VPhysicalVolume * GetPhysicalVolume() const
const G4String & GetName() const
bool G4bool
Definition: G4Types.hh:79
G4VSensitiveDetector * FindSensitiveDetector(G4String dName, G4bool warning=true)
Definition: G4SDManager.cc:124
G4bool isStatus(TrackStatus s)
static G4OpticalPhoton * OpticalPhoton()
G4StepPoint * GetPostStepPoint() const
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
double y() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const
const G4ThreeVector & GetVertexMomentumDirection() const
G4ProcessVector * GetPostStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const

The documentation for this class was generated from the following files: