Belle II Software  release-08-01-10
SVDOnlineToOfflineMap Class Reference

This class implements the methods to map raw SVD hits to basf2 SVD hits. More...

#include <SVDOnlineToOfflineMap.h>

Collaboration diagram for SVDOnlineToOfflineMap:

Classes

class  ChipID
 Class to hold FADC+APV25 numbers. More...
 
struct  ChipInfo
 Struct to hold data about an APV25 chip. More...
 
struct  missingAPV
 struct to hold missing APVs informations More...
 
class  SensorID
 Class to hold numbers related to sensor. More...
 
struct  SensorInfo
 Struct to hold data about a sensor. More...
 

Public Types

typedef std::unordered_map< unsigned short, unsigned short > FADCmap
 FADC map typedef.
 

Public Member Functions

void setErrorRate (int errorRate)
 Setter for suppression factor given by the Unpacker.
 
 SVDOnlineToOfflineMap (const std::string &xml_filename)
 Constructor. More...
 
 SVDOnlineToOfflineMap ()=delete
 No default constructor.
 
SVDShaperDigitNewShaperDigit (unsigned char FADC, unsigned char APV25, unsigned char channel, short samples[6], float time=0.0)
 Return a pointer to a new SVDShpaerDigit whose VxdID, isU and cellID is set. More...
 
const SensorInfogetSensorInfo (unsigned char FADC, unsigned char APV25)
 Get SensorInfo for a given FADC/APV combination. More...
 
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. More...
 
bool isAPVinMap (VxdID sensorID, bool side, unsigned short strip)
 is the APV of the strips in the map? for a given layer/ladder/dssd/side/strip combination. More...
 
void prepareListOfMissingAPVs ()
 prepares the list of the missing APVs using the channel mapping
 
int getNumberOfMissingAPVs ()
 Get number of missing APVs.
 
const ChipInfogetChipInfo (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. More...
 
short getStripNumber (unsigned char channel, const SensorInfo &info) const
 Convert APV channel number to a strip number using a ChipInfo object. More...
 
void prepFADCmaps (FADCmap &, FADCmap &)
 function that maps FADC numbers as 0-(nFADCboards-1) from FADCnumbers unordered_set
 
unsigned short getFADCboardsNumber ()
 get the num,ner of FADC boards
 

Public Attributes

std::vector< missingAPVm_missingAPVs
 list of the missing APVs
 
std::unordered_set< unsigned char > FADCnumbers
 container for FADC numbers from current mapping file
 
std::unordered_multimap< unsigned char, unsigned char > APVforFADCmap
 map containing FADC numbers assigned to multiple APVs, from xml file
 

Private Member Functions

void ReadLayer (int nLayer, boost::property_tree::ptree const &xml_layer)
 Read from the ptree v in the xml file the layer nLayer.
 
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.
 
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.
 
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 ladder nLadder in layer nLayer.
 
void addChip (unsigned char chipN, unsigned char FADCn, int nlayer, int nladder, int nsensor, bool isU, unsigned short stripNumberCh0, bool isParallel)
 add chipN on FADCn to the map
 
void addChip (unsigned char chipN, unsigned char FADCn, unsigned short stripNumberCh0, bool isParallel)
 add chipN on FADCn to the map
 

Private Attributes

std::string m_MapUniqueName
 Human readable unique name of this map.
 
std::unordered_map< ChipID::baseType, SensorInfom_sensors
 m_sensors[ChipID(FADC,APV25)] gives the SensorInfo for the given APV25 on the given FADC (Unpacker) More...
 
std::unordered_map< SensorID::baseType, std::vector< ChipInfo > > m_chips
 needed for the packer, map of VxdID to chips
 
unsigned int nBadMappingErrors = 0
 Counter of the BadMapping errors.
 
int m_errorRate {1000}
 The suppression factor of BadMapping ERRORs messages to be shown.
 
ChipInfo m_currentChipInfo
 internal instance of chipinfo used by the getter
 
SensorInfo m_currentSensorInfo
 current sensor info
 

Detailed Description

This class implements the methods to map raw SVD hits to basf2 SVD hits.

Raw SVD hits are identified by: FADC number, APV number, strip number basf2 SVD hits are identified by PXD Sensor-id, side, strip number

Definition at line 30 of file SVDOnlineToOfflineMap.h.

Constructor & Destructor Documentation

◆ SVDOnlineToOfflineMap()

SVDOnlineToOfflineMap ( const std::string &  xml_filename)
explicit

Constructor.

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

Definition at line 20 of file SVDOnlineToOfflineMap.cc.

21  : m_MapUniqueName("")
24 {
25 
26  // Create an empty property tree object
27 
28  ptree propertyTree;
29 
30  // Load the XML file into the property tree. If reading fails
31  // (cannot open file, parse error), an exception is thrown.
32  string xmlFullPath = FileSystem::findFile(xmlFilename);
33 
34  if (! FileSystem::fileExists(xmlFullPath)) {
35  B2ERROR("The xml filename: " << xmlFilename << endl <<
36  "resolved to: " << xmlFullPath << endl <<
37  "by FileSystem::findFile does not exist." << endl <<
38  "SVD online to offline map cannot be initialized." << endl <<
39  "Be aware: no SVDShaperDigit will be produced by this module." << endl
40  );
41  return;
42  }
43 
44  try {
45  read_xml(xmlFullPath, propertyTree);
46  } catch (std::exception const& ex) {
47  B2ERROR("STD excpetion rised during xml parsing " << ex.what() << endl <<
48  "SVD online to offline map cannot be initialized." << endl <<
49  "Be aware: no SVDShaperDigits will be produced by this module." << endl);
50  return;
51  } catch (...) {
52  B2ERROR("Unknown excpetion rised during xml parsing "
53  "SVD online to offline map cannot be initialized." << endl <<
54  "Be aware: no SVDShaperDigits will be produced by this module." << endl);
55  return;
56  }
57 
58  try {
59  // traverse pt: let us navigate through the daughters of <SVD>
60  for (ptree::value_type const& v : propertyTree.get_child("SVD")) {
61  if (v.first == "unique") {
62  m_MapUniqueName = v.second.get<string>("<xmlattr>.name");
63  B2INFO("Loading the offline -> online SVD map named " << m_MapUniqueName);
64  }
65  // if the daughter is a <layer> then read it!
66  if (v.first == "layer")
67  ReadLayer(v.second.get<int>("<xmlattr>.n"), v.second);
68  }
69  } catch (...) {
70  B2ERROR("Unknown excpetion rised during map initialization! "
71  "SVD online to offline map corrupted." << endl <<
72  "Be aware: the SVDShaperDigits will be unreliable." << endl);
73  // To Do: rise an exception so that the calling module will skip the
74  // SVDShaperDigits filling
75  return;
76  }
77 }
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:148
static bool fileExists(const std::string &filename)
Check if the file with given filename exists.
Definition: FileSystem.cc:32
SensorInfo m_currentSensorInfo
current sensor info
ChipInfo m_currentChipInfo
internal instance of chipinfo used by the getter
void ReadLayer(int nLayer, boost::property_tree::ptree const &xml_layer)
Read from the ptree v in the xml file the layer nLayer.
std::string m_MapUniqueName
Human readable unique name of this map.

Member Function Documentation

◆ getChipInfo()

const SVDOnlineToOfflineMap::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.

Parameters
layeris the the layer number
ladderis the the ladder number
dssdis the the sensor number
sideis true if U
stripis the strip number
Returns
a reference to the corresponding ChipInfo object, all-zero if nonsensical input.

Definition at line 102 of file SVDOnlineToOfflineMap.cc.

◆ getSensorInfo()

const SVDOnlineToOfflineMap::SensorInfo & getSensorInfo ( unsigned char  FADC,
unsigned char  APV25 
)

Get SensorInfo for a given FADC/APV combination.

Parameters
FADCis FADC number from the SVDRawCopper data.
APV25is the APV25 number from the SVDRawCopper data.
Returns
a reference to the corresponding SensorInfo object, all-zero if nonsensical input.

Definition at line 79 of file SVDOnlineToOfflineMap.cc.

◆ getStripNumber()

short getStripNumber ( unsigned char  channel,
const SensorInfo info 
) const
inline

Convert APV channel number to a strip number using a ChipInfo object.

Parameters
channelAPV25 channel
infoConst reference to ChipInfo object.
Returns
The corresponding strip number, -1 if nonsensical input

Definition at line 234 of file SVDOnlineToOfflineMap.h.

235  { return (info.m_channel0 + ((unsigned short)channel) * (info.m_parallel ? 1 : -1)); }

◆ isAPVinMap() [1/2]

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.

Parameters
layeris the layer number
ladderis the ladder number
dssdis the sensor number
sideis true if U
stripis the strip number
Returns
true if the APV that reads the strip is in the map, false otherwise

Definition at line 135 of file SVDOnlineToOfflineMap.cc.

◆ isAPVinMap() [2/2]

bool isAPVinMap ( VxdID  sensorID,
bool  side,
unsigned short  strip 
)

is the APV of the strips in the map? for a given layer/ladder/dssd/side/strip combination.

Parameters
sensorIDis the VxdID of the sensor
sideis true if U
stripis the strip number
Returns
true if the APV that reads the strip is in the map, false otherwise

Definition at line 163 of file SVDOnlineToOfflineMap.cc.

◆ NewShaperDigit()

SVDShaperDigit * NewShaperDigit ( unsigned char  FADC,
unsigned char  APV25,
unsigned char  channel,
short  samples[6],
float  time = 0.0 
)

Return a pointer to a new SVDShpaerDigit whose VxdID, isU and cellID is set.

Parameters
FADCis FADC number from the SVDRawCopper data.
APV25is the APV25 number from the SVDRawCopper data.
channelis the APV25 channel number from the SVDRawCopper data.
samplesAPV samples
timestrip time
Returns
a pointer to the new SVDShaperDigit owned by the caller whose Position is 0 FIXME: There should be no such function in this mapping class, no dependence on SVDShaperDigit and its interface.

Definition at line 169 of file SVDOnlineToOfflineMap.cc.

Member Data Documentation

◆ m_sensors

std::unordered_map< ChipID::baseType, SensorInfo > m_sensors
private

m_sensors[ChipID(FADC,APV25)] gives the SensorInfo for the given APV25 on the given FADC (Unpacker)

mao for chip ID to VxdID

Definition at line 281 of file SVDOnlineToOfflineMap.h.


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