ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
G4UA::AthenaDebugStackingAction Class Reference

Debug version of the AthenaStackingAction used for validation of Russian Roulette algorimts. It can ensure that there is no randomization in simulation caused by turning the Russian Roulette on or off. More...

#include <AthenaDebugStackingAction.h>

Inheritance diagram for G4UA::AthenaDebugStackingAction:
Collaboration diagram for G4UA::AthenaDebugStackingAction:

Public Member Functions

 AthenaDebugStackingAction (const Config &config)
 Constructor with configuration. More...
 
virtual G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *track) override final
 Classify a new track. More...
 

Protected Member Functions

bool isNeutrino (const G4Track *) const
 Identify track as a neutrino. More...
 
bool isGamma (const G4Track *) const
 Identify track as a photon. More...
 
bool isNeutron (const G4Track *) const
 Identify track as a neutron. More...
 
PrimaryParticleInformationgetPrimaryParticleInformation (const G4Track *track) const
 obtain the PrimaryParticleInformation from the current G4Track More...
 

Protected Attributes

Config m_config
 Configuration options. More...
 
double m_oneOverWeightNeutron
 
double m_oneOverWeightPhoton
 

Detailed Description

Debug version of the AthenaStackingAction used for validation of Russian Roulette algorimts. It can ensure that there is no randomization in simulation caused by turning the Russian Roulette on or off.

Author
Miha Muskinja Miha..nosp@m.Musk.nosp@m.inja@.nosp@m.cern.nosp@m..ch

Definition at line 24 of file AthenaDebugStackingAction.h.

Constructor & Destructor Documentation

◆ AthenaDebugStackingAction()

G4UA::AthenaDebugStackingAction::AthenaDebugStackingAction ( const Config config)

Constructor with configuration.

Definition at line 32 of file AthenaDebugStackingAction.cxx.

32  :

Member Function Documentation

◆ ClassifyNewTrack()

G4ClassificationOfNewTrack G4UA::AthenaDebugStackingAction::ClassifyNewTrack ( const G4Track *  track)
finaloverridevirtual

Classify a new track.

Result can be fUrgent, fWaiting, fPostpone, or fKill.

Pass ownership to track. The G4VUserTrackInformation* fpUserInformation member variable set by this method is mutable. G4Tracks are thread-local.

Pass ownership to track. The G4VUserTrackInformation* fpUserInformation member variable set by this method is mutable. G4Tracks are thread-local.

Reimplemented from G4UA::AthenaStackingAction.

Definition at line 39 of file AthenaDebugStackingAction.cxx.

40  {
41  // Kill neutrinos if enabled
43  return fKill;
44  }
45 
46  // Kill super-low-E photons
47  const double safeCut = 0.00005;
48  double totalE = track->GetTotalEnergy();
49  if(isGamma(track) && totalE < safeCut) {
50  return fKill;
51  }
52 
53  // TODO: Why is this here? Can I remove it?
54  G4Event* ev = G4EventManager::GetEventManager()->GetNonconstCurrentEvent();
55  AtlasG4EventUserInfo* atlasG4EvtUserInfo __attribute__ ((unused)) =
56  static_cast<AtlasG4EventUserInfo*> (ev->GetUserInformation());
57 
58  // Was track subject to a RR?
59  bool rouletted = false;
60 
61  // Neutron Russian Roulette
63  track->GetWeight() < m_config.russianRouletteNeutronWeight && // do not re-Roulette particles
64  track->GetKineticEnergy() < m_config.russianRouletteNeutronThreshold) {
65  // shoot random number
66  if ( CLHEP::RandFlat::shoot() > m_oneOverWeightNeutron ) {
67  if (m_config.applyNRR) {
68  // Kill (w-1)/w neutrons
69  return fKill;
70  } else {
71  // process them at the end of the stack
72  return fWaiting;
73  }
74  }
75  rouletted = true;
76  // Weight the rest 1/w neutrons with a weight of w
77  if (m_config.applyNRR) {
78  // TODO There may be another way to set the weights via
79  // another G4 interface avoiding the const_cast, but the
80  // changes are more major and will need more careful validation.
81  G4Track* mutableTrack ATLAS_THREAD_SAFE = const_cast<G4Track*> (track);
82  mutableTrack->SetWeight(m_config.russianRouletteNeutronWeight);
83  }
84  }
85 
86  // Photon Russian Roulette
87  if (m_config.russianRoulettePhotonThreshold > 0 && isGamma(track) && track->GetOriginTouchable() &&
88  track->GetOriginTouchable()->GetVolume()->GetName().substr(0, 3) == "LAr" && // only for photons created in LAr
89  track->GetWeight() < m_config.russianRoulettePhotonWeight && // do not re-Roulette particles
90  track->GetKineticEnergy() < m_config.russianRoulettePhotonThreshold) {
91  // shoot random number
92  if ( CLHEP::RandFlat::shoot() > m_oneOverWeightPhoton ) {
93  if (m_config.applyPRR) {
94  // Kill (w-1)/w photons
95  return fKill;
96  } else {
97  // process them at the end of the stack
98  return fWaiting;
99  }
100  }
101  rouletted = true;
102  // Weight the rest 1/w neutrons with a weight of w
103  if (m_config.applyPRR) {
104  // TODO There may be another way to set the weights via
105  // another G4 interface avoiding the const_cast, but the
106  // changes are more major and will need more careful validation.
107  G4Track* mutableTrack ATLAS_THREAD_SAFE = const_cast<G4Track*> (track);
108  mutableTrack->SetWeight(m_config.russianRoulettePhotonWeight);
109  }
110  }
111 
112  // Handle primary particles
113  if(track->GetParentID() == 0) { // Condition for Primaries
114  // Extract the PrimaryParticleInformation
116  // Fill some information for this track
117  if(primaryPartInfo) {
118  if (!m_config.isISFJob) {
119  // don't do anything
120  auto part = primaryPartInfo->GetHepMCParticle();
121  if(part) {
122  // OK, we got back to HepMC
123  std::unique_ptr<TrackInformation> ti = std::make_unique<TrackInformation>(part);
124  ti->SetRegenerationNr(0);
126  // regNr=0 and classify=Primary are default values anyway
130  track->SetUserInformation(ti.release());
131  }
132  // What does this condition mean?
133  else if(primaryPartInfo->GetParticleUniqueID() >= 0 && primaryPartInfo->GetParticleBarcode() >= 0) {
134  // PrimaryParticleInformation should at least provide a barcode
135  std::unique_ptr<TrackBarcodeInfo> bi = std::make_unique<TrackBarcodeInfo>(primaryPartInfo->GetParticleUniqueID(), primaryPartInfo->GetParticleBarcode());
139  track->SetUserInformation(bi.release());
140  }
141  } // no ISFParticle attached
142  } // has PrimaryParticleInformation
143  }
144  // Secondary track; decide whether to save or kill
145  else if( isGamma(track) &&
147  totalE < m_config.photonEnergyCut )
148  {
149  return fKill;
150  }
151  // Put rouletted tracks at the end of the stack
152  if (rouletted)
153  return fWaiting;
154  else
155  return fUrgent;
156  }

