<div dir="ltr">Maria,<div><br></div><div>Yes, in GlueXStackingAction::ClassifyNewTrack, if you return fKill it will never be handed off to the tracking loop. This method gets called thousands of times per event, so try to make any actions you do efficient. For example, you might hide your code inside some if blocks that are fast to compute, like selecting on particle type before probing the geometry navigator.</div><div><br></div><div>-Richard</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 30, 2017 at 12:09 PM, Maria Patsyuk <span dir="ltr"><<a href="mailto:mpatsyuk@mit.edu" target="_blank">mpatsyuk@mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div style="word-wrap:break-word">
Hi Richard,
<div><br>
</div>
<div>thank you for the detailed answer.</div>
<div><br>
</div>
<div>I’d like to prune at the point where they are generated, before they get posted for tracking.</div>
<div>Is it correct, that I need to modify GlueXStackingAction class for that?</div>
<div><br>
</div>
<div>Best regards,</div>
<div>Maria</div><div><div class="h5">
<div><br>
<div>
<blockquote type="cite">
<div>On May 30, 2017, at 11:18 AM, Richard Jones <<a href="mailto:richard.t.jones@uconn.edu" target="_blank">richard.t.jones@uconn.edu</a>> wrote:</div>
<br class="m_131007897099813456Apple-interchange-newline">
<div>
<div dir="ltr">Maria,
<div><br>
</div>
<div>I am broadcasting this answer to the offline group because I think it is a question that will come up often, and I want to broadcast the answer to a larger audience. In your original email, you asked:</div>
<div><br>
</div>
<div><i><span style="font-size:12.8px">I’m looking for a proper way to stop an optical photon track in hdgeant4. </span><span style="font-size:12.8px">Where should I do so? Is the proper place “GlueX SensitiveDetector” class
 or GlueXSpecialCuts?</span></i><br>
</div>
<div><i><span style="font-size:12.8px"><br>
</span></i></div>
<div><span style="font-size:12.8px">You cannot just "stop" a particle that is being tracked in Geant4 (like you could in G3 by simply setting ISTOP=1). It was one of the design principles of the authors of G4 to prevent this. There are two
 ways to restrict the tracking of particles in G4 (besides not injecting them into the event in the first place):</span></div>
<div>
<ol>
<li><span style="font-size:12.8px">prune them from the secondaries list when they are first spawned by some process, before they get stacked at the end of the step where they are made;</span></li><li><span style="font-size:12.8px">track them to the bitter end, and let them die a natural death, either by decaying, or by stopping and/or being absorbed by interactions in a medium;</span></li></ol>
</div>
<div><span style="font-size:12.8px">If I might invoke an analogy to the legal system that normally protects human life, hdgeant4 has no built-in mechanism for capital punishment. Given that some particles can turn out to be "bad hombres" I
 have experimented with various ways of working around these limitations, but having no connections to the mob and feeling mildly squeemish about violating the law of Geant4, I ultimately decided against that. So in hdgeant4 we are going with the G4 design:
 no early "disappearance" of particles. Even though GlueXSpecialCuts seems like it might be crossing that line, it actually is not. I can give a brief talk on this, and what GlueXSpecialCuts is about, at an upcoming offline meeting, if desired.</span></div>
<div><span style="font-size:12.8px"><br>
</span></div>
<div><span style="font-size:12.8px">So what can you do? If you are talking about Cerenkov photons, you either want to prune them at the point where they are generated, before they get posted for tracking ("stacked" in G4 lingo) or else you
 can write a new physics process (G4Process) that adds a new kind of interaction that gets invoked on every step, and takes action to terminate the particle when some condition is fulfilled. Only G4Process objects can kill/absorb/decay particles that are actively
 being tracked. I have nothing against you writing your own process, but there is quite a bit of detailed knowledge that goes into writing all of the mandatory methods that a G4Process must support, in addition to the small bit of code that actually does what
 you want to do in terminating wayward particles. Also keep in mind, once such a process is added to the simulation, it gets called on every step for every particle of the given type, so it can affect the efficiency of the simulation.</span></div>
