Belle II Software  release-05-01-25
SectorMapComparer.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Lueck *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/trackFindingVXD/sectorMapTools/SectorMapComparer.h>
12 #include <tracking/dataobjects/FullSecID.h>
13 
14 #include <framework/logging/LogConfig.h>
15 
16 #include <TFile.h>
17 #include <TLeaf.h>
18 #include <TLeafI.h>
19 #include <TLeafD.h>
20 #include <TCanvas.h>
21 #include <TObjArray.h>
22 #include <TObject.h>
23 #include <TLegend.h>
24 
25 #include <vector>
26 #include <iostream>
27 
28 
29 
30 
31 using namespace Belle2;
32 
33 SectorMapComparer::SectorMapComparer(const std::string& SMFileFirst,
34  const std::string& SMFileSecond) : m_SMFileName_first(SMFileFirst),
35  m_SMFileName_second(SMFileSecond)
36 {
38 };
39 
40 
41 std::string
42 SectorMapComparer::getHash(long l1, long l2, long l3)
43 {
44  std::string str = std::to_string(l1) + "-" + std::to_string(l2) + "-" + std::to_string(l3);
45  return str;
46 }
47 
48 
49 
50 // sets the addresses of the leafes
51 // assumes each leaf name is unique! (Not sure if root takes care for that)
52 void
53 SectorMapComparer::setLeafAddresses(TTree* t, std::unordered_map<std::string, double>& filterVals,
54  std::unordered_map<std::string, uint>& SecIDVals)
55 {
56  TObjArray* leafList = t->GetListOfLeaves();
57  for (TObject* o : *leafList) {
58  TLeaf* l = (TLeaf*)o;
59  std::string name = l->GetName();
60  // cannot use TClass pointer here as it is TLeaf and not TLeafD or TLeafI, ClassName is virtual (gives the name of the derived)
61  TString classname = l->ClassName();
62 
63  // filter leafs of type TLeafI (sector IDs) from the
64  if (classname.EqualTo("TLeafI")) {
65  SecIDVals[name] = 0;
66  l->SetAddress(&(SecIDVals[name]));
67  } else if (classname.EqualTo("TLeafD")) {
68  filterVals[name] = 0.0;
69  l->SetAddress(&(filterVals[name]));
70  } else {
71  B2WARNING("Unsupported TLeaf type: " << l->ClassName() << ". Will skip this TLeaf.");
72  }
73 
74  }
75 }
76 
77 
78 
79 
80 // returns a map of sector combinations to the position in the branch
81 // WARNING: this messes up the addresses!!!!!!!
82 void
83 SectorMapComparer::fillSectorToTreeIndexMap(TTree* tree, std::unordered_map<std::string, long>& map)
84 {
85  // the branchnames which store the sectorIDs
86  std::vector<std::string> bNames = {"innerFullSecID", "centerFullSecID", "outerFullSecID"};
87  std::vector<uint> bVals = {0, 0, 0}; // lets hope there is no inner sector id 0! But need to be 0 here as later no check for existance in the map for segments, so default value is used.
88 
89  for (uint i = 0; i < bNames.size(); i++) {
90  TLeaf* l = tree->GetLeaf(bNames[i].c_str());
91  if (l) {
92  l->SetAddress(&(bVals[i]));
93  }
94  }
95 
96  // now loop to create the map
97  for (long i = 0; i < tree->GetEntries(); i++) {
98  tree->GetEntry(i);
99  std::string hash = getHash(bVals[0], bVals[1], bVals[2]);
100  //std::cout << hash << " " << i << std::endl;
101  map[hash] = i;
102  }
103 
104 }
105 
106 
107 
108 
109 
110 
111 // actually compares the trees (segment and triplet filters)
112 void
113 SectorMapComparer::compareTrees(TTree* t_first, TTree* t_second, bool unmatchedEntries)
114 {
115 
116  // index the second tree
117  std::unordered_map<std::string, long> indexmap_t_second;
118  // WARNING: this messes with leaf addresses of the sector ids
119  fillSectorToTreeIndexMap(t_second, indexmap_t_second);
120 
121 
122  std::unordered_map<std::string, double> vals_t_first;
123  std::unordered_map<std::string, uint> ids_t_first;
124  setLeafAddresses(t_first, vals_t_first, ids_t_first);
125 
126  std::unordered_map<std::string, double> vals_t_second;
127  std::unordered_map<std::string, uint> ids_t_second;
128  setLeafAddresses(t_second, vals_t_second, ids_t_second);
129 
130 
131  // identify Three hit combinations by existens of the branch centerID
132  bool isTriplet = t_first->GetBranch("centerFullSecID") != nullptr;
133 
134  // some cross checks
135  if (vals_t_second.size() != vals_t_first.size()) {
136  B2WARNING("Number of filters stored in the two SectorMaps seem to differ! This is per se not dangerous, but some cuts may be compared to zero.");
137  }
138 
139  // Creating histograms, using the list of leaves for indexing the histograms
140  TObjArray* leafList = t_first->GetListOfLeaves();
141  for (TObject* o : *leafList) {
142  TLeaf* l_first = (TLeaf*)o;
143  // no histograms for the sector ids
144  TString leafName = l_first->GetName();
145  if (leafName.Contains("FullSecID")) continue;
146 
147  double min = std::min(t_first->GetMinimum(leafName) , t_second->GetMinimum(leafName));
148  double max = std::max(t_first->GetMaximum(leafName) , t_second->GetMaximum(leafName));
149  double range = std::fabs(min - max);
150  // TODO: make this configurable
151  int Nbins = 100;
152 
153  // As in the current version the maps are used for several trees, cross check that histograms are not overwritten
154  if (m_histo_map_first.find(leafName.Data()) != m_histo_map_first.end() ||
155  m_histo_map_second.find(leafName.Data()) != m_histo_map_second.end() ||
156  m_histo_map_diff.find(leafName.Data()) != m_histo_map_diff.end()) {
157 
158  B2ERROR("ERROR: Histogram for key " << leafName.Data() << " already exists");
159  }
160 
161 
162  m_histo_map_first[ leafName.Data() ] = TH1F(leafName + "_first", leafName, Nbins, min, max);
163  m_histo_map_first[ leafName.Data() ].SetDirectory(nullptr);
164  m_histo_map_second[ leafName.Data() ] = TH1F(leafName + "_second", leafName , Nbins, min, max);
165  m_histo_map_second[ leafName.Data() ].SetDirectory(nullptr);
166  m_histo_map_diff[ leafName.Data() ] = TH1F(leafName + "_diff", "difference " + leafName + " (SM1 - SM2)", Nbins, -0.2 * range,
167  0.2 * range);
168  m_histo_map_diff[ leafName.Data() ].SetDirectory(nullptr);
169 
170  // histograms containing the max minus the min
171  TString niceName = leafName;
172  niceName.ReplaceAll("_min", "");
173  niceName.ReplaceAll("_max", "");
174  m_histo_map_range_first[ leafName.Data() ] = TH1F(leafName + "_range_first", niceName + " range (max - min)", Nbins, 0, range);
175  m_histo_map_range_first[ leafName.Data() ].SetDirectory(nullptr);
176  m_histo_map_range_second[ leafName.Data() ] = TH1F(leafName + "_range_second", niceName + " range (max - min)", Nbins, 0, range);
177  m_histo_map_range_second[ leafName.Data() ].SetDirectory(nullptr);
178  }
179 
180 
181 
182  // loop over t1, and get corresponding value for t2
183  for (long i = 0; i < t_first->GetEntries(); i++) {
184  t_first->GetEntry(i);
185 
186  std::string hash = getHash(ids_t_first["innerFullSecID"], ids_t_first["centerFullSecID"], ids_t_first["outerFullSecID"]);
187 
188 
189  // count all connections
190  if (isTriplet) m_map_N3HitCombs[ ids_t_first["outerFullSecID"] ]++;
191  else m_map_N2HitCombs[ ids_t_first["outerFullSecID"] ]++;
192 
193 
194  // filter connections inside both sector maps, if unmatchedEntries is true only the unmatched entries will be selected
195  if (indexmap_t_second.find(hash) == indexmap_t_second.end()) {
196  // case this sector combination not matched, can be thrown away if unmatchedEntries is set false
197  if (!unmatchedEntries) continue;
198  } else {
199  // sector combination is matched, read second tree and skip if unmatchedEntries is set
200  t_second->GetEntry(indexmap_t_second[hash]);
201  if (unmatchedEntries) continue;
202  }
203 
204  // only count the matched ones
205  if (isTriplet) m_map_N3HitCombs_matched[ ids_t_first["outerFullSecID"] ]++;
206  else m_map_N2HitCombs_matched[ ids_t_first["outerFullSecID"] ]++;
207 
208  // now fill the histograms
209  // NOTE: in case unmatchedEntries==true the values in the the second tree do not make any sense, so not fill any histograms with them
210  for (TObject* o : *leafList) {
211  TString leafName = o->GetName();
212  // TODO: find a better way to destinguish the secid leaves from the others
213  if (leafName.Contains("FullSecID")) continue;
214  m_histo_map_first[ leafName.Data() ].Fill(vals_t_first[leafName.Data()]);
215  if (!unmatchedEntries) {
216  m_histo_map_second[ leafName.Data() ].Fill(vals_t_second[leafName.Data()]);
217  m_histo_map_diff[ leafName.Data() ].Fill(vals_t_first[leafName.Data()] - vals_t_second[leafName.Data()]);
218  }
219  // calculate the range only for the max
220  if (leafName.Contains("_max")) {
221  TString minLeafName = leafName;
222  minLeafName.ReplaceAll("_max", "_min");
223  m_histo_map_range_first[ leafName.Data() ].Fill(vals_t_first[leafName.Data()] - vals_t_first[minLeafName.Data()]);
224  if (!unmatchedEntries) m_histo_map_range_second[ leafName.Data() ].Fill(vals_t_second[leafName.Data()] -
225  vals_t_second[minLeafName.Data()]);
226  }
227  }
228 
229  }
230 
231 }
232 
233 void
234 SectorMapComparer::showSetups(TString secmapFileName)
235 {
236  TFile* f = TFile::Open(secmapFileName);
237  if (!f->IsOpen()) {
238  B2WARNING("File not opened: " << secmapFileName);
239  return;
240  }
241 
242  TTree* t = (TTree*)f->Get(m_setupsTreeName.c_str());
243  if (t == nullptr) {
244  B2WARNING("tree not found! tree name: " << m_setupsTreeName);
245  return;
246  }
247 
248  TString* setupKeyName = nullptr;
249  t->SetBranchAddress(m_setupsBranchName.c_str(), & setupKeyName);
250  if (setupKeyName == nullptr) {
251  B2WARNING("setupKeyName not found");
252  return;
253  }
254 
255  std::cout << "Following setups found for file: " << secmapFileName << std::endl;
256  std::cout << "================================ " << std::endl;
257  for (long i = 0; i < t->GetEntries(); ++i) {
258  t->GetEntry(i);
259  std::cout << (*setupKeyName) << std::endl;
260  }
261 
262  if (setupKeyName) delete setupKeyName;
263 }
264 
265 // fills the listOfTrees with the names of all trees in this directory (including their full root-path)
266 // loops recursively over all subdirectories
267 void
268 SectorMapComparer::findTrees(TDirectory* aDir, std::vector<std::string>& listOfTrees)
269 {
270  TList* keys = aDir->GetListOfKeys();
271  for (TObject* akey : *keys) {
272 
273  // there should be no check needed as each key should be attached to an object
274  TObject* o = aDir->Get(akey->GetName());
275 
276 
277  if (o->InheritsFrom(TDirectory::Class())) findTrees((TDirectory*)o, listOfTrees);
278  if (o->InheritsFrom(TTree::Class())) {
279  listOfTrees.emplace_back(std::string(aDir->GetPath()) + std::string("/") + std::string(o->GetName()));
280  }
281  }
282 
283 }
284 
285 
286 void
287 SectorMapComparer::plot(bool logScale, TString pdfFileName, bool drawLegend)
288 {
289 
290  if (!m_isCompared) {
291  B2WARNING("You need to run SectorMapComparer::CompareMaps before this function!");
292  return;
293  }
294 
295  int n = m_histo_map_first.size();
296  int counter = 1;
297  for (const auto& hist : m_histo_map_first) {
298  std::string aName = hist.first;
299  TCanvas* can = new TCanvas((aName + "_can").c_str(), aName.c_str());
300  can->Divide(1, 3);
301 
302  can->cd(1)->SetLogy((int)logScale);
303  // TODO: pretty sure this is a memory leak, but right now I do not care
304  // draw legend only for first
305  TLegend* l = new TLegend(0.15, 0.7, 0.3, 0.9);
306  TH1* hbuff = m_histo_map_first[ aName ].DrawCopy();
307  l->AddEntry(hbuff, "first SectorMap", "lpf");
308  m_histo_map_second[ aName ].SetLineColor(kRed);
309  hbuff = m_histo_map_second[ aName ].DrawCopy("same");
310  l->AddEntry(hbuff, "second SectorMap", "lpf");
311  if (drawLegend) l->Draw();
312 
313  can->cd(2)->SetLogy((int)logScale);;
314  m_histo_map_diff[ aName ].DrawCopy();
315 
316  if (TString(aName).Contains("_max")) {
317  can->cd(3)->SetLogy((int)logScale);
318  m_histo_map_range_first[ aName ].DrawCopy();
319  m_histo_map_range_second[ aName ].SetLineColor(kRed);
320  m_histo_map_range_second[ aName ].DrawCopy("same");
321  }
322 
323  // if file name is specified plot directly to pdf file
324  if (pdfFileName != "") {
325  if (n == 1) can->SaveAs(pdfFileName);
326  else {
327  if (counter == 1) can->SaveAs(pdfFileName + "(");
328  else if (counter == n) can->SaveAs(pdfFileName + ")");
329  else can->SaveAs(pdfFileName);
330  }
331  }
332  counter++;
333  }
334 
335 }
336 
337 
338 void
339 SectorMapComparer::compareMaps(TString setupName, bool unmatchedEntries)
340 {
341  B2INFO("comparing SectorMaps in the following files");
342  B2INFO("first: " << m_SMFileName_first);
343  B2INFO("second: " << m_SMFileName_second);
344 
345  TFile* f_first = TFile::Open(m_SMFileName_first.c_str());
346  TFile* f_second = TFile::Open(m_SMFileName_second.c_str());
347 
348  if (!f_first->IsOpen() || !f_first->IsOpen()) {
349  B2ERROR("ERROR: one of the files not open");
350 
351  if (f_first) f_first->Close();
352  if (f_second) f_second->Close();
353  return;
354  }
355 
356  // get the list of trees from the first file (for second file assume same trees)
357  std::vector<std::string> listOfTrees;
358  findTrees(f_first, listOfTrees);
359 
360  // clear the maps, else old results will be mixed with this run
361  clearMaps();
362 
363  for (const std::string& tname_first : listOfTrees) {
364 
365  // only look at the trees for the specified Setup
366  if (!TString(tname_first).Contains(setupName)) continue;
367 
368 
369  // assume second file has
370  std::string tname_second = tname_first;
371  tname_second.replace(0, m_SMFileName_first.length(), m_SMFileName_second);
372 
373 
374 
375  TTree* t_first = (TTree*)f_first->Get(tname_first.c_str());
376  TTree* t_second = (TTree*)f_second->Get(tname_second.c_str());
377 
378  // filter out the sector id and test for consistency
379  if (TString(tname_first).Contains("CompactSecIDs")) {
380  if (t_first->GetEntries() != t_second->GetEntries())
381  B2FATAL("The number of entries in CompactSecIDs should be identical! This indicates that two sectormaps with"
382  " different sectors on sensors are compared which will lead to wrong results! " << std::endl <<
383  "# CompactSecIDs SM1: " << t_first->GetEntries() << std::endl <<
384  "# CompactSecIDs SM2: " << t_second->GetEntries() << std::endl
385  );
386  // we dont compare those
387  continue;
388  }
389 
390  B2INFO("Comparing tree: " << tname_first << " with tree: " << tname_second << std::endl);
391 
392  if (!t_first || !t_second) {
393  B2ERROR("One of the trees not found!");
394  continue;
395  }
396 
397  compareTrees(t_first, t_second, unmatchedEntries);
398  }
399 
400  f_first->Close();
401  f_second->Close();
402 
403  m_isCompared = true;
404 }
405 
406 
407 uint
408 SectorMapComparer::countConnections(const std::unordered_map<uint, uint>& map, int layer, int ladder, int sensor, int sector)
409 {
410  uint result = 0;
411  for (const auto& entry : map) {
412  // convert to FullSecID
413  FullSecID fullSID(entry.first);
414  if (layer >= 0 && fullSID.getLayerNumber() != layer) continue;
415  if (ladder >= 0 && fullSID.getLadderNumber() != ladder) continue;
416  if (sensor >= 0 && fullSID.getVxdID().getSensorNumber() != sensor) continue;
417  if (sector >= 0 && fullSID.getSecID() != sector) continue;
418 
419  result += entry.second;
420  }
421  return result;
422 }
423 
424 
425 void
426 SectorMapComparer::plotSectorStats(bool logScale, TString pdfFileName, bool drawLegend)
427 {
428  if (!m_isCompared) {
429  B2WARNING("You need to run SectorMapComparer::CompareMaps before this function!");
430  return;
431  }
432 
433  TH1F h_2hits("h_2hits", "number of two hit connections starting at ith layer; layer; number connections", 7, -0.5, 6.5);
434  // stats box does not give any useful information, so deactivate it
435  h_2hits.SetStats(false);
436  // make some copies
437  TH1F h_2hits_matched(h_2hits);
438  h_2hits_matched.SetName("h2hits_matched");
439  h_2hits_matched.SetLineColor(kRed);
440  // make copies for the three hit connections
441  TH1F h_3hits(h_2hits);
442  h_3hits.SetName("h_3hits");
443  h_3hits.SetTitle("number of three hit connections starting at ith layer; layer; number connections");
444  TH1F h_3hits_matched(h_3hits);
445  h_3hits_matched.SetName("h_3hits_matched");
446  h_3hits_matched.SetLineColor(kRed);
447 
448  for (int ilayer = 1; ilayer < 7; ilayer++) {
449 
450  // the bin is the same for all
451  int bin = h_2hits.FindBin(ilayer);
452  h_2hits.SetBinContent(bin, countConnections(m_map_N2HitCombs, ilayer, -1, -1, -1));
453  h_2hits_matched.SetBinContent(bin, countConnections(m_map_N2HitCombs_matched, ilayer, -1, -1, -1));
454  h_3hits.SetBinContent(bin, countConnections(m_map_N3HitCombs, ilayer, -1, -1, -1));
455  h_3hits_matched.SetBinContent(bin, countConnections(m_map_N3HitCombs_matched, ilayer, -1, -1, -1));
456  }
457 
458  TCanvas* can = new TCanvas("secStats", "secStats");
459  can->Divide(1, 2);
460  can->cd(1)->SetLogy((int)logScale);
461  // TODO: potential memory leak, but I dont care
462  TLegend* l = new TLegend(0.15, 0.7, 0.3, 0.9);
463 
464  TH1* hbuff = h_2hits.DrawCopy();
465  l->AddEntry(hbuff, "all from first map", "lpf");
466  hbuff = h_2hits_matched.DrawCopy("same");
467  l->AddEntry(hbuff, "only matched ", "lpf");
468  if (drawLegend) l->Draw();
469 
470  can->cd(2)->SetLogy((int)logScale);
471  h_3hits.DrawCopy();
472  h_3hits_matched.DrawCopy("same");
473 
474 
475 
476  // a stupid way of counting the number of sensors contained without having to invoke the geometry
477  std::vector< std::unordered_map<std::string, int> > sensorsInLayer2Hits(6);
478  for (const auto& entry : m_map_N2HitCombs) {
479  VxdID id = FullSecID(entry.first).getVxdID();
480  sensorsInLayer2Hits[id.getLayerNumber() - 1][(std::string)id ] = 1;
481  }
482  std::vector< std::unordered_map<std::string, int> > sensorsInLayer3Hits(6);
483  for (const auto& entry : m_map_N3HitCombs) {
484  VxdID id = FullSecID(entry.first).getVxdID();
485  sensorsInLayer3Hits[id.getLayerNumber() - 1][(std::string)id] = 1;
486  }
487  // Reusing old histograms!
488  for (int i = 1; i <= 6; i++) {
489  // assumes binning is still the same for all hists!
490  int bin = 0;
491  bin = h_3hits.FindBin(i);
492 
493  int nSensors2Hits = sensorsInLayer2Hits[i - 1].size();
494  int nSensors3Hits = sensorsInLayer3Hits[i - 1].size();
495 
496  if (nSensors2Hits > 0) {
497  h_2hits.SetBinContent(bin, h_2hits.GetBinContent(bin) / nSensors2Hits);
498  h_2hits_matched.SetBinContent(bin, h_2hits_matched.GetBinContent(bin) / nSensors2Hits);
499  } else {
500  B2WARNING("No sensors found in layer " << i);
501  }
502 
503  if (nSensors3Hits > 0) {
504  h_3hits.SetBinContent(bin, h_3hits.GetBinContent(bin) / nSensors3Hits);
505  h_3hits_matched.SetBinContent(bin, h_3hits_matched.GetBinContent(bin) / nSensors3Hits);
506  } else {
507  B2WARNING("No sensors found in layer " << i);
508  }
509  }
510 
511  TCanvas* can2 = new TCanvas("ConPerSensor", "Connections per sensor");
512  can2->Divide(1, 2);
513  can2->cd(1)->SetLogy((int)logScale);
514  // TODO: potential memory leak, but I dont care
515  TLegend* l2 = new TLegend(0.15, 0.7, 0.3, 0.9);
516 
517  h_2hits.SetTitle("average number of 2Hit combinations per sensor starting at ith layer; layer; avg. connections/sensor");
518  hbuff = h_2hits.DrawCopy();
519  l2->AddEntry(hbuff, "all from first map", "lpf");
520  hbuff = h_2hits_matched.DrawCopy("same");
521  l2->AddEntry(hbuff, "only matched ", "lpf");
522  if (drawLegend) l2->Draw();
523 
524  can2->cd(2)->SetLogy((int)logScale);
525  h_3hits.SetTitle("average number of 3Hit combinations per sensor starting at ith layer; layer; avg. connections/sensor");
526  h_3hits.DrawCopy();
527  h_3hits_matched.DrawCopy("same");
528 
529 
530 
531  if (pdfFileName != "") {
532  can->SaveAs(pdfFileName + "(");
533  can2->SaveAs(pdfFileName + ")");
534  }
535 
536 }
537 
538 
539 
540 
Belle2::SectorMapComparer::clearMaps
void clearMaps()
helper that clears all the maps used
Definition: SectorMapComparer.h:150
Belle2::SectorMapComparer::m_histo_map_first
std::unordered_map< std::string, TH1F > m_histo_map_first
histograms for the first sector map
Definition: SectorMapComparer.h:165
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::SectorMapComparer::compareMaps
void compareMaps(TString setup, bool unmatchedEntries=false)
runs the comparison for all filters (and only the filters) in the sectormap files
Definition: SectorMapComparer.cc:339
Belle2::SectorMapComparer::getHash
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 ...
Definition: SectorMapComparer.cc:42
Belle2::SectorMapComparer::m_map_N3HitCombs_matched
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:...
Definition: SectorMapComparer.h:179
Belle2::SectorMapComparer::m_histo_map_diff
std::unordered_map< std::string, TH1F > m_histo_map_diff
histograms that store differences between the two sector maps
Definition: SectorMapComparer.h:167
Belle2::LogConfig::setLogLevel
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:27
Belle2::SectorMapComparer::SectorMapComparer
SectorMapComparer()=delete
dont use this constructor
Belle2::SectorMapComparer::m_histo_map_second
std::unordered_map< std::string, TH1F > m_histo_map_second
histograms for the second sector map
Definition: SectorMapComparer.h:166
Belle2::SectorMapComparer::m_map_N2HitCombs
std::unordered_map< uint, uint > m_map_N2HitCombs
count the number of 2Hit connections for each sector,
Definition: SectorMapComparer.h:172
Belle2::FullSecID::getVxdID
VxdID getVxdID() const
returns VxdID of sensor.
Definition: FullSecID.h:148
Belle2::LogConfig::c_Info
@ c_Info
Info: for informational messages, e.g.
Definition: LogConfig.h:37
Belle2::SectorMapComparer::plotSectorStats
void plotSectorStats(bool logScale=true, TString pdfFileName="", bool drawLegend=true)
Will create canvases showing statistics.
Definition: SectorMapComparer.cc:426
Belle2::SectorMapComparer::m_isCompared
bool m_isCompared
remember if CompareMaps already has been run, to give warnings if functions are called that need Comp...
Definition: SectorMapComparer.h:190
Belle2::SectorMapComparer::m_SMFileName_first
std::string m_SMFileName_first
name of the file containing the first sectormap
Definition: SectorMapComparer.h:183
Belle2::SectorMapComparer::findTrees
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-...
Definition: SectorMapComparer.cc:268
Belle2::SectorMapComparer::m_setupsBranchName
std::string m_setupsBranchName
name of the branch in the setups tree that holds the names of the setups
Definition: SectorMapComparer.h:187
Belle2::FullSecID
Class to identify a sector inside of the VXD.
Definition: FullSecID.h:43
Belle2::LogSystem::getLogConfig
LogConfig * getLogConfig()
Returns global log system configuration.
Definition: LogSystem.h:88
Belle2::SectorMapComparer::plot
void plot(bool logScale=true, TString pdfFileName="", bool drawLegend=true)
will create lots of Canvases!!!
Definition: SectorMapComparer.cc:287
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SectorMapComparer::m_setupsTreeName
std::string m_setupsTreeName
name of the tree all the setups are stored
Definition: SectorMapComparer.h:186
Belle2::SectorMapComparer::m_histo_map_range_first
std::unordered_map< std::string, TH1F > m_histo_map_range_first
histograms that store the range of that filter (max - min)
Definition: SectorMapComparer.h:168
Belle2::FullSecID::getSecID
short int getSecID() const
returns SecID of current FullSecID (only unique for each sensor).
Definition: FullSecID.h:156
Belle2::FullSecID::getLayerNumber
short int getLayerNumber() const
returns LayerID compatible with basf2 standards.
Definition: FullSecID.h:132
Belle2::SectorMapComparer::setLeafAddresses
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.
Definition: SectorMapComparer.cc:53
Belle2::VxdID::getSensorNumber
baseType getSensorNumber() const
Get the sensor id.
Definition: VxdID.h:110
Belle2::SectorMapComparer::m_map_N2HitCombs_matched
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:...
Definition: SectorMapComparer.h:174
Belle2::SectorMapComparer::m_SMFileName_second
std::string m_SMFileName_second
name of the file containing the second sectormap
Definition: SectorMapComparer.h:184
Belle2::LogSystem::Instance
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:33
Belle2::SectorMapComparer::fillSectorToTreeIndexMap
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 (...
Definition: SectorMapComparer.cc:83
Belle2::SectorMapComparer::countConnections
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.
Definition: SectorMapComparer.cc:408
Belle2::SectorMapComparer::m_map_N3HitCombs
std::unordered_map< uint, uint > m_map_N3HitCombs
count the number of 3Hit connections for each sector, can be used to do some statistics
Definition: SectorMapComparer.h:177
Belle2::FullSecID::getLadderNumber
int getLadderNumber() const
returns LadderID compatible with basf2 standards
Definition: FullSecID.h:140
Belle2::SectorMapComparer::showSetups
void showSetups()
lists all setups of sectormaps included in the two files
Definition: SectorMapComparer.h:83
Belle2::SectorMapComparer::m_histo_map_range_second
std::unordered_map< std::string, TH1F > m_histo_map_range_second
histograms that store the range of that filter (max - min)
Definition: SectorMapComparer.h:169
Belle2::SectorMapComparer::compareTrees
void compareTrees(TTree *t_first, TTree *t_second, bool unmatchedEntries=false)
makes the comparison of two trees, and fills histograms and certain maps
Definition: SectorMapComparer.cc:113