Belle II Software development
SVDLocalCalibrationsImporter Class Reference

This class import to the database the dbobjects storing the SVD Local Calibrations. More...

#include <SVDLocalCalibrationsImporter.h>

Public Member Functions

 SVDLocalCalibrationsImporter ()
 Default constructor.
 
 SVDLocalCalibrationsImporter (int fexp, int frun, int lexp, int lrun)
 A constructor accepting as arguments the interval of validity coordinates.
 
virtual ~SVDLocalCalibrationsImporter ()
 Destructor.
 
void importSVDChannelMapping (const std::string &fileName=std::string("svd/data/svd_mapping.xml"))
 This method import to the database the channel mapping which is always required to properly fulfilled the other payloads.
 
void importSVDNoiseCalibrationsFromXML (const std::string &xmlFileName, bool errorTollerant=false)
 This method import to the database the strip noise from the pedestal local runs.
 
void importSVDPedestalCalibrationsFromXML (const std::string &xmlFileName, bool errorTollerant=false)
 This method import to the database the strip pedestal from the pedestal local runs.
 
void importSVDCalAmpCalibrationsFromXML (const std::string &xmlFileName, bool errorTollerant=false)
 This method import to the database the strip pulse width, time and gain from the injection local runs.
 
void importSVDHotStripsCalibrationsFromXML (const std::string &xmlFileName, bool errorTollerant=false)
 This method import to the database the list of hot strips flagged online and written in the local run xml output.
 
void importSVDFADCMaskedStripsFromXML (const std::string &xmlFileName, bool errorTollerant=false)
 This method import to the database the list of strips masked at FADC level.
 
template<class SVDcalibration >
void importSVDCalibrationsFromXML (const std::string &condDbname, const std::string &xmlFileName, const std::string &xmlTag, typename SVDcalibration::t_perSideContainer::calibrationType defaultValue, bool errorTollerant)
 This method import to the database the strip noise from the noise local runs.
 

Private Attributes

int m_firstExperiment
 The interval of validity coordinates are defined as private members.
 
int m_firstRun
 First run.
 
int m_lastExperiment
 Last experiment.
 
int m_lastRun
 Last run.
 

Detailed Description

This class import to the database the dbobjects storing the SVD Local Calibrations.

Definition at line 24 of file SVDLocalCalibrationsImporter.h.

Constructor & Destructor Documentation

◆ SVDLocalCalibrationsImporter() [1/2]

Default constructor.

Definition at line 31 of file SVDLocalCalibrationsImporter.h.

31 :
34 {
35 }
int m_firstExperiment
The interval of validity coordinates are defined as private members.

◆ SVDLocalCalibrationsImporter() [2/2]

SVDLocalCalibrationsImporter ( int  fexp,
int  frun,
int  lexp,
int  lrun 
)
inline

A constructor accepting as arguments the interval of validity coordinates.

Definition at line 41 of file SVDLocalCalibrationsImporter.h.

41 :
42 m_firstExperiment(fexp), m_firstRun(frun),
43 m_lastExperiment(lexp), m_lastRun(lrun)
44 {
45 }

◆ ~SVDLocalCalibrationsImporter()

virtual ~SVDLocalCalibrationsImporter ( )
inlinevirtual

Destructor.

Definition at line 51 of file SVDLocalCalibrationsImporter.h.

52 {}

Member Function Documentation

◆ importSVDCalAmpCalibrationsFromXML()

void importSVDCalAmpCalibrationsFromXML ( const std::string &  xmlFileName,
bool  errorTollerant = false 
)

This method import to the database the strip pulse width, time and gain from the injection local runs.

Parameters
xmlFileNameis the file name of the xml file
errorTollerantif true bypasses sanity checks

Definition at line 212 of file SVDLocalCalibrationsImporter.cc.

