File indexing completed on 2025-12-16 09:24:11
0001 #include <TCanvas.h>
0002 #include <TFile.h>
0003 #include <TH1.h>
0004 #include <TString.h>
0005 #include <TText.h>
0006
0007 #include <iostream>
0008
0009 void plot_nodes()
0010 {
0011 TFile *file = new TFile("HIST_CALOR_QA-00043901-0004.root", "READ");
0012
0013 TString name = "h_CaloValid_nodes_exists";
0014 TH1 *hist = (TH1*)file->Get(name.Data());
0015
0016 TCanvas *c1 = new TCanvas("c1", "Histogram with Bin Labels", 800, 600);
0017
0018 hist->Draw();
0019
0020
0021
0022 std::string binNames[] = {"GlobalVertexMap", "TOWERINFO_CALIB_CEMC", "TOWERINFO_CALIB_HCALIN", "TOWERINFO_CALIB_HCALOUT", "TOWERINFO_CALIB_ZDC", "TOWERS_ZDC", "TOWERS_CEMC", "TOWERS_HCALOUT", "TOWERS_HCALIN", "MbdPmtContainer", "CLUSTERINFO_POS_COR_CEMC"};
0023
0024 int size = sizeof(binNames)/sizeof(binNames[0]);
0025
0026 for (int i=0; i<size; i++)
0027 {
0028 std::cout << binNames[i] << std::endl;
0029 }
0030
0031 for (int i = 1; i <= hist->GetNbinsX(); i++)
0032 {
0033 float binCenter = hist->GetBinCenter(i);
0034 float binContent = hist->GetBinContent(i);
0035
0036 TText *text = new TText(binCenter, binContent + 1, binNames[i-1].c_str());
0037
0038
0039
0040 text->SetTextAlign(22);
0041 text->SetTextSize(0.04);
0042 text->SetTextAngle(90);
0043 text->Draw();
0044 }
0045
0046 c1->Update();
0047 }