Belle II Software  release-05-01-25
DQMHistAnalysisV0.cc
1 //+
2 // File : DQMHistAnalysisV0.cc
3 // Description : Overlay plotting for V0
4 //
5 // Author : Bryan Fulsom (PNNL), B Spruck
6 // Date : 2019-01-17
7 //-
8 
9 
10 #include <dqm/analysis/modules/DQMHistAnalysisV0.h>
11 
12 #include <TFile.h>
13 #include <TROOT.h>
14 #include <TStyle.h>
15 #include <TString.h>
16 #include <TH2.h>
17 #include <TGraph.h>
18 
19 using namespace std;
20 using namespace Belle2;
21 
22 //-----------------------------------------------------------------
23 // Register the Module
24 //-----------------------------------------------------------------
25 REG_MODULE(DQMHistAnalysisV0)
26 
27 //-----------------------------------------------------------------
28 // Implementation
29 //-----------------------------------------------------------------
30 
33 {
34  //Parameter definition
35  addParam("OverlayPath", m_OverlayPath, "Path to CAD drawings", std::string(""));
36 
37 }
38 
39 
40 void DQMHistAnalysisV0Module::initialize()
41 {
42  B2INFO("DQMHistAnalysisV0: initialized.");
43 
44  gROOT->cd();
45  for (int i = 0; i < 32; i++) {
46  m_c_xvsy[i] = new TCanvas(Form("V0Object/c_xvsy[%i]", i), Form("c_xvsy[%i]", i), 800, 800);
47  }
48 
49  m_c_xvsz = new TCanvas("V0Object/c_xvsz", "c_xvsz", 1500, 400); //Stretch in x to enhance visibility
50 
51  auto* m_fh = new TFile(Form("%s/v0cad.root", m_OverlayPath.c_str()));
52 
53  contLevelXY.resize(32);
54  for (int i = 0; i < 32; i++) {
55  contLevelXY[i] = new TList();
56  m_fh->cd();
57  if (m_fh->cd(Form("h_%dc", i))) {
58  for (int j = 0; j < 500; j++) {
59  auto curv = gDirectory->Get(Form("Graph_%d", j));
60  if (!curv) break;
61  contLevelXY[i]->AddLast(curv);
62  }
63  }
64  }
65  {
66  contLevelXZ = new TList();
67  m_fh->cd();
68  if (m_fh->cd("h_xzc")) {
69  for (int j = 0; true; j++) {
70  auto curv = gDirectory->Get(Form("Graph_%d", j));
71  if (!curv) break;
72  contLevelXZ->AddLast(curv);
73  }
74  }
75  }
77  gROOT->cd();
78 }
79 
80 
81 void DQMHistAnalysisV0Module::event()
82 {
83 
84  //gStyle requirements
85  gStyle->SetOptStat(0);
86  gStyle->SetPalette(kViridis, 0, 0.7);
87  for (int i = 0; i < 32; i++) {
88  TH2* h = (TH2*) findHist(Form("V0Objects/xvsy[%i]", i));
89  m_c_xvsy[i]->cd();
90  if (h) h->Draw("COLZ");
91 
92  TList* c = contLevelXY[i];
93  if (c && c->GetSize() > 0) {
94  auto* curv = (TGraph*)c->First();
95  for (int j = 0; j < c->GetSize(); j++) {
96  //auto* gc = (TGraph*)curv->Clone();
97  //gc->Draw("C");
98  curv->Draw("L");
99  curv = (TGraph*)c->After(curv); // Get Next graph
100  }
101  }
102 
103  m_c_xvsy[i]->Modified();
104  m_c_xvsy[i]->Update();
105  }
106 
107  TH2* hxz = (TH2*) findHist("V0Objects/xvsz");
108  m_c_xvsz->cd();
109 
110  // create a new pad for every event? -> mem leak!
111 
112  m_c_xvsz->cd();
113  if (hxz) hxz->Draw("COLZ");
114  {
115  TList* c = contLevelXZ;
116  if (c && c->GetSize() > 0) {
117  auto* curv = (TGraph*)c->First();
118  for (int j = 0; j < c->GetSize(); j++) {
119  //auto* gc = (TGraph*)curv->Clone();
120  //gc->Draw("C");
121  curv->Draw("L");
122  curv = (TGraph*)c->After(curv); // Get Next graph
123  }
124  }
125  }
126 
127  m_c_xvsz->Modified();
128  m_c_xvsz->Update();
129 
130 }
131 
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::DQMHistAnalysisV0Module
Class definition for the output module of Sequential ROOT I/O.
Definition: DQMHistAnalysisV0.h:23
Belle2::DQMHistAnalysisModule
The base class for the histogram analysis module.
Definition: DQMHistAnalysis.h:27