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 #include <memory>
8 
9 // Geant4 includes
10 #include "G4MagneticField.hh"
11 
12 //-----------------------------------------------------------------------------
13 // Implementation file for class : G4MagFieldSvcBase
14 //
15 // 2015-11-17: Andrea Dell'Acqua
16 //-----------------------------------------------------------------------------
17 
18 
19 //=============================================================================
20 // Standard constructor, initializes variables
21 //=============================================================================
23  ISvcLocator* pSvcLocator)
24  : base_class(name, pSvcLocator)
25 {
26 }
27 
28 //=============================================================================
29 // Retrieve a G4 mag field object
30 //=============================================================================
31 G4MagneticField* G4MagFieldSvcBase::getField()
32 {
33  ATH_MSG_DEBUG("G4MagFieldSvcBase::getField");
34 
35  // create a thread-local magnetic field instance
36  static thread_local std::unique_ptr<G4MagneticField> field{makeField()};
37 
38  return field.get();
39 }
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
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:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
G4MagFieldSvcBase::G4MagFieldSvcBase
G4MagFieldSvcBase(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: G4MagFieldSvcBase.cxx:22