10#include <svd/calibration/SVDDetectorConfigurationImporter.h>
17#include <framework/database/Database.h>
18#include <framework/database/IntervalOfValidity.h>
19#include <framework/database/DBImportObjPtr.h>
22#include <framework/logging/Logger.h>
24#include <framework/utilities/FileSystem.h>
27#include <svd/dbobjects/SVDLocalConfigParameters.h>
28#include <svd/dbobjects/SVDGlobalConfigParameters.h>
30#include <boost/property_tree/ptree.hpp>
31#include <boost/property_tree/xml_parser.hpp>
38using boost::property_tree::ptree;
41void SVDDetectorConfigurationImporter::importSVDGlobalXMLFile(
const std::string& fileName)
46 B2INFO(
"Importing the global run configuration xml file " << fileName <<
"\n");
48 const std::string payloadname =
"SVDGlobalXMLFile.xml";
52 B2INFO(
"Failure :( ua uaa uaa uaa uaaaa)");
62 read_xml(xmlFileName, pt);
66 float zeroSuppression = 0;
68 std::string systemClock =
"";
70 int relativeTimeShift = 0;
73 for (ptree::value_type
const& cfgDocumentChild :
74 pt.get_child(
"cfg_document")) {
76 if (cfgDocumentChild.first ==
"noise_run") {
77 maskFilter = cfgDocumentChild.second.get<
int>(
"<xmlattr>.mask") ;
78 B2INFO(
" masking bitmap = " << maskFilter);
81 if (cfgDocumentChild.first ==
"hardware_run") {
82 zeroSuppression = cfgDocumentChild.second.get<
float>(
"<xmlattr>.zs_cut") ;
83 B2INFO(
" zero suppression cut = " << zeroSuppression);
87 if (cfgDocumentChild.first ==
"i2c") {
88 latency = cfgDocumentChild.second.get<
float>(
"<xmlattr>.lat") ;
89 B2INFO(
" latency = " << latency);
93 if (cfgDocumentChild.first ==
"fadc_ctrl") {
94 systemClock = cfgDocumentChild.second.get<std::string>(
"<xmlattr>.system_clock") ;
95 B2INFO(
" APV clock units = " << systemClock);
96 nrFrames = cfgDocumentChild.second.get<
int>(
"<xmlattr>.nr_frames") ;
97 B2INFO(
" Number of Frames = " << nrFrames);
101 if (cfgDocumentChild.first ==
"controller") {
102 relativeTimeShift = cfgDocumentChild.second.get<
int>(
"<xmlattr>.mix_trg_delay") ;
103 B2INFO(
" delay of 3-sample VS 6-sample in units of APV clock /4 = " << relativeTimeShift);
104 if (relativeTimeShift < 0)
105 B2FATAL(
"OOPS!! The relative time shift is negative. This is not allowed. Please check the global xml. For the moment we set it to 0.");
106 else if (relativeTimeShift > 15)
107 B2FATAL(
"OOPS!! The relative time shift = " << relativeTimeShift <<
108 " is not allowed! It must be an int between 0 and 15 included. Please check the global xml. For the moment we set it to 0.");
112 for (ptree::value_type
const& cfgDocumentChild :
113 pt.get_child(
"cfg_document.ps_setup.hv_config")) {
114 if (cfgDocumentChild.first ==
"config") {
115 hv = cfgDocumentChild.second.get<
float>(
"<xmlattr>.v_conf") ;
116 B2INFO(
" HV = " << hv);
123 svdGlobalConfig.construct(xmlFileName);
125 svdGlobalConfig->setZeroSuppression(zeroSuppression);
126 svdGlobalConfig->setLatency(latency);
127 svdGlobalConfig->setMaskFilter(maskFilter);
128 svdGlobalConfig->setAPVClockInRFCUnits(systemClock);
129 svdGlobalConfig->setHV(hv);
130 svdGlobalConfig->setRelativeTimeShift(relativeTimeShift);
131 svdGlobalConfig->setNrFrames(nrFrames);
136 svdGlobalConfig.import(iov);
137 B2RESULT(
"SVDGlobalConfigParameters imported to database.");
149 read_xml(xmlFileName, pt);
153 std::string calInjectedCharge;
154 std::string calibTimeUnits =
"";
155 std::string calibDate =
"";
157 for (ptree::value_type
const& apvChild :
158 pt.get_child(
"cfg_document.back_end_layout.fadc.adc.apv25")) {
161 if (apvChild.first ==
"cal_peaks") {
162 calInjectedCharge = apvChild.second.get<std::string>(
"<xmlattr>.units");
163 B2INFO(
" injected charge from XML = " << calInjectedCharge <<
", but actually set to 22500, hardcoded");
166 if (apvChild.first ==
"cal_peak_time") {
167 calibTimeUnits = apvChild.second.get<std::string>(
"<xmlattr>.units");
168 B2INFO(
" calibration time units = " << calibTimeUnits);
172 for (ptree::value_type
const& latestRunChild :
173 pt.get_child(
"cfg_document.latest_runs")) {
175 if (latestRunChild.first ==
"Noise") {
176 calibDate = latestRunChild.second.get<std::string>(
"<xmlattr>.end_of_run");
177 B2INFO(
" calibration date = " << calibDate);
184 svdLocalConfig.construct(xmlFileName);
186 svdLocalConfig->setCalibrationTimeInRFCUnits(calibTimeUnits);
187 svdLocalConfig->setCalibDate(calibDate);
190 svdLocalConfig->setInjectedCharge(22500);
196 svdLocalConfig.import(iov);
197 B2RESULT(
"SVDLocalConfigParameters imported to database.");
Class for importing a single object to the database.
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
A class that describes the interval of experiments/runs for which an object in the database is valid.
void importSVDGlobalConfigParametersFromXML(const std::string &xmlFileName)
This method import to the database the global configuration parameters used during data taking.
void importSVDLocalConfigParametersFromXML(const std::string &xmlFileName)
This method import to the database the local configuration parameters used during data taking.
int m_lastExperiment
Last experiment.
int m_firstExperiment
The interval of validity coordinates are defined as private members.
static Database & Instance()
Instance of a singleton Database.
Abstract base class for different kinds of events.