ATLAS Offline Software
FixG4CreatorProcess.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "FixG4CreatorProcess.h"
6 
7 #include "G4Step.hh"
8 #include "G4Event.hh"
9 #include "G4Gamma.hh"
10 #include "G4ParticleDefinition.hh"
11 #include "G4VProcess.hh"
12 #include "G4EmParameters.hh"
13 
14 namespace G4UA
15 {
16 
17  //---------------------------------------------------------------------------
19 
20 
21  //---------------------------------------------------------------------------
22  void FixG4CreatorProcess::UserSteppingAction(const G4Step* aStep)
23  {
24  //
25  // M. Novak, M. Bandieramonte: 10 November 2021
26  //
27  // Make sure that the creator process of the secondary tracks of the current step
28  // is the same as the one that limited the step. These can be different in case of
29  // using `wrapper` processes e.g. G4GammaGeneralProcess or G4HepEm, etc.
30  if (G4EmParameters::Instance()->GeneralProcessActive()) {
31  const G4ParticleDefinition* thePrimaryParticle = aStep->GetTrack()->GetParticleDefinition();
32  const std::size_t numThisSecondaries = aStep->GetNumberOfSecondariesInCurrentStep();
33  if (thePrimaryParticle==G4Gamma::GammaDefinition() && numThisSecondaries>0) {
34  // Get the pointer to the process that limited the step: i.e. the one that
35  // created the secondaries of the current step
36  const G4VProcess* theLimiterProcess = aStep->GetPostStepPoint()->GetProcessDefinedStep();
37  // note: this is a vector of secondaries containing all secondaries created
38  // along the tracking of the current `primary` track (i.e. not only
39  // secondaries created in this step)
40  const G4TrackVector* theSecTrackVector = aStep->GetSecondary();
41  const std::size_t numAllSecondaries = theSecTrackVector->size();
42  for (std::size_t it = numAllSecondaries-numThisSecondaries; it<numAllSecondaries; ++it) {
43 
44  G4Track* secTrack = (*theSecTrackVector)[it];
45  if (secTrack->GetCreatorProcess()!=theLimiterProcess) {
46 
47  secTrack->SetCreatorProcess(theLimiterProcess);
48  }
49  }
50  }
51 
52  }
53  }
54 } // namespace G4UA
G4UA::FixG4CreatorProcess::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override final
Definition: FixG4CreatorProcess.cxx:22
G4UA
for nSW
Definition: CalibrationDefaultProcessing.h:19
skel.it
it
Definition: skel.GENtoEVGEN.py:396
G4UA::FixG4CreatorProcess::FixG4CreatorProcess
FixG4CreatorProcess()
Definition: FixG4CreatorProcess.cxx:18
FixG4CreatorProcess.h