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>
39 using boost::property_tree::ptree;
42 void SVDDetectorConfigurationImporter::importSVDGlobalXMLFile(
const std::string& fileName)
46 const std::string filename = FileSystem::findFile(fileName);
47 B2INFO(
"Importing the global run configuration xml file " << fileName <<
"\n");
49 const std::string payloadname =
"SVDGlobalXMLFile.xml";
50 if (Database::Instance().addPayload(payloadname, filename, iov))
53 B2INFO(
"Failure :( ua uaa uaa uaa uaaaa)");
56 void SVDDetectorConfigurationImporter::importSVDGlobalConfigParametersFromXML(
const std::string& xmlFileName)
63 read_xml(xmlFileName, pt);
67 float zeroSuppression = 0;
69 std::string systemClock =
"";
71 int relativeTimeShift = 0;
74 for (ptree::value_type
const& cfgDocumentChild :
75 pt.get_child(
"cfg_document")) {
77 if (cfgDocumentChild.first ==
"noise_run") {
78 maskFilter = cfgDocumentChild.second.get<
int>(
"<xmlattr>.mask") ;
79 B2INFO(
" masking bitmap = " << maskFilter);
82 if (cfgDocumentChild.first ==
"hardware_run") {
83 zeroSuppression = cfgDocumentChild.second.get<
float>(
"<xmlattr>.zs_cut") ;
84 B2INFO(
" zero suppression cut = " << zeroSuppression);
88 if (cfgDocumentChild.first ==
"i2c") {
89 latency = cfgDocumentChild.second.get<
float>(
"<xmlattr>.lat") ;
90 B2INFO(
" latency = " << latency);
94 if (cfgDocumentChild.first ==
"fadc_ctrl") {
95 systemClock = cfgDocumentChild.second.get<std::string>(
"<xmlattr>.system_clock") ;
96 B2INFO(
" APV clock units = " << systemClock);
97 nrFrames = cfgDocumentChild.second.get<
int>(
"<xmlattr>.nr_frames") ;
98 B2INFO(
" Number of Frames = " << nrFrames);
102 if (cfgDocumentChild.first ==
"controller") {
103 relativeTimeShift = cfgDocumentChild.second.get<
int>(
"<xmlattr>.mix_trg_delay") ;
104 B2INFO(
" delay of 3-sample VS 6-sample in units of APV clock /4 = " << relativeTimeShift);
105 if ((relativeTimeShift < 0) || (relativeTimeShift > 15))
106 B2FATAL(
"OOPS!! the relative time shift = " << relativeTimeShift <<
107 " 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");
111 for (ptree::value_type
const& cfgDocumentChild :
112 pt.get_child(
"cfg_document.ps_setup.hv_config")) {
113 if (cfgDocumentChild.first ==
"config") {
114 hv = cfgDocumentChild.second.get<
float>(
"<xmlattr>.v_conf") ;
115 B2INFO(
" HV = " << hv);
122 svdGlobalConfig.construct(xmlFileName);
124 svdGlobalConfig->setZeroSuppression(zeroSuppression);
125 svdGlobalConfig->setLatency(latency);
126 svdGlobalConfig->setMaskFilter(maskFilter);
127 svdGlobalConfig->setAPVClockInRFCUnits(systemClock);
128 svdGlobalConfig->setHV(hv);
129 svdGlobalConfig->setRelativeTimeShift(relativeTimeShift);
130 svdGlobalConfig->setNrFrames(nrFrames);
133 m_lastExperiment, m_lastRun);
135 svdGlobalConfig.import(iov);
136 B2RESULT(
"SVDGlobalConfigParameters imported to database.");
140 void SVDDetectorConfigurationImporter::importSVDLocalConfigParametersFromXML(
const std::string& xmlFileName)
148 read_xml(xmlFileName, pt);
152 std::string calInjectedCharge;
153 std::string calibTimeUnits =
"";
154 std::string calibDate =
"";
156 for (ptree::value_type
const& apvChild :
157 pt.get_child(
"cfg_document.back_end_layout.fadc.adc.apv25")) {
160 if (apvChild.first ==
"cal_peaks") {
161 calInjectedCharge = apvChild.second.get<std::string>(
"<xmlattr>.units");
162 B2INFO(
" injected charge from XML = " << calInjectedCharge <<
", but actually set to 22500, hardcoded");
165 if (apvChild.first ==
"cal_peak_time") {
166 calibTimeUnits = apvChild.second.get<std::string>(
"<xmlattr>.units");
167 B2INFO(
" calibration time units = " << calibTimeUnits);
171 for (ptree::value_type
const& latestRunChild :
172 pt.get_child(
"cfg_document.latest_runs")) {
174 if (latestRunChild.first ==
"Noise") {
175 calibDate = latestRunChild.second.get<std::string>(
"<xmlattr>.end_of_run");
176 B2INFO(
" calibration date = " << calibDate);
183 svdLocalConfig.construct(xmlFileName);
185 svdLocalConfig->setCalibrationTimeInRFCUnits(calibTimeUnits);
186 svdLocalConfig->setCalibDate(calibDate);
189 svdLocalConfig->setInjectedCharge(22500);
193 m_lastExperiment, m_lastRun);
195 svdLocalConfig.import(iov);
196 B2RESULT(
"SVDLocalConfigParameters imported to database.");
Class for importing a single object to the database.
A class that describes the interval of experiments/runs for which an object in the database is valid.
Abstract base class for different kinds of events.