Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:08:56

0001 #include "SiStripQualityHistoryPlots.h"
0002 #include <iostream>
0003 #include <algorithm>
0004 #include <vector>
0005 #include <string>
0006 #include <map>
0007 #include "TPad.h"
0008 #include "TFile.h"
0009 #include "TH2F.h"
0010 #include "TH1F.h"
0011 #include "TProfile.h"
0012 #include "TGraph.h"
0013 #include "DPGAnalysis/SiStripTools/interface/CommonAnalyzer.h"
0014 #include "TCanvas.h"
0015 #include "TStyle.h"
0016 
0017 TH1D* AverageRunBadChannels(TFile& ff, const char* module, const char* histo, const bool excludeLastBins) {
0018   CommonAnalyzer camult(&ff, "", module);
0019 
0020   TH1D* badchannels = new TH1D("badchannels", "Average Number of Bad Channels vs run", 10, 0., 10.);
0021   badchannels->SetCanExtend(TH1::kXaxis);
0022 
0023   std::vector<unsigned int> runs = camult.getRunList();
0024   std::sort(runs.begin(), runs.end());
0025 
0026   {
0027     for (unsigned int i = 0; i < runs.size(); ++i) {
0028       char runlabel[100];
0029       sprintf(runlabel, "%d", runs[i]);
0030       char runpath[100];
0031       sprintf(runpath, "run_%d", runs[i]);
0032       camult.setPath(runpath);
0033 
0034       TProfile* multvstime = nullptr;
0035       if (multvstime == nullptr)
0036         multvstime = (TProfile*)camult.getObject(histo);
0037       if (multvstime) {
0038         // compute mean exlucing the last filled bins
0039 
0040         if (excludeLastBins) {
0041           int lastbin = multvstime->GetNbinsX() + 1;
0042           int firstbin = 1;
0043           for (int ibin = multvstime->GetNbinsX() + 1; ibin > 0; --ibin) {
0044             if (multvstime->GetBinEntries(ibin) != 0) {
0045               lastbin = ibin;
0046               break;
0047             }
0048           }
0049 
0050           std::cout << "Restricted range: " << firstbin << " " << lastbin << std::endl;
0051           multvstime->GetXaxis()->SetRangeUser(multvstime->GetBinLowEdge(firstbin),
0052                                                multvstime->GetBinLowEdge(lastbin - 2));
0053         }
0054         // fill the summary
0055         badchannels->Fill(runlabel, multvstime->GetMean(2));
0056       }
0057     }
0058   }
0059   return badchannels;
0060 }
0061 
0062 TCanvas* StripCompletePlot(TFile& ff, const char* module, const bool excludeLastBins) {
0063   TCanvas* cc = new TCanvas();
0064 
0065   TH1D* cabling = AverageRunBadChannels(ff, module, "badmodrun_Cabling", excludeLastBins);
0066   TH1D* runinfo = AverageRunBadChannels(ff, module, "badmodrun_RunInfo", excludeLastBins);
0067   TH1D* badchannel = AverageRunBadChannels(ff, module, "badmodrun_BadChannel", excludeLastBins);
0068   TH1D* dcs = AverageRunBadChannels(ff, module, "badmodrun_DCS", excludeLastBins);
0069   TH1D* badfiber = AverageRunBadChannels(ff, module, "badmodrun_BadFiber", excludeLastBins);
0070 
0071   cabling->SetLineColor(kRed);
0072   runinfo->SetLineColor(kMagenta);
0073   badchannel->SetLineColor(kCyan);
0074   dcs->SetLineColor(kGreen);
0075   badfiber->SetLineColor(kBlue);
0076 
0077   badfiber->Draw();
0078   dcs->Draw("same");
0079   badchannel->Draw("same");
0080   runinfo->Draw("same");
0081   cabling->Draw("same");
0082 
0083   return cc;
0084 }