ATLAS Offline Software
Loading...
Searching...
No Matches
G4UA::FastIDKiller Class Reference

NEEDS DOCUMENTATION. More...

#include <FastIDKiller.h>

Inheritance diagram for G4UA::FastIDKiller:
Collaboration diagram for G4UA::FastIDKiller:

Classes

struct  Config
 Configuration parameters. More...
struct  Report
 Per-thread results for merging at end of run. More...

Public Member Functions

 FastIDKiller (const Config &config)
 Constructor.
const ReportgetReport () const
virtual void BeginOfRunAction (const G4Run *) override
virtual void UserSteppingAction (const G4Step *) override
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Member Functions

void KillParticle (const G4Step *aStep)
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

Config m_config
Report m_report
bool m_init
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

NEEDS DOCUMENTATION.

Definition at line 17 of file FastIDKiller.h.

Constructor & Destructor Documentation

◆ FastIDKiller()

G4UA::FastIDKiller::FastIDKiller ( const Config & config)

Constructor.

Definition at line 25 of file FastIDKiller.cxx.

25 :
26 AthMessaging(Gaudi::svcLocator()->service< IMessageSvc >( "MessageSvc" ),"FastIDKiller"),
27 m_config(config),
28 m_report(),
29 m_init(false)
30 {
31 }
AthMessaging()
Default constructor:

Member Function Documentation

◆ BeginOfRunAction()

void G4UA::FastIDKiller::BeginOfRunAction ( const G4Run * )
overridevirtual

Definition at line 34 of file FastIDKiller.cxx.

35 {
36 if (m_config.isDalek==false){
37 ATH_MSG_INFO( "Including the Fast Inner Detector Killer." << std::endl
38 << "\t This piece of code will kill all particles leaving the" << std::endl
39 << "\t inner detector region (which should be defined in your" << std::endl
40 << "\t job options) except those satisfying certain criteria." << std::endl
41 << "\t (e/gamma will not be killed above " << m_config.energyCut/1000. << " GeV)" );
42 }
43 else{
44 ATH_MSG_INFO( "Including Fast Inner Detector Killer as DALEK (Domain Actuated" << std::endl
45 << "\t Low Energy Killer). It will exterminate all particles with kin." << std::endl
46 << "\t energy below " << m_config.energyCut << " MeV leaving the inner detector" << std::endl
47 << "\t region (which should be defined in your job options)." );
48 }
49
50
51 //FIXME need a nice way of getting the maximum size of the ID envelope in R and Z.
52 // EnvelopeGeometryManager *gm=EnvelopeGeometryManager::GetGeometryManager();
53
54 // // if not set through jobOptions, get values from envelope manager
55 // if(m_config.R==0.)
56 // m_config.R = gm->IdetOuterRadius();
57 // if(m_config.Z==0.)
58 // m_config.Z = gm->IdetMaxZ();
59
60 ATH_MSG_INFO( "Fast ID Killer initialized with radius " << m_config.R << " and Z " << m_config.Z);
61
62 m_init=true;
63
64 }
#define ATH_MSG_INFO(x)

◆ getReport()

const Report & G4UA::FastIDKiller::getReport ( ) const
inline

Definition at line 45 of file FastIDKiller.h.

46 { return m_report; }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ KillParticle()

void G4UA::FastIDKiller::KillParticle ( const G4Step * aStep)
private

Definition at line 67 of file FastIDKiller.cxx.

68 {
69 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
70 const G4TrackVector *tv = aStep->GetSecondary();
71 for (unsigned int i=0;i<tv->size();i++){
72 if ( (*tv)[i]->GetPosition().rho() < m_config.R &&
73 (*tv)[i]->GetPosition().z() < m_config.Z &&
74 (*tv)[i]->GetPosition().z() > -m_config.Z
75 ) continue;
76 (*tv)[i]->SetTrackStatus(fStopAndKill);
77 }
78 m_report.killCount++;
79 }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ UserSteppingAction()

void G4UA::FastIDKiller::UserSteppingAction ( const G4Step * aStep)
overridevirtual

Definition at line 83 of file FastIDKiller.cxx.

