CMS 3D CMS Logo

SOF_profiles.cc
Go to the documentation of this file.
1 #include "SOF_profiles.h"
2 #include "TCanvas.h"
3 #include "TFile.h"
4 #include "TProfile.h"
5 #include "TH1F.h"
6 #include "TDirectory.h"
7 #include "TLine.h"
8 #include "TGaxis.h"
9 #include "TLegend.h"
10 #include <iostream>
11 
12 TCanvas* printSOF(TFile* file, const int run, const int firstLS, const int zoom) {
13  TCanvas* canout = nullptr;
14 
15  char rname[400];
16  sprintf(rname, "run_%d", run);
17 
18  if (file == nullptr)
19  return canout;
20 
21  TProfile* badmod = nullptr;
22  TH1F* evtanydcs = nullptr;
23  TH1F* evtdcson = nullptr;
24  TH1F* evtnostrip = nullptr;
25 
26  char dname[422];
27 
28  sprintf(dname, "ssqhistory/%s", rname);
29  if (file->cd(dname)) {
30  badmod = (TProfile*)gDirectory->Get("badmodrun_HVDCS");
31  }
32 
33  sprintf(dname, "eventtimedistranydcs/%s", rname);
34  if (file->cd(dname)) {
35  evtanydcs = (TH1F*)gDirectory->Get("orbit");
36  }
37 
38  sprintf(dname, "eventtimedistribution/%s", rname);
39  if (file->cd(dname)) {
40  evtdcson = (TH1F*)gDirectory->Get("orbit");
41  }
42 
43  sprintf(dname, "eventtimedistrnostrip/%s", rname);
44  if (file->cd(dname)) {
45  evtnostrip = (TH1F*)gDirectory->Get("orbit");
46  }
47 
48  if (badmod && evtanydcs && evtdcson && evtnostrip) {
49  badmod->SetStats(kFALSE);
50  badmod->SetLineColor(kGreen);
51  badmod->SetMarkerColor(kGreen);
52  evtanydcs->SetStats(kFALSE);
53  evtanydcs->SetLineColor(kBlue);
54  evtdcson->SetStats(kFALSE);
55  evtdcson->SetLineColor(kRed);
56  evtnostrip->SetStats(kFALSE);
57  evtnostrip->SetLineColor(kRed);
58  evtnostrip->SetFillColor(kRed);
59  evtnostrip->SetFillStyle(1000);
60 
61  canout = new TCanvas;
62 
63  badmod->Draw();
64  badmod->GetYaxis()->SetRangeUser(1, 100000);
65  badmod->GetYaxis()->SetTitle("");
66  badmod->SetTitle(rname);
67  badmod->GetXaxis()->SetRangeUser((firstLS - zoom) * 262144, (firstLS + zoom) * 262144);
68  evtanydcs->Draw("same");
69  evtdcson->Draw("same");
70  evtnostrip->Rebin(int(badmod->GetBinWidth(1) / evtnostrip->GetBinWidth(1)));
71  std::cout << "rebin " << int(badmod->GetBinWidth(1) / evtnostrip->GetBinWidth(1)) << std::endl;
72  evtnostrip->Draw("same");
73 
74  TGaxis* lsaxis = new TGaxis((firstLS - zoom) * 262144,
75  100000,
76  (firstLS + zoom) * 262144,
77  100000,
78  firstLS - zoom + 1,
79  firstLS + zoom + 1,
80  2 * zoom,
81  "-SM");
82  // TGaxis* lsaxis = new TGaxis(badmod->GetXaxis()->GetXmin(),100000,
83  // badmod->GetXaxis()->GetXmax(),100000,
84  // badmod->GetXaxis()->GetXmin()/262144+1,badmod->GetXaxis()->GetXmax()/262144+1,50,"-SM");
85  lsaxis->Draw();
86 
87  TLine* line = new TLine((firstLS - 1) * 262144, 1, (firstLS - 1) * 262144, 100000);
88  line->SetLineWidth(2);
89  line->SetLineStyle(2);
90  line->Draw();
91 
92  TLegend* leg = new TLegend(.5, .65, .9, .85, "");
93  leg->AddEntry(badmod, "Modules with HV off", "l");
94  leg->AddEntry(evtanydcs, "Events with any DCS bit", "l");
95  leg->AddEntry(evtdcson, "Events with DCS bit ON", "l");
96  leg->AddEntry(evtnostrip, "DCS bit ON No strip clus (masked FED)", "f");
97  leg->AddEntry(line, "first good LS (DCSonly JSON)", "l");
98 
99  leg->SetFillStyle(0);
100  leg->Draw();
101 
102  canout->SetLogy(1);
103  }
104 
105  return canout;
106 }
TCanvas * printSOF(TFile *file, const int run, const int firstLS, const int zoom)
Definition: SOF_profiles.cc:12
const G4String rname[NREG]