ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
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. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

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

Private Attributes

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

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"),
28  m_report(),
29  m_init(false)
30  {
31  }

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  }

◆ 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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ 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  }
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 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ 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 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ 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_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ 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  }

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.

◆ 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.

◆ 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:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
G4UA::FastIDKiller::KillParticle
void KillParticle(const G4Step *aStep)
Definition: FastIDKiller.cxx:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
G4UA::FastIDKiller::Report::killCount
int killCount
Definition: FastIDKiller.h:39
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
G4UA::FastIDKiller::Config::isDalek
bool isDalek
Definition: FastIDKiller.h:30
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
G4UA::FastIDKiller::m_init
bool m_init
Definition: FastIDKiller.h:57
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
G4UA::FastIDKiller::Config::R
float R
Definition: FastIDKiller.h:27
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
AthMessaging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Test the output level.
Definition: AthMessaging.h:151
lumiFormat.i
int i
Definition: lumiFormat.py:85
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
G4UA::FastIDKiller::Config::energyCut
float energyCut
Definition: FastIDKiller.h:29
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
G4UA::FastIDKiller::Config::Z
float Z
Definition: FastIDKiller.h:28
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
DEBUG
#define DEBUG
Definition: page_access.h:11
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
G4UA::FastIDKiller::m_report
Report m_report
Definition: FastIDKiller.h:56
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
G4UA::FastIDKiller::m_config
Config m_config
Definition: FastIDKiller.h:55
fitman.rho
rho
Definition: fitman.py:532