83 {
84
85 if (msgLvl(MSG::VERBOSE)){
86 ATH_MSG_DEBUG( " ===================================================== " );
87 ATH_MSG_DEBUG( " Writing out Information for debugging: " );
88 ATH_MSG_DEBUG( " Track-Pointer: " << aStep->GetTrack() );
89 ATH_MSG_DEBUG( " GetDefinition is in the next line " );
90 ATH_MSG_DEBUG( aStep->GetTrack()->GetDefinition() );
91 ATH_MSG_DEBUG( " still going on ? " );
92 ATH_MSG_DEBUG( " ===================================================== " );
93 }
94
95 // Outside DALEK mode: first ignore muons
96 if ( m_config.isDalek==false &&
97 ( G4MuonPlus::MuonPlusDefinition() == aStep->GetTrack()->GetDefinition() ||
98 G4MuonMinus::MuonMinusDefinition() == aStep->GetTrack()->GetDefinition() ) ) return;
99
100 // Now we check if the particle is outside the Z or R edges of the inner detector envelope
101 if (msgLvl(MSG::VERBOSE)){
102 ATH_MSG_VERBOSE( " Checking pointers ... " );
103
104 if ( !aStep->GetPostStepPoint() ||
105 !aStep->GetPreStepPoint() )
106 {
107 ATH_MSG_ERROR( " One of the pointers was null! This should never happen!!!" );
108 throw "Null position pointer";
109 }
110 }
111
112 if ( aStep->GetPreStepPoint()->GetPosition().rho() > m_config.R ||
113 aStep->GetPreStepPoint()->GetPosition().z() > m_config.Z ||
114 aStep->GetPreStepPoint()->GetPosition().z() < -m_config.Z
115 )
116 {
117 return; // We started outside the ID envelope
118 }
119
120 if ( aStep->GetPostStepPoint()->GetPosition().rho() < m_config.R &&
121 aStep->GetPostStepPoint()->GetPosition().z() < m_config.Z &&
122 aStep->GetPostStepPoint()->GetPosition().z() > -m_config.Z
123 )
124 {
125 return; // We finished inside the ID envelope
126 }
127
128 // Otherwise we have a non-muon that started inside and ended outside the ID envelope! KILL IT!
129
130 ATH_MSG_VERBOSE( " We have a " << aStep->GetTrack()->GetDefinition()->GetParticleName()
131 << " going from " << std::endl
132 << " ----> " << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion()->GetName()
133 << " to "
134 << aStep->GetPostStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion()->GetName()
135 << std::endl
136 << " with attributes: " << std::endl
137 << " Energy: " << aStep->GetTrack()->GetTotalEnergy()
138 << " Eta: " << aStep->GetTrack()->GetMomentum ().getEta()
139 << " Pt: " << aStep->GetTrack()->GetMomentum ().perp()
140 << " and at coordinates: " << std::endl
141 << " R: " << aStep->GetPostStepPoint()->GetPosition().rho()
142 << " Z: " << aStep->GetPostStepPoint()->GetPosition().z()
143 << " Phi: " << aStep->GetPostStepPoint()->GetPosition().phi() );
144
145 // Outside DALEK mode: ignore electrons above a certain energy
146 // at some point it might be interesting to see what effect this has on other particles (eg pi0)
147 if ( m_config.isDalek==false &&
148 ( G4Electron::ElectronDefinition() == aStep->GetTrack()->GetDefinition() ||
149 G4Positron::PositronDefinition() == aStep->GetTrack()->GetDefinition() ||
150 G4Gamma::GammaDefinition() == aStep->GetTrack()->GetDefinition() ) &&
151 m_config.energyCut < aStep->GetTrack()->GetTotalEnergy() ) return;
152
153 // In DALEK mode: kill particles below threshold regardless of particle type
154 if ( m_config.isDalek && m_config.energyCut < aStep->GetTrack()->GetKineticEnergy() ) return;
155
156 if (msgLvl(MSG::DEBUG)){
157 std::string name = aStep->GetTrack()->GetDefinition()->GetParticleName();
158 ATH_MSG_DEBUG( " -------> The particle passed. It is a " << name << " and will be killed ! " );
159 }
160
161 // Otherwise kill the particle now
162 KillParticle( aStep );
163 }
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
bool msgLvl(const MSG::Level lvl) const
Test the output level.
void KillParticle(const G4Step *aStep)

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_config

Config G4UA::FastIDKiller::m_config
private

Definition at line 55 of file FastIDKiller.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_init

bool G4UA::FastIDKiller::m_init
private

Definition at line 57 of file FastIDKiller.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_report

Report G4UA::FastIDKiller::m_report
private

Definition at line 56 of file FastIDKiller.h.


The documentation for this class was generated from the following files: