<!-- ******************************************************** -->
<!--                                                          -->
<!--  [History]                                               -->
<!--    1st version created:  Katsuya Amako, Dec-2006         -->
<!--                                                          -->
<!-- ******************************************************** -->


<!-- ********************* QandA Section ******************** -->
<section id="qanda.TrackSteps">
<title>
Tracks and steps
</title>

<qandaset defaultlabel="qanda">


<!-- ******* QandA Entry ******** -->
<qandaentry id="qanda.TrackSteps.AccssTrkInfo">

<question><para>
  How can I access the track information through the step object and 
  what information am I allowed to access ?
</para></question>

<answer><para>
  <para>
  A <literal>G4Step</literal> object consists of two points:
  <informalexample><programlisting>
      G4StepPoint* point1 = step-&gt;GetPreStepPoint();
      G4StepPoint* point2 = step-&gt;GetPostStepPoint();
  </programlisting></informalexample>
  </para>

  <para>
  To get their positions in the global coordinate system:
  <informalexample><programlisting>
      G4ThreeVector pos1 = point1-&gt;GetPosition();
      G4ThreeVector pos2 = point2-&gt;GetPosition();
  </programlisting></informalexample>
  </para>

  <para>
  Hereafter we call current volume the volume where the step has just 
  gone through. Geometrical informations are available from 
  <literal>preStepPoint</literal>.
  <literal>G4VTouchable</literal> and its derivates keep these geometrical 
  informations. We retrieve a touchable by creating a handle for it:

  <informalexample><programlisting>
      G4TouchableHandle touch1 = point1-&gt;GetTouchableHandle();
  </programlisting></informalexample>  
  </para>

  <para>
  To get the current volume:
  <informalexample><programlisting>
       G4VPhysicalVolume* volume = touch1-&gt;GetVolume();
  </programlisting></informalexample>  
  </para>

  <para>
  To get its name:
  <informalexample><programlisting>
      G4String name = volume-&gt;GetName();
  </programlisting></informalexample>  
  </para>

<?soft-pagebreak ?>
  <para>
  To get the physical volume copy number:
  <informalexample><programlisting>
      G4int copyNumber = touch1-&gt;GetCopyNumber();
  </programlisting></informalexample>  
  </para>

  <para>
  To get logical volume:
  <informalexample><programlisting>
      G4LogicalVolume* lVolume = volume-&gt;GetLogicalVolume();
  </programlisting></informalexample>  
  </para>

<?soft-pagebreak ?>
  <para>
  To get the associated material: the following statements are equivalent:
  <informalexample><programlisting>
      G4Material* material = point1  -&gt;GetMaterial();
      G4Material* material = lVolume -&gt;GetMaterial();
  </programlisting></informalexample>  
  </para>

<?soft-pagebreak ?>
  <para>
  To get the geometrical region:
  <informalexample><programlisting>
      G4Region* region = lVolume-&gt;GetRegion();
  </programlisting></informalexample>  
  </para>

<?soft-pagebreak ?>
  <para>
  To get its mother volume:
  <informalexample><programlisting>
      G4VPhysicalVolume* mother = touch1-&gt;GetVolume(depth=1);
      grandMother: depth=2 ...etc...
  </programlisting></informalexample>  
  </para>

<?soft-pagebreak ?>
  <para>
  To get the copy number of the mother volume:
  <informalexample><programlisting>
      G4int copyNumber = touch1-&gt;GetCopyNumber(depth=1);
      grandMother: depth=2 ...etc...
  </programlisting></informalexample>  
  </para>

  <para>
  To get the process which has limited the current step:
  <informalexample><programlisting>
      G4VProcess* aProcess = point2-&gt;GetProcessDefinedStep();
  </programlisting></informalexample>  
  </para>

  <para>
  To check that the particle has just entered in the current volume 
  (i.e. it is at the first step in the volume; the 
  <literal>preStepPoint</literal> is at the boundary):

  <informalexample><programlisting>
      if (point1-&gt;GetStepStatus() == fGeomBoundary) 
  </programlisting></informalexample>  
  </para>

  <para>
  To check that the particle is leaving the current volume 
  (i.e. it is at the last step in the volume; the 
  <literal>postStepPoint</literal> is at the boundary):

  <informalexample><programlisting>
      if (point2-&gt;GetStepStatus() == fGeomBoundary)
  </programlisting></informalexample>  
  </para>

  <para>
  In the above situation, to get touchable of the next volume:

  <informalexample><programlisting>
      G4TouchableHandle touch2 = point2-&gt;GetTouchableHandle();
  </programlisting></informalexample>  

  From <literal>touch2</literal>, all informations on the next 
  volume can be retrieved as above.
  </para>

  <para>
  Physics quantities are available from the step 
  (<literal>G4Step</literal>) or from the track (<literal>G4Track</literal>).
  </para>

  <para>
  To get the energy deposition, step length, displacement and time 
  of flight spent by the current step:
  <informalexample><programlisting>
      G4double eDeposit      = step-&gt;GetTotalEnergyDeposit();
      G4double sLength       = step-&gt;GetStepLength();
      G4ThreeVector displace = step-&gt;GetDeltaPosition();
      G4double tof           = step-&gt;GetDeltaTime();
  </programlisting></informalexample>  
  </para>

  <para>
  To get momentum, kinetic energy and global time (time since the 
  beginning of the event) of the track after the completion of the 
  current step:
  <informalexample><programlisting>
      G4Track* track         = step-&gt;GetTrack();
      G4ThreeVector momentum = track-&gt;GetMomentum();
      G4double kinEnergy     = track-&gt;GetKineticEnergy();
      G4double globalTime    = track-&gt;GetGlobalTime();
      ...etc...
  </programlisting></informalexample>  

    <note>
    <title>Remark</title>
    <para>
      To transform a position from the global coordinate system to the 
      local system of the current volume, use the 
      <literal>preStepPoint</literal> transformation, as described in the 
      <link linkend="qanda.Geometry.ConvGtoL">geometry section</link> above.
    </para>
    </note>
  </para>
</para></answer>

</qandaentry>


</qandaset>
</section>
