 |
Belle II Software
release-05-01-25
|
11 #include "svd/online/SVDOnlineToOfflineMap.h"
12 #include <boost/property_tree/xml_parser.hpp>
13 #include <framework/logging/Logger.h>
14 #include <framework/utilities/FileSystem.h>
15 #include <vxd/geometry/GeoCache.h>
19 using boost::property_tree::ptree;
34 B2ERROR(
"The xml filename: " << xmlFilename << endl <<
35 "resolved to: " << xmlFullPath << endl <<
36 "by FileSystem::findFile does not exist." << endl <<
37 "SVD online to offline map cannot be initialized." << endl <<
38 "Be aware: no SVDShaperDigit will be produced by this module." << endl
44 read_xml(xmlFullPath, propertyTree);
45 }
catch (std::exception
const& ex) {
46 B2ERROR(
"STD excpetion rised during xml parsing " << ex.what() << endl <<
47 "SVD online to offline map cannot be initialized." << endl <<
48 "Be aware: no SVDShaperDigits will be produced by this module." << endl);
51 B2ERROR(
"Unknown excpetion rised during xml parsing "
52 "SVD online to offline map cannot be initialized." << endl <<
53 "Be aware: no SVDShaperDigits will be produced by this module." << endl);
59 for (ptree::value_type
const& v : propertyTree.get_child(
"SVD")) {
60 if (v.first ==
"unique") {
62 B2INFO(
"Loading the offline -> online SVD map named " <<
m_MapUniqueName);
65 if (v.first ==
"layer")
66 ReadLayer(v.second.get<
int>(
"<xmlattr>.n"), v.second);
69 B2ERROR(
"Unknown excpetion rised during map initialization! "
70 "SVD online to offline map corrupted." << endl <<
71 "Be aware: the SVDShaperDigits will be unreliable." << endl);
88 int(FADC)) <<
LogVar(
"APV",
int(APV25)));
102 unsigned short dssd,
bool side,
unsigned short strip)
104 SensorID id(layer, ladder, dssd, side);
105 auto chipIter =
m_chips.find(
id);
107 if (chipIter ==
m_chips.end()) B2WARNING(
" The following combination: sensorID: " << layer <<
"." << ladder <<
"." << dssd <<
108 ", isU=" << side <<
", strip=" << strip <<
109 " - is not found in the SVD Off-line to On-line map! The payload retrieved from database may be wrong! ");
112 vector<ChipInfo> vecChipInfo = chipIter->second;
117 for (std::vector<ChipInfo>::iterator it = vecChipInfo.begin() ; it != vecChipInfo.end(); ++it) {
122 if (strip >= channelFirst and strip <= channelLast) {
127 if (pinfo->
fadc == 0) B2WARNING(
"The strip number " << strip <<
" is not found in the SVDOnlineToOfflineMap for sensor " << layer <<
128 "." << ladder <<
"." << dssd <<
" on side " << (side ?
"u" :
"v") <<
"! Related APV chip is excluded in the hardware mapping.");
135 unsigned short dssd,
bool side,
unsigned short strip)
137 SensorID id(layer, ladder, dssd, side);
138 auto chipIter =
m_chips.find(
id);
140 if (chipIter ==
m_chips.end())
return false;
142 vector<ChipInfo> vecChipInfo = chipIter->second;
147 for (std::vector<ChipInfo>::iterator it = vecChipInfo.begin() ; it != vecChipInfo.end(); ++it) {
152 if (strip >= channelFirst and strip <= channelLast) {
157 if (pinfo->
fadc == 0)
return false;
169 unsigned char APV25,
unsigned char channel,
short samples[6],
float time,
SVDModeByte mode)
173 B2WARNING(
" channel out of range (0-127):" <<
LogVar(
"channel",
int(channel)));
183 if (info.m_sensorID) {
184 return new SVDShaperDigit(info.m_sensorID, info.m_uSide, strip, rawSamples, time, mode);
195 for (ptree::value_type
const& v : xml_layer) {
197 if (v.first ==
"ladder") {
198 ReadLadder(nlayer, v.second.get<
int>(
"<xmlattr>.n") , v.second);
207 for (ptree::value_type
const& v : xml_ladder) {
209 if (v.first ==
"sensor") {
210 ReadSensor(nlayer, nladder, v.second.get<
int>(
"<xmlattr>.n") , v.second);
219 for (ptree::value_type
const& v : xml_sensor) {
221 if (v.first ==
"side") {
222 std::string tagSide = v.second.get<std::string>(
"<xmlattr>.side");
224 bool isOnSideU = (tagSide ==
"U" || tagSide ==
"u");
225 bool isOnSideV = (tagSide ==
"V" || tagSide ==
"v");
227 if ((! isOnSideU) && (! isOnSideV)) {
228 B2ERROR(
"Side '" << tagSide <<
"' on layer " << nlayer
229 <<
" ladder " << nladder <<
" sensor " << nsensor
230 <<
" is neither 'U' nor 'V'");
241 ptree
const& xml_side)
247 vector<ChipInfo> vecInfo;
248 SensorID sid(nlayer, nladder, nsensor, isU);
250 for (ptree::value_type
const& v : xml_side) {
253 if (v.first ==
"chip") {
254 auto tags = v.second;
255 unsigned char chipN = tags.get<
unsigned char>(
"<xmlattr>.n");
256 unsigned char FADCn = tags.get<
unsigned char>(
"<xmlattr>.FADCn");
260 APVforFADCmap.insert(std::pair<unsigned char, unsigned char>(FADCn, chipN));
267 B2WARNING(
"Repeated insertion for FADC " << FADCn <<
" and APV "
268 << chipN <<
", layer/ladder/sensor " << nlayer <<
"/" << nladder
269 <<
"/" << nsensor <<
", side " << (isU ?
"u" :
"v"));
271 unsigned short stripNumberCh0 = tags.get<
unsigned short>(
"<xmlattr>.strip_number_of_ch0");
272 unsigned short stripNumberCh127 = tags.get<
unsigned short>(
"<xmlattr>.strip_number_of_ch127");
278 sinfo.m_parallel = (stripNumberCh127 > stripNumberCh0);
279 sinfo.m_channel0 = stripNumberCh0;
280 sinfo.m_channel127 = stripNumberCh127;
291 vecInfo.push_back(cinfo);
302 unsigned short it = 0;
317 for (
auto ladder : geoCache.getLadders(layer))
319 for (
int view = 0; view < 2; view++) {
322 if (layer.getLayerNumber() != 3 && view == 0)
326 for (
int apv = 0; apv < nAPVs; apv++) {
327 B2DEBUG(29,
"checking " << sensor.getLayerNumber() <<
"." << sensor.getLadderNumber() <<
"." << sensor.getSensorNumber() <<
328 ", view = " << view <<
", apv = " << apv);
329 if (!
isAPVinMap(sensor, view, apv * 128 + 63.5)) {
336 B2DEBUG(29,
"FOUND MISSING APV: " << sensor <<
", " << view <<
", " << apv);
std::unordered_map< ChipID::baseType, SensorInfo > m_sensors
m_sensors[ChipID(FADC,APV25)] gives the SensorInfo for the given APV25 on the given FADC (Unpacker)
std::unordered_multimap< unsigned char, unsigned char > APVforFADCmap
map containing FADC numbers assigned to multiple APVs, from xml file
std::unordered_set< unsigned char > FADCnumbers
container for FADC numbers from current mapping file
Class to uniquely identify a any structure of the PXD and SVD.
void ReadLayer(int nLayer, boost::property_tree::ptree const &xml_layer)
Read from the ptree v in the xml file the layer nLayer.
void ReadSensor(int nLayer, int nLadder, int nSensor, boost::property_tree::ptree const &xml_sensor)
Read from the ptree xml_sensor the sensor nSensor in ladder nLadder in layer nLayer.
unsigned short m_channel127
Strip corresponding to channel 127.
baseType getLadderNumber() const
Get the ladder id.
Struct to hold data about an APV25 chip.
void prepareListOfMissingAPVs()
prepares the list of the missing APVs using the channel mapping
VxdID m_sensorID
Sensor ID.
Class to store SVD mode information.
VxdID m_sensorID
Sensor ID.
bool m_isUSide
True if u-side of the sensor.
short getStripNumber(unsigned char channel, const SensorInfo &info) const
Convert APV channel number to a strip number using a ChipInfo object.
void ReadLadder(int nLayer, int nLadder, boost::property_tree::ptree const &xml_ladder)
Read from the ptree xml_ladde the ladder nLadder in layer nLayer.
unsigned short m_channel0
Strip corresponding to channel 0.
float m_halfStrip
floating strip in the middle of the APV
The SVD ShaperDigit class.
unsigned short stripFirst
first strip number
struct to hold missing APVs informations
int m_errorRate
The suppression factor of BadMapping ERRORs messages to be shown.
bool isAPVinMap(unsigned short layer, unsigned short ladder, unsigned short dssd, bool side, unsigned short strip)
is the APV of the strips in the map? for a given layer/ladder/dssd/side/strip combination.
Struct to hold data about a sensor.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Abstract base class for different kinds of events.
Class to store variables with their name which were sent to the logging service.
unsigned short stripLast
last strip number
SensorInfo m_currentSensorInfo
current sensor info
unsigned short fadc
fadc number
const ChipInfo & getChipInfo(unsigned short layer, unsigned short ladder, unsigned short dssd, bool side, unsigned short strip)
Get ChipInfo for a given layer/ladder/dssd/side/strip combination.
Class to hold FADC+APV25 numbers.
void ReadSensorSide(int nLayer, int nLadder, int nSensor, bool isU, boost::property_tree::ptree const &xml_side)
Read from the ptree xml_side the U-side, if isU, (the V-side otherwise) of the sensor nSensor in ladd...
std::unordered_map< unsigned short, unsigned short > FADCmap
FADC map typedef.
baseType getSensorNumber() const
Get the sensor id.
SVDShaperDigit * NewShaperDigit(unsigned char FADC, unsigned char APV25, unsigned char channel, short samples[6], float time=0.0, SVDModeByte mode=SVDModeByte())
Return a pointer to a new SVDShpaerDigit whose VxdID, isU and cellID is set.
SVDOnlineToOfflineMap()=delete
No default constructor.
static bool fileExists(const std::string &filename)
Check if the file with given filename exists.
unsigned char apvChannel
apv channel
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
std::vector< missingAPV > m_missingAPVs
list of the missing APVs
unsigned char apv
apv number
static const std::size_t c_nAPVSamples
Number of APV samples stored.
std::unordered_map< SensorID::baseType, std::vector< ChipInfo > > m_chips
needed for the packer, map of VxdID to chips
std::array< APVRawSampleType, c_nAPVSamples > APVRawSamples
array of APVRawSamplesType objects
baseType getLayerNumber() const
Get the layer id.
std::string m_MapUniqueName
Human readable unique name of this map.
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...
const SensorInfo & getSensorInfo(unsigned char FADC, unsigned char APV25)
Get SensorInfo for a given FADC/APV combination.
unsigned int nBadMappingErrors
Counter of the BadMapping errors.
ChipInfo m_currentChipInfo
internal instance of chipinfo used by the getter
void prepFADCmaps(FADCmap &, FADCmap &)
function that maps FADC numbers as 0-(nFADCboards-1) from FADCnumbers unordered_set
Class to hold numbers related to sensor.