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

A root tool that compares two Sectormaps (local root files) and produces some statistics output. More...

#include <SectorMapComparer.h>

Inheritance diagram for SectorMapComparer:
Collaboration diagram for SectorMapComparer:

Public Member Functions

 SectorMapComparer ()=delete
 dont use this constructor
 
 SectorMapComparer (const std::string &SMFileFirst, const std::string &SMFileSecond)
 constructor More...
 
 ~SectorMapComparer ()=default
 default destructor
 
void plot (bool logScale=true, TString pdfFileName="", bool drawLegend=true)
 will create lots of Canvases!!! More...
 
void plotSectorStats (bool logScale=true, TString pdfFileName="", bool drawLegend=true)
 Will create canvases showing statistics. More...
 
void compareMaps (TString setup, bool unmatchedEntries=false)
 runs the comparison for all filters (and only the filters) in the sectormap files
 
void showSetups ()
 lists all setups of sectormaps included in the two files
 
void showSetups (TString sectorMapFileName)
 lists all sector map setups in the specified file
 
void showFiles ()
 lists the names of the files which are used
 

Private Member Functions

uint countConnections (const std::unordered_map< uint, uint > &map, int layer=-1, int ladder=-1, int sensor=-1, int sector=-1)
 counts all connections for given layer, ladder, sensor, sector. More...
 
std::string getHash (long l1, long l2, long l3)
 I was too lacy to implement a proper hash function, so I convert the three numbers into a string and use the string as hash for the map. More...
 
void findTrees (TDirectory *aDir, std::vector< std::string > &listOfTrees)
 helper function that returns a list of names for all trees contained in the TDirectory including sub-directories More...
 
void setLeafAddresses (TTree *t, std::unordered_map< std::string, double > &filterVals, std::unordered_map< std::string, uint > &SecIDVals)
 automatically sets the TLeaf addresses for a tree. More...
 
void fillSectorToTreeIndexMap (TTree *tree, std::unordered_map< std::string, long > &map)
 fills a map that maps sector combinations in the tree to string which is a hash combining the three (two) sector ids More...
 
void compareTrees (TTree *t_first, TTree *t_second, bool unmatchedEntries=false)
 makes the comparison of two trees, and fills histograms and certain maps More...
 
void clearMaps ()
 helper that clears all the maps used
 

Private Attributes

std::unordered_map< std::string, TH1F > m_histo_map_first
 histograms for the first sector map
 
std::unordered_map< std::string, TH1F > m_histo_map_second
 histograms for the second sector map
 
std::unordered_map< std::string, TH1F > m_histo_map_diff
 histograms that store differences between the two sector maps
 
std::unordered_map< std::string, TH1F > m_histo_map_range_first
 histograms that store the range of that filter (max - min)
 
std::unordered_map< std::string, TH1F > m_histo_map_range_second
 histograms that store the range of that filter (max - min)
 
std::unordered_map< uint, uint > m_map_N2HitCombs
 count the number of 2Hit connections for each sector,
 
std::unordered_map< uint, uint > m_map_N2HitCombs_matched
 count the number of 2Hit connections for each sector, only if sector combination was "matched" (Note: meaning of "matched" depends on the setting)
 
std::unordered_map< uint, uint > m_map_N3HitCombs
 count the number of 3Hit connections for each sector, can be used to do some statistics
 
std::unordered_map< uint, uint > m_map_N3HitCombs_matched
 count the number of 3Hit connections for each sector, only if sector combination was "matched" (Note: meaning of "matched" depends on the setting)
 
std::string m_SMFileName_first
 name of the file containing the first sectormap
 
std::string m_SMFileName_second
 name of the file containing the second sectormap
 
std::string m_setupsTreeName = "Setups"
 name of the tree all the setups are stored
 
std::string m_setupsBranchName = "name"
 name of the branch in the setups tree that holds the names of the setups
 
bool m_isCompared = false
 remember if CompareMaps already has been run, to give warnings if functions are called that need CompareMaps to have run
 

Detailed Description

A root tool that compares two Sectormaps (local root files) and produces some statistics output.

Yes we old people do use root. So get over it and open a root session to create an Object to let its magic unfold. This tool assumes that both sectormaps use the same setup (i.e. number of sectors on sensor, and filter configuration). It still may work with slightly different filters as long as the naming did not change. But if the number of sectors on sensor is different the matching of sectors will not work and the results may become misleading!

The output will be several plots comparing the filter cuts (min, max) for each of the contained filters. In addition a simple counting of sector connections is provided.

Per default only sector combinations which are matched between both sectormaps are drawn. If the option unmatchedEntries==true is set when calling CompareMaps only the sector combinations which are not matched from the first sector map are plotted.

