ATLAS Offline Software
Loading...
Searching...
No Matches
StandardFieldSvc.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef G4ATLASSERVICES_StandardFieldSvc_H
6#define G4ATLASSERVICES_StandardFieldSvc_H
7
8// STL library
9#include <string>
10
11// Geant4
12#include "G4MagneticField.hh"
13
14// Gaudi/Athena
15#include "GaudiKernel/ServiceHandle.h"
17
18// Base classes
19#include "G4MagFieldSvcBase.h"
20
21// MagField cache
23
24// forward declarations
25namespace MagField {
26 class AtlasFieldMap;
27}
28
31class AtlasField : public G4MagneticField
32{
33 public:
35 AtlasField(double scaleSolenoid, double scaleToroid, const MagField::AtlasFieldMap* fieldMap)
36 : m_fieldCache (MagField::AtlasFieldCache( scaleSolenoid, scaleToroid, fieldMap))
37 {
38 }
39
43
44
45 MagField::AtlasFieldCache& fieldCache() { return m_fieldCache; }
46
48 void GetFieldValue(const double *point, double *field) const
49 {
50 if (m_magFieldSvc) m_magFieldSvc->getField(point, field);
51 else m_fieldCache.getField(point, field);
52 }
53
54 private:
57
61};
62
63
68{
69 public:
70
72 StandardFieldSvc(const std::string& name, ISvcLocator* pSvcLocator);
74 ~StandardFieldSvc() = default;
75
77 StatusCode initialize() override final;
78
81 G4MagneticField* makeField() override final;
82
83 private:
84
85 // There are two options for the magnetic field:
86 //
87 // 1) For solenoid and toroid, this has moved to use AtlasFieldCache and here we must create and
88 // same the field map
89 // 2) For the forward quadrupole fields, we preserve the access to the magnetic field service
90 //
91 // The boolean flag UseMagFieldSvc is now used to differentiate between the two cases (default is false)
92 //
93
94 // flag to use magnet field service
96 "UseMagFieldSvc", false, "Use magnetic field service - Should ONLY be used for ForwardRegionFieldSvc"};
97
100
101 StatusCode createFieldMap();
102
103 // properties taken from AtlasFieldMapCondAlg
104 bool solenoidOn() { return (m_mapSoleCurrent > 0.0); }
105 bool toroidOn() { return (m_mapToroCurrent > 0.0); }
106
108 Gaudi::Property<std::string> m_fullMapFilename {this,
109 "FullMapFile", "MagneticFieldMaps/bfieldmap_7730_20400_14m.root",
110 "File storing the full magnetic field map"};
111 Gaudi::Property<std::string> m_soleMapFilename {this,
112 "SoleMapFile", "MagneticFieldMaps/bfieldmap_7730_0_14m.root",
113 "File storing the solenoid-only magnetic field map"};
114 Gaudi::Property<std::string> m_toroMapFilename {this,
115 "ToroMapFile", "MagneticFieldMaps/bfieldmap_0_20400_14m.root",
116 "File storing the toroid-only magnetic field map"};
117
118 Gaudi::Property<double> m_mapSoleCurrent {this,
119 "MapSoleCurrent", 7730., "Nominal solenoid current (A)"};
120 Gaudi::Property<double> m_mapToroCurrent {this,
121 "MapToroCurrent", 20400., "Nominal toroid current (A)"};
122
123 Gaudi::Property<double> m_useSoleCurrent {this,
124 "UseSoleCurrent", 7730., "Configured solenoid current (A)"};
125 Gaudi::Property<double> m_useToroCurrent {this,
126 "UseToroCurrent", 20400., "Configured toroid current (A)"};
127
128 // field map held locally in svc - in Athena, this would go into a conditions object
129 std::unique_ptr<MagField::AtlasFieldMap> m_fieldMap;
130};
131
132#endif // G4ATLASSERVICES_StandardFieldSvc_H
#define protected
AtlasField(MagField::IMagFieldSvc *m)
Construct the field object from the IMagFieldSvc.
AtlasField(double scaleSolenoid, double scaleToroid, const MagField::AtlasFieldMap *fieldMap)
Construct the field object from conditions object.
MagField::AtlasFieldCache & fieldCache()
MagField::IMagFieldSvc * m_magFieldSvc
Pointer to the magnetic field service.
MagField::AtlasFieldCache m_fieldCache ATLAS_THREAD_SAFE
Field cache - mutable because getField modifies the cache.
void GetFieldValue(const double *point, double *field) const
Implementation of G4 method to retrieve field value.
G4MagFieldSvcBase(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
Map for magnetic field.
@ class IMagFieldSvc
Support class for PropertyMgr.
Definition Property.h:23
StandardFieldSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Gaudi::Property< double > m_useSoleCurrent
configurable current for map scaling
~StandardFieldSvc()=default
Empty destructor.
Gaudi::Property< double > m_mapSoleCurrent
nominal current for the maps
Gaudi::Property< std::string > m_fullMapFilename
map file names
std::unique_ptr< MagField::AtlasFieldMap > m_fieldMap
Gaudi::Property< double > m_useToroCurrent
StatusCode initialize() override final
Athena method. called at initialization time, being customized here.
ServiceHandle< MagField::IMagFieldSvc > m_magFieldSvc
Handle to the the Forward ATLAS magnetic field service.
Gaudi::Property< std::string > m_toroMapFilename
Gaudi::Property< std::string > m_soleMapFilename
StatusCode createFieldMap()
Gaudi::Property< double > m_mapToroCurrent
G4MagneticField * makeField() override final
Create/retrieve the AtlasField object.
Gaudi::Property< bool > m_useMagFieldSvc
=============================================================================
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
#define private