◆ getPrimaryParticleInformation()

PrimaryParticleInformation * G4UA::AthenaStackingAction::getPrimaryParticleInformation ( const G4Track *  track) const
protectedinherited

obtain the PrimaryParticleInformation from the current G4Track

Definition at line 155 of file AthenaStackingAction.cxx.

156  {
157  const G4DynamicParticle* dp = track->GetDynamicParticle();
158  if(dp) {
159  const G4PrimaryParticle* pp = nullptr;
160  pp = dp->GetPrimaryParticle();
161  if(pp) {
162  // Extract the PrimaryParticleInformation
163  return dynamic_cast<PrimaryParticleInformation*>
164  ( pp->GetUserInformation() );
165  }
166  }
167  return nullptr;
168  }

◆ isGamma()

bool G4UA::AthenaStackingAction::isGamma ( const G4Track *  track) const
protectedinherited

Identify track as a photon.

Definition at line 185 of file AthenaStackingAction.cxx.

186  {
187  return track->GetParticleDefinition() == G4Gamma::Gamma();
188  }

◆ isNeutrino()

bool G4UA::AthenaStackingAction::isNeutrino ( const G4Track *  track) const
protectedinherited

Identify track as a neutrino.

It might be useful to move this kind of functionality into some standalong helper function(s).

Definition at line 173 of file AthenaStackingAction.cxx.

174  {
175  auto particleDef = track->GetParticleDefinition();
176  return (particleDef == G4NeutrinoE::NeutrinoEDefinition() ||
177  particleDef == G4AntiNeutrinoE::AntiNeutrinoEDefinition() ||
178  particleDef == G4NeutrinoMu::NeutrinoMuDefinition() ||
179  particleDef == G4AntiNeutrinoMu::AntiNeutrinoMuDefinition() ||
180  particleDef == G4NeutrinoTau::NeutrinoTauDefinition() ||
181  particleDef == G4AntiNeutrinoTau::AntiNeutrinoTauDefinition());
182  }

◆ isNeutron()

bool G4UA::AthenaStackingAction::isNeutron ( const G4Track *  track) const
protectedinherited

Identify track as a neutron.

Definition at line 191 of file AthenaStackingAction.cxx.

192  {
193  return track->GetParticleDefinition() == G4Neutron::Neutron();
194  }

Member Data Documentation

◆ m_config

Config G4UA::AthenaStackingAction::m_config
protectedinherited

Configuration options.

Definition at line 61 of file AthenaStackingAction.h.

◆ m_oneOverWeightNeutron

double G4UA::AthenaStackingAction::m_oneOverWeightNeutron
protectedinherited

Definition at line 78 of file AthenaStackingAction.h.

◆ m_oneOverWeightPhoton

double G4UA::AthenaStackingAction::m_oneOverWeightPhoton
protectedinherited

Definition at line 81 of file AthenaStackingAction.h.


