File indexing completed on 2025-08-05 08:12:17
0001
0002 #include <string>
0003 #include <iostream>
0004 #include <iomanip>
0005 #include <fstream>
0006 #include <filesystem>
0007
0008
0009 #include <TH2F.h>
0010 #include <TF1.h>
0011 #include <TDirectory.h>
0012 #include <TKey.h>
0013 #include <TFile.h>
0014 #include <TLine.h>
0015 #include <TLegend.h>
0016 #include <TLatex.h>
0017 #include <TCanvas.h>
0018 #include <TDatime.h>
0019 #include <TGaxis.h>
0020
0021
0022 #include "sPhenixStyle.C"
0023
0024 using std::cout;
0025 using std::cerr;
0026 using std::endl;
0027 using std::string;
0028 using std::to_string;
0029 using std::vector;
0030 using std::stringstream;
0031 using std::min;
0032 using std::max;
0033 using std::ofstream;
0034
0035 namespace myAnalysis {
0036 void plots(const string& i_input, const string &outputDir);
0037
0038 UInt_t threshold = 400;
0039 }
0040
0041 void myAnalysis::plots(const string& i_input, const string &outputDir) {
0042
0043 string outputSigmaDir = outputDir + "/sigma/";
0044
0045 TFile input(i_input.c_str());
0046
0047 TCanvas* c1 = new TCanvas();
0048 c1->SetTickx();
0049 c1->SetTicky();
0050
0051 c1->SetCanvasSize(1500, 1000);
0052 c1->SetLeftMargin(.13);
0053 c1->SetTopMargin(.08);
0054 c1->SetRightMargin(.05);
0055
0056 gStyle->SetOptTitle(1);
0057 gStyle->SetTitleStyle(0);
0058 gStyle->SetTitleFontSize(0.08);
0059 gStyle->SetTitleW(1);
0060 gStyle->SetTitleH(0.08);
0061 gStyle->SetTitleFillColor(0);
0062 gStyle->SetTitleBorderSize(0);
0063 gStyle->SetTitleXOffset(1);
0064 gStyle->SetTitleYOffset(1);
0065
0066 auto hSigma = (TH1F*)input.Get("hSigmaHot");
0067 auto hSigmaFreqHot = (TH1F*)input.Get("hSigmaFreqHot");
0068 auto hSigmaTypeA = (TH1F*)input.Get("hSigmaTypeA");
0069 auto hSigmaTypeB = (TH1F*)input.Get("hSigmaTypeB");
0070 auto hSigmaTypeC = (TH1F*)input.Get("hSigmaTypeC");
0071
0072
0073 cout << "threshold: " << threshold << endl;
0074 c1->cd();
0075
0076 gPad->SetLogy();
0077
0078 hSigma->Rebin(5);
0079 hSigmaTypeA->Rebin(5);
0080 hSigmaTypeB->Rebin(5);
0081 hSigmaTypeC->Rebin(5);
0082
0083 auto sigma_threshold = new TLine(5, 0, 5, hSigma->GetMaximum()*1.05);
0084 sigma_threshold->SetLineColor(kOrange);
0085 sigma_threshold->SetLineWidth(3);
0086
0087 hSigma->SetTitle("Towers");
0088
0089 hSigma->GetXaxis()->SetRangeUser(0,30);
0090 hSigma->GetYaxis()->SetRangeUser(1,1e7);
0091 hSigma->Draw();
0092 sigma_threshold->Draw("same");
0093
0094 hSigmaTypeA->SetLineColor(kRed);
0095 hSigmaTypeA->Draw("same");
0096
0097 hSigmaTypeB->SetLineColor(kGreen+2);
0098 hSigmaTypeB->Draw("same");
0099
0100 hSigmaTypeC->SetLineColor(kBlue);
0101 hSigmaTypeC->Draw("same");
0102
0103 auto leg = new TLegend(0.5,.5,0.7,.9);
0104 leg->SetFillStyle(0);
0105 leg->AddEntry(hSigma,("Flagged Hot < " + to_string(threshold) + " Runs").c_str(),"f");
0106 leg->AddEntry(hSigmaTypeA,"Hot Type A","f");
0107 leg->AddEntry(hSigmaTypeB,"Hot Type B","f");
0108 leg->AddEntry(hSigmaTypeC,"Hot Type C","f");
0109 leg->AddEntry(sigma_threshold,"Sigma Threshold","l");
0110 leg->Draw("same");
0111
0112 c1->Print((outputSigmaDir + string(hSigma->GetName()) + "-HotType.png").c_str());
0113
0114 input.Close();
0115 }
0116
0117 void displayHotType(const string &input, const string &outputDir=".") {
0118 cout << "#############################" << endl;
0119 cout << "Run Parameters" << endl;
0120 cout << "input: " << input << endl;
0121 cout << "outputDir: " << outputDir << endl;
0122 cout << "#############################" << endl;
0123
0124
0125 SetsPhenixStyle();
0126
0127
0128 std::filesystem::create_directories(outputDir + "/sigma");
0129
0130 myAnalysis::plots(input, outputDir);
0131 }
0132
0133 # ifndef __CINT__
0134 Int_t main(Int_t argc, char* argv[]) {
0135 if(argc < 2 || argc > 3){
0136 cout << "usage: ./displayHotType input [output]" << endl;
0137 cout << "input: input root file" << endl;
0138 cout << "outputDir: output directory" << endl;
0139 return 1;
0140 }
0141
0142 string outputDir = ".";
0143
0144 if(argc >= 3) {
0145 outputDir = argv[2];
0146 }
0147
0148 displayHotType(argv[1], outputDir);
0149
0150 cout << "======================================" << endl;
0151 cout << "done" << endl;
0152 return 0;
0153 }
0154 # endif