Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
#include "SOF_profiles.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TProfile.h"
#include "TH1F.h"
#include "TDirectory.h"
#include "TLine.h"
#include "TGaxis.h"
#include "TLegend.h"
#include <iostream>

TCanvas* printSOF(TFile* file, const int run, const int firstLS, const int zoom) {
  TCanvas* canout = nullptr;

  char rname[400];
  sprintf(rname, "run_%d", run);

  if (file == nullptr)
    return canout;

  TProfile* badmod = nullptr;
  TH1F* evtanydcs = nullptr;
  TH1F* evtdcson = nullptr;
  TH1F* evtnostrip = nullptr;

  char dname[422];

  sprintf(dname, "ssqhistory/%s", rname);
  if (file->cd(dname)) {
    badmod = (TProfile*)gDirectory->Get("badmodrun_HVDCS");
  }

  sprintf(dname, "eventtimedistranydcs/%s", rname);
  if (file->cd(dname)) {
    evtanydcs = (TH1F*)gDirectory->Get("orbit");
  }

  sprintf(dname, "eventtimedistribution/%s", rname);
  if (file->cd(dname)) {
    evtdcson = (TH1F*)gDirectory->Get("orbit");
  }

  sprintf(dname, "eventtimedistrnostrip/%s", rname);
  if (file->cd(dname)) {
    evtnostrip = (TH1F*)gDirectory->Get("orbit");
  }

  if (badmod && evtanydcs && evtdcson && evtnostrip) {
    badmod->SetStats(kFALSE);
    badmod->SetLineColor(kGreen);
    badmod->SetMarkerColor(kGreen);
    evtanydcs->SetStats(kFALSE);
    evtanydcs->SetLineColor(kBlue);
    evtdcson->SetStats(kFALSE);
    evtdcson->SetLineColor(kRed);
    evtnostrip->SetStats(kFALSE);
    evtnostrip->SetLineColor(kRed);
    evtnostrip->SetFillColor(kRed);
    evtnostrip->SetFillStyle(1000);

    canout = new TCanvas;

    badmod->Draw();
    badmod->GetYaxis()->SetRangeUser(1, 100000);
    badmod->GetYaxis()->SetTitle("");
    badmod->SetTitle(rname);
    badmod->GetXaxis()->SetRangeUser((firstLS - zoom) * 262144, (firstLS + zoom) * 262144);
    evtanydcs->Draw("same");
    evtdcson->Draw("same");
    evtnostrip->Rebin(int(badmod->GetBinWidth(1) / evtnostrip->GetBinWidth(1)));
    std::cout << "rebin " << int(badmod->GetBinWidth(1) / evtnostrip->GetBinWidth(1)) << std::endl;
    evtnostrip->Draw("same");

    TGaxis* lsaxis = new TGaxis((firstLS - zoom) * 262144,
                                100000,
                                (firstLS + zoom) * 262144,
                                100000,
                                firstLS - zoom + 1,
                                firstLS + zoom + 1,
                                2 * zoom,
                                "-SM");
    //    TGaxis* lsaxis = new TGaxis(badmod->GetXaxis()->GetXmin(),100000,
    //				badmod->GetXaxis()->GetXmax(),100000,
    //				badmod->GetXaxis()->GetXmin()/262144+1,badmod->GetXaxis()->GetXmax()/262144+1,50,"-SM");
    lsaxis->Draw();

    TLine* line = new TLine((firstLS - 1) * 262144, 1, (firstLS - 1) * 262144, 100000);
    line->SetLineWidth(2);
    line->SetLineStyle(2);
    line->Draw();

    TLegend* leg = new TLegend(.5, .65, .9, .85, "");
    leg->AddEntry(badmod, "Modules with HV off", "l");
    leg->AddEntry(evtanydcs, "Events with any DCS bit", "l");
    leg->AddEntry(evtdcson, "Events with DCS bit ON", "l");
    leg->AddEntry(evtnostrip, "DCS bit ON No strip clus (masked FED)", "f");
    leg->AddEntry(line, "first good LS (DCSonly JSON)", "l");

    leg->SetFillStyle(0);
    leg->Draw();

    canout->SetLogy(1);
  }

  return canout;
}