ATLAS Offline Software
AtlasFieldMap.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
12 #ifndef MAGFIELDCONDITIONS_ATLASFIELDMAP_H
13 #define MAGFIELDCONDITIONS_ATLASFIELDMAP_H 1
14 
15 // MagField includes
16 #include "CxxUtils/restrict.h"
17 #include "GaudiKernel/ServiceHandle.h"
23 
24 #include <iostream>
25 #include <memory>
26 
27 // forward declarations
28 class TFile;
29 
30 namespace MagField {
31 
39 {
40 public:
41  AtlasFieldMap() = default;
42  ~AtlasFieldMap() { delete m_meshZR; }
43 
44  // initialize map from root file
45  bool initializeMap(TFile* rootfile,
46  float solenoidCurrent,
47  float toroidCurrent);
48 
49  // Functions used by getField[ZR] in AtlasFieldCache
50  // search for a "zone" to which the point (z,r,phi) belongs
51  const BFieldZone* findBFieldZone(double z, double r, double phi) const;
52 
53  // fast 2d map (made of one zone)
54  const BFieldMeshZR* getBFieldMesh() const;
55 
57  bool solenoidOn() const { return solenoidCurrent() > 0.0; }
58  bool toroidOn() const { return toroidCurrent() > 0.0; }
59  // magnet currents read with map - needed for scaling
60  float solenoidCurrent() const { return m_solenoidCurrent; }
61  float toroidCurrent() const { return m_toroidCurrent; }
62  int solenoidZoneId() const { return m_solenoidZoneId; }
63 
64 private:
66  AtlasFieldMap(const AtlasFieldMap& other) = delete;
69 
70  // slow zone search is used during initialization to build the LUT
71  BFieldZone* findZoneSlow(double z, double r, double phi);
72 
73  // utility functions used by readMap
74  int read_packed_data(std::istream& input, std::vector<int>& data) const;
75  int read_packed_int(std::istream& input, int& n) const;
76  void buildLUT();
77  void buildZR();
78 
80  int memSize() const;
81 
84  // field map name
85  std::string m_filename;
86 
87  // currents read in with map
88  float m_solenoidCurrent{ 0 }; // solenoid current in ampere
89  float m_toroidCurrent{ 0 }; // toroid current in ampere
90  int m_solenoidZoneId{ -1 }; // solenoid zone id
91 
92  // full 3d map (made of multiple zones)
93  std::vector<BFieldZone> m_zone;
94 
95  // fast 2d map (made of one zone)
96  BFieldMeshZR* m_meshZR{ nullptr };
97 
98  // data members used in zone-finding
99  std::vector<double> m_edge[3]; // zone boundaries in z, r, phi
100  std::vector<int> m_edgeLUT[3]; // look-up table for zone edges
101  double m_invq[3]; // 1/stepsize in m_edgeLUT
102  std::vector<const BFieldZone*> m_zoneLUT; // look-up table for zones
103  // more data members to speed up zone-finding
104  double m_zmin{ 0 }; // minimum z
105  double m_zmax{ 0 }; // maximum z
106  int m_nz{ 0 }; // number of z bins in zoneLUT
107  double m_rmax{ 0 }; // maximum r
108  int m_nr{ 0 }; // number of r bins in zoneLUT
109  int m_nphi{ 0 }; // number of phi bins in zoneLUT
110  bool m_mapIsInitialized{ false };
111 };
112 
113 } // namespace MagField
114 
115 #include "AtlasFieldMap.icc"
116 #endif // MAGFIELDCONDITIONS_ATLASFIELDMAP_H
MagField::AtlasFieldMap::m_mapIsInitialized
bool m_mapIsInitialized
Definition: AtlasFieldMap.h:110
beamspotman.r
def r
Definition: beamspotman.py:676
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
MagField::AtlasFieldMap::m_meshZR
BFieldMeshZR * m_meshZR
Definition: AtlasFieldMap.h:96
MagField::AtlasFieldMap::m_nr
int m_nr
Definition: AtlasFieldMap.h:108
MagField::AtlasFieldMap::AtlasFieldMap
AtlasFieldMap(const AtlasFieldMap &other)=delete
BFieldMeshZR
Definition: BFieldMeshZR.h:24
MagField::AtlasFieldMap::m_solenoidZoneId
int m_solenoidZoneId
Definition: AtlasFieldMap.h:90
BFieldCache.h
BFieldCond.h
MagField::AtlasFieldMap::m_nphi
int m_nphi
Definition: AtlasFieldMap.h:109
MagField::AtlasFieldMap::solenoidOn
bool solenoidOn() const
status of the magnets
Definition: AtlasFieldMap.h:57
MagField::AtlasFieldMap::m_zmin
double m_zmin
Definition: AtlasFieldMap.h:104
AtlasFieldMap.icc
MagField::AtlasFieldMap::m_rmax
double m_rmax
Definition: AtlasFieldMap.h:107
MagField::AtlasFieldMap::m_edge
std::vector< double > m_edge[3]
Definition: AtlasFieldMap.h:99
MagField::AtlasFieldMap::read_packed_data
int read_packed_data(std::istream &input, std::vector< int > &data) const
MagField::AtlasFieldMap::buildLUT
void buildLUT()
Definition: AtlasFieldMap.cxx:226
LArCalib_HVScale2NtupleConfig.rootfile
string rootfile
Definition: LArCalib_HVScale2NtupleConfig.py:74
MagField::AtlasFieldMap::m_zoneLUT
std::vector< const BFieldZone * > m_zoneLUT
Definition: AtlasFieldMap.h:102
MagField::AtlasFieldMap::m_invq
double m_invq[3]
Definition: AtlasFieldMap.h:101
BFieldCacheZR.h
z
#define z
beamspotman.n
n
Definition: beamspotman.py:731
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
MagField::AtlasFieldMap::operator=
AtlasFieldMap & operator=(AtlasFieldMap &&other)=delete
BFieldZone.h
MagField::AtlasFieldMap::buildZR
void buildZR()
Definition: AtlasFieldMap.cxx:325
MagField::AtlasFieldMap::toroidCurrent
float toroidCurrent() const
Definition: AtlasFieldMap.h:61
BFieldZone
Definition: BFieldZone.h:29
MagField::AtlasFieldMap::m_nz
int m_nz
Definition: AtlasFieldMap.h:106
MagField::AtlasFieldMap::findBFieldZone
const BFieldZone * findBFieldZone(double z, double r, double phi) const
MagField
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
Definition: ForwardRegionFieldSvc.h:27
restrict.h
Macro wrapping the nonstandard restrict keyword.
MagField::AtlasFieldMap::m_zone
std::vector< BFieldZone > m_zone
Definition: AtlasFieldMap.h:93
MagField::AtlasFieldMap::m_filename
std::string m_filename
Data Members.
Definition: AtlasFieldMap.h:85
MagField::AtlasFieldMap::memSize
int memSize() const
approximate memory footprint in bytes
Definition: AtlasFieldMap.cxx:393
MagField::AtlasFieldMap::AtlasFieldMap
AtlasFieldMap(AtlasFieldMap &&other)=delete
MagField::AtlasFieldMap
Map for magnetic field.
Definition: AtlasFieldMap.h:39
MagField::AtlasFieldMap::m_solenoidCurrent
float m_solenoidCurrent
Definition: AtlasFieldMap.h:88
MagField::AtlasFieldMap::operator=
AtlasFieldMap & operator=(const AtlasFieldMap &other)=delete
MagField::AtlasFieldMap::toroidOn
bool toroidOn() const
Definition: AtlasFieldMap.h:58
MagField::AtlasFieldMap::m_zmax
double m_zmax
Definition: AtlasFieldMap.h:105
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
MagField::AtlasFieldMap::solenoidZoneId
int solenoidZoneId() const
Definition: AtlasFieldMap.h:62
MagField::AtlasFieldMap::findZoneSlow
BFieldZone * findZoneSlow(double z, double r, double phi)
Definition: AtlasFieldMap.cxx:210
MagField::AtlasFieldMap::m_edgeLUT
std::vector< int > m_edgeLUT[3]
Definition: AtlasFieldMap.h:100
MagField::AtlasFieldMap::read_packed_int
int read_packed_int(std::istream &input, int &n) const
MagField::AtlasFieldMap::m_toroidCurrent
float m_toroidCurrent
Definition: AtlasFieldMap.h:89
BFieldMeshZR.h
MagField::AtlasFieldMap::solenoidCurrent
float solenoidCurrent() const
Definition: AtlasFieldMap.h:60
MagField::AtlasFieldMap::initializeMap
bool initializeMap(TFile *rootfile, float solenoidCurrent, float toroidCurrent)
Definition: AtlasFieldMap.cxx:26
MagField::AtlasFieldMap::AtlasFieldMap
AtlasFieldMap()=default
MagField::AtlasFieldMap::getBFieldMesh
const BFieldMeshZR * getBFieldMesh() const
MagField::AtlasFieldMap::~AtlasFieldMap
~AtlasFieldMap()
Definition: AtlasFieldMap.h:42