CMS 3D CMS Logo

SiStripQualityHistoryPlots.cc
Go to the documentation of this file.
2 #include <iostream>
3 #include <algorithm>
4 #include <vector>
5 #include <string>
6 #include <map>
7 #include "TPad.h"
8 #include "TFile.h"
9 #include "TH2F.h"
10 #include "TH1F.h"
11 #include "TProfile.h"
12 #include "TGraph.h"
14 #include "TCanvas.h"
15 #include "TStyle.h"
16 
17 TH1D* AverageRunBadChannels(TFile& ff, const char* module, const char* histo, const bool excludeLastBins) {
18  CommonAnalyzer camult(&ff, "", module);
19 
20  TH1D* badchannels = new TH1D("badchannels", "Average Number of Bad Channels vs run", 10, 0., 10.);
21  badchannels->SetCanExtend(TH1::kXaxis);
22 
23  std::vector<unsigned int> runs = camult.getRunList();
24  std::sort(runs.begin(), runs.end());
25 
26  {
27  for (unsigned int i = 0; i < runs.size(); ++i) {
28  char runlabel[100];
29  sprintf(runlabel, "%d", runs[i]);
30  char runpath[100];
31  sprintf(runpath, "run_%d", runs[i]);
32  camult.setPath(runpath);
33 
34  TProfile* multvstime = nullptr;
35  if (multvstime == nullptr)
36  multvstime = (TProfile*)camult.getObject(histo);
37  if (multvstime) {
38  // compute mean exlucing the last filled bins
39 
40  if (excludeLastBins) {
41  int lastbin = multvstime->GetNbinsX() + 1;
42  int firstbin = 1;
43  for (int ibin = multvstime->GetNbinsX() + 1; ibin > 0; --ibin) {
44  if (multvstime->GetBinEntries(ibin) != 0) {
45  lastbin = ibin;
46  break;
47  }
48  }
49 
50  std::cout << "Restricted range: " << firstbin << " " << lastbin << std::endl;
51  multvstime->GetXaxis()->SetRangeUser(multvstime->GetBinLowEdge(firstbin),
52  multvstime->GetBinLowEdge(lastbin - 2));
53  }
54  // fill the summary
55  badchannels->Fill(runlabel, multvstime->GetMean(2));
56  }
57  }
58  }
59  return badchannels;
60 }
61 
62 TCanvas* StripCompletePlot(TFile& ff, const char* module, const bool excludeLastBins) {
63  TCanvas* cc = new TCanvas();
64 
65  TH1D* cabling = AverageRunBadChannels(ff, module, "badmodrun_Cabling", excludeLastBins);
66  TH1D* runinfo = AverageRunBadChannels(ff, module, "badmodrun_RunInfo", excludeLastBins);
67  TH1D* badchannel = AverageRunBadChannels(ff, module, "badmodrun_BadChannel", excludeLastBins);
68  TH1D* dcs = AverageRunBadChannels(ff, module, "badmodrun_DCS", excludeLastBins);
69  TH1D* badfiber = AverageRunBadChannels(ff, module, "badmodrun_BadFiber", excludeLastBins);
70 
71  cabling->SetLineColor(kRed);
72  runinfo->SetLineColor(kMagenta);
73  badchannel->SetLineColor(kCyan);
74  dcs->SetLineColor(kGreen);
75  badfiber->SetLineColor(kBlue);
76 
77  badfiber->Draw();
78  dcs->Draw("same");
79  badchannel->Draw("same");
80  runinfo->Draw("same");
81  cabling->Draw("same");
82 
83  return cc;
84 }
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
TCanvas * StripCompletePlot(TFile &ff, const char *module, const bool excludeLastBins)
TObject * getObject(const char *name) const
TH1D * AverageRunBadChannels(TFile &ff, const char *module, const char *histo, const bool excludeLastBins)
void setPath(const char *path)
const std::vector< unsigned int > getRunList() const