213{
214
216
217 DBObjPtr<PayloadFile> OnlineToOfflineMapFileName("SVDChannelMapping.xml");
218
219 OnlineToOfflineMapFileName.hasChanged();
220
221 std::unique_ptr<SVDOnlineToOfflineMap> map =
222 std::make_unique<SVDOnlineToOfflineMap>(OnlineToOfflineMapFileName->getFileName());
223
224 pulseShapes.construct(SVDStripCalAmp(), xmlFileName);
225
226 // This is the property tree
227 ptree pt;
228
229 // Load the XML file into the property tree. If reading fails
230 // (cannot open file, parse error), an exception is thrown.
231 read_xml(xmlFileName, pt);
232
233 for (ptree::value_type const& backEndLayoutChild :
234 pt.get_child("cfg_document.back_end_layout")) {
235
236 if (backEndLayoutChild.first == "fadc") {
237 int FADCid(0);
238 std::string FADCidString = backEndLayoutChild.second.get<std::string>("<xmlattr>.id");
239 std::stringstream ss;
240 ss << std::hex << FADCidString;
241 ss >> FADCid;
242
243 for (ptree::value_type const& fadcChild : backEndLayoutChild.second.get_child("")) {
244 if (fadcChild.first == "adc") {
245 int ADCid = fadcChild.second.get<int>("<xmlattr>.id") ;
246 B2DEBUG(1, " ADC id = " << ADCid);
247
248 int layerId = fadcChild.second.get<int>("<xmlattr>.layer_id");
249 B2DEBUG(1, " layer_id = " << layerId);
250
251 int ladderId = fadcChild.second.get<int>("<xmlattr>.ladder_id") ;
252 B2DEBUG(1, " ladder_id = " << ladderId);
253
254 int hybridId = fadcChild.second.get<int>("<xmlattr>.hybrid_id");
255 B2DEBUG(1, " hybrid_id = " << hybridId);
256
257 B2DEBUG(1, " delay25 = " << fadcChild.second.get<int>("<xmlattr>.delay25"));
258
259 for (ptree::value_type const& apvChild : fadcChild.second.get_child("")) {
260 if (apvChild.first == "apv25") {
261 int apv25ADCid = apvChild.second.get<int>("<xmlattr>.id");
262 std::string ampString = apvChild.second.get<std::string>("cal_peaks") ;
263 std::string widthString = apvChild.second.get<std::string>("cal_width") ;
264 std::string peakTimeString = apvChild.second.get<std::string>("cal_peak_time") ;
265
266 std::stringstream ssAmp;
267 ssAmp << ampString;
268
269 std::stringstream ssWidth;
270 ssWidth << widthString;
271
272 std::stringstream ssPeak;
273 ssPeak << peakTimeString;
274
275 double amp, width, peakTime;
276 for (int apvChannel = 0 ; apvChannel < 128; apvChannel ++) {
277 ssAmp >> amp;
278 ssWidth >> width;
279 ssPeak >> peakTime;
280
281 const SVDOnlineToOfflineMap::SensorInfo& info = map->getSensorInfo(FADCid, ADCid * 6 + apv25ADCid);
282
283 short strip = map->getStripNumber(apvChannel, info);
284 int side = info.m_uSide ?
285 SVDPulseShapeCalibrations::t_calAmp_payload::Uindex :
286 SVDPulseShapeCalibrations::t_calAmp_payload::Vindex;
287
288 int layer = info.m_sensorID.getLayerNumber();
289 int ladder = info.m_sensorID.getLadderNumber();
290 int sensor = info.m_sensorID.getSensorNumber();
291 if (errorTollerant || layer != layerId || ladder != ladderId // ||
292 // test on the sensor != f( hybrid) anr apv perhaps
293 )
294 B2ERROR("Inconsistency among maps: xml files tels \n" <<
295 "layer " << layerId << " ladder " << ladderId << " hybridID " << hybridId << "\n" <<
296 "while the basf2 map tels \n" <<
297 "layer " << layer << " ladder " << ladder << " sensor " << sensor << "\n");
298
299 SVDStripCalAmp stripCalAmp;
300 // UGLY: 22500. 31.44/8 should be written somewhere in the XML file provided by Hao
301 stripCalAmp.gain = amp / 22500.;
302 stripCalAmp.peakTime = peakTime * 31.44 / 8;
303 stripCalAmp.pulseWidth = width * 31.44 / 8 ;
304 pulseShapes->set(layer, ladder, sensor, side, strip, stripCalAmp);
305
306 }
307 }
308 }
309 }
310 }
311 }
312 }
313
314
315
318
319 pulseShapes.import(iov);
320
321 B2RESULT("Imported to database.");
322
323
324}
Class for importing a single object to the database.
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
A class that describes the interval of experiments/runs for which an object in the database is valid.
static std::string calAmp_name
name of the SVDStripCalAmp payload
Struct to hold data about a sensor.
contains the parameter of the APV pulse
float pulseWidth
pulseWidth (in ns) is the width of the shaper output TO BE CLARIFIED: how this width is defined?
float peakTime
peakTimes (in ns) is the time at which the shaper output reach the maximum.
float gain
gain is expressed in ADC counts / # electrons injected in the channel

◆ importSVDCalibrationsFromXML()

void importSVDCalibrationsFromXML ( const std::string &  condDbname,
const std::string &  xmlFileName,
const std::string &  xmlTag,
typename SVDcalibration::t_perSideContainer::calibrationType  defaultValue,
bool  errorTollerant 
)

