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) {
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:
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;
......
......@@ -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;
......
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