title: Why is my modified Pol01 running in batch mode works for all polarized photon states except for left circularly polarized photons?
body: <p>I am attempting to use Pol01 example to examine the angular distribution of initially polarized photons Compton scattering off G4_Si.<br />
  I have had to include several lines of code in the SteppingAction.cc which will print out information like, for example, the Compton scattering angle and the photon's final kinetic energy.</p>
  <p>The simulations seems to work well for horizontally and vertically polarized photons, linear polarized +- 45 degrees and right circularly polarized (RCP) photons. But when I try and run the simulation for left circuarly polarized (LCP) photons I get a segmentation fault part way through the printing of the information to my terminal window.</p>
  <p>In macro code this is what I found</p>
  <pre><code>### RCP (works)
  # /gun/polarization 0. 0. 1.
  
  ### LCP ( Segmentation fault )
  /gun/polarization 0. 0. -1.
  
  ### vertical ( works )
  # /gun/polarization -1. 0. 0.
  
  ### horizontal ( works )
  # /gun/polarization 1. 0. 0.
  
  ### LP ( 45 degrees ) (works)
  # /gun/polarization 0. 1. 0.
  
  ### LP ( -45 degrees ) ( works )
  # /gun/polarization 0. -1. 0.
  
  /gun/particle gamma
  #
  /gun/energy 511 keV  
  </code></pre>
  <p>However, above this code there is the following instruction</p>
  <p><code>/polarization/volume/set theBox 0. 0. 0.08</code></p>
  <p>If I set <code>0.08</code> to <code>0.</code> , then I do not get the segmentation fault. I would like help in figuring out why only LCP photons cause the segmentation fault?</p>
  <p>FYI, the only extra code I included into Pol01 (in SteppingAction.cc) is the following</p>
  <pre><code>  // Inside this method you should access the track from the step object:
    G4Track *aTrack = aStep-&gt;GetTrack();
  
    // Then you should get the  KineticEnergy of the track if the process is 
    // &quot;Compton scattering&quot; and if the volume remains the same in the next step. 
    // See the code lines below:
    G4StepPoint* preStepPoint = aStep-&gt;GetPreStepPoint();
  
    const G4VProcess* CurrentProcess = preStepPoint-&gt;GetProcessDefinedStep();
    if (CurrentProcess != 0) 
    {
    // To implement the next line, one needs to include &quot; #include &quot;G4VProcess.hh&quot; &quot;
    // (See SteppingAction.cc in TestEm6)      
    const G4String &amp; StepProcessName = CurrentProcess-&gt;GetProcessName();
    // Get track ID for current processes
    G4double TrackID = aStep-&gt;GetTrack()-&gt;GetTrackID();
      if( (StepProcessName == &quot;pol-compt&quot;)&amp;&amp;(TrackID==1) ) 
        {
        // processing hit when entering the volume
        G4double kineticEnergy = aStep-&gt;GetTrack()-&gt;GetKineticEnergy();
        auto EkinUnits = G4BestUnit(kineticEnergy, &quot;Energy&quot;);
  
        // Get energy in units of keV              
        G4double En = kineticEnergy/keV;
  
        // Determine angle in radians
        G4double thetaRad = std::acos( 2- 511/En );
    
        // Place condition to reject Compton scattering at 0 rad.
        // (This is to avoid nan results when dividing through by 2pisin(theta))
          if ( (thetaRad &gt; 0) &amp;&amp; (thetaRad &lt; pi))
          {
          // fill histogram id = 13 (angular spread (in radians) as a function of scattering angle)
          // analysisManager-&gt;FillH1(13, thetaRad);
  
          // get particle name that's undergone the Compton scattering      
          G4String ParticleName = aStep-&gt;GetTrack()-&gt;GetParticleDefinition()-&gt;GetParticleName();
          // Find position (c.f. /examples/extended/medical/GammaTherapy) in CheckVolumeSD.cc
          // G4ThreeVector pos = aStep-&gt;GetPreStepPoint()-&gt;GetPosition();
          // G4double z = pos.z();   
  
          // Check if volume is sensitive detector
          G4String fromVolume = aTrack-&gt;GetNextVolume()-&gt;GetName();
          // see https://geant4-forum.web.cern.ch/t/get-particle-info-in-steppingaction-if-particle-pass-through-specific-volume/2863/2
          // for possible solution for finding which volume the gamma is in
          // G4String SDname = aStep-&gt;GetPostStepPoint()-&gt;GetSensitiveDetector()-&gt;GetName();
          // FOR CHECKING
          std::cout &lt;&lt; &quot;fromVolume: &quot;                 &lt;&lt; fromVolume
                    &lt;&lt; &quot;    Particle: &quot;               &lt;&lt; ParticleName
                    &lt;&lt; &quot;    Process: &quot;                &lt;&lt; StepProcessName
                    &lt;&lt; &quot;    Energy: &quot;                 &lt;&lt; EkinUnits 
                    &lt;&lt; &quot;    Angle: &quot;                  &lt;&lt; thetaRad/degree &lt;&lt; &quot; deg.&quot; &lt;&lt; std::endl;
        }
      }
    }
  </code></pre>
  <p>Thank you for your time.
  Peter</p>