<div><span style="font-size:12.8px"><br>
</span></div>
<div><span style="font-size:12.8px">-Richard Jones</span></div>
<div><i><span style="font-size:12.8px"><br>
</span></i></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, May 30, 2017 at 9:07 AM, Maria Patsyuk <span dir="ltr">
<<a href="mailto:mpatsyuk@mit.edu" target="_blank">mpatsyuk@mit.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Hi Richard,
<div><br>
</div>
<div>yes. I’m going to implement what you are saying.</div>
<div>My question is - in which place it is better to put?</div>
<div>Should I do so in GlueXSpecialCuts class?</div>
<div>I need a tool to stop the particle, and I don’t see an example of stopping a particle except for in the  GlueXSpecialCuts.</div>
<div>Please advise.</div>
<div><br>
</div>
<div>Best regards,</div>
<div>Maria</div>
<div>
<div class="m_131007897099813456h5">
<div><br>
<div>
<blockquote type="cite">
<div>On May 29, 2017, at 6:33 PM, Richard Jones <<a href="mailto:rjones30@gmail.com" target="_blank">rjones30@gmail.com</a>> wrote:</div>
<br class="m_131007897099813456m_1035841491089293241Apple-interchange-newline">
<div>
<div dir="ltr">Maria,
<div><br>
</div>
<div>Yes, this is a very good idea, a standard thing to do is to apply the wavelength-dependent detection efficiency already at the generation stage, and then at the detector, detect with probability one. Is this what you want to implement?</div>
<div><br>
</div>
<div>-Richard</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, May 29, 2017 at 11:42 AM, Maria Patsyuk <span dir="ltr">
<<a href="mailto:mpatsyuk@mit.edu" target="_blank">mpatsyuk@mit.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I’m looking for a proper way to stop an optical photon track in hdgeant4.<br>
Where should I do so? Is the proper place “GlueX SensitiveDetector” class or GlueXSpecialCuts?<br>
I’d like to introduce the photon detection efficiency at the production stage to save processing time (since quite a lot of optical photons anyways did not get detected, and the number of steps they are tracked is high).<br>
<br>
Best regards,<br>
Maria<br>
<span class="m_131007897099813456m_1035841491089293241HOEnZb"><font color="#888888"><br>
--<br>
You received this message because you are subscribed to the Google Groups "GlueX Software Help" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an email to
<a href="mailto:gluex-software%2Bunsubscribe@googlegroups.com" target="_blank">
gluex-software+unsubscribe@goo<wbr>glegroups.com</a>.<br>
To post to this group, send email to <a href="mailto:gluex-software@googlegroups.com" target="_blank">
gluex-software@googlegroups.co<wbr>m</a>.<br>
To view this discussion on the web visit <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_gluex-2Dsoftware_EE5408B3-2D9FFD-2D4437-2D9087-2D6D3722E32B4B-2540mit.edu&d=DwMFaQ&c=lz9TcOasaINaaC3U7FbMev2lsutwpI4--09aP8Lu18s&r=oyKV5joTkJsuRYv6hh48IMTw3i-IrYD-ZUAHHU0DdAY&m=dHf2eZB5Qhsm7CKXNc-pVgTCcPW1miXEv1FqHslpOY4&s=9Bzz_Sl7xl9UFKBfRNmfdqBeCfBLbbB_E1NsrPRmjNs&e=" rel="noreferrer" target="_blank">
https://groups.google.com/d/ms<wbr>gid/gluex-software/EE5408B3-9F<wbr>FD-4437-9087-6D3722E32B4B%40mi<wbr>t.edu</a>.<br>
For more options, visit <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_optout&d=DwMFaQ&c=lz9TcOasaINaaC3U7FbMev2lsutwpI4--09aP8Lu18s&r=oyKV5joTkJsuRYv6hh48IMTw3i-IrYD-ZUAHHU0DdAY&m=dHf2eZB5Qhsm7CKXNc-pVgTCcPW1miXEv1FqHslpOY4&s=nDtN3vaWZAeLex2EgvxYpQUTd3QuYt9W1m0B_Ni2Bqc&e=" rel="noreferrer" target="_blank">
https://groups.google.com/d/op<wbr>tout</a>.<br>
</font></span></blockquote>
</div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div></div></div>

</blockquote></div><br></div>