Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:12:17

0001 // -- c++ includes --
0002 #include <string>
0003 #include <iostream>
0004 #include <iomanip>
0005 #include <fstream>
0006 #include <filesystem>
0007 
0008 // -- root includes --
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 // -- sPHENIX Style
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 ntowers = 24576;
0039     UInt_t threshold = 400; // nRuns above which tower is frequently bad
0040     Float_t zMax = 1700;
0041     TDatime d("2024-08-13 16:00:00"); // start of 1.5 mrad
0042 }
0043 
0044 void myAnalysis::plots(const string& i_input, const string &outputDir) {
0045 
0046     string outputSigmaDir = outputDir + "/sigma/";
0047     string outputAccptDir = outputDir + "/acceptance/";
0048     string outputSigma    = outputSigmaDir + "sigma.pdf";
0049     string outputAccpt    = outputAccptDir + "plots.pdf";
0050 
0051     TFile input(i_input.c_str());
0052 
0053     TCanvas* c1 = new TCanvas();
0054     c1->SetTickx();
0055     c1->SetTicky();
0056 
0057     c1->SetCanvasSize(1500, 1000);
0058     c1->SetLeftMargin(.13);
0059     c1->SetTopMargin(.08);
0060     c1->SetRightMargin(.05);
0061 
0062     gStyle->SetOptTitle(1);
0063     gStyle->SetTitleStyle(0);
0064     gStyle->SetTitleFontSize(0.08);
0065     gStyle->SetTitleW(1);
0066     gStyle->SetTitleH(0.08);
0067     gStyle->SetTitleFillColor(0);
0068     gStyle->SetTitleBorderSize(0);
0069     gStyle->SetTitleXOffset(1);
0070     gStyle->SetTitleYOffset(1);
0071 
0072     auto hRunStatus = (TH1F*)input.Get("hRunStatus");
0073 
0074     auto hBadTowers    = (TH1F*)input.Get("hBadTowers");
0075     auto hBadTowersDead  = (TH1F*)input.Get("hBadTowersDead");
0076     auto hBadTowersHot  = (TH1F*)input.Get("hBadTowersHot");
0077     auto hBadTowersCold  = (TH1F*)input.Get("hBadTowersCold");
0078     auto hBadTowersHotChi2 = (TH1F*)input.Get("hBadTowersHotChi2");
0079 
0080     auto h2BadTowers   = (TH2F*)input.Get("h2BadTowers");
0081     auto h2BadTowersDead = (TH2F*)input.Get("h2BadTowersDead");
0082     auto h2BadTowersHot = (TH2F*)input.Get("h2BadTowersHot");
0083     auto h2BadTowersCold = (TH2F*)input.Get("h2BadTowersCold");
0084     auto h2BadTowersHotChi2 = (TH2F*)input.Get("h2BadTowersHotChi2");
0085 
0086     auto hSigma = (TH1F*)input.Get("hSigmaHot");
0087     auto hSigmaFreqHot = (TH1F*)input.Get("hSigmaFreqHot");
0088 
0089     auto hHotTowerStatus = (TH1F*)input.Get("hHotTowerStatus");
0090 
0091     auto h2HotTowerFrequency_dummy = (TH2F*)input.Get("h2HotTowerFrequency/h2HotTowerFrequency_27_7");
0092 
0093     auto hAcceptance = (TH1F*)input.Get("hAcceptance");
0094     auto hFracDead = (TH1F*)input.Get("hFracDead");
0095     auto hFracHot = (TH1F*)input.Get("hFracHot");
0096     auto hFracCold = (TH1F*)input.Get("hFracCold");
0097     auto hFracBadChi2 = (TH1F*)input.Get("hFracBadChi2");
0098 
0099     auto hAcceptanceVsTime = (TH1F*)input.Get("hAcceptanceVsTime");
0100     auto hDeadVsTime = (TH1F*)input.Get("hDeadVsTime");
0101     auto hHotVsTime = (TH1F*)input.Get("hHotVsTime");
0102     auto hColdVsTime = (TH1F*)input.Get("hColdVsTime");
0103     auto hBadChi2VsTime = (TH1F*)input.Get("hBadChi2VsTime");
0104 
0105     auto h2BadTowersFreq = new TH2F("h2BadTowersFreq", "Bad Towers; #phi Index; #eta Index", h2BadTowers->GetNbinsX(), -0.5, h2BadTowers->GetNbinsX()-0.5, h2BadTowers->GetNbinsY(), -0.5, h2BadTowers->GetNbinsY()-0.5);
0106 
0107     // threshold = h2HotTowerFrequency_dummy->GetEntries()/2;
0108     cout << "threshold: " << threshold << endl;
0109 
0110     for(UInt_t i = 1; i <= h2BadTowers->GetNbinsX(); ++i) {
0111         for(UInt_t j = 1; j <= h2BadTowers->GetNbinsY(); ++j) {
0112             Double_t val = 0;
0113             val = max(val, h2BadTowersDead->GetBinContent(i, j));
0114             val = max(val, h2BadTowersHot->GetBinContent(i, j));
0115             val = max(val, h2BadTowersCold->GetBinContent(i, j));
0116             val = max(val, h2BadTowersHotChi2->GetBinContent(i, j));
0117 
0118             if(val >= threshold) h2BadTowersFreq->SetBinContent(i, j, val);
0119         }
0120     }
0121 
0122     // vector<string> hBadTowersTitle = {"Runs [with Bad Towers]", "Runs [with Dead Towers]","Runs [with Hot Towers]","Runs [with Cold Towers]","Runs [with BadChi2 Towers]"};
0123     vector<TH1F*> hBadTowersVec  = {hBadTowers, hBadTowersDead, hBadTowersHot, hBadTowersCold, hBadTowersHotChi2};
0124     vector<TH2F*> h2BadTowersVec = {h2BadTowersFreq, h2BadTowersDead, h2BadTowersHot, h2BadTowersCold, h2BadTowersHotChi2};
0125     // vector<string> label         = {"Status #neq 0", "Dead", "Hot", "Cold"};
0126 
0127     string dirName = "hHotTowerSigma";
0128     TDirectory* dir = (TDirectory*) input.Get(dirName.c_str());
0129     if (!dir)
0130     {
0131       cerr << "Directory not found: " << dirName << endl;
0132       input.Close();
0133       return;
0134     }
0135 
0136     TIter nextkey(dir->GetListOfKeys());
0137     TKey* key;
0138 
0139     stringstream name;
0140 
0141     c1->Print((outputSigma + "[").c_str(), "pdf portrait");
0142     c1->cd();
0143 
0144     gPad->SetLogy();
0145 
0146     hSigma->Rebin(5);
0147 
0148     auto sigma_threshold = new TLine(5, 0, 5, hSigma->GetMaximum()*1.05);
0149     sigma_threshold->SetLineColor(kOrange);
0150     sigma_threshold->SetLineWidth(3);
0151 
0152     hSigma->SetTitle("Towers");
0153     hSigma->SetLineColor(kBlue);
0154     hSigma->GetXaxis()->SetRangeUser(0,30);
0155     hSigma->GetYaxis()->SetRangeUser(1,1e7);
0156     hSigma->Draw();
0157     sigma_threshold->Draw("same");
0158     c1->Print((outputSigmaDir + string(hSigma->GetName()) + ".png").c_str());
0159 
0160     hSigmaFreqHot->Rebin(5);
0161 
0162     hSigmaFreqHot->SetLineColor(kRed);
0163     hSigmaFreqHot->Draw("same");
0164 
0165     auto leg = new TLegend(0.5,.75,0.7,.9);
0166     leg->SetFillStyle(0);
0167     leg->AddEntry(hSigma,("Flagged Hot < " + to_string(threshold) + " Runs").c_str(),"f");
0168     leg->AddEntry(hSigmaFreqHot,("Flagged Hot #geq " + to_string(threshold) +" Runs").c_str(),"f");
0169     leg->AddEntry(sigma_threshold,"Sigma Threshold","l");
0170     leg->Draw("same");
0171 
0172     c1->Print((outputSigmaDir + string(hSigma->GetName()) + ".png").c_str());
0173     c1->Print(outputSigma.c_str(), "pdf portrait");
0174 
0175     gPad->SetLogy(0);
0176 
0177     TLatex latex;
0178     latex.SetTextSize(0.05);
0179 
0180     while ((key = (TKey*) nextkey())) {
0181         name.str("");
0182         name << dirName << "/" << key->GetName();
0183 
0184         auto h = (TH1F*)input.Get(name.str().c_str());
0185         h->Rebin(5);
0186 
0187         sigma_threshold = new TLine(5, 0, 5, h->GetMaximum()*1.2);
0188         sigma_threshold->SetLineColor(kRed);
0189         sigma_threshold->SetLineWidth(3);
0190         h->Draw();
0191         Int_t overFlow = 0;
0192         Int_t xlow = -4;
0193         if(string(key->GetName()) == "hHotTowerSigma_27_84") {
0194             h->GetXaxis()->SetRangeUser(xlow,30);
0195             overFlow = h->Integral(h->FindBin(30),h->GetNbinsX()+1);
0196         }
0197         else if(string(key->GetName()) == "hHotTowerSigma_27_85") {
0198             h->GetXaxis()->SetRangeUser(xlow,20);
0199             overFlow = h->Integral(h->FindBin(20),h->GetNbinsX()+1);
0200         }
0201         else {
0202             h->GetXaxis()->SetRangeUser(xlow,15);
0203             overFlow = h->Integral(h->FindBin(15),h->GetNbinsX()+1);
0204         }
0205 
0206         h->GetYaxis()->SetRangeUser(0,h->GetMaximum()*1.2);
0207 
0208         name.str("");
0209         name << "Overflow: " << overFlow << " Runs";
0210 
0211         latex.DrawLatexNDC(0.67,0.85, name.str().c_str());
0212 
0213         name.str("");
0214         name << "Underflow: " << h->Integral(0,h->FindBin(xlow)-1) << " Runs";
0215 
0216         latex.DrawLatexNDC(0.67,0.8, name.str().c_str());
0217 
0218         sigma_threshold->Draw("same");
0219 
0220         c1->Print((outputSigmaDir + string(h->GetName()) + "-sigma.png").c_str());
0221         c1->Print(outputSigma.c_str(), "pdf portrait");
0222     }
0223 
0224     c1->Print((outputSigma + "]").c_str(), "pdf portrait");
0225 
0226     c1->Print((outputAccpt + "[").c_str(), "pdf portrait");
0227 
0228     TLine* line = new TLine(0, threshold, ntowers, threshold);
0229     line->SetLineColor(kRed);
0230     line->SetLineStyle(9);
0231     line->SetLineWidth(3);
0232 
0233     for(UInt_t i = 0; i < hBadTowersVec.size(); ++i) {
0234 
0235         // hBadTowersVec[i]->GetYaxis()->SetTitle(hBadTowersTitle[i].c_str());
0236         Float_t norm = (i < hBadTowersVec.size()-1) ? hRunStatus->GetBinContent(1) : hRunStatus->GetBinContent(2);
0237         cout << "norm: " << norm << endl;
0238         hBadTowersVec[i]->Scale(100./norm);
0239 
0240         hBadTowersVec[i]->GetYaxis()->SetTitle("Runs [%]");
0241         hBadTowersVec[i]->GetYaxis()->SetTitleOffset(1.3);
0242         if(hBadTowersVec[i]->GetMaximum() <= 100) hBadTowersVec[i]->GetYaxis()->SetRangeUser(0,100);
0243         hBadTowersVec[i]->Draw("HIST");
0244 
0245         auto line = new TLine(0, threshold*100/norm, ntowers, threshold*100/norm);
0246         line->SetLineColor(kRed);
0247         line->SetLineStyle(9);
0248         line->SetLineWidth(3);
0249         line->Draw("same");
0250 
0251         c1->Print((outputAccptDir + string(hBadTowersVec[i]->GetName()) + ".png").c_str());
0252         c1->Print(outputAccpt.c_str(), "pdf portrait");
0253 
0254         delete line;
0255     }
0256 
0257     c1->SetCanvasSize(2900, 1000);
0258     c1->SetLeftMargin(.06);
0259     c1->SetRightMargin(.12);
0260     c1->SetTopMargin(.1);
0261     c1->SetBottomMargin(.12);
0262     gPad->SetGrid();
0263 
0264     for(UInt_t i = 0; i < h2BadTowersVec.size(); ++i) {
0265         h2BadTowersVec[i]->SetMaximum(zMax);
0266 
0267         h2BadTowersVec[i]->GetXaxis()->SetLimits(0,256);
0268         h2BadTowersVec[i]->GetXaxis()->SetNdivisions(32, false);
0269         h2BadTowersVec[i]->GetXaxis()->SetLabelSize(0.04);
0270         h2BadTowersVec[i]->GetXaxis()->SetTickSize(0.01);
0271         h2BadTowersVec[i]->GetYaxis()->SetTickSize(0.01);
0272         h2BadTowersVec[i]->GetYaxis()->SetLabelSize(0.04);
0273         h2BadTowersVec[i]->GetYaxis()->SetLimits(0,96);
0274         h2BadTowersVec[i]->GetYaxis()->SetNdivisions(12, false);
0275         h2BadTowersVec[i]->GetYaxis()->SetTitleOffset(0.5);
0276 
0277         if(i == 0) h2BadTowersVec[i]->SetMinimum(threshold);
0278 
0279         h2BadTowersVec[i]->Draw("colz1");
0280 
0281         c1->Print((outputAccptDir +string(h2BadTowersVec[i]->GetName()) + ".png").c_str());
0282         c1->Print(outputAccpt.c_str(), "pdf portrait");
0283     }
0284 
0285     h2BadTowersDead->SetMinimum(threshold);
0286     h2BadTowersDead->Draw("colz1");
0287 
0288     c1->Print((outputAccptDir + string(h2BadTowersDead->GetName()) + "-threshold.png").c_str());
0289     c1->Print(outputAccpt.c_str(), "pdf portrait");
0290 
0291     h2BadTowersHot->SetMinimum(threshold);
0292     h2BadTowersHot->Draw("colz1");
0293 
0294     c1->Print((outputAccptDir + string(h2BadTowersHot->GetName()) + "-threshold.png").c_str());
0295     c1->Print(outputAccpt.c_str(), "pdf portrait");
0296 
0297     h2BadTowersCold->SetMinimum(threshold);
0298     h2BadTowersCold->Draw("colz1");
0299 
0300     c1->Print((outputAccptDir + string(h2BadTowersCold->GetName()) + "-threshold.png").c_str());
0301     c1->Print(outputAccpt.c_str(), "pdf portrait");
0302 
0303     h2BadTowersHotChi2->SetMinimum(threshold);
0304     h2BadTowersHotChi2->Draw("colz1");
0305 
0306     c1->Print((outputAccptDir + string(h2BadTowersHotChi2->GetName()) + "-threshold.png").c_str());
0307     c1->Print(outputAccpt.c_str(), "pdf portrait");
0308 
0309     h2BadTowersHotChi2->SetMinimum(0);
0310     h2BadTowersHotChi2->SetMaximum(40);
0311 
0312     c1->Print((outputAccptDir + string(h2BadTowersHotChi2->GetName()) + "-zoom.png").c_str());
0313     c1->Print(outputAccpt.c_str(), "pdf portrait");
0314 
0315     // ----------------------------
0316 
0317     c1->SetRightMargin(.1);
0318     gPad->SetGrid(0,0);
0319 
0320     c1->SetTicky(0);
0321 
0322     auto vl = new TLine(d.Convert(), 0, d.Convert(), hAcceptanceVsTime->GetMaximum()*1.05);
0323     vl->SetLineColor(kRed);
0324     vl->SetLineWidth(1);
0325 
0326     Float_t xmax = hAcceptanceVsTime->GetXaxis()->GetXmax();
0327     auto axis = new TGaxis(xmax,0,xmax,100,0,24576,110,"+L");
0328     axis->SetTitle("Towers");
0329     axis->SetTitleSize(0.05);
0330     axis->SetTitleOffset(0.8);
0331     axis->SetLabelSize(0.05);
0332     // axis->SetTextAngle();
0333 
0334     hAcceptanceVsTime->Draw("P");
0335     hAcceptanceVsTime->SetMarkerColor(kBlue);
0336     hAcceptanceVsTime->SetMarkerStyle(3);
0337     hAcceptanceVsTime->GetYaxis()->SetTitleOffset(0.5);
0338     vl->Draw("same");
0339 
0340     cout << "Max: " << hAcceptanceVsTime->GetXaxis()->GetXmax() << endl;
0341     axis->Draw();
0342 
0343     c1->Print((outputAccptDir + string(hAcceptanceVsTime->GetName()) + ".png").c_str());
0344     c1->Print(outputAccpt.c_str(), "pdf portrait");
0345 
0346     // compute averages
0347     UInt_t bin_change = hAcceptanceVsTime->FindBin(d.Convert());
0348     Float_t acceptanceTotal[2] = {0};
0349     UInt_t bin_ctr[2] = {0};
0350     for(UInt_t i = 1; i <= hAcceptanceVsTime->GetNbinsX(); ++i) {
0351         Float_t val = hAcceptanceVsTime->GetBinContent(i);
0352         if(i < bin_change && val != 0) {
0353            acceptanceTotal[0] += val;
0354            ++bin_ctr[0];
0355         }
0356         if(i >= bin_change && val != 0) {
0357            acceptanceTotal[1] += hAcceptanceVsTime->GetBinContent(i);
0358            ++bin_ctr[1];
0359         }
0360     }
0361 
0362     cout << "#########################" << endl;
0363     cout << "Average Acceptance" << endl;
0364     cout << "Bin Change: " << bin_change << endl;
0365     cout << "Overall: " << (acceptanceTotal[0]+acceptanceTotal[1])/(bin_ctr[0]+bin_ctr[1]) << " %" << endl;
0366     cout << "0 mrad: " << acceptanceTotal[0]/bin_ctr[0] << " %" << endl;
0367     cout << "1.5 mrad: " << acceptanceTotal[1]/bin_ctr[1] << " %" << endl;
0368     cout << "#########################" << endl;
0369 
0370     // ----------------------------
0371 
0372     hDeadVsTime->Draw("P");
0373     hDeadVsTime->SetMarkerStyle(3);
0374     hDeadVsTime->SetMarkerColor(kBlue);
0375     hDeadVsTime->GetYaxis()->SetTitleOffset(0.5);
0376     axis->Draw();
0377     vl->Draw("same");
0378 
0379     c1->Print((outputAccptDir + string(hDeadVsTime->GetName()) + ".png").c_str());
0380     c1->Print(outputAccpt.c_str(), "pdf portrait");
0381 
0382     delete axis;
0383     axis = new TGaxis(xmax,0.8,xmax,2,196,492,510,"+L");
0384     axis->SetTitle("Towers");
0385     axis->SetTitleSize(0.05);
0386     axis->SetTitleOffset(0.6);
0387     axis->SetLabelSize(0.05);
0388     vl->SetY1(0.8);
0389     vl->SetY2(2);
0390 
0391     hDeadVsTime->GetYaxis()->SetRangeUser(0.8,2);
0392     axis->Draw();
0393 
0394 
0395     c1->Print((outputAccptDir + string(hDeadVsTime->GetName()) + "-zoom.png").c_str());
0396     c1->Print(outputAccpt.c_str(), "pdf portrait");
0397 
0398     // ----------------------------
0399 
0400     delete axis;
0401     axis = new TGaxis(xmax,0,xmax, hHotVsTime->GetMaximum()*1.05,0,ntowers*hHotVsTime->GetMaximum()*1.05/100.,510,"+L");
0402     axis->SetTitle("Towers");
0403     axis->SetTitleSize(0.05);
0404     axis->SetTitleOffset(0.6);
0405     axis->SetLabelSize(0.05);
0406 
0407     hHotVsTime->Draw("P");
0408     hHotVsTime->SetMarkerStyle(3);
0409     hHotVsTime->SetMarkerColor(kBlue);
0410     hHotVsTime->GetYaxis()->SetTitleOffset(0.5);
0411     axis->Draw();
0412     vl->SetY1(0);
0413     vl->SetY2(hHotVsTime->GetMaximum()*1.05);
0414     vl->Draw("same");
0415 
0416     c1->Print((outputAccptDir + string(hHotVsTime->GetName()) + ".png").c_str());
0417     c1->Print(outputAccpt.c_str(), "pdf portrait");
0418 
0419     delete axis;
0420     axis = new TGaxis(xmax,0,xmax,0.5,0,123,510,"+L");
0421     axis->SetTitle("Towers");
0422     axis->SetTitleSize(0.05);
0423     axis->SetTitleOffset(0.6);
0424     axis->SetLabelSize(0.05);
0425     axis->Draw();
0426     vl->SetY2(0.5);
0427 
0428     hHotVsTime->GetYaxis()->SetTitleOffset(0.6);
0429     hHotVsTime->GetYaxis()->SetRangeUser(0,0.5);
0430 
0431     c1->Print((outputAccptDir + string(hHotVsTime->GetName()) + "-zoom.png").c_str());
0432     c1->Print(outputAccpt.c_str(), "pdf portrait");
0433 
0434     // ----------------------------
0435 
0436     delete axis;
0437     axis = new TGaxis(xmax,0,xmax, hColdVsTime->GetMaximum()*1.05,0,ntowers*hColdVsTime->GetMaximum()*1.05/100.,510,"+L");
0438 
0439     axis->SetTitle("Towers");
0440     axis->SetTitleSize(0.05);
0441     axis->SetTitleOffset(0.6);
0442     axis->SetLabelSize(0.05);
0443 
0444     hColdVsTime->Draw("P");
0445     hColdVsTime->SetMarkerStyle(3);
0446     hColdVsTime->SetMarkerColor(kBlue);
0447     hColdVsTime->GetYaxis()->SetTitleOffset(0.5);
0448     axis->Draw();
0449     vl->SetY2(hColdVsTime->GetMaximum()*1.05);
0450     vl->Draw("same");
0451 
0452     c1->Print((outputAccptDir + string(hColdVsTime->GetName()) + ".png").c_str());
0453     c1->Print(outputAccpt.c_str(), "pdf portrait");
0454 
0455     // ----------------------------
0456 
0457     delete axis;
0458     axis = new TGaxis(xmax,0,xmax, hBadChi2VsTime->GetMaximum()*1.05,0,ntowers*hBadChi2VsTime->GetMaximum()*1.05/100.,510,"+L");
0459     axis->SetTitle("Towers");
0460     axis->SetTitleSize(0.05);
0461     axis->SetTitleOffset(0.8);
0462     axis->SetLabelSize(0.05);
0463 
0464     hBadChi2VsTime->Draw("P");
0465     hBadChi2VsTime->SetMarkerStyle(3);
0466     hBadChi2VsTime->SetMarkerColor(kBlue);
0467     hBadChi2VsTime->GetYaxis()->SetTitleOffset(0.5);
0468     axis->Draw();
0469     vl->SetY2(hBadChi2VsTime->GetMaximum()*1.05);
0470     vl->Draw("same");
0471 
0472     c1->Print((outputAccptDir + string(hBadChi2VsTime->GetName()) + ".png").c_str());
0473     c1->Print(outputAccpt.c_str(), "pdf portrait");
0474 
0475     delete axis;
0476     axis = new TGaxis(xmax,0,xmax,1,0,246,510,"+L");
0477     axis->SetTitle("Towers");
0478     axis->SetTitleSize(0.05);
0479     axis->SetTitleOffset(0.6);
0480     axis->SetLabelSize(0.05);
0481     axis->Draw();
0482     vl->SetY2(1);
0483 
0484     // hBadChi2VsTime->GetYaxis()->SetTitleOffset(0.6);
0485     hBadChi2VsTime->GetYaxis()->SetRangeUser(0,1);
0486 
0487     c1->Print((outputAccptDir + string(hBadChi2VsTime->GetName()) + "-zoom.png").c_str());
0488     c1->Print(outputAccpt.c_str(), "pdf portrait");
0489 
0490     // ----------------------------
0491 
0492     gPad->SetLogy();
0493 
0494     c1->SetTicky();
0495     c1->SetCanvasSize(1300,1000);
0496     c1->SetRightMargin(0.05);
0497     c1->SetLeftMargin(0.1);
0498 
0499     hAcceptance->Draw();
0500     c1->Print((outputAccptDir + string(hAcceptance->GetName()) + ".png").c_str());
0501     c1->Print(outputAccpt.c_str(), "pdf portrait");
0502 
0503     // ----------------------------
0504 
0505     hFracDead->Draw();
0506     c1->Print((outputAccptDir + string(hFracDead->GetName()) + ".png").c_str());
0507     c1->Print(outputAccpt.c_str(), "pdf portrait");
0508 
0509     // ----------------------------
0510 
0511     hFracHot->GetXaxis()->SetRangeUser(0,12);
0512     hFracHot->Draw();
0513     c1->Print((outputAccptDir + string(hFracHot->GetName()) + ".png").c_str());
0514     c1->Print(outputAccpt.c_str(), "pdf portrait");
0515 
0516     // ----------------------------
0517 
0518     hFracCold->GetXaxis()->SetRangeUser(0,3);
0519     hFracCold->Draw();
0520     c1->Print((outputAccptDir + string(hFracCold->GetName()) + ".png").c_str());
0521     c1->Print(outputAccpt.c_str(), "pdf portrait");
0522 
0523     // ----------------------------
0524 
0525     hFracBadChi2->GetXaxis()->SetRangeUser(0,80);
0526     hFracBadChi2->Draw();
0527     c1->Print((outputAccptDir + string(hFracBadChi2->GetName()) + ".png").c_str());
0528     c1->Print(outputAccpt.c_str(), "pdf portrait");
0529 
0530     // ----------------------------
0531 
0532     hHotTowerStatus->GetYaxis()->SetTitleOffset(0.9);
0533     hHotTowerStatus->Draw();
0534 
0535     c1->Print((outputAccptDir + string(hHotTowerStatus->GetName()) + ".png").c_str());
0536     c1->Print(outputAccpt.c_str(), "pdf portrait");
0537 
0538     // ----------------------------
0539 
0540     c1->Print((outputAccpt + "]").c_str(), "pdf portrait");
0541 
0542     UInt_t ctr[10] = {0};
0543 
0544     for(UInt_t i = 1; i <= h2BadTowers->GetNbinsX(); ++i) {
0545         for(UInt_t j = 1; j <= h2BadTowers->GetNbinsY(); ++j) {
0546             if(h2BadTowers->GetBinContent(i, j) > 0)                 ++ctr[0];
0547             if(h2BadTowersFreq->GetBinContent(i, j) >= threshold)    ++ctr[1];
0548             if(h2BadTowersDead->GetBinContent(i, j) > 0)             ++ctr[2];
0549             if(h2BadTowersDead->GetBinContent(i, j) >= threshold)    ++ctr[3];
0550             if(h2BadTowersHot->GetBinContent(i, j) > 0)              ++ctr[4];
0551             if(h2BadTowersHot->GetBinContent(i, j) >= threshold)     ++ctr[5];
0552             if(h2BadTowersCold->GetBinContent(i, j) > 0)             ++ctr[6];
0553             if(h2BadTowersCold->GetBinContent(i, j) >= threshold)    ++ctr[7];
0554             if(h2BadTowersHotChi2->GetBinContent(i, j) > 0)          ++ctr[8];
0555             if(h2BadTowersHotChi2->GetBinContent(i, j) >= threshold) ++ctr[9];
0556         }
0557     }
0558 
0559     cout << "Bad Towers" << endl
0560          << "Any Run: "                          << ctr[0] << ", " << ctr[0]*100./ntowers << " %" << endl
0561          << "Threshold >= " << threshold << ": " << ctr[1] << ", " << ctr[1]*100./ntowers << " %" << endl << endl;
0562 
0563     cout << "Dead Towers" << endl
0564          << "Any Run: "                          << ctr[2] << ", " << ctr[2]*100./ntowers << " %" << endl
0565          << "Threshold >= " << threshold << ": " << ctr[3] << ", " << ctr[3]*100./ntowers << " %" << endl << endl;
0566 
0567     cout << "Hot Towers" << endl
0568          << "Any Run: "                          << ctr[4] << ", " << ctr[4]*100./ntowers << " %" << endl
0569          << "Threshold >= " << threshold << ": " << ctr[5] << ", " << ctr[5]*100./ntowers << " %" << endl << endl;
0570 
0571     cout << "Cold Towers" << endl
0572          << "Any Run: "                          << ctr[6] << ", " << ctr[6]*100./ntowers << " %" << endl
0573          << "Threshold >= " << threshold << ": " << ctr[7] << ", " << ctr[7]*100./ntowers << " %" << endl << endl;
0574 
0575     cout << "Bad Chi2 Towers" << endl
0576          << "Any Run: "                          << ctr[8] << ", " << ctr[8]*100./ntowers << " %" << endl
0577          << "Threshold >= " << threshold << ": " << ctr[9] << ", " << ctr[9]*100./ntowers << " %" << endl;
0578 
0579     input.Close();
0580 }
0581 
0582 void display(const string &input, const string &outputDir=".") {
0583     cout << "#############################" << endl;
0584     cout << "Run Parameters" << endl;
0585     cout << "input: "  << input << endl;
0586     cout << "outputDir: " << outputDir << endl;
0587     cout << "#############################" << endl;
0588 
0589     // set sPHENIX plotting style
0590     SetsPhenixStyle();
0591 
0592     // make the output directories
0593     std::filesystem::create_directories(outputDir + "/acceptance");
0594     std::filesystem::create_directories(outputDir + "/sigma");
0595 
0596     myAnalysis::plots(input, outputDir);
0597 }
0598 
0599 # ifndef __CINT__
0600 Int_t main(Int_t argc, char* argv[]) {
0601 if(argc < 2 || argc > 3){
0602         cout << "usage: ./display input [output]" << endl;
0603         cout << "input: input root file" << endl;
0604         cout << "outputDir: output directory" << endl;
0605         return 1;
0606     }
0607 
0608     string outputDir = ".";
0609 
0610     if(argc >= 3) {
0611         outputDir = argv[2];
0612     }
0613 
0614     display(argv[1], outputDir);
0615 
0616     cout << "======================================" << endl;
0617     cout << "done" << endl;
0618     return 0;
0619 }
0620 # endif