ATLAS Offline Software
Loading...
Searching...
No Matches
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
15PunchThroughSimWrapper::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
30void 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(const std::string &, const std::string &, const IInterface *)
Constructor.
PublicToolHandle< IPunchThroughG4Tool > m_PunchThroughG4Tool
virtual StatusCode initialize()
AlgTool initialize method.
PublicToolHandle< IPunchThroughG4Classifier > m_PunchThroughG4Classifier
virtual StatusCode finalize()
AlgTool finalize method.
virtual void DoPunchThroughSim(G4ParticleTable &ptable, CLHEP::HepRandomEngine *rng, const double simE, std::vector< double > simEfrac, const G4FastTrack &fastTrack, G4FastStep &fastStep)