Skip to content
Snippets Groups Projects
Commit 68021277 authored by Frank Gaede's avatar Frank Gaede
Browse files

- fixed logic for writing out MCParticles:

   - don't write particles created in calo
     unless scattered back into tracker)
   - don't write particles created in tracker
     if below MinimalKineticEnergy ( Geant4ParticleHandler)
parent 69553233
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@
// Framework include files
#include "DDG4/Geant4UserParticleHandler.h"
/*
* DD4hep namespace declaration
*/
......@@ -70,6 +71,7 @@ namespace DD4hep {
#include "DDG4/Geant4Particle.h"
#include "DDG4/Factories.h"
using namespace DD4hep::Simulation;
DECLARE_GEANT4ACTION(Geant4TCUserParticleHandler)
......@@ -83,16 +85,31 @@ Geant4TCUserParticleHandler::Geant4TCUserParticleHandler(Geant4Context* context,
/// Post-track action callback
void Geant4TCUserParticleHandler::end(const G4Track* /* track */, Particle& p) {
double r_end = sqrt(p.vex*p.vex + p.vey*p.vey);
double z_end = fabs(p.vez);
// Keep particles with end-vertex inside tracking (including back-scattered particles)
if ( r_end <= m_rTracker && z_end <= m_zTracker ) {
return;
}
double r_prod = sqrt(p.vsx*p.vsx + p.vsy*p.vsy);
double z_prod = fabs(p.vsz);
// Otherwise: reject particles created outside the tracking volume.
if ( r_prod > m_rTracker || z_prod > m_zTracker ) {
bool starts_in_trk_vol = ( r_prod <= m_rTracker && z_prod <= m_zTracker ) ;
// created in tracking volume but below energy cut
if( starts_in_trk_vol && ! (p.reason&G4PARTICLE_ABOVE_ENERGY_THRESHOLD) ){
p.reason = 0 ;
return;
}
double r_end = sqrt(p.vex*p.vex + p.vey*p.vey);
double z_end = fabs(p.vez);
bool ends_in_trk_vol = ( r_end <= m_rTracker && z_end <= m_zTracker ) ;
// created and ended in calo
if( !starts_in_trk_vol && !ends_in_trk_vol ){
p.reason = 0;
return ;
}
//fg: backscatter ??
// if( !starts_in_trk_vol && ends_in_trk_vol ){ keep ? }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment