CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
18 TH1D* AverageRunBadChannels(TFile& ff, const char* module, const char* histo, const bool excludeLastBins) {
19 
20  CommonAnalyzer camult(&ff,"",module);
21 
22  TH1D* badchannels = new TH1D("badchannels","Average Number of Bad Channels vs run",10,0.,10.);
23  badchannels->SetCanExtend(TH1::kXaxis);
24 
25  std::vector<unsigned int> runs = camult.getRunList();
26  std::sort(runs.begin(),runs.end());
27 
28  {
29  for(unsigned int i=0;i<runs.size();++i) {
30 
31  char runlabel[100];
32  sprintf(runlabel,"%d",runs[i]);
33  char runpath[100];
34  sprintf(runpath,"run_%d",runs[i]);
35  camult.setPath(runpath);
36 
37 
38  TProfile* multvstime=0;
39  if(multvstime==0) multvstime = (TProfile*)camult.getObject(histo);
40  if(multvstime) {
41  // compute mean exlucing the last filled bins
42 
43  if(excludeLastBins) {
44  int lastbin= multvstime->GetNbinsX()+1;
45  int firstbin= 1;
46  for(int ibin=multvstime->GetNbinsX()+1;ibin>0;--ibin) {
47  if(multvstime->GetBinEntries(ibin)!=0) {
48  lastbin=ibin;
49  break;
50  }
51  }
52 
53  std::cout << "Restricted range: " << firstbin << " " << lastbin << std::endl;
54  multvstime->GetXaxis()->SetRangeUser(multvstime->GetBinLowEdge(firstbin),multvstime->GetBinLowEdge(lastbin-2));
55  }
56  // fill the summary
57  badchannels->Fill(runlabel,multvstime->GetMean(2));
58 
59  }
60  }
61  }
62  return badchannels;
63 
64 
65 
66 }
67 
68 TCanvas* StripCompletePlot(TFile& ff, const char* module, const bool excludeLastBins) {
69 
70  TCanvas* cc = new TCanvas();
71 
72  TH1D* cabling = AverageRunBadChannels(ff,module,"badmodrun_Cabling",excludeLastBins);
73  TH1D* runinfo = AverageRunBadChannels(ff,module,"badmodrun_RunInfo",excludeLastBins);
74  TH1D* badchannel = AverageRunBadChannels(ff,module,"badmodrun_BadChannel",excludeLastBins);
75  TH1D* dcs = AverageRunBadChannels(ff,module,"badmodrun_DCS",excludeLastBins);
76  TH1D* badfiber = AverageRunBadChannels(ff,module,"badmodrun_BadFiber",excludeLastBins);
77 
78  cabling->SetLineColor(kRed);
79  runinfo->SetLineColor(kMagenta);
80  badchannel->SetLineColor(kCyan);
81  dcs->SetLineColor(kGreen);
82  badfiber->SetLineColor(kBlue);
83 
84  badfiber->Draw();
85  dcs->Draw("same");
86  badchannel->Draw("same");
87  runinfo->Draw("same");
88  cabling->Draw("same");
89 
90  return cc;
91 }
int i
Definition: DBlmapReader.cc:9
TObject * getObject(const char *name) const
TCanvas * StripCompletePlot(TFile &ff, const char *module, const bool excludeLastBins)
tuple runs
Definition: gather_cfg.py:87
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
tuple cout
Definition: gather_cfg.py:145
Definition: vlib.h:208