Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:19:54

0001 void plot_nodes()
0002 {
0003     TFile *file = new TFile("HIST_CALOR_QA-00043901-0004.root", "READ");
0004     
0005     TString name = "h_CaloValid_nodes_exists";
0006     TH1F *hist = (TH1F*)file->Get(name.Data());
0007 
0008     TCanvas *c1 = new TCanvas("c1", "Histogram with Bin Labels", 800, 600);
0009 
0010     hist->Draw();
0011 
0012     //label each bin
0013     
0014     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"};
0015 
0016     int size = sizeof(binNames)/sizeof(binNames[0]);
0017     
0018     for (int i=0; i<size; i++)
0019     {
0020         std::cout << binNames[i] << std::endl;
0021     }
0022 
0023     for (int i = 1; i <= hist->GetNbinsX(); i++)
0024     {
0025         float binCenter = hist->GetBinCenter(i);
0026         float binContent = hist->GetBinContent(i);
0027         // Create a TText object
0028         TText *text = new TText(binCenter, binContent + 1, binNames[i-1].c_str());
0029         //TText *text = new TText(binCenter, binContent + 1, Form(binNames[i-1].c_str()));
0030         //TText *text = new TText(binCenter, binContent + 1, Form("Bin %d", i));
0031         // Set text alignment (centered)
0032         text->SetTextAlign(22);
0033         text->SetTextSize(0.04);
0034         text->SetTextAngle(90);
0035         text->Draw();
0036     }
0037 
0038     c1->Update();
0039 }