The documentation for this class was generated from the following files:
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
G4UA::AthenaStackingAction::m_config
Config m_config
Configuration options.
Definition: AthenaStackingAction.h:61
G4UA::AthenaStackingAction::AthenaStackingAction
AthenaStackingAction(const Config &config)
Constructor with configuration.
Definition: AthenaStackingAction.cxx:41
G4UA::AthenaStackingAction::Config::isISFJob
bool isISFJob
Is this an ISF job.
Definition: AthenaStackingAction.h:47
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
G4UA::AthenaStackingAction::Config::photonEnergyCut
double photonEnergyCut
Photon energy cut.
Definition: AthenaStackingAction.h:33
AtlasG4EventUserInfo
This class is attached to G4Event objects as UserInformation. It holds a pointer to the HepMC::GenEve...
Definition: AtlasG4EventUserInfo.h:21
VP1PartSpect::Neutron
@ Neutron
Definition: VP1PartSpectFlags.h:25
G4UA::AthenaStackingAction::Config::russianRouletteNeutronThreshold
double russianRouletteNeutronThreshold
Energy threshold for the Neutron Russian Roulette.
Definition: AthenaStackingAction.h:37
G4UA::AthenaStackingAction::m_oneOverWeightNeutron
double m_oneOverWeightNeutron
Definition: AthenaStackingAction.h:78
G4UA::AthenaStackingAction::Config::russianRoulettePhotonThreshold
double russianRoulettePhotonThreshold
Energy threshold for the Photon Russian Roulette.
Definition: AthenaStackingAction.h:43
VP1PartSpect::Gamma
@ Gamma
Definition: VP1PartSpectFlags.h:22
G4UA::AthenaStackingAction::isNeutron
bool isNeutron(const G4Track *) const
Identify track as a neutron.
Definition: AthenaStackingAction.cxx:191
G4UA::AthenaStackingAction::Config::killAllNeutrinos
bool killAllNeutrinos
Flag to toggle killing neutrinos at tracking stage.
Definition: AthenaStackingAction.h:31
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
PrimaryParticleInformation::GetParticleBarcode
int GetParticleBarcode() const
Definition: PrimaryParticleInformation.cxx:18
G4UA::AthenaStackingAction::Config::applyPRR
bool applyPRR
Apply the Photon Russian Roulette.
Definition: AthenaStackingAction.h:41
G4UA::AthenaStackingAction::isGamma
bool isGamma(const G4Track *) const
Identify track as a photon.
Definition: AthenaStackingAction.cxx:185
G4UA::AthenaStackingAction::Config::russianRoulettePhotonWeight
double russianRoulettePhotonWeight
Weight for the Photon Russian Roulette.
Definition: AthenaStackingAction.h:45
ev
int ev
Definition: globals.cxx:25
VTrackInformation::Primary
@ Primary
Definition: VTrackInformation.h:32
VTrackInformation::SetClassification
void SetClassification(TrackClassification tc)
update the classification of the currently tracked particle, usually called when a new G4Track is cre...
Definition: VTrackInformation.h:45
TrackInformation::SetRegenerationNr
void SetRegenerationNr(int i)
update the number of times the particle represented by the G4Track has undergone a non-destructive in...
Definition: TrackInformation.h:96
G4UA::AthenaStackingAction::getPrimaryParticleInformation
PrimaryParticleInformation * getPrimaryParticleInformation(const G4Track *track) const
obtain the PrimaryParticleInformation from the current G4Track
Definition: AthenaStackingAction.cxx:155
PrimaryParticleInformation::GetHepMCParticle
HepMC::ConstGenParticlePtr GetHepMCParticle() const
return a pointer to the GenParticle used to create the G4PrimaryParticle
Definition: PrimaryParticleInformation.h:47
PrimaryParticleInformation
This class is attached to G4PrimaryParticle objects as UserInformation. The member variable m_thePart...
Definition: PrimaryParticleInformation.h:39
unused
void unused(Args &&...)
Definition: VP1ExpertSettings.cxx:39
__attribute__
__attribute__((always_inline)) inline uint16_t TileCalibDrawerBase
Definition: TileCalibDrawerBase.h:190
G4UA::AthenaStackingAction::m_oneOverWeightPhoton
double m_oneOverWeightPhoton
Definition: AthenaStackingAction.h:81
G4UA::AthenaStackingAction::Config::russianRouletteNeutronWeight
double russianRouletteNeutronWeight
Weight for the Neutron Russian Roulette.
Definition: AthenaStackingAction.h:39
G4UA::AthenaStackingAction::isNeutrino
bool isNeutrino(const G4Track *) const
Identify track as a neutrino.
Definition: AthenaStackingAction.cxx:173
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
PrimaryParticleInformation::GetParticleUniqueID
int GetParticleUniqueID() const
Definition: PrimaryParticleInformation.cxx:28
G4UA::AthenaStackingAction::Config::applyNRR
bool applyNRR
Apply the Neutron Russian Roulette.
Definition: AthenaStackingAction.h:35