Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I finally found an effective solution to that problem: I search for a nucleus in the secondary track vector of a step ending by a neutron capture. This nucleus is the one which captured the neutron and which recoil is tracked by Geant4. Do not forget to subtract 1 neutron to this nucleus to get what you want (for a capture on hydrogen, you will get deuterium with this method).</p> <p>So in my SteppingAction, I add:</p> <pre><code>// neutron capture if ( aStep-&gt;GetPostStepPoint()-&gt;GetProcessDefinedStep() &amp;&amp; aStep-&gt;GetPostStepPoint()-&gt;GetProcessDefinedStep()-&gt;GetProcessType() == fHadronic // see G4ProcessType.hh &amp;&amp; aStep-&gt;GetPostStepPoint()-&gt;GetProcessDefinedStep()-&gt;GetProcessSubType() == fCapture // see G4HadronicProcessType.hh ) { if ( aStep-&gt;GetSecondary() != 0 &amp;&amp; aStep-&gt;GetSecondary()-&gt;size() != 0 ) { std::vector&lt;G4Track*&gt;::const_iterator it; for (it=aStep-&gt;GetSecondary()-&gt;begin(); it!=aStep-&gt;GetSecondary()-&gt;end(); it++) { if ( !(*it)-&gt;GetCreatorProcess() || (*it)-&gt;GetCreatorProcess()-&gt;GetProcessSubType() != fCapture // see G4HadronicProcessType.hh || (*it)-&gt;GetCreatorProcess()-&gt;GetProcessType() != fHadronic // see G4ProcessType.hh || !(*it)-&gt;GetDynamicParticle() || (*it)-&gt;GetDynamicParticle()-&gt;GetParticleDefinition()-&gt;GetAtomicNumber() == 0 // keep only nucleus || (*it)-&gt;GetDynamicParticle()-&gt;GetParticleDefinition() == G4Neutron::NeutronDefinition() // but not the neutron (perhaps antiparticles could also be checked) ) { continue; } myEventAction-&gt;TreatNeutronCapture(*it); break; } if (it == aStep-&gt;GetSecondary()-&gt;end()) { G4cerr &lt;&lt; "\n#### END OF SECONDARY VECTOR REACHED AFTER NEUTRON CAPTURE ! ###\n"; myEventAction-&gt;TreatNeutronCapture(0); } } else { myEventAction-&gt;TreatNeutronCapture(0); } } </code></pre> <p>As you can see, I defer the actual stepping treatment to methods of EventAction. This is my TreatNeutronCapture method :</p> <pre><code>void MyExperimentEventAction::TreatNeutronCapture(const G4Track* track) { myParticle = myMC-&gt;GetParticle(ParticleMap[track-&gt;GetParentID()]); if (track == 0) { myParticle-&gt;SetFinalProcess(-1); } // if no nucleus is found in secondaries else { myParticle-&gt;SetFinalProcess(track-&gt;GetDynamicParticle()-&gt;GetPDGcode()); } } </code></pre> <p>myParticle and myMC refers to my own data classes.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload