9#include <svd/online/SVDIgnoredStripsMap.h>
10#include <boost/property_tree/xml_parser.hpp>
11#include <framework/logging/Logger.h>
12#include <framework/utilities/FileSystem.h>
16using boost::property_tree::ptree;
20 m_Map(12), m_lastSensorID(0)
24 if (xmlFilename ==
"") {
25 B2INFO(
"No xml list of ignored strips specified.");
37 B2WARNING(
"The xml filename: " << xmlFilename << endl <<
38 "resolved to: " << xmlFullPath << endl <<
39 "by FileSystem::findFile does not exist." << endl <<
40 "SVD ignored strips map cannot be initialized." << endl
46 read_xml(xmlFullPath, propertyTree);
47 }
catch (std::exception
const& ex) {
48 B2WARNING(
"STD excpetion raised during xml parsing " << ex.what() << endl <<
49 "SVD ignored strips map cannot be initialized." << endl);
52 B2WARNING(
"Unknown excpetion raised during xml parsing "
53 "SVD ignored strips map cannot be initialized." << endl);
60 for (ptree::value_type
const& layer : propertyTree.get_child(
"SVD"))
61 if (layer.first ==
"layer") {
62 sensorID.
setLayerNumber(
static_cast<unsigned short>(layer.second.get<
int>(
"<xmlattr>.n")));
63 for (ptree::value_type
const& ladder : layer.second)
64 if (ladder.first ==
"ladder") {
65 sensorID.
setLadderNumber(
static_cast<unsigned short>(ladder.second.get<
int>(
"<xmlattr>.n")));
66 for (ptree::value_type
const& sensor : ladder.second)
67 if (sensor.first ==
"sensor") {
68 sensorID.
setSensorNumber(
static_cast<unsigned short>(sensor.second.get<
int>(
"<xmlattr>.n")));
69 for (ptree::value_type
const& side : sensor.second)
70 if (side.first ==
"side") {
71 std::string tagSide = side.second.get<std::string>(
"<xmlattr>.side");
75 for (ptree::value_type
const& tag : side.second)
76 if (tag.first ==
"strip") {
77 strips.insert(tag.second.get<
unsigned short>(
"<xmlattr>.stripNo"));
78 }
else if (tag.first ==
"stripsFromTo") {
79 auto limits = tag.second;
80 unsigned short fromStrip = limits.get<
unsigned short>(
"<xmlattr>.fromStrip");
81 unsigned short toStrip = limits.get<
unsigned short>(
"<xmlattr>.toStrip");
82 for (
unsigned short iStrip = fromStrip; iStrip <= toStrip; iStrip++)
83 strips.insert(iStrip);
85 m_Map.insert(std::pair<unsigned short, IgnoredStripsSet>(sensorID.
getID(), strips));
91 B2WARNING(
"Unknown excpetion raised during map initialization! "
92 "SVD ignored strips map may be corrupted." << endl);
103 auto mapIter =
m_Map.find(
id);
104 if (mapIter !=
m_Map.end()) {
117 auto mapIter =
m_Map.find(
id);
118 if (mapIter !=
m_Map.end()) {
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...
static bool fileExists(const std::string &filename)
Check if the file with given filename exists.
bool stripOK(VxdID id, unsigned short strip)
Check whether a strip on a given sensor is OK or not.
const std::set< unsigned short > & getIgnoredStrips(VxdID id)
Get the set of ignored strips for a sensor.
IgnoredStripsSet m_lastIgnored
Set of ingored strips for the most currently queried sensor.
VxdID m_lastSensorID
The most currently queried sensor number.
std::set< unsigned short > IgnoredStripsSet
A set of ignored strips.
SVDIgnoredStripsMap()=delete
No default constructor.
std::unordered_map< unsigned short, IgnoredStripsSet > m_Map
Structure holiding sets of ingored strips for all sensors.
Class to uniquely identify a any structure of the PXD and SVD.
void setSegmentNumber(baseType segment)
Set the sensor segment.
baseType getID() const
Get the unique id.
void setSensorNumber(baseType sensor)
Set the sensor id.
void setLadderNumber(baseType ladder)
Set the ladder id.
void setLayerNumber(baseType layer)
Set the layer id.
Abstract base class for different kinds of events.