Definition at line 38 of file SectorMapComparer.h.

Constructor & Destructor Documentation

◆ SectorMapComparer()

SectorMapComparer ( const std::string &  SMFileFirst,
const std::string &  SMFileSecond 
)

constructor

Parameters
SMFileFirstroot file name the first sector map is contained in
SMFileSecondroot file name the second sector map is contained in

Definition at line 31 of file SectorMapComparer.cc.

32  : m_SMFileName_first(SMFileFirst),
33  m_SMFileName_second(SMFileSecond)
34 {
36 };
@ c_Info
Info: for informational messages, e.g.
Definition: LogConfig.h:27
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:25
LogConfig * getLogConfig()
Returns global log system configuration.
Definition: LogSystem.h:78
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31
std::string m_SMFileName_first
name of the file containing the first sectormap
std::string m_SMFileName_second
name of the file containing the second sectormap

Member Function Documentation

◆ compareTrees()

void compareTrees ( TTree *  t_first,
TTree *  t_second,
bool  unmatchedEntries = false 
)
private

makes the comparison of two trees, and fills histograms and certain maps

Parameters
t_firstfirst tree
t_secondsecdon tree
unmatchedEntriesif true only the unmatched entries will be filled (only for the first tree)

Definition at line 111 of file SectorMapComparer.cc.

◆ countConnections()

uint countConnections ( const std::unordered_map< uint, uint > &  map,
int  layer = -1,
int  ladder = -1,
int  sensor = -1,
int  sector = -1 
)
private

counts all connections for given layer, ladder, sensor, sector.

If -1 is given for any of those it is summed over the corresponding entries This has to be called after the CompareMaps function, else the result will be zero

Parameters
mapreference to map mapping from fullsecid to number of times
layer,ladder,sensor,sectorlayer, ladder, sensor, sector number, if -1 it will be summed over

Definition at line 406 of file SectorMapComparer.cc.

◆ fillSectorToTreeIndexMap()

void fillSectorToTreeIndexMap ( TTree *  tree,
std::unordered_map< std::string, long > &  map 
)
private

fills a map that maps sector combinations in the tree to string which is a hash combining the three (two) sector ids

Parameters
treethe tree to be mapped
mapthe map which will be filled in the function

Definition at line 81 of file SectorMapComparer.cc.

◆ findTrees()

void findTrees ( TDirectory *  aDir,
std::vector< std::string > &  listOfTrees 
)
private

helper function that returns a list of names for all trees contained in the TDirectory including sub-directories

Parameters
aDira root directory pointer (e.g. TFile *)
listOfTreesthis vector will be filled with the names of the tree (NOTE: the name contains the full path (including file name))

Definition at line 266 of file SectorMapComparer.cc.

◆ getHash()

std::string getHash ( long  l1,
long  l2,
long  l3 
)
private

I was too lacy to implement a proper hash function, so I convert the three numbers into a string and use the string as hash for the map.

Parameters
l1,l2,l3just three numbers of type long
Returns
: a string which combines the three numbers which can be used as hash as the hash function for std::string already exists

Definition at line 40 of file SectorMapComparer.cc.

◆ plot()

void plot ( bool  logScale = true,
TString  pdfFileName = "",
bool  drawLegend = true 
)

will create lots of Canvases!!!

Parameters
logScaleif true the y-axis will be log scale
pdfFileNamename of the output file, has to be a file format which is supported by TCanvas::SaveAs (e.g. .pdf) if empty "" no output file will be created
drawLegendif true a legend is drawn, may hide interisting parts so one can deactivate it

Definition at line 285 of file SectorMapComparer.cc.

◆ plotSectorStats()

void plotSectorStats ( bool  logScale = true,
TString  pdfFileName = "",
bool  drawLegend = true 
)

Will create canvases showing statistics.

Parameters
logScaleif true the y-axis will be log scale
pdfFileNamename of the output file, has to a file format which is supported by TCanvas::SaveAs (e.g. .pdf) if empty "" no output file will be created
drawLegendif true a legend is drawn, may hide interisting parts so one can deactivate it

Definition at line 424 of file SectorMapComparer.cc.

◆ setLeafAddresses()

void setLeafAddresses ( TTree *  t,
std::unordered_map< std::string, double > &  filterVals,
std::unordered_map< std::string, uint > &  SecIDVals 
)
private

automatically sets the TLeaf addresses for a tree.

Currently only TLeafI and TLeafD are supported

Parameters
tthe tree for setting the addresses
filterValsthe targets for the TLeafD addresses, will be filled in the function
SecIDValsthe targets for the TLeafI addresses, will be filled in the function

Definition at line 51 of file SectorMapComparer.cc.


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