Skip to content
Snippets Groups Projects
Commit 82dcf7a8 authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

WIP: provider is an attribute and source is a tag.

parent 47fe39c8
No related branches found
No related tags found
No related merge requests found
...@@ -16,3 +16,14 @@ void GenericBFieldMapBrBz::fieldComponents(const double* pos, double* field) { ...@@ -16,3 +16,14 @@ void GenericBFieldMapBrBz::fieldComponents(const double* pos, double* field) {
return; 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);
}
}
...@@ -22,6 +22,10 @@ public: ...@@ -22,6 +22,10 @@ public:
virtual void fieldComponents(const double* pos, double* field); 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: private:
IFieldMapProvider* m_provider; IFieldMapProvider* m_provider;
......
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
* In this file, the xml is parsed and the GenericBFieldMapBrBz object is created and configured. * In this file, the xml is parsed and the GenericBFieldMapBrBz object is created and configured.
* *
* The properties for the GenericBFieldMapBrBz * The properties for the GenericBFieldMapBrBz
* - provider * - provider (attribute)
* - [file, db] * - [file, db]
* - source * - source (tag)
* - file path for the 'file' mode. * - the attributes include:
* - DB ... for the 'db' mode. * - url
* - file path for the 'file' mode.
* - DB instance ... for the 'db' mode.
* - rhoMin, rhoMax, zMin, zMax * - rhoMin, rhoMax, zMin, zMax
* *
* -- Tao Lin <lintao AT ihep.ac.cn> * -- Tao Lin <lintao AT ihep.ac.cn>
...@@ -41,10 +43,22 @@ static dd4hep::Ref_t create_GenericBFieldMapBrBz(dd4hep::Detector& , ...@@ -41,10 +43,22 @@ static dd4hep::Ref_t create_GenericBFieldMapBrBz(dd4hep::Detector& ,
throw std::runtime_error(error_msg); 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 // 2. create the CartesianField
dd4hep::CartesianField obj; dd4hep::CartesianField obj;
GenericBFieldMapBrBz* ptr = new GenericBFieldMapBrBz(); GenericBFieldMapBrBz* ptr = new GenericBFieldMapBrBz();
ptr->init_provider(provider);
obj.assign(ptr, xmlParameter.nameStr(), xmlParameter.typeStr()); obj.assign(ptr, xmlParameter.nameStr(), xmlParameter.typeStr());
return obj; return obj;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment