Belle II Software development
|
A root tool that compares two Sectormaps (local root files) and produces some statistics output. More...
#include <SectorMapComparer.h>
Public Member Functions | |
SectorMapComparer ()=delete | |
dont use this constructor | |
SectorMapComparer (const std::string &SMFileFirst, const std::string &SMFileSecond) | |
constructor | |
~SectorMapComparer ()=default | |
default destructor | |
void | plot (bool logScale=true, TString pdfFileName="", bool drawLegend=true) |
will create lots of Canvases!!! | |
void | plotSectorStats (bool logScale=true, TString pdfFileName="", bool drawLegend=true) |
Will create canvases showing statistics. | |
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. | |
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. | |
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 | |
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. | |
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 | |
void | compareTrees (TTree *t_first, TTree *t_second, bool unmatchedEntries=false) |
makes the comparison of two trees, and fills histograms and certain maps | |
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 | |
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.
SectorMapComparer | ( | const std::string & | SMFileFirst, |
const std::string & | SMFileSecond | ||
) |
constructor
SMFileFirst | root file name the first sector map is contained in |
SMFileSecond | root file name the second sector map is contained in |
Definition at line 31 of file SectorMapComparer.cc.
|
inlineprivate |
helper that clears all the maps used
Definition at line 140 of file SectorMapComparer.h.
void compareMaps | ( | TString | setup, |
bool | unmatchedEntries = false |
||
) |
runs the comparison for all filters (and only the filters) in the sectormap files
Definition at line 337 of file SectorMapComparer.cc.
|
private |
makes the comparison of two trees, and fills histograms and certain maps
t_first | first tree |
t_second | secdon tree |
unmatchedEntries | if true only the unmatched entries will be filled (only for the first tree) |
Definition at line 111 of file SectorMapComparer.cc.
|
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
map | reference to map mapping from fullsecid to number of times |
layer,ladder,sensor,sector | layer, ladder, sensor, sector number, if -1 it will be summed over |
Definition at line 406 of file SectorMapComparer.cc.
|
private |
fills a map that maps sector combinations in the tree to string which is a hash combining the three (two) sector ids
tree | the tree to be mapped |
map | the map which will be filled in the function |
Definition at line 81 of file SectorMapComparer.cc.
|
private |
helper function that returns a list of names for all trees contained in the TDirectory including sub-directories
aDir | a root directory pointer (e.g. TFile *) |
listOfTrees | this 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.
|
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.
l1,l2,l3 | just three numbers of type long |
Definition at line 40 of file SectorMapComparer.cc.
void plot | ( | bool | logScale = true , |
TString | pdfFileName = "" , |
||
bool | drawLegend = true |
||
) |
will create lots of Canvases!!!
logScale | if true the y-axis will be log scale |
pdfFileName | name 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 |
drawLegend | if true a legend is drawn, may hide interisting parts so one can deactivate it |
Definition at line 285 of file SectorMapComparer.cc.
void plotSectorStats | ( | bool | logScale = true , |
TString | pdfFileName = "" , |
||
bool | drawLegend = true |
||
) |
Will create canvases showing statistics.
logScale | if true the y-axis will be log scale |
pdfFileName | name 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 |
drawLegend | if true a legend is drawn, may hide interisting parts so one can deactivate it |
Definition at line 424 of file SectorMapComparer.cc.
|
private |
automatically sets the TLeaf addresses for a tree.
Currently only TLeafI and TLeafD are supported
t | the tree for setting the addresses |
filterVals | the targets for the TLeafD addresses, will be filled in the function |
SecIDVals | the targets for the TLeafI addresses, will be filled in the function |
Definition at line 51 of file SectorMapComparer.cc.
|
inline |
lists the names of the files which are used
Definition at line 85 of file SectorMapComparer.h.
|
inline |
lists all setups of sectormaps included in the two files
Definition at line 73 of file SectorMapComparer.h.
void showSetups | ( | TString | sectorMapFileName | ) |
lists all sector map setups in the specified file
Definition at line 232 of file SectorMapComparer.cc.
|
private |
histograms that store differences between the two sector maps
Definition at line 157 of file SectorMapComparer.h.
|
private |
histograms for the first sector map
Definition at line 155 of file SectorMapComparer.h.
|
private |
histograms that store the range of that filter (max - min)
Definition at line 158 of file SectorMapComparer.h.
|
private |
histograms that store the range of that filter (max - min)
Definition at line 159 of file SectorMapComparer.h.
|
private |
histograms for the second sector map
Definition at line 156 of file SectorMapComparer.h.
|
private |
remember if CompareMaps already has been run, to give warnings if functions are called that need CompareMaps to have run
Definition at line 180 of file SectorMapComparer.h.
|
private |
count the number of 2Hit connections for each sector,
Definition at line 162 of file SectorMapComparer.h.
|
private |
count the number of 2Hit connections for each sector, only if sector combination was "matched" (Note: meaning of "matched" depends on the setting)
Definition at line 164 of file SectorMapComparer.h.
|
private |
count the number of 3Hit connections for each sector, can be used to do some statistics
Definition at line 167 of file SectorMapComparer.h.
|
private |
count the number of 3Hit connections for each sector, only if sector combination was "matched" (Note: meaning of "matched" depends on the setting)
Definition at line 169 of file SectorMapComparer.h.
|
private |
name of the branch in the setups tree that holds the names of the setups
Definition at line 177 of file SectorMapComparer.h.
|
private |
name of the tree all the setups are stored
Definition at line 176 of file SectorMapComparer.h.
|
private |
name of the file containing the first sectormap
Definition at line 173 of file SectorMapComparer.h.
|
private |
name of the file containing the second sectormap
Definition at line 174 of file SectorMapComparer.h.