File indexing completed on 2024-04-06 12:06:33
0001 #include "SOF_profiles.h"
0002 #include "TCanvas.h"
0003 #include "TFile.h"
0004 #include "TProfile.h"
0005 #include "TH1F.h"
0006 #include "TDirectory.h"
0007 #include "TLine.h"
0008 #include "TGaxis.h"
0009 #include "TLegend.h"
0010 #include <iostream>
0011
0012 TCanvas* printSOF(TFile* file, const int run, const int firstLS, const int zoom) {
0013 TCanvas* canout = nullptr;
0014
0015 char rname[400];
0016 sprintf(rname, "run_%d", run);
0017
0018 if (file == nullptr)
0019 return canout;
0020
0021 TProfile* badmod = nullptr;
0022 TH1F* evtanydcs = nullptr;
0023 TH1F* evtdcson = nullptr;
0024 TH1F* evtnostrip = nullptr;
0025
0026 char dname[422];
0027
0028 sprintf(dname, "ssqhistory/%s", rname);
0029 if (file->cd(dname)) {
0030 badmod = (TProfile*)gDirectory->Get("badmodrun_HVDCS");
0031 }
0032
0033 sprintf(dname, "eventtimedistranydcs/%s", rname);
0034 if (file->cd(dname)) {
0035 evtanydcs = (TH1F*)gDirectory->Get("orbit");
0036 }
0037
0038 sprintf(dname, "eventtimedistribution/%s", rname);
0039 if (file->cd(dname)) {
0040 evtdcson = (TH1F*)gDirectory->Get("orbit");
0041 }
0042
0043 sprintf(dname, "eventtimedistrnostrip/%s", rname);
0044 if (file->cd(dname)) {
0045 evtnostrip = (TH1F*)gDirectory->Get("orbit");
0046 }
0047
0048 if (badmod && evtanydcs && evtdcson && evtnostrip) {
0049 badmod->SetStats(kFALSE);
0050 badmod->SetLineColor(kGreen);
0051 badmod->SetMarkerColor(kGreen);
0052 evtanydcs->SetStats(kFALSE);
0053 evtanydcs->SetLineColor(kBlue);
0054 evtdcson->SetStats(kFALSE);
0055 evtdcson->SetLineColor(kRed);
0056 evtnostrip->SetStats(kFALSE);
0057 evtnostrip->SetLineColor(kRed);
0058 evtnostrip->SetFillColor(kRed);
0059 evtnostrip->SetFillStyle(1000);
0060
0061 canout = new TCanvas;
0062
0063 badmod->Draw();
0064 badmod->GetYaxis()->SetRangeUser(1, 100000);
0065 badmod->GetYaxis()->SetTitle("");
0066 badmod->SetTitle(rname);
0067 badmod->GetXaxis()->SetRangeUser((firstLS - zoom) * 262144, (firstLS + zoom) * 262144);
0068 evtanydcs->Draw("same");
0069 evtdcson->Draw("same");
0070 evtnostrip->Rebin(int(badmod->GetBinWidth(1) / evtnostrip->GetBinWidth(1)));
0071 std::cout << "rebin " << int(badmod->GetBinWidth(1) / evtnostrip->GetBinWidth(1)) << std::endl;
0072 evtnostrip->Draw("same");
0073
0074 TGaxis* lsaxis = new TGaxis((firstLS - zoom) * 262144,
0075 100000,
0076 (firstLS + zoom) * 262144,
0077 100000,
0078 firstLS - zoom + 1,
0079 firstLS + zoom + 1,
0080 2 * zoom,
0081 "-SM");
0082
0083
0084
0085 lsaxis->Draw();
0086
0087 TLine* line = new TLine((firstLS - 1) * 262144, 1, (firstLS - 1) * 262144, 100000);
0088 line->SetLineWidth(2);
0089 line->SetLineStyle(2);
0090 line->Draw();
0091
0092 TLegend* leg = new TLegend(.5, .65, .9, .85, "");
0093 leg->AddEntry(badmod, "Modules with HV off", "l");
0094 leg->AddEntry(evtanydcs, "Events with any DCS bit", "l");
0095 leg->AddEntry(evtdcson, "Events with DCS bit ON", "l");
0096 leg->AddEntry(evtnostrip, "DCS bit ON No strip clus (masked FED)", "f");
0097 leg->AddEntry(line, "first good LS (DCSonly JSON)", "l");
0098
0099 leg->SetFillStyle(0);
0100 leg->Draw();
0101
0102 canout->SetLogy(1);
0103 }
0104
0105 return canout;
0106 }