Belle II Software  release-06-02-00
DQMHistAnalysisPXDTrackCharge.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 //+
9 // File : DQMHistAnalysisPXDTrackCharge.cc
10 // Description : Analysis of PXD Cluster Charge
11 //-
12 
13 
14 #include <dqm/analysis/modules/DQMHistAnalysisPXDTrackCharge.h>
15 #include <TROOT.h>
16 #include <TStyle.h>
17 #include <TClass.h>
18 #include <TLatex.h>
19 #include <vxd/geometry/GeoCache.h>
20 #include <TKey.h>
21 
22 #include <RooDataHist.h>
23 #include <RooAbsPdf.h>
24 #include <RooPlot.h>
25 
26 
27 using namespace std;
28 using namespace Belle2;
29 
30 //-----------------------------------------------------------------
31 // Register the Module
32 //-----------------------------------------------------------------
33 REG_MODULE(DQMHistAnalysisPXDTrackCharge)
34 
35 //-----------------------------------------------------------------
36 // Implementation
37 //-----------------------------------------------------------------
38 
41 {
42  // This module CAN NOT be run in parallel!
43 
44  //Parameter definition
45  addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of Histogram dir", std::string("PXDER"));
46  addParam("RangeLow", m_rangeLow, "Lower border for fit", 20.);
47  addParam("RangeHigh", m_rangeHigh, "High border for fit", 80.);
48 // addParam("PeakBefore", m_peakBefore, "Range for fit before peak (positive)", 5.);
49 // addParam("PeakAfter", m_peakAfter, "Range for after peak", 40.);
50  addParam("PVPrefix", m_pvPrefix, "PV Prefix", std::string("DQM:PXD:TrackCharge:"));
51  addParam("useEpics", m_useEpics, "Whether to update EPICS PVs.", false);
52  addParam("RefHistoFile", m_refFileName, "Reference histrogram file name", std::string("refHisto.root"));
53  addParam("ColorAlert", m_color, "Whether to show the color alert", true);
54 
55  B2DEBUG(99, "DQMHistAnalysisPXDTrackCharge: Constructor done.");
56 }
57 
58 DQMHistAnalysisPXDTrackChargeModule::~DQMHistAnalysisPXDTrackChargeModule()
59 {
60 #ifdef _BELLE2_EPICS
61  if (m_useEpics) {
62  if (ca_current_context()) ca_context_destroy();
63  }
64 #endif
65 }
66 
67 void DQMHistAnalysisPXDTrackChargeModule::initialize()
68 {
69  B2DEBUG(99, "DQMHistAnalysisPXDTrackCharge: initialized.");
70 
71  m_refFile = NULL;
72  if (m_refFileName != "") {
73  m_refFile = new TFile(m_refFileName.data());
74  }
75 
76  m_monObj = getMonitoringObject("pxd");
77  const VXD::GeoCache& geo = VXD::GeoCache::getInstance();
78 
79  m_rfws = new RooWorkspace("w");
80  m_rfws->factory("Landau::landau(x[0,100],ml[20,10,50],sl[5,1,30])");
81  m_rfws->factory("Gaussian::gauss(x,mg[0],sg[2,0.1,10])");
82  m_rfws->factory("FCONV::lxg(x,landau,gauss)");
83 
84  m_x = m_rfws->var("x");
85  m_x->setRange("signal", m_rangeLow, m_rangeHigh);
86 
87  // collect the list of all PXD Modules in the geometry here
88  std::vector<VxdID> sensors = geo.getListOfSensors();
89  for (VxdID& aVxdID : sensors) {
90  VXD::SensorInfoBase info = geo.getSensorInfo(aVxdID);
91  if (info.getType() != VXD::SensorInfoBase::PXD) continue;
92  m_PXDModules.push_back(aVxdID); // reorder, sort would be better
93 
94  std::string name = "PXD_Track_Cluster_Charge_" + (std::string)aVxdID;
95  std::replace(name.begin(), name.end(), '.', '_');
96  m_cChargeMod[aVxdID] = new TCanvas((m_histogramDirectoryName + "/c_Fit_" + name).data());
97  if (aVxdID == VxdID("1.5.1")) {
98  for (int s = 0; s < 6; s++) {
99  for (int d = 0; d < 4; d++) {
100  m_cChargeModASIC[aVxdID][s][d] = new TCanvas((m_histogramDirectoryName + "/c_Fit_" + name + Form("_s%d_d%d", s + 1, d + 1)).data());
101  }
102  }
103  m_hChargeModASIC2d[aVxdID] = new TH2F(("hPXD_TCChargeMPV_" + name).data(),
104  ("PXD TCCharge MPV " + name + ";Switcher;DCD;MPV").data(),
105  6, 0.5, 6.5, 4, 0.5, 4.5);
106  m_cChargeModASIC2d[aVxdID] = new TCanvas((m_histogramDirectoryName + "/c_TCCharge_MPV_" + name).data());
107  }
108  }
109  std::sort(m_PXDModules.begin(), m_PXDModules.end()); // back to natural order
110 
111  gROOT->cd(); // this seems to be important, or strange things happen
112 
113  m_cTrackedClusters = new TCanvas((m_histogramDirectoryName + "/c_TrackedClusters").data());
114  m_hTrackedClusters = new TH1F("hPXDTrackedClusters", "PXD Tracked Clusters/Event;Module", 40, 0, 40);
115  m_hTrackedClusters->Draw();
116  auto ax = m_hTrackedClusters->GetXaxis();
117  if (ax) {
118  ax->Set(m_PXDModules.size(), 0, m_PXDModules.size());
119  for (unsigned int i = 0; i < m_PXDModules.size(); i++) {
120  TString ModuleName = (std::string)m_PXDModules[i];
121  ax->SetBinLabel(i + 1, ModuleName);
122  }
123  } else B2ERROR("no axis");
124 
125  m_cCharge = new TCanvas((m_histogramDirectoryName + "/c_TrackCharge").data());
126  m_monObj->addCanvas(m_cCharge);
127 
128  m_gCharge = new TGraphErrors();
129  m_gCharge->SetName("Track_Cluster_Charge");
130  m_gCharge->SetTitle("Track Cluster Charge");
131 
133  m_line_up = new TLine(0, 10, m_PXDModules.size(), 10);
134  m_line_mean = new TLine(0, 16, m_PXDModules.size(), 16);
135  m_line_low = new TLine(0, 3, m_PXDModules.size(), 3);
136  m_line_up->SetHorizontal(true);
137  m_line_up->SetLineColor(kMagenta);// Green
138  m_line_up->SetLineWidth(3);
139  m_line_up->SetLineStyle(7);
140  m_line_mean->SetHorizontal(true);
141  m_line_mean->SetLineColor(kGreen);// Black
142  m_line_mean->SetLineWidth(3);
143  m_line_mean->SetLineStyle(4);
144  m_line_low->SetHorizontal(true);
145  m_line_low->SetLineColor(kMagenta);
146  m_line_low->SetLineWidth(3);
147  m_line_low->SetLineStyle(7);
148 
149  m_fMean = new TF1("f_Mean", "pol0", 0, m_PXDModules.size());
150  m_fMean->SetParameter(0, 50);
151  m_fMean->SetLineColor(kYellow);
152  m_fMean->SetLineWidth(3);
153  m_fMean->SetLineStyle(7);
154  m_fMean->SetNpx(m_PXDModules.size());
155  m_fMean->SetNumberFitPoints(m_PXDModules.size());
156 
157 #ifdef _BELLE2_EPICS
158  if (m_useEpics) {
159  if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback), "ca_context_create");
160  mychid.resize(3);
161  SEVCHK(ca_create_channel((m_pvPrefix + "Mean").data(), NULL, NULL, 10, &mychid[0]), "ca_create_channel failure");
162  SEVCHK(ca_create_channel((m_pvPrefix + "Diff").data(), NULL, NULL, 10, &mychid[1]), "ca_create_channel failure");
163  SEVCHK(ca_create_channel((m_pvPrefix + "Status").data(), NULL, NULL, 10, &mychid[2]), "ca_create_channel failure");
164  SEVCHK(ca_pend_io(5.0), "ca_pend_io failure");
165  }
166 #endif
167 }
168 
169 
170 void DQMHistAnalysisPXDTrackChargeModule::beginRun()
171 {
172  B2DEBUG(99, "DQMHistAnalysisPXDTrackCharge: beginRun called.");
173 
174  m_cCharge->Clear();
175 }
176 
177 void DQMHistAnalysisPXDTrackChargeModule::event()
178 {
179  if (!m_cCharge) return;
180 
181  gStyle->SetOptStat(0);
182  gStyle->SetStatStyle(1);
183  gStyle->SetOptDate(22);// Date and Time in Bottom Right, does no work
184 
185  bool enough = false;
186 
187 // auto landau = m_rfws->pdf("landau");
188 // auto gauss = m_rfws->pdf("gauss");
189  auto model = m_rfws->pdf("lxg");
190 
191  auto ml = m_rfws->var("ml");
192 // auto sl = m_rfws->var("sl");
193 // auto mg = m_rfws->var("mg");
194 // auto sg = m_rfws->var("sg");
195 
196  {
197  m_cTrackedClusters->Clear();
198  m_cTrackedClusters->cd();
199  m_hTrackedClusters->Reset();
200 
201  std::string name = "Tracked_Clusters"; // new name
202  TH1* hh2 = findHist(m_histogramDirectoryName, "PXD_Tracked_Clusters");
203  if (hh2) {
204  auto scale = hh2->GetBinContent(0);// overflow misused as event counter!
205  if (scale > 0) {
206  int j = 1;
207  for (int i = 0; i < 64; i++) {
208  auto layer = (((i >> 5) & 0x1) + 1);
209  auto ladder = ((i >> 1) & 0xF);
210  auto sensor = ((i & 0x1) + 1);
211 
212  auto id = Belle2::VxdID(layer, ladder, sensor);
213  // Check if sensor exist
214  if (Belle2::VXD::GeoCache::getInstance().validSensorID(id)) {
215  m_hTrackedClusters->SetBinContent(j, hh2->GetBinContent(i + 1) / scale);
216  j++;
217  }
218  }
219  }
220  m_hTrackedClusters->SetName(name.data());
221  m_hTrackedClusters->SetTitle("Tracked Clusters/Event");
222  m_hTrackedClusters->SetFillColor(kWhite);
223  m_hTrackedClusters->SetStats(kFALSE);
224  m_hTrackedClusters->SetLineStyle(1);// 2 or 3
225  m_hTrackedClusters->SetLineColor(kBlue);
226  m_hTrackedClusters->Draw("hist");
227 
228  TH1* href2 = GetHisto("ref/" + m_histogramDirectoryName + "/" + name);
229 
230  if (href2) {
231  href2->SetLineStyle(3);// 2 or 3
232  href2->SetLineColor(kBlack);
233  href2->Draw("same,hist");
234  }
235 
236  // keep this commented code as we may have excluded modules in phase4
237 // auto tt = new TLatex(5.5, 0, " 1.3.2 Module is excluded, please ignore");
238 // tt->SetTextAngle(90);// Rotated
239 // tt->SetTextAlign(12);// Centered
240 // tt->Draw();
241  }
242  }
243 
244  m_gCharge->Set(0);
245 
246  for (unsigned int i = 0; i < m_PXDModules.size(); i++) {
247  TCanvas* canvas = m_cChargeMod[m_PXDModules[i]];
248  if (canvas == nullptr) continue;
249 
250  std::string name = "PXD_Track_Cluster_Charge_" + (std::string)m_PXDModules[i];
251  std::replace(name.begin(), name.end(), '.', '_');
252 
253  canvas->cd();
254  canvas->Clear();
255 
256  TH1* hh1 = findHist(m_histogramDirectoryName, name);
257  if (hh1) {
258 
259  if (hh1->GetEntries() > 50) {
260 
261  auto hdata = new RooDataHist(hh1->GetName(), hh1->GetTitle(), *m_x, (const TH1*) hh1);
262  auto plot = m_x->frame(RooFit::Title(hh1->GetTitle()));
263  /*auto r =*/ model->fitTo(*hdata, RooFit::Range("signal"));
264 
265  model->paramOn(plot, RooFit::Format("NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.6, 0.9, 0.9));
266  hdata->plotOn(plot, RooFit::LineColor(kBlue)/*, RooFit::Range("plot"), RooFit::NormRange("signal")*/);
267  model->plotOn(plot, RooFit::LineColor(kRed), RooFit::Range("signal"), RooFit::NormRange("signal"));
268 
269  plot->Draw("");
270 
271 // model->Print("");
272 // ml->Print("");
273 // sl->Print("");
274 // mg->Print("");
275 // sg->Print("");
276 // cout << "ZZZ , " << Form("%d%02d%d ,", std::get<0>(t), std::get<1>(t), std::get<2>(t)) << ml->getValV() << "," << ml->getError() << "," << sl->getValV() << "," << sl->getError() << "," << sg->getValV() << "," << sg->getError() << endl;
277 
278 
279  int p = m_gCharge->GetN();
280  m_gCharge->SetPoint(p, i + 0.49, ml->getValV());
281  m_gCharge->SetPointError(p, 0.1, ml->getError()); // error in x is useless
282  m_monObj->setVariable(("trackcharge_" + (std::string)m_PXDModules[i]).c_str(), ml->getValV(), ml->getError());
283  }
284 
285  TH1* hist2 = GetHisto("ref/" + m_histogramDirectoryName + "/" + name);
286 
287  if (hist2) {
288 // B2INFO("Draw Normalized " << hist2->GetName());
289  hist2->SetLineStyle(3);// 2 or 3
290  hist2->SetLineColor(kBlack);
291 
292 // TIter nextkey(canvas->GetListOfPrimitives());
293 // TObject* obj = NULL;
294 // while ((obj = (TObject*)nextkey())) {
295 // if (obj->IsA()->InheritsFrom("TH1")) {
296 // if (string(obj->GetName()) == string(hist2->GetName())) {
297 // delete obj;
298 // }
299 // }
300 // }
301 
302  canvas->cd();
303 
304  // if draw normalized
305  TH1* h = (TH1*)hist2->Clone(); // Annoying ... Maybe an memory leak? TODO
306  if (abs(hist2->GetEntries()) > 0) h->Scale(hh1->GetEntries() / hist2->GetEntries());
307 
308  h->SetStats(kFALSE);
309  h->Draw("same,hist");
310  }
311 
312  // add coloring, cuts? based on fit, compare with ref?
313  canvas->Pad()->SetFrameFillColor(10);
314  if (m_color) {
315  if (hh1->GetEntries() < 100) {
316  // not enough Entries
317  canvas->Pad()->SetFillColor(kGray);
318  } else {
319  canvas->Pad()->SetFillColor(kGreen);
320  }
321  } else {
322  canvas->Pad()->SetFillColor(kWhite);// White
323  }
324 
325  canvas->Modified();
326  canvas->Update();
327 
328  // means if ANY plot is > 100 entries, all plots are assumed to be o.k.
329  if (hh1->GetEntries() >= 1000) enough = true;
330  }
331  }
332 
333  // now loop per module over asics pairs (1.5.1)
334  for (unsigned int i = 0; i < m_PXDModules.size(); i++) {
335 // TCanvas* canvas = m_cChargeMod[m_PXDModules[i]];
336  VxdID& aVxdID = m_PXDModules[i];
337 
338  if (m_hChargeModASIC2d[aVxdID]) m_hChargeModASIC2d[aVxdID]->Reset();
339  if (m_cChargeModASIC2d[aVxdID]) m_cChargeModASIC2d[aVxdID]->Clear();
340 
341  for (int s = 1; s <= 6; s++) {
342  for (int d = 1; d <= 4; d++) {
343  std::string name = "PXD_Track_Cluster_Charge_" + (std::string)m_PXDModules[i] + Form("_sw%d_dcd%d", s, d);
344  std::replace(name.begin(), name.end(), '.', '_');
345 
346  if (m_cChargeModASIC[aVxdID][s - 1][d - 1]) {
347  m_cChargeModASIC[aVxdID][s - 1][d - 1]->Clear();
348  m_cChargeModASIC[aVxdID][s - 1][d - 1]->cd();
349  }
350 
351  TH1* hh1 = findHist(m_histogramDirectoryName, name);
352  if (hh1) {
353  double mpv = 0.0;
354  if (hh1->GetEntries() > 50) {
355  auto hdata = new RooDataHist(hh1->GetName(), hh1->GetTitle(), *m_x, (const TH1*) hh1);
356  auto plot = m_x->frame(RooFit::Title(hh1->GetTitle()));
357  /*auto r =*/ model->fitTo(*hdata, RooFit::Range("signal"));
358 
359  if (m_cChargeModASIC[aVxdID][s - 1][d - 1]) {
360  model->paramOn(plot, RooFit::Format("NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.6, 0.9, 0.9));
361  hdata->plotOn(plot, RooFit::LineColor(kBlue)/*, RooFit::Range("plot"), RooFit::NormRange("signal")*/);
362  model->plotOn(plot, RooFit::LineColor(kRed), RooFit::Range("signal"), RooFit::NormRange("signal"));
363  }
364  plot->Draw("");
365 
366  mpv = ml->getValV();
367  }
368 
369  if (m_hChargeModASIC2d[aVxdID]) {
370  if (mpv > 0.0) m_hChargeModASIC2d[aVxdID]->Fill(s, d, mpv); // TODO check what is s, d
371  }
372  }
373  }
374  }
375 
376  // Overview map of ASCI combinations
377  if (m_hChargeModASIC2d[aVxdID] && m_cChargeModASIC2d[aVxdID]) {
378  m_cChargeModASIC2d[aVxdID]->cd();
379  m_hChargeModASIC2d[aVxdID]->Draw("colz");
380  }
381  }
382 
383  m_cCharge->cd();
384  m_cCharge->Clear();
385  m_gCharge->SetMinimum(0);
386  m_gCharge->SetMaximum(70);
387  auto ax = m_gCharge->GetXaxis();
388  if (ax) {
389  ax->Set(m_PXDModules.size(), 0, m_PXDModules.size());
390  for (unsigned int i = 0; i < m_PXDModules.size(); i++) {
391  TString ModuleName = (std::string)m_PXDModules[i];
392  ax->SetBinLabel(i + 1, ModuleName);
393  }
394  } else B2ERROR("no axis");
395 
396  m_gCharge->SetLineColor(4);
397  m_gCharge->SetLineWidth(2);
398  m_gCharge->SetMarkerStyle(8);
399  m_gCharge->Draw("AP");
400 // {
401  // keep this commented code as we may have excluded modules in phase4
402 // auto tt = new TLatex(5.5, 0, " 1.3.2 Module is excluded, please ignore");
403 // tt->SetTextAngle(90);// Rotated
404 // tt->SetTextAlign(12);// Centered
405 // tt->Draw();
406 // }
407  m_cCharge->cd(0);
408  m_cCharge->Modified();
409  m_cCharge->Update();
410 
411  double data = 0;
412  double diff = 0;
413  if (m_gCharge && enough) {
414 // double currentMin, currentMax;
415  m_gCharge->Fit(m_fMean, "R");
416  double mean = m_gCharge->GetMean(2);
417  double maxi = mean + 15;
418  double mini = mean - 15;
419  m_line_up->SetY1(maxi);
420  m_line_up->SetY2(maxi);
421  m_line_mean->SetY1(mean);
422  m_line_mean->SetY2(mean);
423  m_line_low->SetY1(mini);
424  m_line_low->SetY2(mini);
425  data = mean; // m_fMean->GetParameter(0); // we are more interessted in the maximum deviation from mean
426  // m_gCharge->GetMinimumAndMaximum(currentMin, currentMax);
427  diff = m_gCharge->GetRMS(2);// RMS of Y
428  // better, max deviation as fabs(data - currentMin) > fabs(currentMax - data) ? fabs(data - currentMin) : fabs(currentMax - data);
429  m_line_up->Draw();
430  m_line_mean->Draw();
431  m_line_low->Draw();
432 
433  m_monObj->setVariable("trackcharge", mean, diff);
434  }
435 
436 #ifdef _BELLE2_EPICS
437  if (m_useEpics) {
438  SEVCHK(ca_put(DBR_DOUBLE, mychid[0], (void*)&data), "ca_set failure");
439  SEVCHK(ca_put(DBR_DOUBLE, mychid[1], (void*)&diff), "ca_set failure");
440  }
441 #endif
442 
443  int status = 0;
444 
445  if (!enough) {
446  // not enough Entries
447  m_cCharge->Pad()->SetFillColor(kGray);// Magenta or Gray
448  status = 0; // default
449  } else {
451  if (fabs(data - 30.) > 20. || diff > 12) {
452  m_cCharge->Pad()->SetFillColor(kRed);// Red
453  status = 4;
454  } else if (fabs(data - 30) > 15. || diff > 8) {
455  m_cCharge->Pad()->SetFillColor(kYellow);// Yellow
456  status = 3;
457  } else {
458  m_cCharge->Pad()->SetFillColor(kGreen);// Green
459  status = 2;
460  }
461 
462  // FIXME overwrite for now
463  // m_cCharge->Pad()->SetFillColor(kGreen);// Green
464 
465  }
466 
467 #ifdef _BELLE2_EPICS
468  if (m_useEpics) {
469  SEVCHK(ca_put(DBR_INT, mychid[2], (void*)&status), "ca_set failure");
470  SEVCHK(ca_pend_io(5.0), "ca_pend_io failure");
471  }
472 #endif
473 
474 }
475 
476 void DQMHistAnalysisPXDTrackChargeModule::endRun()
477 {
478  B2DEBUG(99, "DQMHistAnalysisPXDTrackCharge : endRun called");
479 }
480 
481 
482 void DQMHistAnalysisPXDTrackChargeModule::terminate()
483 {
484  B2DEBUG(99, "DQMHistAnalysisPXDTrackCharge: terminate called");
485  // should delete canvas here, maybe hist, too? Who owns it?
486 #ifdef _BELLE2_EPICS
487  if (m_useEpics) {
488  for (auto m : mychid) SEVCHK(ca_clear_channel(m), "ca_clear_channel failure");
489  SEVCHK(ca_pend_io(5.0), "ca_pend_io failure");
490  }
491 #endif
492  if (m_refFile) delete m_refFile;
493 
494 }
495 
496 TH1* DQMHistAnalysisPXDTrackChargeModule::GetHisto(TString histoname)
497 {
498  TH1* hh1 = nullptr;
499  gROOT->cd();
500 // hh1 = findHist(histoname.Data());
501  // cppcheck-suppress knownConditionTrueFalse
502  if (hh1 == NULL) {
503  B2DEBUG(20, "findHisto failed " << histoname << " not in memfile");
504 
505  // first search reference root file ... if ther is one
506  if (m_refFile && m_refFile->IsOpen()) {
507  TDirectory* d = m_refFile;
508  TString myl = histoname;
509  TString tok;
510  Ssiz_t from = 0;
511  B2DEBUG(20, myl);
512  while (myl.Tokenize(tok, from, "/")) {
513  TString dummy;
514  Ssiz_t f;
515  f = from;
516  if (myl.Tokenize(dummy, f, "/")) { // check if its the last one
517  auto e = d->GetDirectory(tok);
518  if (e) {
519  B2DEBUG(20, "Cd Dir " << tok << " from " << d->GetPath());
520  d = e;
521  } else {
522  B2DEBUG(20, "cd failed " << tok << " from " << d->GetPath());
523  }
524  } else {
525  break;
526  }
527  }
528  TObject* obj = d->FindObject(tok);
529  if (obj != NULL) {
530  if (obj->IsA()->InheritsFrom("TH1")) {
531  B2DEBUG(20, "Histo " << histoname << " found in ref file");
532  hh1 = (TH1*)obj;
533  } else {
534  B2DEBUG(20, "Histo " << histoname << " found in ref file but wrong type");
535  }
536  } else {
537  // seems find will only find objects, not keys, thus get the object on first access
538  TIter next(d->GetListOfKeys());
539  TKey* key;
540  while ((key = (TKey*)next())) {
541  TObject* obj2 = key->ReadObj() ;
542  if (obj2->InheritsFrom("TH1")) {
543  if (obj2->GetName() == tok) {
544  hh1 = (TH1*)obj2;
545  B2DEBUG(20, "Histo " << histoname << " found as key -> readobj");
546  break;
547  }
548  }
549  }
550  if (hh1 == NULL) B2DEBUG(20, "Histo " << histoname << " NOT found in ref file " << tok);
551  }
552  }
553 
554  if (hh1 == NULL) {
555  B2DEBUG(20, "Histo " << histoname << " not in memfile or ref file");
556 
557  TDirectory* d = gROOT;
558  TString myl = histoname;
559  TString tok;
560  Ssiz_t from = 0;
561  while (myl.Tokenize(tok, from, "/")) {
562  TString dummy;
563  Ssiz_t f;
564  f = from;
565  if (myl.Tokenize(dummy, f, "/")) { // check if its the last one
566  auto e = d->GetDirectory(tok);
567  if (e) {
568  B2DEBUG(20, "Cd Dir " << tok);
569  d = e;
570  } else B2DEBUG(20, "cd failed " << tok);
571  d->cd();
572  } else {
573  break;
574  }
575  }
576  TObject* obj = d->FindObject(tok);
577  if (obj != NULL) {
578  if (obj->IsA()->InheritsFrom("TH1")) {
579  B2DEBUG(20, "Histo " << histoname << " found in mem");
580  hh1 = (TH1*)obj;
581  }
582  } else {
583  B2DEBUG(20, "Histo " << histoname << " NOT found in mem");
584  }
585  }
586  }
587 
588  if (hh1 == NULL) {
589  B2DEBUG(20, "Histo " << histoname << " not found");
590  }
591 
592  return hh1;
593 }
The base class for the histogram analysis module.
DQM Histogram Analysis for PXD Cluster Charge.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
Definition: GeoCache.cc:58
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:66
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
Base class to provide Sensor Information for PXD and SVD.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.