ATLAS Offline Software
AtlasFieldCache.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 inline MagField::AtlasFieldCache::AtlasFieldCache(double solFieldScale,
5  double torFieldScale,
6  const AtlasFieldMap* fieldMap)
7  : m_solScale(solFieldScale)
8  , m_torScale(torFieldScale)
9  , m_fieldMap(fieldMap)
10 {
11  if (m_fieldMap) {
12  // save ZR bfield
13  m_meshZR = m_fieldMap->getBFieldMesh();
14  // Get solenoid zone id from field service
15  m_solZoneId = fieldMap->solenoidZoneId();
16  }
17 }
18 
19 inline bool
20 MagField::AtlasFieldCache::fillFieldCache(double z, double r, double phi)
21 {
22  // We have gone outside of a cache volume. For the solenoid, it is 'safe' to
23  // just check\n if we are inside the solenoid zone, and then we can find the
24  // next cache volume. For toroid, it is best to not check if we are inside
25  // the zone, and just find the zone for the current point.
26  // So we need to look up a fieldZone:
27  // 1) If we do NOT have one
28  // 2) Everytime we are in a Zone that does NOT have a solenoid ID
29  // 3) If it has solenoid ID and we are NOT inside
30  if (!m_zone3d || m_zone3d->id() != m_solZoneId ||
31  !m_zone3d->inside(z, r, phi)) {
32  m_zone3d = m_fieldMap ? m_fieldMap->findBFieldZone(z, r, phi) : nullptr;
33  }
34 
35  if (!m_zone3d) {
36  // we failed to find a zone
37  return false;
38  }
39 
40  m_scaleToUse = (m_zone3d->id() == m_solZoneId) ? m_solScale : m_torScale;
41  // fill the cache, pass in current scale factor
42  m_zone3d->getCache(z, r, phi, m_cache3d, m_scaleToUse);
43  // save pointer to the conductors in the zone
44  m_cond = m_zone3d->condVector();
45 
46  return true;
47 }
48 
49 inline bool
50 MagField::AtlasFieldCache::fillFieldCacheZR(double z, double r)
51 {
52  // No mesh available
53  if (!m_meshZR) {
54  return false;
55  }
56  // Not inside the solenoid zone?
57  if (!m_meshZR->inside(z, r)) {
58  return false;
59  }
60  // fill the cache, pass in current scale factor
61  m_meshZR->getCache(z, r, m_cacheZR, m_solScale);
62  return true;
63 }
64 
65 inline bool
66 MagField::AtlasFieldCache::solenoidOn() const
67 {
68  return m_fieldMap ? m_fieldMap->solenoidOn() && m_solScale > 0.0 : false;
69 }
70 
71 inline bool
72 MagField::AtlasFieldCache::toroidOn() const
73 {
74  return m_fieldMap ? m_fieldMap->toroidOn() && m_torScale > 0.0 : false;
75 }