ATLAS Offline Software
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
25 namespace MagField {
26  class AtlasFieldMap;
27 }
28 
31 class 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  }
42  {}
43 
44 
45  MagField::AtlasFieldCache& fieldCache() { return m_fieldCache; }
46 
48  void GetFieldValue(const double *point, double *field) const
49  {
51  else m_fieldCache.getField(point, field);
52  }
53 
54  private:
57 
61 };
62 
63 
67 class StandardFieldSvc final : public G4MagFieldSvcBase
68 {
69  public:
70 
72  StandardFieldSvc(const std::string& name, ISvcLocator* pSvcLocator);
74  ~StandardFieldSvc() = default;
75 
77  StatusCode initialize() override final;
78 
79  protected:
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 
99  ServiceHandle<MagField::IMagFieldSvc> m_magFieldSvc {this, "MagneticFieldSvc", ""};
100 
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"};
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)"};
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
StandardFieldSvc::toroidOn
bool toroidOn()
Definition: StandardFieldSvc.h:105
G4MagFieldSvcBase.h
StandardFieldSvc::m_toroMapFilename
Gaudi::Property< std::string > m_toroMapFilename
Definition: StandardFieldSvc.h:114
StandardFieldSvc::m_magFieldSvc
ServiceHandle< MagField::IMagFieldSvc > m_magFieldSvc
Handle to the the Forward ATLAS magnetic field service.
Definition: StandardFieldSvc.h:99
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
StandardFieldSvc::m_useMagFieldSvc
Gaudi::Property< bool > m_useMagFieldSvc
Definition: StandardFieldSvc.h:95
StandardFieldSvc::m_mapSoleCurrent
Gaudi::Property< double > m_mapSoleCurrent
nominal current for the maps
Definition: StandardFieldSvc.h:118
StandardFieldSvc::m_fieldMap
std::unique_ptr< MagField::AtlasFieldMap > m_fieldMap
Definition: StandardFieldSvc.h:129
StandardFieldSvc::m_mapToroCurrent
Gaudi::Property< double > m_mapToroCurrent
Definition: StandardFieldSvc.h:120
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
AtlasField::AtlasField
AtlasField(double scaleSolenoid, double scaleToroid, const MagField::AtlasFieldMap *fieldMap)
Construct the field object from conditions object.
Definition: StandardFieldSvc.h:35
Property
Support class for PropertyMgr.
Definition: Property.h:23
StandardFieldSvc
Athena service for constructing the AtlasField object.
Definition: StandardFieldSvc.h:68
protected
#define protected
Definition: DetDescrConditionsDict_dict_fixes.cxx:14
AtlasField::fieldCache
MagField::AtlasFieldCache & fieldCache()
Definition: StandardFieldSvc.h:45
AtlasField::AtlasField
AtlasField(MagField::IMagFieldSvc *m)
Construct the field object from the IMagFieldSvc.
Definition: StandardFieldSvc.h:40
G4MagFieldSvcBase
Definition: G4MagFieldSvcBase.h:29
StandardFieldSvc::StandardFieldSvc
StandardFieldSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: StandardFieldSvc.cxx:23
AtlasField
G4 wrapper around the main ATLAS magnetic field cache or field svc for forward field.
Definition: StandardFieldSvc.h:32
StandardFieldSvc::m_useToroCurrent
Gaudi::Property< double > m_useToroCurrent
Definition: StandardFieldSvc.h:125
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IMagFieldSvc.h
StandardFieldSvc::m_fullMapFilename
Gaudi::Property< std::string > m_fullMapFilename
map file names
Definition: StandardFieldSvc.h:108
AtlasFieldCache.h
AtlasField::GetFieldValue
void GetFieldValue(const double *point, double *field) const
Implementation of G4 method to retrieve field value.
Definition: StandardFieldSvc.h:48
StandardFieldSvc::makeField
G4MagneticField * makeField() override final
Create/retrieve the AtlasField object.
Definition: StandardFieldSvc.cxx:53
MagField
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
Definition: ForwardRegionFieldSvc.h:27
AtlasField::m_magFieldSvc
MagField::IMagFieldSvc * m_magFieldSvc
Pointer to the magnetic field service.
Definition: StandardFieldSvc.h:60
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MagField::AtlasFieldMap
Map for magnetic field.
Definition: AtlasFieldMap.h:39
StandardFieldSvc::solenoidOn
bool solenoidOn()
Definition: StandardFieldSvc.h:104
StandardFieldSvc::~StandardFieldSvc
~StandardFieldSvc()=default
Empty destructor.
StandardFieldSvc::createFieldMap
StatusCode createFieldMap()
Definition: StandardFieldSvc.cxx:76
MagField::IMagFieldSvc::getField
virtual void getField(const double *xyz, double *bxyz, double *deriv=nullptr) const =0
get B field value at given position
MagField::AtlasFieldCache
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
Definition: AtlasFieldCache.h:43
StandardFieldSvc::m_soleMapFilename
Gaudi::Property< std::string > m_soleMapFilename
Definition: StandardFieldSvc.h:111
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
StandardFieldSvc::initialize
StatusCode initialize() override final
Athena method. called at initialization time, being customized here.
Definition: StandardFieldSvc.cxx:32
AtlasField::ATLAS_THREAD_SAFE
MagField::AtlasFieldCache m_fieldCache ATLAS_THREAD_SAFE
Field cache - mutable because getField modifies the cache.
Definition: StandardFieldSvc.h:56
MagField::IMagFieldSvc
@ class IMagFieldSvc
Definition: IMagFieldSvc.h:26
ServiceHandle< MagField::IMagFieldSvc >
StandardFieldSvc::m_useSoleCurrent
Gaudi::Property< double > m_useSoleCurrent
configurable current for map scaling
Definition: StandardFieldSvc.h:123