Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/optical/wls/src/WLSSteppingAction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/optical/wls/src/WLSSteppingAction.cc (Version 11.3.0) and /examples/extended/optical/wls/src/WLSSteppingAction.cc (Version 10.3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: WLSSteppingAction.cc 99622 2016-09-29 10:16:04Z gcosmo $
 26 //                                                 27 //
 27 /// \file optical/wls/src/WLSSteppingAction.cc     28 /// \file optical/wls/src/WLSSteppingAction.cc
 28 /// \brief Implementation of the WLSSteppingAc     29 /// \brief Implementation of the WLSSteppingAction class
 29 //                                                 30 //
 30 //                                                 31 //
 31 #include "WLSSteppingAction.hh"                <<  32 #include "G4Run.hh"
                                                   >>  33 #include "G4Step.hh"
                                                   >>  34 #include "G4Track.hh"
                                                   >>  35 #include "G4StepPoint.hh"
                                                   >>  36 #include "G4TrackStatus.hh"
                                                   >>  37 #include "G4VPhysicalVolume.hh"
                                                   >>  38 #include "G4ParticleDefinition.hh"
 32                                                    39 
                                                   >>  40 #include "WLSSteppingAction.hh"
 33 #include "WLSDetectorConstruction.hh"              41 #include "WLSDetectorConstruction.hh"
 34 #include "WLSEventAction.hh"                   << 
 35 #include "WLSPhotonDetSD.hh"                   << 
 36 #include "WLSSteppingActionMessenger.hh"           42 #include "WLSSteppingActionMessenger.hh"
                                                   >>  43 #include "WLSPhotonDetSD.hh"
                                                   >>  44 
                                                   >>  45 #include "G4ParticleTypes.hh"
                                                   >>  46 
 37 #include "WLSUserTrackInformation.hh"              47 #include "WLSUserTrackInformation.hh"
 38                                                    48 
 39 #include "G4OpBoundaryProcess.hh"              << 
 40 #include "G4OpticalPhoton.hh"                  << 
 41 #include "G4ProcessManager.hh"                     49 #include "G4ProcessManager.hh"
 42 #include "G4Run.hh"                            <<  50 #include "G4OpBoundaryProcess.hh"
                                                   >>  51 
                                                   >>  52 #include "G4RunManager.hh"
 43 #include "G4SDManager.hh"                          53 #include "G4SDManager.hh"
 44 #include "G4Step.hh"                           << 
 45 #include "G4StepPoint.hh"                      << 
 46 #include "G4SystemOfUnits.hh"                  << 
 47 #include "G4ThreeVector.hh"                    << 
 48 #include "G4Track.hh"                          << 
 49 #include "G4TrackStatus.hh"                    << 
 50 #include "G4UImanager.hh"                          54 #include "G4UImanager.hh"
 51 #include "G4VPhysicalVolume.hh"                <<  55 
                                                   >>  56 #include "G4ThreeVector.hh"
 52 #include "G4ios.hh"                                57 #include "G4ios.hh"
                                                   >>  58 #include "G4SystemOfUnits.hh"
                                                   >>  59 #include <sstream>
 53                                                    60 
 54 // Purpose: Save relevant information into Use     61 // Purpose: Save relevant information into User Track Information
 55                                                    62 
                                                   >>  63 static const G4ThreeVector ZHat = G4ThreeVector(0.0,0.0,1.0);
                                                   >>  64 
                                                   >>  65 G4int WLSSteppingAction::fMaxRndmSave = 10000;
                                                   >>  66 
 56 //....oooOO0OOooo........oooOO0OOooo........oo     67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 57                                                    68 
 58 WLSSteppingAction::WLSSteppingAction(WLSDetect <<  69 WLSSteppingAction::WLSSteppingAction(WLSDetectorConstruction* detector)
 59   : fDetector(detector), fEventAction(event)   <<  70   : fDetector(detector)
 60 {                                                  71 {
 61   fSteppingMessenger = new WLSSteppingActionMe     72   fSteppingMessenger = new WLSSteppingActionMessenger(this);
                                                   >>  73 
                                                   >>  74   fCounterEnd = 0;
                                                   >>  75   fCounterMid = 0;
                                                   >>  76   fBounceLimit = 100000;
                                                   >>  77 
                                                   >>  78   fOpProcess = NULL;
                                                   >>  79  
 62   ResetCounters();                                 80   ResetCounters();
 63 }                                                  81 }
 64                                                    82 
 65 //....oooOO0OOooo........oooOO0OOooo........oo     83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 66                                                    84 
 67 WLSSteppingAction::~WLSSteppingAction()            85 WLSSteppingAction::~WLSSteppingAction()
 68 {                                                  86 {
 69   delete fSteppingMessenger;                       87   delete fSteppingMessenger;
 70 }                                                  88 }
 71                                                    89 
 72 //....oooOO0OOooo........oooOO0OOooo........oo     90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 73                                                    91 
 74 void WLSSteppingAction::SetBounceLimit(G4int i <<  92 void  WLSSteppingAction::SetBounceLimit(G4int i)   {fBounceLimit = i;}
 75 {                                              << 
 76   fBounceLimit = i;                            << 
 77 }                                              << 
 78                                                    93 
 79 //....oooOO0OOooo........oooOO0OOooo........oo     94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 80                                                    95 
 81 G4int WLSSteppingAction::GetNumberOfBounces()  <<  96 G4int WLSSteppingAction::GetNumberOfBounces()      {return fCounterBounce;}
 82 {                                              << 
 83   return fCounterBounce;                       << 
 84 }                                              << 
 85                                                    97 
 86 //....oooOO0OOooo........oooOO0OOooo........oo     98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 87                                                    99 
 88 G4int WLSSteppingAction::GetNumberOfClad1Bounc << 100 G4int WLSSteppingAction::GetNumberOfClad1Bounces() {return fCounterClad1Bounce;}
 89 {                                              << 
 90   return fCounterClad1Bounce;                  << 
 91 }                                              << 
 92                                                   101 
 93 //....oooOO0OOooo........oooOO0OOooo........oo    102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 94                                                   103 
 95 G4int WLSSteppingAction::GetNumberOfClad2Bounc << 104 G4int WLSSteppingAction::GetNumberOfClad2Bounces() {return fCounterClad2Bounce;}
 96 {                                              << 
 97   return fCounterClad2Bounce;                  << 
 98 }                                              << 
 99                                                   105 
100 //....oooOO0OOooo........oooOO0OOooo........oo    106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101                                                   107 
102 G4int WLSSteppingAction::GetNumberOfWLSBounces << 108 G4int WLSSteppingAction::GetNumberOfWLSBounces()   {return fCounterWLSBounce;}
103 {                                              << 109 
104   return fCounterWLSBounce;                    << 110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 111 
                                                   >> 112 G4int WLSSteppingAction::ResetSuccessCounter()     {
                                                   >> 113       G4int temp = fCounterEnd; fCounterEnd = 0; return temp;
105 }                                                 114 }
106                                                   115 
107 //....oooOO0OOooo........oooOO0OOooo........oo    116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108                                                   117 
109 G4int WLSSteppingAction::ResetSuccessCounter() << 118 inline void WLSSteppingAction::SaveRandomStatus(G4String subDir) 
                                                   >> 119 // save the random status into a sub-directory
                                                   >> 120 // Pre: subDir must be empty or ended with "/"
110 {                                                 121 {
111   G4int temp = fCounterEnd;                    << 122  
112   fCounterEnd = 0;                             << 123     // don't save if the maximum amount has been reached
113   return temp;                                 << 124     if (WLSSteppingAction::fMaxRndmSave == 0) return;
                                                   >> 125 
                                                   >> 126     G4RunManager* theRunManager = G4RunManager::GetRunManager();
                                                   >> 127     G4String randomNumberStatusDir = theRunManager->GetRandomNumberStoreDir();
                                                   >> 128  
                                                   >> 129     G4String fileIn  = randomNumberStatusDir + "currentEvent.rndm";
                                                   >> 130 
                                                   >> 131     std::ostringstream os;
                                                   >> 132 
                                                   >> 133     os << "run" << theRunManager->GetCurrentRun()->GetRunID() << "evt"
                                                   >> 134        << theRunManager->GetCurrentEvent()->GetEventID() << ".rndm" << '\0';
                                                   >> 135 
                                                   >> 136     G4String fileOut = randomNumberStatusDir + subDir + os.str();
                                                   >> 137 
                                                   >> 138     G4String copCmd = "/control/shell cp "+fileIn+" "+fileOut;
                                                   >> 139     G4UImanager::GetUIpointer()->ApplyCommand(copCmd);
                                                   >> 140 
                                                   >> 141     WLSSteppingAction::fMaxRndmSave--;
114 }                                                 142 }
115                                                   143 
116 //....oooOO0OOooo........oooOO0OOooo........oo    144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117                                                   145 
118 void WLSSteppingAction::UserSteppingAction(con    146 void WLSSteppingAction::UserSteppingAction(const G4Step* theStep)
119 {                                                 147 {
120   G4Track* theTrack = theStep->GetTrack();        148   G4Track* theTrack = theStep->GetTrack();
121   auto trackInformation = (WLSUserTrackInforma << 149   WLSUserTrackInformation* trackInformation
                                                   >> 150       = (WLSUserTrackInformation*)theTrack->GetUserInformation();
122                                                   151 
123   G4StepPoint* thePrePoint = theStep->GetPreSt << 152   G4StepPoint* thePrePoint  = theStep->GetPreStepPoint();
124   G4StepPoint* thePostPoint = theStep->GetPost    153   G4StepPoint* thePostPoint = theStep->GetPostStepPoint();
125                                                   154 
126   G4VPhysicalVolume* thePrePV = thePrePoint->G << 155   G4VPhysicalVolume* thePrePV  = thePrePoint->GetPhysicalVolume();
127   G4VPhysicalVolume* thePostPV = thePostPoint-    156   G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
128                                                   157 
129   G4String thePrePVname = " ";                 << 158   G4String thePrePVname  = " ";
130   G4String thePostPVname = " ";                   159   G4String thePostPVname = " ";
131                                                   160 
132   if (thePostPV) {                                161   if (thePostPV) {
133     thePrePVname = thePrePV->GetName();        << 162      thePrePVname  = thePrePV->GetName();
134     thePostPVname = thePostPV->GetName();      << 163      thePostPVname = thePostPV->GetName();
135   }                                               164   }
136                                                   165 
137   // Recording data for start                  << 166   //Recording data for start
138   // static const G4ThreeVector ZHat = G4Three << 167   if (theTrack->GetParentID()==0) {
139   if (theTrack->GetParentID() == 0) {          << 168      //This is a primary track
140     // This is a primary track                 << 169      if ( theTrack->GetCurrentStepNumber() == 1 ) {
141     if (theTrack->GetCurrentStepNumber() == 1) << 170 //        G4double x  = theTrack->GetVertexPosition().x();
142       //        G4double x  = theTrack->GetVer << 171 //        G4double y  = theTrack->GetVertexPosition().y();
143       //        G4double y  = theTrack->GetVer << 172 //        G4double z  = theTrack->GetVertexPosition().z();
144       //        G4double z  = theTrack->GetVer << 173 //        G4double pz = theTrack->GetVertexMomentumDirection().z();
145       //        G4double pz = theTrack->GetVer << 174 //        G4double fInitTheta = 
146       //        G4double fInitTheta =          << 175 //                         theTrack->GetVertexMomentumDirection().angle(ZHat);
147       //                         theTrack->Get << 176      }
148     }                                          << 
149   }                                               177   }
150                                                   178 
151   // Retrieve the status of the photon            179   // Retrieve the status of the photon
152   G4OpBoundaryProcessStatus theStatus = Undefi    180   G4OpBoundaryProcessStatus theStatus = Undefined;
153                                                   181 
154   static G4ThreadLocal G4ProcessManager* OpMan << 182   G4ProcessManager* OpManager =
155     G4OpticalPhoton::OpticalPhoton()->GetProce << 183                       G4OpticalPhoton::OpticalPhoton()->GetProcessManager();
156                                                   184 
157   if (OpManager) {                                185   if (OpManager) {
158     G4int nproc = OpManager->GetPostStepProces << 186      G4int MAXofPostStepLoops =
159     G4ProcessVector* fPostStepDoItVector = OpM << 187               OpManager->GetPostStepProcessVector()->entries();
160                                                << 188      G4ProcessVector* fPostStepDoItVector =
161     for (G4int i = 0; i < nproc; ++i) {        << 189               OpManager->GetPostStepProcessVector(typeDoIt);
162       G4VProcess* fCurrentProcess = (*fPostSte << 190 
163       fOpProcess = dynamic_cast<G4OpBoundaryPr << 191      for ( G4int i=0; i<MAXofPostStepLoops; i++) {
164       if (fOpProcess) {                        << 192          G4VProcess* fCurrentProcess = (*fPostStepDoItVector)[i];
165         theStatus = fOpProcess->GetStatus();   << 193          fOpProcess = dynamic_cast<G4OpBoundaryProcess*>(fCurrentProcess);
166         break;                                 << 194          if (fOpProcess) { theStatus = fOpProcess->GetStatus(); break;}
167       }                                        << 195      }
168     }                                          << 
169   }                                               196   }
170                                                   197 
171   // Find the skewness of the ray at first cha    198   // Find the skewness of the ray at first change of boundary
172   if (fInitGamma == -1                         << 199   if ( fInitGamma == -1 &&
173       && (theStatus == TotalInternalReflection << 200        (theStatus == TotalInternalReflection
174           || theStatus == FresnelRefraction)   << 201         || theStatus == FresnelReflection
175       && trackInformation->IsStatus(InsideOfFi << 202         || theStatus == FresnelRefraction)
176   {                                            << 203         && trackInformation->IsStatus(InsideOfFiber) ) {
177     G4double px = theTrack->GetVertexMomentumD << 204 
178     G4double py = theTrack->GetVertexMomentumD << 205         G4double px = theTrack->GetVertexMomentumDirection().x();
179     G4double x = theTrack->GetPosition().x();  << 206         G4double py = theTrack->GetVertexMomentumDirection().y();
180     G4double y = theTrack->GetPosition().y();  << 207         G4double x  = theTrack->GetPosition().x();
                                                   >> 208         G4double y  = theTrack->GetPosition().y();
181                                                   209 
182     fInitGamma = x * px + y * py;              << 210         fInitGamma = x * px + y * py;
183                                                   211 
184     fInitGamma = fInitGamma / std::sqrt(px * p << 212         fInitGamma = 
                                                   >> 213                  fInitGamma / std::sqrt(px*px + py*py) / std::sqrt(x*x + y*y);
185                                                   214 
186     fInitGamma = std::acos(fInitGamma * rad);  << 215         fInitGamma = std::acos(fInitGamma*rad);
187                                                   216 
188     if (fInitGamma / deg > 90.0) {             << 217         if ( fInitGamma / deg > 90.0)  { fInitGamma = 180 * deg - fInitGamma;}
189       fInitGamma = 180 * deg - fInitGamma;     << 
190     }                                          << 
191   }                                               218   }
192   // Record Photons that missed the photon det    219   // Record Photons that missed the photon detector but escaped from readout
193   if (!thePostPV && trackInformation->IsStatus << 220   if ( !thePostPV && trackInformation->IsStatus(EscapedFromReadOut) ) {
194     // G4cout << "SteppingAction: status = Esc << 221 //     UpdateHistogramSuccess(thePostPoint,theTrack);
195     fEventAction->AddEscaped();                << 222      ResetCounters();
196     // UpdateHistogramSuccess(thePostPoint,the << 223  
197     ResetCounters();                           << 224      return;
198                                                << 
199     return;                                    << 
200   }                                               225   }
201                                                   226 
202   // Assumed photons are originated at the fib    227   // Assumed photons are originated at the fiber OR
203   // the fiber is the first material the photo    228   // the fiber is the first material the photon hits
204   switch (theStatus) {                            229   switch (theStatus) {
205     // Exiting the fiber                       << 230  
206     case FresnelRefraction:                    << 231      // Exiting the fiber
207     case SameMaterial:                         << 232      case FresnelRefraction:
208       fEventAction->AddExiting();              << 233      case SameMaterial:
209                                                << 234 
210       if (thePostPVname == "WLSFiber" || thePo << 235        G4bool isFiber;
211         if (trackInformation->IsStatus(Outside << 236        isFiber = thePostPVname == "WLSFiber"
212           trackInformation->AddStatusFlag(Insi << 237                      || thePostPVname == "Clad1"
213                                                << 238                      || thePostPVname == "Clad2";
214         // Set the Exit flag when the photon r << 239  
215       }                                        << 240        if ( isFiber ) {
216       else if (trackInformation->IsStatus(Insi << 241 
217         // EscapedFromReadOut if the z positio << 242            if (trackInformation->IsStatus(OutsideOfFiber))
218         if (theTrack->GetPosition().z() == fDe << 243                                trackInformation->AddStatusFlag(InsideOfFiber);
219           trackInformation->AddStatusFlag(Esca << 244 
220           fCounterEnd++;                       << 245        // Set the Exit flag when the photon refracted out of the fiber
221           fEventAction->AddEscapedEnd();       << 246        } else if (trackInformation->IsStatus(InsideOfFiber)) {
222         }                                      << 247 
223         else  // Escaped from side             << 248            // EscapedFromReadOut if the z position is the same as fiber's end
224         {                                      << 249            if (theTrack->GetPosition().z() == fDetector->GetWLSFiberEnd())
225           trackInformation->AddStatusFlag(Esca << 250            {
226           trackInformation->SetExitPosition(th << 251               trackInformation->AddStatusFlag(EscapedFromReadOut);
227           //  UpdateHistogramEscape(thePostPoi << 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
                                                   >> 273      case TotalInternalReflection:
                                                   >> 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
                                                   >> 317      case LambertianReflection:
                                                   >> 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 
                                                   >> 333           G4SDManager* SDman = G4SDManager::GetSDMpointer();
                                                   >> 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);
228                                                   343 
229           fCounterMid++;                       << 344           // Stop Tracking when it hits the detector's surface
230           fEventAction->AddEscapedMid();       << 
231           ResetCounters();                        345           ResetCounters();
232         }                                      << 346           theTrack->SetTrackStatus(fStopAndKill);
233                                                   347 
234         trackInformation->AddStatusFlag(Outsid << 348           return;
235         trackInformation->SetExitPosition(theT << 349        }
236       }                                        << 
237                                                << 
238       return;                                  << 
239                                                << 
240     // Internal Reflections                    << 
241     case TotalInternalReflection:              << 
242                                                << 
243       fEventAction->AddTIR();                  << 
244                                                << 
245       // Kill the track if it's number of boun << 
246       if (fBounceLimit > 0 && fCounterBounce > << 
247         theTrack->SetTrackStatus(fStopAndKill) << 
248         trackInformation->AddStatusFlag(murder << 
249         ResetCounters();                       << 
250         G4cout << "\n Bounce Limit Exceeded" < << 
251         return;                                << 
252       }                                        << 
253       break;                                   << 
254                                                << 
255     case FresnelReflection:                    << 
256                                                << 
257       fCounterBounce++;                        << 
258       fEventAction->AddBounce();               << 
259                                                << 
260       if (thePrePVname == "WLSFiber") {        << 
261         fCounterWLSBounce++;                   << 
262         fEventAction->AddWLSBounce();          << 
263       }                                        << 
264       else if (thePrePVname == "Clad1") {      << 
265         fCounterClad1Bounce++;                 << 
266         fEventAction->AddClad1Bounce();        << 
267       }                                        << 
268       else if (thePrePVname == "Clad2") {      << 
269         fCounterClad2Bounce++;                 << 
270         fEventAction->AddClad1Bounce();        << 
271       }                                        << 
272                                                << 
273       // Determine if the photon has reflected << 
274       if (theTrack->GetPosition().z() == fDete << 
275         if (!trackInformation->IsStatus(Reflec << 
276             && trackInformation->IsStatus(Insi << 
277         {                                      << 
278           trackInformation->AddStatusFlag(Refl << 
279                                                << 
280           if (fDetector->IsPerfectFiber() && t << 
281             theTrack->SetTrackStatus(fStopAndK << 
282             trackInformation->AddStatusFlag(mu << 
283             // UpdateHistogramReflect(thePostP << 
284             ResetCounters();                   << 
285             return;                            << 
286           }                                    << 
287         }                                      << 
288       }                                        << 
289       return;                                  << 
290                                                << 
291     // Reflection off the mirror               << 
292     case LambertianReflection:                 << 
293     case LobeReflection:                       << 
294     case SpikeReflection:                      << 
295                                                << 
296       fEventAction->AddReflected();            << 
297       // Check if it hits the mirror           << 
298       if (thePostPVname == "Mirror") {         << 
299         trackInformation->AddStatusFlag(Reflec << 
300         fEventAction->AddMirror();             << 
301       }                                        << 
302       return;                                  << 
303                                                << 
304     // Detected by a detector                  << 
305     case Detection:                            << 
306       // Detected automatically with G4OpBound << 
307                                                << 
308       // Stop Tracking when it hits the detect << 
309       ResetCounters();                         << 
310       theTrack->SetTrackStatus(fStopAndKill);  << 
311       return;                                  << 
312                                                   350 
313     default:                                   << 351        break;
314       break;                                   << 
315   }                                            << 
316                                                   352 
                                                   >> 353      default: break;
                                                   >> 354 
                                                   >> 355   }
                                                   >> 356  
317   // Check for absorbed photons                   357   // Check for absorbed photons
318   if (theTrack->GetTrackStatus() != fAlive &&  << 358   if (theTrack->GetTrackStatus() != fAlive  &&
319     // UpdateHistogramAbsorb(thePostPoint,theT << 359       trackInformation->IsStatus(InsideOfFiber))
320     ResetCounters();                           << 360   {
321     return;                                    << 361 //     UpdateHistogramAbsorb(thePostPoint,theTrack);
                                                   >> 362      ResetCounters();
                                                   >> 363      return;
322   }                                               364   }
                                                   >> 365  
323 }                                                 366 }
324                                                   367