Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:15:42

0001 // $Id: $                                                                                             
0002 
0003 /*!
0004  * \file Draw.C
0005  * \brief 
0006  * \author Jin Huang <jhuang@bnl.gov>
0007  * \version $Revision:   $
0008  * \date $Date: $
0009  */
0010 
0011 #include <cmath>
0012 #include <TFile.h>
0013 #include <TString.h>
0014 #include <TLine.h>
0015 #include <TTree.h>
0016 #include <TLatex.h>
0017 #include <TGraphErrors.h>
0018 #include <cassert>
0019 #include "SaveCanvas.C"
0020 #include "SetOKStyle.C"
0021 using namespace std;
0022 
0023 void
0024 DrawEMCalTower_LineShape( //
0025     const TString base =
0026         "../../sPHENIX_work/Prototype_2016/test_sim/15Degree_1Col_No0Sup/", //
0027     const double E = 12)
0028 {
0029   SetOKStyle();
0030   gStyle->SetOptStat(0);
0031   gStyle->SetOptFit(0);
0032   TVirtualFitter::SetDefaultFitter("Minuit2");
0033 
0034   const TString sE = Form("%.0f", E);
0035 
0036   TText * t;
0037   TCanvas *c1 = new TCanvas("DrawEMCalTower_LineShape_" + sE,
0038       "DrawEMCalTower_LineShape_" + sE, 1000, 600);
0039   c1->Divide(1, 1);
0040   int idx = 1;
0041   TPad * p;
0042 
0043   p = (TPad *) c1->cd(idx++);
0044   c1->Update();
0045   p->SetLogy();
0046   p->SetGridx(0);
0047   p->SetGridy(0);
0048 
0049   p->DrawFrame(0, .0008, E * 1.3, 1,
0050       Form("Line shape for %.1f GeV beam (Green: e^{-}, Red: #pi^{-}, Blue: K^{-}, Black: #mu^{-});Energy Sum (GeV);Probability / bin", E));
0051 
0052   MakeOnePlot(base, "e-", sE, kGreen + 3)->DrawClone("same E1")->DrawClone("same hist LF2");
0053   MakeOnePlot(base, "pi-", sE, kRed )->DrawClone("same E1");
0054   MakeOnePlot(base, "kaon-", sE, kBlue )->DrawClone("same E1");
0055   MakeOnePlot(base, "mu-", sE, kBlack )->DrawClone("same E1");
0056 
0057   SaveCanvas(c1, base + TString(c1->GetName()), kTRUE);
0058 }
0059 
0060 TH1 *
0061 MakeOnePlot(const TString base, const TString particle, const TString sE,
0062     const Color_t color)
0063 {
0064 
0065   TString fname = base + TString("Prototype_") + particle + "_" + sE
0066       + "_SegALL_DSTReader.root_DrawEMCalTower_EMCDistribution_SUM_all_event.root";
0067 //  Prototype_e-_2_Seg0_DSTReader.root_DrawEMCalTower_EMCDistribution_SUMall_event.root
0068 
0069   TFile * f = new TFile(fname);
0070   assert(f->IsOpen());
0071 
0072   TH1 * hEnergySum = (TH1 *) f->GetObjectChecked("EnergySum_LG", "TH1");
0073   assert(hEnergySum);
0074 
0075   hEnergySum->Scale(1. / hEnergySum->Integral(1, -1));
0076   hEnergySum->GetFunction("fgaus_LG")->Delete();
0077   hEnergySum->SetStats(false);
0078   hEnergySum->Rebin(2);
0079 
0080   hEnergySum->SetFillColor(color);
0081   hEnergySum->SetLineColor(color);
0082   hEnergySum->SetMarkerColor(color);
0083   hEnergySum->SetMarkerSize(1.5);
0084   hEnergySum->SetLineWidth(3);
0085 
0086   return hEnergySum;
0087 }