Belle II Software  release-05-01-25
DQMHistAnalysisTracking.cc
1 //+
2 // File : DQMHistAnalysisTracking.cc
3 // Description : Analysis of Tracking
4 //
5 // Author : Bjoern Spruck, Univerisity Mainz
6 // Date : 2018
7 //-
8 
9 
10 #include <dqm/analysis/modules/DQMHistAnalysisTracking.h>
11 #include <TROOT.h>
12 
13 using namespace std;
14 using namespace Belle2;
15 
16 //-----------------------------------------------------------------
17 // Register the Module
18 //-----------------------------------------------------------------
19 REG_MODULE(DQMHistAnalysisTracking)
20 
21 //-----------------------------------------------------------------
22 // Implementation
23 //-----------------------------------------------------------------
24 
27 {
28  // This module CAN NOT be run in parallel!
29 
30  //Parameter definition
31  addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of Histogram dir", std::string("TracksDQM"));
32  B2DEBUG(99, "DQMHistAnalysisTracking: Constructor done.");
33 }
34 
35 void DQMHistAnalysisTrackingModule::initialize()
36 {
37  gROOT->cd(); // this seems to be important, or strange things happen
38 
39  m_cTrackingError = new TCanvas((m_histogramDirectoryName + "/c_TrackingError").data());
40 
41  B2DEBUG(99, "DQMHistAnalysisTracking: initialized.");
42 }
43 
44 void DQMHistAnalysisTrackingModule::beginRun()
45 {
46  B2DEBUG(99, "DQMHistAnalysisTracking: beginRun called.");
47 
48  m_cTrackingError->Clear();
49  m_cTrackingError->SetLogz();
50 }
51 
52 void DQMHistAnalysisTrackingModule::event()
53 {
54  if (!m_cTrackingError) return;
55 
56  std::string name = "NumberTrackingErrorFlags";
57 
58  TH1* hh1 = findHist(name);
59  if (hh1 == NULL) {
60  hh1 = findHist(m_histogramDirectoryName, name);
61  }
62  if (hh1) {
63  hh1->SetStats(true); // maybe we want the mean?
64 
65  bool error_flag = false;
66  bool warn_flag = false;
67  double nGood = hh1->GetBinContent(1);
68  double nBad = hh1->GetBinContent(2);
69  double ratio = (nGood > 1) ? (nBad / nGood) : 1;
70  error_flag |= (ratio > 5e-2);
71  warn_flag |= (ratio > 1e-2);
72 
73  m_cTrackingError->cd();
74 
75  if (error_flag) {
76  m_cTrackingError->Pad()->SetFillColor(kRed);// Red
77  } else if (warn_flag) {
78  m_cTrackingError->Pad()->SetFillColor(kYellow);// Yellow
79  } else if (nBad < 10) {
80  m_cTrackingError->Pad()->SetFillColor(kGreen);// Green
81  } else {
82  m_cTrackingError->Pad()->SetFillColor(kWhite);// White
83  }
84 
85  hh1->Draw("hist");
86  }
87  m_cTrackingError->Modified();
88  m_cTrackingError->Update();
89 }
90 
91 
Belle2::DQMHistAnalysisTrackingModule
DQM Histogram Analysis for Tracking.
Definition: DQMHistAnalysisTracking.h:22
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DQMHistAnalysisModule
The base class for the histogram analysis module.
Definition: DQMHistAnalysis.h:27