Viewing all processes of a particle

Hi All,

I am curious to see if it is possible to view all of the processes that a particle, specifically an optical photon in my case, undergoes during an event.

The optical photon starts within a material and is directed perpendicular to a surface with the world volume, and is expected to either reflect or refract at the surface.

So far I have attempted to implement some methods borrowed from the “OpNovice2” example within my stepping action script:

G4OpBoundaryProcessStatus theStatus = Undefined;

      G4ProcessManager* OpManager = 
        G4OpticalPhoton::OpticalPhoton()->GetProcessManager();
      G4int MAXofPostStepLoops = 
        OpManager->GetPostStepProcessVector()->entries();
      G4ProcessVector* postStepDoItVector = 
        OpManager->GetPostStepProcessVector(typeDoIt);

      for (G4int i=0; i<MAXofPostStepLoops; ++i)
      {
          G4VProcess* currentProcess = (*postStepDoItVector)[i];

          G4OpBoundaryProcess* opProc = 
            dynamic_cast<G4OpBoundaryProcess*>(currentProcess);

          if(currentProcess->GetProcessName())
              G4cout << currentProcess->GetProcessName() << endl;

          if (opProc)
          {
            theStatus = opProc->GetStatus();
            //G4cout << theStatus << endl;
            
            if(theStatus == Undefined)                    G4cout << "Boundary Process = Undefined" << endl;
            else if(theStatus == Transmission)            G4cout << "Boundary Process = Transmission" << endl;
            else if(theStatus == FresnelRefraction)       G4cout << "Boundary Process = Fresnel Refraction" << endl;
            else if(theStatus == FresnelReflection)       G4cout << "Boundary Process = Fresnel Reflection" << endl;
            else if(theStatus == TotalInternalReflection) G4cout << "Boundary Process = Total Internal Reflection" << endl;
            else if(theStatus == LambertianReflection)    G4cout << "Boundary Process = Lambertian Reflection" << endl;
            else if(theStatus == LobeReflection)          G4cout << "Boundary Process = Lobe Reflection" << endl;
            else if(theStatus == SpikeReflection)         G4cout << "Boundary Process = Spike Reflection" << endl;
            else if(theStatus == BackScattering)          G4cout << "Boundary Process = Back Scattering" << endl;
            else if(theStatus == Absorption)              G4cout << "Boundary Process = Absorption" << endl;
            else if(theStatus == Detection)               G4cout << "Boundary Process = Detection" << endl;
            else if(theStatus == NotAtBoundary)           G4cout << "Boundary Process = Not At Boundary" << endl;
            else if(theStatus == SameMaterial)            G4cout << "Boundary Process = Same Material" << endl;
            else if(theStatus == StepTooSmall)            G4cout << "Boundary Process = Step Too Small" << endl;
            else G4cout << "The status = " << theStatus << endl;
            G4cout << endl;
          }
      }

To check my understanding, in the above block, is the G4cout << currentProcess->GetProcessName() << endl; command printing the current process that the photon is using/being used on it? I find that the output from this is always the same:

Transportation
OpAbsorption
OpRayleigh
OpMieHG
OpWLS
OpBoundary
Boundary Process = Fresnel Refraction

with the last output line regarding the boundary process changing dependent on the interaction with a boundary, taking on values of Fresnel Refraction, Total Internal Reflection, or Step Too Small.

I have also used the method:

G4StepPoint* endPoint   = theStep->GetPostStepPoint();
G4StepPoint* startPoint = theStep->GetPreStepPoint();
const G4VProcess* pds = endPoint->GetProcessDefinedStep();
G4cout << "Endpoint = " << endPoint->GetPosition() << endl;
  
if(pds->GetProcessName()) G4cout << pds->GetProcessName() << endl;

which will output as an example:

Endpoint = (398.3,0,0)
Transportation
Endpoint = (-2000,-461.604,247.795)
Transportation

If possible, what is the difference between these two methods, as in does the first method show every processes involved and the second method show just the process at the end point of a step? Also, is there a more efficient/correct way to view all the processes involved in simulating the photon’s interactions, such that I could see what the photon is doing and what is done to it along its path?

Thank you so much in advance!

-Frank