Belle II Software development
SVDIgnoredStripsMap Class Reference

This class provides a list of ignored (=cold, hot or otherwise deffective) strips for the use in SVD data reconstruction. More...

#include <SVDIgnoredStripsMap.h>

Public Types

typedef std::set< unsigned short > IgnoredStripsSet
 A set of ignored strips.
 

Public Member Functions

 SVDIgnoredStripsMap (const std::string &xml_filename)
 Constructor.
 
 SVDIgnoredStripsMap ()=delete
 No default constructor.
 
const std::set< unsigned short > & getIgnoredStrips (VxdID id)
 Get the set of ignored strips for a sensor.
 
bool stripOK (VxdID id, unsigned short strip)
 Check whether a strip on a given sensor is OK or not.
 

Private Attributes

std::unordered_map< unsigned short, IgnoredStripsSetm_Map
 Structure holiding sets of ingored strips for all sensors.
 
IgnoredStripsSet m_lastIgnored
 Set of ingored strips for the most currently queried sensor.
 
VxdID m_lastSensorID
 The most currently queried sensor number.
 

Detailed Description

This class provides a list of ignored (=cold, hot or otherwise deffective) strips for the use in SVD data reconstruction.

The class has non-intrusive behavior, that is, it will not interfere when queries on non-existent sensors are asked.

Definition at line 28 of file SVDIgnoredStripsMap.h.

Member Typedef Documentation

◆ IgnoredStripsSet

typedef std::set<unsigned short> IgnoredStripsSet

A set of ignored strips.

Definition at line 32 of file SVDIgnoredStripsMap.h.

Constructor & Destructor Documentation

◆ SVDIgnoredStripsMap()

SVDIgnoredStripsMap ( const std::string &  xml_filename)
explicit

Constructor.

Parameters
xml_filenameis the name of the xml file containing the map.

Definition at line 19 of file SVDIgnoredStripsMap.cc.

19 :
20 m_Map(12), m_lastSensorID(0)
21{
22 // If the xmlFilename is empty, the user apparently doesn't want the map.
23 // So keep low-profile, don't bother.
24 if (xmlFilename == "") {
25 B2INFO("No xml list of ignored strips specified.");
26 return;
27 }
28 // Create an empty property tree object
29
30 ptree propertyTree;
31
32 // Load the XML file into the property tree. If reading fails
33 // (cannot open file, parse error), an exception is thrown.
34 string xmlFullPath = FileSystem::findFile(xmlFilename);
35
36 if (! FileSystem::fileExists(xmlFullPath)) {
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
41 );
42 return;
43 }
44
45 try {
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);
50 return;
51 } catch (...) {
52 B2WARNING("Unknown excpetion raised during xml parsing "
53 "SVD ignored strips map cannot be initialized." << endl);
54 return;
55 }
56
57 try {
58 // traverse the xml tree: navigate through the daughters of <SVD>
59 VxdID sensorID;
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");
72 sensorID.setSegmentNumber((tagSide == "U" || tagSide == "u") ? 1 : 0);
73 // We have complete VxdID, now we read the list of strips.
74 IgnoredStripsSet strips;
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);
84 }
85 m_Map.insert(std::pair<unsigned short, IgnoredStripsSet>(sensorID.getID(), strips));
86 } // if side
87 } // if sensor
88 } // if ladder
89 } // if sensor
90 } catch (...) {
91 B2WARNING("Unknown excpetion raised during map initialization! "
92 "SVD ignored strips map may be corrupted." << endl);
93 return;
94 }
95}
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 bool fileExists(const std::string &filename)
Check if the file with given filename exists.
Definition: FileSystem.cc:32
VxdID m_lastSensorID
The most currently queried sensor number.
std::set< unsigned short > IgnoredStripsSet
A set of ignored strips.
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.
Definition: VxdID.h:33
void setSegmentNumber(baseType segment)
Set the sensor segment.
Definition: VxdID.h:113
baseType getID() const
Get the unique id.
Definition: VxdID.h:94
void setSensorNumber(baseType sensor)
Set the sensor id.
Definition: VxdID.h:111
void setLadderNumber(baseType ladder)
Set the ladder id.
Definition: VxdID.h:109
void setLayerNumber(baseType layer)
Set the layer id.
Definition: VxdID.h:107

Member Function Documentation

◆ getIgnoredStrips()

const std::set< unsigned short > & getIgnoredStrips ( VxdID  id)

Get the set of ignored strips for a sensor.

Use to save map searches.

Parameters
idVxdID of the required sensor, with segment number 0 for v, 1 for u
Returns
the set of ignored strips, and empty set for non-existent VxdID.

Definition at line 97 of file SVDIgnoredStripsMap.cc.

98{
99 if (id == m_lastSensorID)
100 return m_lastIgnored;
101 else {
102 m_lastSensorID = id;
103 auto mapIter = m_Map.find(id);
104 if (mapIter != m_Map.end()) {
105 m_lastIgnored = mapIter->second;
106 } else {
107 m_lastIgnored.clear();
108 }
109 return m_lastIgnored;
110 }
111}
IgnoredStripsSet m_lastIgnored
Set of ingored strips for the most currently queried sensor.

◆ stripOK()

bool stripOK ( VxdID  id,
unsigned short  strip 
)

Check whether a strip on a given sensor is OK or not.

Parameters
idVxdID of the sensor, with segment number 0 for v, 1 for u
stripStrip number
Returns
true if strip or the id is not found in the list, otherwise false.

Definition at line 113 of file SVDIgnoredStripsMap.cc.

114{
115 if (id != m_lastSensorID) {
116 m_lastSensorID = id;
117 auto mapIter = m_Map.find(id);
118 if (mapIter != m_Map.end()) {
119 m_lastIgnored = mapIter->second;
120 } else {
121 m_lastIgnored.clear();
122 return true;
123 }
124 }
125 return (m_lastIgnored.count(strip) == 0);
126}

Member Data Documentation

◆ m_lastIgnored

IgnoredStripsSet m_lastIgnored
private

Set of ingored strips for the most currently queried sensor.

Definition at line 62 of file SVDIgnoredStripsMap.h.

◆ m_lastSensorID

VxdID m_lastSensorID
private

The most currently queried sensor number.

Definition at line 65 of file SVDIgnoredStripsMap.h.

◆ m_Map

std::unordered_map<unsigned short, IgnoredStripsSet> m_Map
private

Structure holiding sets of ingored strips for all sensors.

Definition at line 59 of file SVDIgnoredStripsMap.h.


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