diff --git a/Detector/MagneticFieldMap/src/GenericBFieldMapBrBz.cpp b/Detector/MagneticFieldMap/src/GenericBFieldMapBrBz.cpp index f69a94c2e49bcd5fb45461ee37479ac2afa98e4b..fe268217c0b0376cd09c45ff3d3cf51db36f7585 100644 --- a/Detector/MagneticFieldMap/src/GenericBFieldMapBrBz.cpp +++ b/Detector/MagneticFieldMap/src/GenericBFieldMapBrBz.cpp @@ -16,3 +16,14 @@ void GenericBFieldMapBrBz::fieldComponents(const double* pos, double* field) { return; } + +void GenericBFieldMapBrBz::init_provider(const std::string& provider) { + if (provider == "file") { + std::cout << "Initialize provider with file. " << std::endl; + } else if (provider == "db") { + std::cout << "Initialize provider with file. " << std::endl; + } else { + std::string error_msg = "[ERROR] GenericBFieldMapBrBz: Unknown provider: " + provider; + throw std::runtime_error(error_msg); + } +} diff --git a/Detector/MagneticFieldMap/src/GenericBFieldMapBrBz.h b/Detector/MagneticFieldMap/src/GenericBFieldMapBrBz.h index c8edf9a27acd46e793a959ca04cf245db6c1ec38..3b1711f5abcf411253dfd8901510510fab8bfd0c 100644 --- a/Detector/MagneticFieldMap/src/GenericBFieldMapBrBz.h +++ b/Detector/MagneticFieldMap/src/GenericBFieldMapBrBz.h @@ -22,6 +22,10 @@ public: virtual void fieldComponents(const double* pos, double* field); +public: + // following are interfaces to configure this field map + void init_provider(const std::string& provider); + private: IFieldMapProvider* m_provider; diff --git a/Detector/MagneticFieldMap/src/GenericBFieldMapBrBzFactory.cpp b/Detector/MagneticFieldMap/src/GenericBFieldMapBrBzFactory.cpp index 41bd439f0f970dc377c0b8691015c0afc557c81d..b738332c12f8f8396aa79de1cbf9751ae906885a 100644 --- a/Detector/MagneticFieldMap/src/GenericBFieldMapBrBzFactory.cpp +++ b/Detector/MagneticFieldMap/src/GenericBFieldMapBrBzFactory.cpp @@ -2,11 +2,13 @@ * In this file, the xml is parsed and the GenericBFieldMapBrBz object is created and configured. * * The properties for the GenericBFieldMapBrBz - * - provider + * - provider (attribute) * - [file, db] - * - source - * - file path for the 'file' mode. - * - DB ... for the 'db' mode. + * - source (tag) + * - the attributes include: + * - url + * - file path for the 'file' mode. + * - DB instance ... for the 'db' mode. * - rhoMin, rhoMax, zMin, zMax * * -- Tao Lin <lintao AT ihep.ac.cn> @@ -41,10 +43,22 @@ static dd4hep::Ref_t create_GenericBFieldMapBrBz(dd4hep::Detector& , throw std::runtime_error(error_msg); } + std::string provider = xmlParameter.attr<std::string>(_Unicode(provider)); + + // - source + bool hasSource = xmlParameter.hasChild(_Unicode(source)); + if (!hasSource) { + std::string error_msg = "[ERROR] GenericBFieldMapBrBz: Must specify the 'source' tag. "; + throw std::runtime_error(error_msg); + + } + // 2. create the CartesianField dd4hep::CartesianField obj; GenericBFieldMapBrBz* ptr = new GenericBFieldMapBrBz(); + ptr->init_provider(provider); + obj.assign(ptr, xmlParameter.nameStr(), xmlParameter.typeStr()); return obj;