ATLAS Offline Software
G4MagFieldSvcBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "G4MagFieldSvcBase.h"
6 
7 // Geant4 includes
8 #include "G4MagneticField.hh"
9 
10 //-----------------------------------------------------------------------------
11 // Implementation file for class : G4MagFieldSvcBase
12 //
13 // 2015-11-17: Andrea Dell'Acqua
14 //-----------------------------------------------------------------------------
15 
16 
17 //=============================================================================
18 // Standard constructor, initializes variables
19 //=============================================================================
21  ISvcLocator* pSvcLocator)
22  : base_class(name, pSvcLocator)
23 {
24 }
25 
26 //=============================================================================
27 // Retrieve a G4 mag field object
28 //=============================================================================
29 G4MagneticField* G4MagFieldSvcBase::getField()
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 }
G4MagFieldSvcBase::makeField
virtual G4MagneticField * makeField()=0
This method must be overridden by concrete tools to create a new field.
G4MagFieldSvcBase.h
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
G4MagFieldSvcBase::getField
G4MagneticField * getField() override final
Retrieve a G4 magnetic field object.
Definition: G4MagFieldSvcBase.cxx: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:195
G4MagFieldSvcBase::G4MagFieldSvcBase
G4MagFieldSvcBase(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: G4MagFieldSvcBase.cxx:20
G4MagFieldSvcBase::m_fieldHolder
thread_utils::ThreadLocalOwner< G4MagneticField > m_fieldHolder
Thread-local field object.
Definition: G4MagFieldSvcBase.h:48