ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
G4MagFieldSvcBase Class Referenceabstract

#include "G4AtlasServices/G4MagFieldSvcBase.h"

Inheritance diagram for G4MagFieldSvcBase:
Collaboration diagram for G4MagFieldSvcBase:

Public Member Functions

 G4MagFieldSvcBase (const std::string &name, ISvcLocator *pSvcLocator)
 Standard constructor. More...
 
virtual ~G4MagFieldSvcBase ()
 Empty destructor. More...
 
G4MagneticField * getField () override final
 Retrieve a G4 magnetic field object. More...
 

Protected Member Functions

virtual G4MagneticField * makeField ()=0
 This method must be overridden by concrete tools to create a new field. More...
 

Protected Attributes

thread_utils::ThreadLocalOwner< G4MagneticField > m_fieldHolder
 Thread-local field object. More...
 

Detailed Description

Base class for services that create/manage G4 magnetic fields.

Author
Andrea Dell'Acqua
Date
2015-11-17

Definition at line 29 of file G4MagFieldSvcBase.h.

Constructor & Destructor Documentation

◆ G4MagFieldSvcBase()

G4MagFieldSvcBase::G4MagFieldSvcBase ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Standard constructor.

Definition at line 20 of file G4MagFieldSvcBase.cxx.

22  : base_class(name, pSvcLocator)
23 {
24 }

◆ ~G4MagFieldSvcBase()

virtual G4MagFieldSvcBase::~G4MagFieldSvcBase ( )
inlinevirtual

Empty destructor.

Definition at line 36 of file G4MagFieldSvcBase.h.

36 {};

Member Function Documentation

◆ getField()

G4MagneticField * G4MagFieldSvcBase::getField ( )
finaloverride

Retrieve a G4 magnetic field object.

If one doesn't yet exist in the current thread, it will be created.

Definition at line 29 of file G4MagFieldSvcBase.cxx.

30 {
31  ATH_MSG_DEBUG("G4MagFieldSvcBase::getField");
32 
33  // Check if we already have a field setup for current thread
34  auto field = m_fieldHolder.get();
35  // If not, we create one
36  if(!field) {
37  field = makeField();
39  }
40 
41  return field;
42 }

◆ makeField()

virtual G4MagneticField* G4MagFieldSvcBase::makeField ( )
protectedpure virtual

This method must be overridden by concrete tools to create a new field.

Implemented in StandardFieldSvc, and ConstantFieldSvc.

Member Data Documentation

◆ m_fieldHolder

thread_utils::ThreadLocalOwner<G4MagneticField> G4MagFieldSvcBase::m_fieldHolder
protected

Thread-local field object.

Definition at line 48 of file G4MagFieldSvcBase.h.


The documentation for this class was generated from the following files:
G4MagFieldSvcBase::makeField
virtual G4MagneticField * makeField()=0
This method must be overridden by concrete tools to create a new field.
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
thread_utils::ThreadLocalHolder::set
void set(T *obj)
Assign the object of the current thread.
Definition: ThreadLocalHolder.h:67
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
thread_utils::ThreadLocalHolder::get
T * get()
Get the object of the current thread.
Definition: ThreadLocalHolder.h:60
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
G4MagFieldSvcBase::m_fieldHolder
thread_utils::ThreadLocalOwner< G4MagneticField > m_fieldHolder
Thread-local field object.
Definition: G4MagFieldSvcBase.h:48