diff --git a/MagneticField/MagFieldElements/MagFieldElements/AtlasFieldCache.icc b/MagneticField/MagFieldElements/MagFieldElements/AtlasFieldCache.icc index 44ca36ea26ad29d79aa10aad37ea271c02ee790c..953f29aaae07796641d9c6c750ac5a36b108bd26 100644 --- a/MagneticField/MagFieldElements/MagFieldElements/AtlasFieldCache.icc +++ b/MagneticField/MagFieldElements/MagFieldElements/AtlasFieldCache.icc @@ -37,22 +37,7 @@ MagField::AtlasFieldCache::fillFieldCache(double z, double r, double phi) return false; } - // We have a map with both on - if (solenoidOn() && toroidOn()) { - m_scaleToUse = (m_zone3d->id() == m_solZoneId) ? m_solScale : m_torScale; - } - // We have a solenoid only map - else if (solenoidOn()) { - m_scaleToUse = m_solScale; - } - // We have a toroid only map - else if (toroidOn()) { - m_scaleToUse = m_torScale; - } - // Both off - else { - m_scaleToUse = 0; - } + m_scaleToUse = (m_zone3d->id() == m_solZoneId) ? m_solScale : m_torScale; // fill the cache, pass in current scale factor m_zone3d->getCache(z, r, phi, m_cache3d, m_scaleToUse); // save pointer to the conductors in the zone diff --git a/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx b/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx index 2e751c1efdf7f27356419516fb2edf4ac67df612..15b9518ca53d93c1415eb1a047d8c74facb0c34c 100644 --- a/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx +++ b/MagneticField/MagFieldServices/src/AtlasFieldCacheCondAlg.cxx @@ -287,16 +287,24 @@ MagField::AtlasFieldCacheCondAlg::scaleField( Cache& cache, const MagField::AtlasFieldMap* fieldMap) const { - // Calculate the scale factor for solenoid and toroid - // For each current, if it is 0, either from conditions or jobOpt, set the - // corresponding SF to 0 - + // Calculate the scale factor for solenoid and toroid. + + // We have one piece of information coming from the map. + // Do we have a map including both Toroid/Solenoid or only one. + // The values are typically the nominal value for the map + // or 0. + bool mapHasToroid = fieldMap && (fieldMap->toroidCurrent()>0); + bool mapHasSolenoid = fieldMap && (fieldMap->solenoidCurrent()>0); + + // Then we have the info we get on the actual current we have + // So we might need to scale the map with it. + // Set the SF for the solenoid if (cache.m_solenoidCurrent > 0.0) { - if (fieldMap && fieldMap->solenoidCurrent() > 0.0 && + if (mapHasSolenoid && std::abs(cache.m_solenoidCurrent / fieldMap->solenoidCurrent() - 1.0) > - 0.001) { + 0.001) { cache.m_solScaleFactor = - cache.m_solenoidCurrent / fieldMap->solenoidCurrent(); + cache.m_solenoidCurrent / fieldMap->solenoidCurrent(); } ATH_MSG_INFO("scaleField: Solenoid field scale factor " << cache.m_solScaleFactor @@ -314,9 +322,10 @@ MagField::AtlasFieldCacheCondAlg::scaleField( << ((fieldMap) ? fieldMap->solenoidCurrent() : 0)); } - // + + // Set the SF for the toroid if (cache.m_toroidCurrent > 0.0) { - if (fieldMap && fieldMap->toroidCurrent() > 0.0 && + if (mapHasToroid && std::abs(cache.m_toroidCurrent / fieldMap->toroidCurrent() - 1.0) > 0.001) { // scale the field in all zones except for the solenoid zone @@ -336,4 +345,14 @@ MagField::AtlasFieldCacheCondAlg::scaleField( << cache.m_toroidCurrent << "," << ((fieldMap) ? fieldMap->toroidCurrent() : 0)); } + // If the map was toroid only set both to the toroid + // the 0s in the solenoid should be covered by the map + if (mapHasToroid && !mapHasSolenoid) { + cache.m_solScaleFactor = cache.m_torScaleFactor; + } + // if the map is solenoid only set both to the solenoid + // the 0s in the toroid should be covered by the map + if (!mapHasToroid && mapHasSolenoid) { + cache.m_torScaleFactor = cache.m_solScaleFactor; + } }