This method import to the database the strip noise from the noise local runs.

Parameters
condDbnameis the name of the payload in the condition database
xmlFileNameis the file name of the xml file
xmlTagis the tag in the xml file that contains the actual calibrations
defaultValueis the value assigned to the calibration constant by default
errorTollerantif true bypasses sanity checks

Definition at line 100 of file SVDLocalCalibrationsImporter.cc.

105{
106 DBImportObjPtr< SVDcalibration> payload(condDbname);
107
108 DBObjPtr<PayloadFile> OnlineToOfflineMapFileName("SVDChannelMapping.xml");
109
110 OnlineToOfflineMapFileName.hasChanged();
111
112 std::unique_ptr<SVDOnlineToOfflineMap> map =
113 std::make_unique<SVDOnlineToOfflineMap>(OnlineToOfflineMapFileName->getFileName());
114
115 payload.construct(defaultValue, xmlFileName);
116
117 // This is the property tree
118 ptree pt;
119
120 // Load the XML file into the property tree. If reading fails
121 // (cannot open file, parse error), an exception is thrown.
122 read_xml(xmlFileName, pt);
123
124 for (ptree::value_type const& backEndLayoutChild :
125 pt.get_child("cfg_document.back_end_layout")) {
126
127 if (backEndLayoutChild.first == "fadc") {
128 int FADCid(0);
129 std::string FADCidString = backEndLayoutChild.second.get<std::string>("<xmlattr>.id");
130 std::stringstream ss;
131 ss << std::hex << FADCidString;
132 ss >> FADCid;
133
134 for (ptree::value_type const& fadcChild : backEndLayoutChild.second.get_child("")) {
135 if (fadcChild.first == "adc") {
136 int ADCid = fadcChild.second.get<int>("<xmlattr>.id") ;
137 B2DEBUG(1, " ADC id = " << ADCid);
138
139 int layerId = fadcChild.second.get<int>("<xmlattr>.layer_id");
140 B2DEBUG(1, " layer_id = " << layerId);
141
142 int ladderId = fadcChild.second.get<int>("<xmlattr>.ladder_id") ;
143 B2DEBUG(1, " ladder_id = " << ladderId);
144
145 int hybridId = fadcChild.second.get<int>("<xmlattr>.hybrid_id");
146 B2DEBUG(1, " hybrid_id = " << hybridId);
147
148 B2DEBUG(1, " delay25 = " <<
149 fadcChild.second.get<int>("<xmlattr>.delay25"));
150
151 for (ptree::value_type const& apvChild : fadcChild.second.get_child("")) {
152 if (apvChild.first == "apv25") {
153 int apv25ADCid = apvChild.second.get<int>("<xmlattr>.id");
154 std::string valuesString = apvChild.second.get<std::string>(xmlTag) ;
155 B2DEBUG(10, xmlTag << " APV25ID" << apv25ADCid << " "
156 << valuesString << "\n~~~~~~~~\n");
157
158 std::stringstream ssn;
159 ssn << valuesString;
160 double value;
161 for (int apvChannel = 0 ; apvChannel < 128; apvChannel ++) {
162 ssn >> value;
164 map->getSensorInfo(FADCid, ADCid * 6 + apv25ADCid);
165
166 short strip = map->getStripNumber(apvChannel, info);
167 int side = info.m_uSide ?
168 SVDcalibration::Uindex :
169 SVDcalibration::Vindex ;
170 int layer = info.m_sensorID.getLayerNumber();
171 int ladder = info.m_sensorID.getLadderNumber();
172 int sensor = info.m_sensorID.getSensorNumber();
173 if (apvChannel % 127 == 0)
174 B2DEBUG(100, layer << "_" << ladder << "_" <<
175 sensor << "_" << side << "_" << strip << "( " <<
176 apvChannel << ") " << value);
177 if (errorTollerant || layer != layerId || ladder != ladderId
178 // ||
179 // test on the sensor != f( hybrid) anr apv perhaps
180 )
181 B2FATAL("Inconsistency among maps: xml files tells \n" <<
182 "layer " << layerId << " ladder " << ladderId <<
183 " hybridID " << hybridId << "\n" <<
184 "while the basf2 map tells \n" <<
185 "layer " << layer << " ladder " << ladder <<
186 " sensor " << sensor << "\n");
187
188
189 payload->set(layer, ladder, sensor, side, strip, value);
190 }
191 }
192 }
193 }
194 }
195 }
196 }
197
198
199
202
203 payload.import(iov);
204
205 B2RESULT("Imported to database.");
206
207}

◆ importSVDChannelMapping()

void importSVDChannelMapping ( const std::string &  fileName = std::string("svd/data/svd_mapping.xml"))

