Commit 88154d83 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'fiedCache_fieldOffFix' into 'master'

fixes to allow setting map current to zero and then not reading in the map

See merge request !35431
parents b90f4659 cdb6e093
......@@ -37,7 +37,7 @@ public:
const MagField::AtlasFieldMap* fieldMap() const { return m_fieldMap; }
/** set values for field scale and service to be able to build the cache **/
bool initialize(double solFieldScale, double torFieldScale,
void initialize(double solFieldScale, double torFieldScale,
const MagField::AtlasFieldMap* fieldMap);
private:
......
......@@ -9,7 +9,7 @@ AtlasFieldCacheCondObj::AtlasFieldCacheCondObj()
AtlasFieldCacheCondObj::~AtlasFieldCacheCondObj() {}
bool
void
AtlasFieldCacheCondObj::initialize(double solFieldScale,
double torFieldScale,
const MagField::AtlasFieldMap* fieldMap)
......@@ -18,6 +18,5 @@ AtlasFieldCacheCondObj::initialize(double solFieldScale,
m_solFieldScale = solFieldScale;
m_torFieldScale = torFieldScale;
m_fieldMap = fieldMap;
return (m_fieldMap) != nullptr; // return false if cast failed
}
......@@ -116,13 +116,9 @@ MagField::AtlasFieldCacheCondAlg::execute(const EventContext& ctx) const {
auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
// initialize cond obj with current scale factors and the field svc (needed to setup cache)
if (!fieldCondObj->initialize(cache.m_solScaleFactor,
cache.m_torScaleFactor,
fieldMap)) {
ATH_MSG_ERROR("execute: Could not initialize conditions field object with solenoid/toroid currents "
<< cache.m_solScaleFactor << "," << cache.m_torScaleFactor);
return StatusCode::FAILURE;
}
fieldCondObj->initialize(cache.m_solScaleFactor,
cache.m_torScaleFactor,
fieldMap);
// Record in conditions store the conditions object with scale factors and map pointer for cache
if(writeHandle.record(cache.m_condObjOutputRange, std::move(fieldCondObj)).isFailure()) {
......@@ -134,7 +130,12 @@ MagField::AtlasFieldCacheCondAlg::execute(const EventContext& ctx) const {
ATH_MSG_INFO ( "execute: initialized AtlasFieldCacheCondObj and cache with SFs - sol/tor "
<< cache.m_solScaleFactor << "/" << cache.m_torScaleFactor );
ATH_MSG_INFO ( "execute: solenoid zone id " << fieldMap->solenoidZoneId());
if (fieldMap) {
ATH_MSG_INFO ( "execute: solenoid zone id " << fieldMap->solenoidZoneId());
}
else {
ATH_MSG_INFO ( "execute: no map read (currents == 0");
}
return StatusCode::SUCCESS;
}
......
......@@ -97,15 +97,20 @@ MagField::AtlasFieldMapCondAlg::execute(const EventContext& ctx) const {
ATH_CHECK( updateFieldMap(ctx, cache) );
ATH_MSG_INFO ( "execute: solenoid zone id " << cache.m_fieldMap->solenoidZoneId());
if (cache.m_fieldMap) {
ATH_MSG_INFO ( "execute: solenoid zone id " << cache.m_fieldMap->solenoidZoneId());
}
else {
ATH_MSG_INFO ( "execute: no map read (currents == 0");
}
// Save newly created map in conditions object, and record it in the conditions store, with its
// own range
auto fieldMapCondObj = std::make_unique<AtlasFieldMapCondObj>();
// move ownership of the field map to the fieldMapCondObj
fieldMapCondObj->setFieldMap(std::move(cache.m_fieldMap));
if (cache.m_fieldMap) fieldMapCondObj->setFieldMap(std::move(cache.m_fieldMap));
if(mapWriteHandle.record(cache.m_mapCondObjOutputRange, std::move(fieldMapCondObj)).isFailure()) {
ATH_MSG_ERROR("execute: Could not record AtlasFieldMapCondObj object with "
<< mapWriteHandle.key()
......@@ -202,7 +207,7 @@ MagField::AtlasFieldMapCondAlg::updateFieldMap(const EventContext& ctx, Cache& c
cache.m_mapCondObjOutputRange = rangeW;
ATH_MSG_INFO("updateFieldMap: useMapsFromCOOL == false, using default range " << rangeW);
}
// We allow to set currents via the TagInfoMgr which adds tags to the TagInfo object - only allowed for offline
if (m_useMapsFromCOOL) {
......@@ -235,7 +240,7 @@ MagField::AtlasFieldMapCondAlg::updateFieldMap(const EventContext& ctx, Cache& c
ATH_MSG_INFO("updateFieldMap: tagInfoH " << tagInfoH.fullKey() << " is NOT valid. ");
}
}
// Select map file according to the value of the currents which indicate which map is 'on'
// determine the map to load
......
......@@ -321,7 +321,7 @@ void createAtlasFieldCacheCondObj(SGTest::TestStore &store) {
SG::WriteCondHandle<AtlasFieldCacheCondObj> fieldHandle {fieldKey};
std::unique_ptr<MagField::AtlasFieldMap> fieldMap=getFieldMap("MagneticFieldMaps/bfieldmap_7730_20400_14m.root",7730,20400);
auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
assert( fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release()));
fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release());
assert( fieldHandle.record(r1_1, std::move(fieldCondObj)).isSuccess());
}
......
......@@ -93,7 +93,7 @@ int main()
auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
// initialize cond obj with current scale factors and the field svc (needed to setup cache)
assert( fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.get()));
fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.get());
Trk::SolenoidParametrization sol (*fieldCondObj);
test1 (sol, *fieldCondObj);
......
......@@ -341,7 +341,7 @@ void createSolenoidParametrizationCondData(SGTest::TestStore &store) {
{
std::unique_ptr<MagField::AtlasFieldMap> fieldMap=getFieldMap("MagneticFieldMaps/bfieldmap_7730_20400_14m.root",7730,20400);
auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
assert( fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release()));
fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release());
parm_ptr = std::make_unique<Trk::SolenoidParametrization>(*fieldCondObj);
assert( fieldHandle.record(r1_1, std::move(fieldCondObj)).isSuccess());
......
......@@ -157,7 +157,7 @@ void createNewtonTrkDistanceFinderCondData(SGTest::TestStore &store) {
{
std::unique_ptr<MagField::AtlasFieldMap> fieldMap=getFieldMap("MagneticFieldMaps/bfieldmap_7730_20400_14m.root",7730,20400);
auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
assert( fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release()));
fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release());
assert( fieldHandle.record(r1_1, std::move(fieldCondObj)).isSuccess());
}
}
......
......@@ -133,7 +133,7 @@ void createNewtonTrkDistanceFinderCondData(SGTest::TestStore &store) {
{
std::unique_ptr<MagField::AtlasFieldMap> fieldMap=getFieldMap("MagneticFieldMaps/bfieldmap_7730_20400_14m.root",7730,20400);
auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
assert( fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release()));
fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release());
assert( fieldHandle.record(r1_1, std::move(fieldCondObj)).isSuccess());
}
}
......
......@@ -140,7 +140,7 @@ void createNewtonTrkDistanceFinderCondData(SGTest::TestStore &store) {
{
std::unique_ptr<MagField::AtlasFieldMap> fieldMap=getFieldMap("MagneticFieldMaps/bfieldmap_7730_20400_14m.root",7730,20400);
auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
assert( fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release()));
fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release());
assert( fieldHandle.record(r1_1, std::move(fieldCondObj)).isSuccess());
}
}
......
......@@ -146,7 +146,7 @@ void createNewtonTrkDistanceFinderCondData(SGTest::TestStore &store) {
{
std::unique_ptr<MagField::AtlasFieldMap> fieldMap=getFieldMap("MagneticFieldMaps/bfieldmap_7730_20400_14m.root",7730,20400);
auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
assert( fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release()));
fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release());
assert( fieldHandle.record(r1_1, std::move(fieldCondObj)).isSuccess());
}
}
......
......@@ -165,7 +165,7 @@ void createNewtonTrkDistanceFinderCondData(SGTest::TestStore &store) {
{
std::unique_ptr<MagField::AtlasFieldMap> fieldMap=getFieldMap("MagneticFieldMaps/bfieldmap_7730_20400_14m.root",7730,20400);
auto fieldCondObj = std::make_unique<AtlasFieldCacheCondObj>();
assert( fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release()));
fieldCondObj->initialize(1. /*solenoid current scale factor*/, 1. /*toroid current scale factor*/, fieldMap.release());
assert( fieldHandle.record(r1_1, std::move(fieldCondObj)).isSuccess());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment