ATLAS Offline Software
PunchThroughSimWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 // CLHEP
8 #include "CLHEP/Random/RandFlat.h"
9 #include "CLHEP/Random/RandomEngine.h"
10 
11 //Geant4
12 #include "G4Track.hh"
13 #include "G4TrackVector.hh"
14 
15 PunchThroughSimWrapper::PunchThroughSimWrapper(const std::string& type, const std::string& name, const IInterface* parent)
16  : base_class(type,name,parent)
17 {
18 }
19 
21 {
22  return StatusCode::SUCCESS;
23 }
24 
26 {
27  return StatusCode::SUCCESS;
28 }
29 
30 void PunchThroughSimWrapper::DoPunchThroughSim(G4ParticleTable &ptable, CLHEP::HepRandomEngine* rng, const double simE, std::vector<double> simEfrac, const G4FastTrack& fastTrack, G4FastStep& fastStep)
31 {
32  // Get Geant4 primary track
33  const G4Track* G4PrimaryTrack = fastTrack.GetPrimaryTrack();
34 
35  // Get calo-ms variables
36  std::vector<double> caloMSVars = m_PunchThroughG4Tool->getCaloMSVars();
37 
38  // Declare array holders
39  std::vector<std::map<std::string, double>> secKinematicsMapVect;
40 
41  // Create output particle (secondaries) collection
42  auto secTrackCont = std::make_unique<G4TrackVector>();
43 
44  // Draw flat random number to compare punchthrough probability
45  double punchThroughClassifierRand = CLHEP::RandFlat::shoot(rng);
46 
47  // Calculate probability of punch through using punchThroughClassifier
48  double punchThroughProbability = m_PunchThroughG4Classifier->computePunchThroughProbability(fastTrack, simE, simEfrac);
49 
50  // Safety condition
51  if( punchThroughProbability > punchThroughClassifierRand){
52  secKinematicsMapVect = m_PunchThroughG4Tool->computePunchThroughParticles(fastTrack, rng, punchThroughProbability, punchThroughClassifierRand);
53 
54  // Create secondary tracks
55  if(secKinematicsMapVect.size()!=0){
56  // Now create all secondary tracks after all consistency checks (conservation of energy etc):
57  m_PunchThroughG4Tool->createAllSecondaryTracks(ptable, fastStep, *G4PrimaryTrack, secKinematicsMapVect, *secTrackCont, caloMSVars);
58  }
59  }
60  // done punchthrough procedure
61 }
PunchThroughSimWrapper::m_PunchThroughG4Tool
PublicToolHandle< IPunchThroughG4Tool > m_PunchThroughG4Tool
Definition: PunchThroughSimWrapper.h:52
PunchThroughSimWrapper::DoPunchThroughSim
virtual void DoPunchThroughSim(G4ParticleTable &ptable, CLHEP::HepRandomEngine *rng, const double simE, std::vector< double > simEfrac, const G4FastTrack &fastTrack, G4FastStep &fastStep)
Definition: PunchThroughSimWrapper.cxx:30
PunchThroughSimWrapper.h
D3PDTest::rng
uint32_t rng()
Definition: FillerAlg.cxx:40
PunchThroughSimWrapper::PunchThroughSimWrapper
PunchThroughSimWrapper(const std::string &, const std::string &, const IInterface *)
Constructor.
Definition: PunchThroughSimWrapper.cxx:15
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PunchThroughSimWrapper::m_PunchThroughG4Classifier
PublicToolHandle< IPunchThroughG4Classifier > m_PunchThroughG4Classifier
Definition: PunchThroughSimWrapper.h:53
test_pyathena.parent
parent
Definition: test_pyathena.py:15
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
PunchThroughSimWrapper::initialize
virtual StatusCode initialize()
AlgTool initialize method.
Definition: PunchThroughSimWrapper.cxx:20
PunchThroughSimWrapper::finalize
virtual StatusCode finalize()
AlgTool finalize method.
Definition: PunchThroughSimWrapper.cxx:25