ATLAS Offline Software
Loading...
Searching...
No Matches
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.
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 initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

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

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.

44 : IPhysicsContructor(name, level),
45 m_standardpdgidtodecay(standardpdgidtodecay) {}
IPhysicsContructor(const std::string &name, MSG::Level level)
Standard constructor.

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}
#define ATH_MSG_DEBUG(x)

◆ 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}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static bool isCustomParticle(G4ParticleDefinition *particle)
const std::string process
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses

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

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

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.

135{ nullptr };

◆ 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_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: