ATLAS Offline Software
Loading...
Searching...
No Matches
StoppedParticleFastSim.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7
9
10#include "G4FastTrack.hh"
11#include "G4Track.hh"
12#include "G4DynamicParticle.hh"
13#include "G4ParticleDefinition.hh"
14#include "G4Material.hh"
15#include "G4ElementVector.hh"
16#include "G4SDManager.hh"
17#include "G4VSensitiveDetector.hh"
18
19#include "CLHEP/Units/PhysicalConstants.h"
20
21#include <G4Region.hh>
22#include <cmath>
23
24StoppedParticleFastSim::StoppedParticleFastSim(const std::string& name, G4Region* region, const std::string& fsSDname)
25 : G4VFastSimulationModel(name, region)
26 , m_fsSDname(fsSDname)
27{
28}
29
30G4bool StoppedParticleFastSim::IsApplicable(const G4ParticleDefinition&)
31{
32 return true;
33}
34
35G4bool StoppedParticleFastSim::ModelTrigger(const G4FastTrack& fastTrack)
36{
37 // Trigger if the energy is below our threshold or if the time is over 150 ns
38 int id = fastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetDefinition()->GetPDGEncoding();
39 if (id<1000000 || id>1100000) return true; // skip SM particles and super-partners of RH-fermions
40 if (MC::isSquarkLH(id) ||
41 id == 1000021 || // gluino
42 MC::isRHadron(id)) {
43 G4Material * mat = fastTrack.GetPrimaryTrack()->GetMaterial();
44 double minA=1500000.;
45 for (unsigned int i=0;i<mat->GetNumberOfElements();++i){
46 if (mat->GetElement(i) &&
47 minA>mat->GetElement(i)->GetN()){
48 minA=mat->GetElement(i)->GetN();
49 }
50 }
51 if (fastTrack.GetPrimaryTrack()->GetVelocity()<0.15*std::pow(minA,-2./3.)*CLHEP::c_light) return true;
52 return false;
53 }
54 return true;
55}
56
57void StoppedParticleFastSim::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
58{
59 if (!m_init){
60 m_init = true;
61
62 G4SDManager *sdm = G4SDManager::GetSDMpointer();
63 G4VSensitiveDetector * vsd = sdm->FindSensitiveDetector( m_fsSDname );
64 if (vsd) {
65 m_fsSD = dynamic_cast<TrackFastSimSD*>(vsd);
66 if (!m_fsSD) {
67 G4ExceptionDescription description;
68 description << "DoIt: Could not cast the SD into an instance of TrackFasSimSD.";
69 G4Exception("StoppedParticleFastSim", "MissingTrackFastSimSD", FatalException, description);
70 abort();
71 }
72 }
73 else {
74 G4cout << "StoppedParticleFastSim::DoIt INFO Could not get TrackFastSimSD sensitive detector. If you are not writing track records this is expected." << G4endl;
75 }
76 // found the SD
77 } // End of lazy init
78 const int id = fastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetDefinition()->GetPDGEncoding();
79 if (m_fsSD &&
80 (MC::isSquarkLH(id) ||
81 id == 1000021 || // gluino
82 MC::isRHadron(id))) {
83 m_fsSD->WriteTrack( fastTrack.GetPrimaryTrack() , false , true );
84 }
85 fastStep.KillPrimaryTrack();
86}
ATLAS-specific HepMC functions.
StoppedParticleFastSim(const std::string &name, G4Region *region, const std::string &fsSDname)
G4bool IsApplicable(const G4ParticleDefinition &) override final
void DoIt(const G4FastTrack &, G4FastStep &) override final
virtual G4bool ModelTrigger(const G4FastTrack &) override final
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91
bool isSquarkLH(const T &p)
bool isRHadron(const T &p)