Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
RHadronsPhysicsTool::PhysicsConstructor Class Reference

#include <RHadronsPhysicsTool.h>

Inheritance diagram for RHadronsPhysicsTool::PhysicsConstructor:
Collaboration diagram for RHadronsPhysicsTool::PhysicsConstructor:

Public Member Functions

 PhysicsConstructor (const std::string &name, MSG::Level level, const std::vector< int > &standardpdgidtodecay)
 
virtual void ConstructParticle () override
 
virtual void ConstructProcess () 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 initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

std::vector< int > m_standardpdgidtodecay
 
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

Definition at line 40 of file RHadronsPhysicsTool.h.

Constructor & Destructor Documentation

◆ PhysicsConstructor()

RHadronsPhysicsTool::PhysicsConstructor::PhysicsConstructor ( const std::string &  name,
MSG::Level  level,
const std::vector< int > &  standardpdgidtodecay 
)
inline

Definition at line 42 of file RHadronsPhysicsTool.h.

45  m_standardpdgidtodecay(standardpdgidtodecay) {}

Member Function Documentation

◆ ConstructParticle()

void RHadronsPhysicsTool::PhysicsConstructor::ConstructParticle ( )
overridevirtual

Definition at line 65 of file RHadronsPhysicsTool.cxx.

65  {
66  ATH_MSG_DEBUG("RHadronsPhysicsTool::ConstructParticle() - start");
68  ATH_MSG_DEBUG("RHadronsPhysicsTool::ConstructParticle() - end");
69 }

◆ ConstructProcess()

void RHadronsPhysicsTool::PhysicsConstructor::ConstructProcess ( )
overridevirtual

Definition at line 70 of file RHadronsPhysicsTool.cxx.

70  {
71  ATH_MSG_DEBUG("RHadronsPhysicsTool::ConstructProcess() - start");
72  G4Decay* pythiaDecayProcess = new G4Decay();
73  pythiaDecayProcess->SetExtDecayer( new RHadronPythiaDecayer("RHadronPythiaDecayer") );
74  G4ParticleTable::G4PTblDicIterator* particleIterator = G4ParticleTable::GetParticleTable()->GetIterator();
75  particleIterator->reset();
76 
77  //First deal with the standard particles that G4 doesn't know about...
78  //G4Etac::Definition();
79  G4BaryonConstructor::ConstructParticle();
80  ATH_MSG_DEBUG("RHadronsPhysicsTool::ConstructProcess() - m_standardpdgidtodecay = " << m_standardpdgidtodecay);
81  G4ProcessManager *templateProcessMgr = G4ParticleTable::GetParticleTable()->FindParticle(4122)->GetProcessManager();
82  for (const int pid : m_standardpdgidtodecay) {
83  ATH_MSG_VERBOSE ( "Adding decay for "<<pid );
84  G4ParticleDefinition *particle = G4ParticleTable::GetParticleTable()->FindParticle( pid );
85  if (particle) {
86  ATH_MSG_VERBOSE ( particle->GetParticleName()<<" is standard for Pythia, lifetime is "<<particle->GetPDGLifeTime() );
87  G4ProcessManager *processMgr = particle->GetProcessManager();
88  if (!processMgr) {
89  ATH_MSG_VERBOSE ( "No process manager found for " << particle->GetParticleName() << " (" << pid << "). Copying process manager from 4122 (one we know works) to this particle" );
90  particle->SetProcessManager(new G4ProcessManager(*templateProcessMgr));
91  processMgr = particle->GetProcessManager();
92  }
93  // Look for native G4Decay process
94  G4ProcessVector *fullProcessList = processMgr->GetProcessList(); // NB G4ProcessVector does not support range-based for loops in G4 10.6....
95  std::vector< G4VProcess * > existingDecayProcesses; existingDecayProcesses.reserve(2);
96  for (unsigned int i=0; i<fullProcessList->size(); ++i) {
97  G4VProcess* process = (*fullProcessList)[i];
98  if (process->GetProcessType() == fDecay) {
99  ATH_MSG_VERBOSE ( "Found a pre-existing decay process for " <<particle->GetParticleName() << " (" << pid << "). Will remove in favour of using RHadronPythiaDecayer." );
100  existingDecayProcesses.push_back(process);
101  }
102  }
103  // Actually remove the existing decay processes
104  for (G4VProcess* process : existingDecayProcesses) {
105  processMgr->RemoveProcess(process);
106  }
107  // Cross-check
108  for (unsigned int i=0; i<fullProcessList->size(); ++i) {
109  G4VProcess* process = (*fullProcessList)[i];
110  if (process->GetProcessType() == fDecay) {
111  ATH_MSG_WARNING ( "There is another decay process for " <<particle->GetParticleName() << " (" << pid << ") already defined!" );
112  processMgr->DumpInfo();
113  }
114  }
115  ATH_MSG_VERBOSE ( "Adding decay process for " <<particle->GetParticleName() << " (" << pid << ") using RHadronPythiaDecayer." );
116  processMgr->AddProcess(pythiaDecayProcess);
117  processMgr->SetProcessOrdering(pythiaDecayProcess, idxPostStep); processMgr->SetProcessOrdering(pythiaDecayProcess, idxAtRest);
118  //processMgr->DumpInfo();
119  } else {
120  ATH_MSG_WARNING ( "Particle with pdgid "<<pid<<" has no definition in G4?" );
121  }
122  } // Loop over all particles that we need to define
123 
124  // Now add RHadrons... Keep a vector of those we've already dealt with
125  std::vector<int> handled;
126  // Use the G4 particle iterator
127  while ((*particleIterator)()) {
128  G4ParticleDefinition *particle = particleIterator->value();
130  const int pid = particle->GetPDGEncoding();
131  if (find(handled.begin(), handled.end(), pid) == handled.end()) {
132  handled.push_back(pid);
133  ATH_MSG_VERBOSE ( particle->GetParticleName() << " (" << particle->GetPDGEncoding() << ") " << " is a Custom Particle. Attempting to add a decay process." );
134  G4ProcessManager *processMgr = particle->GetProcessManager();
135  // Look for native G4Decay process
136  G4ProcessVector *fullProcessList = processMgr->GetProcessList(); // NB G4ProcessVector does not support range-based for loops in G4 10.6....
137  std::vector< G4VProcess * > existingDecayProcesses; existingDecayProcesses.reserve(2);
138  for (unsigned int i=0; i<fullProcessList->size(); ++i) {
139  G4VProcess* process = (*fullProcessList)[i];
140  if (process->GetProcessType() == fDecay) {
141  ATH_MSG_VERBOSE ( "Found a pre-existing decay process for " <<particle->GetParticleName() << " (" << pid << "). Will remove in favour of using RHadronPythiaDecayer." );
142  existingDecayProcesses.push_back(process);
143  }
144  }
145  // Actually remove the existing decay process(es)
146  for (G4VProcess* process : existingDecayProcesses) {
147  processMgr->RemoveProcess(process);
148  }
149  // Cross-check
150  for (unsigned int i=0; i<fullProcessList->size(); ++i) {
151  G4VProcess* process = (*fullProcessList)[i];
152  if (process->GetProcessType() == fDecay) {
153  ATH_MSG_WARNING ( "There is another decay process for " <<particle->GetParticleName() << " (" << pid << ") already defined!" );
154  processMgr->DumpInfo();
155  }
156  }
157  if (particle->GetParticleType()=="rhadron" ) {
158  processMgr->AddDiscreteProcess(new FullModelHadronicProcess());
159  if (pythiaDecayProcess->IsApplicable(*particle)) {
160  ATH_MSG_VERBOSE ( "Adding decay..." );
161  processMgr->AddProcess(pythiaDecayProcess);
162  // set ordering for PostStepDoIt and AtRestDoIt
163  processMgr->SetProcessOrdering(pythiaDecayProcess, idxPostStep);
164  processMgr->SetProcessOrdering(pythiaDecayProcess, idxAtRest);
165  } else {
166  ATH_MSG_WARNING ( "No decay allowed for " << particle->GetParticleName() );
167  if (!particle->GetPDGStable() && particle->GetPDGLifeTime()<0.1*CLHEP::ns) {
168  ATH_MSG_WARNING ( "Gonna decay it anyway!!!" );
169  processMgr->AddProcess(pythiaDecayProcess);
170  // set ordering for PostStepDoIt and AtRestDoIt
171  processMgr->SetProcessOrdering(pythiaDecayProcess, idxPostStep);
172  processMgr->SetProcessOrdering(pythiaDecayProcess, idxAtRest);
173  }
174  }
175  }
176  if (particle->GetPDGCharge()/CLHEP::eplus != 0) {
177  processMgr->AddProcess(new G4hMultipleScattering, -1, 1, 1);
178  processMgr->AddProcess(new G4hIonisation, -1, 2, 2);
179  ATH_MSG_VERBOSE ( "Processes for charged particle added." );
180  } else {
181  ATH_MSG_VERBOSE ( "It is neutral!!" );
182  }
183  processMgr->DumpInfo();
184  } else {
185  ATH_MSG_VERBOSE ( "Skipping already handled particle: "<<particle->GetParticleName() );
186  } // If it has not been handled yet
187  } // If this is one of our custom particles (RHadrons)
188  } // End of the particle iterator
189  ATH_MSG_DEBUG("RHadronsPhysicsTool::ConstructProcess() - list of handled RHadrons = " << handled);
190  ATH_MSG_DEBUG("RHadronsPhysicsTool::ConstructProcess() - end");
191 }

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

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

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_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.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_standardpdgidtodecay

std::vector<int> RHadronsPhysicsTool::PhysicsConstructor::m_standardpdgidtodecay
private

Definition at line 50 of file RHadronsPhysicsTool.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
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CustomParticleFactory::loadCustomParticles
static void loadCustomParticles()
Definition: CustomParticleFactory.cxx:32
IPhysicsContructor::IPhysicsContructor
IPhysicsContructor(const std::string &name, MSG::Level level)
Standard constructor.
Definition: IPhysicsConstructor.h:44
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
lumiFormat.i
int i
Definition: lumiFormat.py:85
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
RHadronPythiaDecayer
Definition: RHadronPythiaDecayer.h:18
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
CustomParticleFactory::isCustomParticle
static bool isCustomParticle(G4ParticleDefinition *particle)
Definition: CustomParticleFactory.cxx:26
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
python.SystemOfUnits.ns
int ns
Definition: SystemOfUnits.py:130
python.SystemOfUnits.eplus
int eplus
Definition: SystemOfUnits.py:137
RHadronsPhysicsTool::PhysicsConstructor::m_standardpdgidtodecay
std::vector< int > m_standardpdgidtodecay
Definition: RHadronsPhysicsTool.h:50
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