This method import to the database the channel mapping which is always required to properly fulfilled the other payloads.

Definition at line 45 of file SVDLocalCalibrationsImporter.cc.

46{
47
49 const std::string filename = FileSystem::findFile(fileName); //phase 3 xmlMapping
50 B2INFO("Importing the svd online -> offline map " << fileName << "\n");
51 // const std::string filename = FileSystem::findFile("testbeam/vxd/data/2017_svd_mapping.xml");
52 const std::string payloadname = "SVDChannelMapping.xml";
53 if (Database::Instance().addPayload(payloadname, filename, iov))
54 B2INFO("Success!");
55 else
56 B2INFO("Failure :( ua uaa uaa uaa uaaaa)");
57}
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...
Definition: FileSystem.cc:151
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:41

◆ importSVDFADCMaskedStripsFromXML()

void importSVDFADCMaskedStripsFromXML ( const std::string &  xmlFileName,
bool  errorTollerant = false 
)

This method import to the database the list of strips masked at FADC level.

Parameters
xmlFileNameis the file name of the xml file
errorTollerantif true bypasses sanity checks

Definition at line 89 of file SVDLocalCalibrationsImporter.cc.

90{
91 importSVDCalibrationsFromXML< SVDFADCMaskedStrips::t_payload >(SVDFADCMaskedStrips::name,
92 xmlFileName, "masks",
93 false, errorTollerant);
94}
static std::string name
name of the SVDFADCMaskedStrips payload

◆ importSVDHotStripsCalibrationsFromXML()

void importSVDHotStripsCalibrationsFromXML ( const std::string &  xmlFileName,
bool  errorTollerant = false 
)

This method import to the database the list of hot strips flagged online and written in the local run xml output.

Parameters
xmlFileNameis the file name of the xml file
errorTollerantif true bypasses sanity checks

Definition at line 81 of file SVDLocalCalibrationsImporter.cc.

83{
84 importSVDCalibrationsFromXML< SVDHotStripsCalibrations::t_payload >(SVDHotStripsCalibrations::name,
85 xmlFileName, "hot_strips",
86 false, errorTollerant);
87}
static std::string name
name of the SVDHotStripsCalibrations payload

◆ importSVDNoiseCalibrationsFromXML()

void importSVDNoiseCalibrationsFromXML ( const std::string &  xmlFileName,
bool  errorTollerant = false 
)

This method import to the database the strip noise from the pedestal local runs.

Parameters
xmlFileNameis the file name of the xml file
errorTollerantif true bypasses sanity checks

Definition at line 60 of file SVDLocalCalibrationsImporter.cc.

61{
62 // We do initialize the noise to a negative value so that
63 // the SNR for not properly initialized channels is negative
64 // CAVEAT EMPTOR: if thou will disable an APV25 chip and will
65 // not update the noise.... the hits on the previously disabled
66 // chips will be discarded by the clusterizer.
67 // That is: please please pleaseeee do not upload calibrations
68 // with incomplete setup.
69 importSVDCalibrationsFromXML< SVDNoiseCalibrations::t_payload >(SVDNoiseCalibrations::name,
70 xmlFileName, "noises",
71 -1.0, errorTollerant);
72}
static std::string name
name of the SVDNoiseCalibrations payload

◆ importSVDPedestalCalibrationsFromXML()

void importSVDPedestalCalibrationsFromXML ( const std::string &  xmlFileName,
bool  errorTollerant = false 
)

This method import to the database the strip pedestal from the pedestal local runs.

Parameters
xmlFileNameis the file name of the xml file
errorTollerantif true bypasses sanity checks

Definition at line 74 of file SVDLocalCalibrationsImporter.cc.

75{
76 importSVDCalibrationsFromXML< SVDPedestalCalibrations::t_payload >(SVDPedestalCalibrations::name,
77 xmlFileName, "pedestals",
78 -1.0, errorTollerant);
79}
static std::string name
name of the SVDPedestalCalibrations payload

Member Data Documentation

◆ m_firstExperiment

int m_firstExperiment
private

The interval of validity coordinates are defined as private members.

First experiment.

Definition at line 129 of file SVDLocalCalibrationsImporter.h.

◆ m_firstRun

int m_firstRun
private

First run.

Definition at line 130 of file SVDLocalCalibrationsImporter.h.

◆ m_lastExperiment

int m_lastExperiment
private

Last experiment.

Definition at line 131 of file SVDLocalCalibrationsImporter.h.

◆ m_lastRun

int m_lastRun
private

Last run.

Definition at line 132 of file SVDLocalCalibrationsImporter.h.


The documentation for this class was generated from the following files: