ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmpR.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file cmpR.C
1 // Draw Radial Shower Profile
2 
3 #include "TH1D.h"
4 #include "TFile.h"
5 #include "THStack.h"
6 #include "TCanvas.h"
7 #include "TString.h"
8 #include "TLegend.h"
9 
10 
11 TCanvas *cmpR() {
12 
13  //TString dataDir("/net/llrdata1.in2p3.fr/data/DATA/data.harpo/BH5D/");
14  TString dataDir("./");
15 
16  TString dataFile[2];
17  dataFile[0] = "gflash00.root";
18  dataFile[1] = "gflash01.root";
19 
20 
21  TFile *f[2];
22  TProfile *p[2];
23  // UInt_t col[] = { kRed, kBlue, kGreen, kViolet };
24  UInt_t col[] = { kRed, kGreen, kBlue, kViolet };
25  // UInt_t mark[] = { 20, 32, 21, 22};
26  UInt_t mark[] = { 20, 21, 32, 22};
27 //
28  THStack *hs = new THStack("hs","");
29 
30  for (UInt_t i = 0; i < 2; i++) {
31  TString tmp = dataDir + dataFile[i];
32  f[i] = TFile::Open(tmp);
33  if (!f[i]) return 0;
34  p[i] = (TProfile *) (f[i])->Get("p1");
35  //ShiftUp(p[i],0.0);
36  // histogram
37  p[i]->SetFillColor(col[i]);
38  p[i]->SetLineStyle(i+2);
39  p[i]->SetLineColor(col[i]);
40  p[i]->SetLineWidth(2);
41  p[i]->SetMarkerStyle(mark[i]);
42  p[i]->SetMarkerColor(col[i]);
43  p[i]->SetMarkerSize(1.5);
44  hs->Add(p[i]);
45  }
46  TCanvas *cst = new TCanvas("cst","stacked hists",10,10,800,700);
47  //gPad->SetGrid();
48  hs->Draw("p,nostack");
49  hs->SetTitle("Radial Profile");
50  hs->GetXaxis()->SetTitle("Radius (RadLen)");
51  hs->GetYaxis()->SetTitle("E/E_{tot} (%/RadLen)");
52 
53  cst->RedrawAxis();
54  cst->Update();
55 
56  TLegend* legend = new TLegend(0.79,0.84,0.94,0.94);
57  legend->AddEntry(p[0],"full ","p");
58  legend->AddEntry(p[1],"gflash","p");
59  legend->Draw();
60  cst->Update();
61 
62  //img->FromPad(c, 10, 10, 300, 200);
63 
64  // TImage *img = TImage::Create();
65 
66  // img->FromPad(cst);
67 
68  // img->WriteImage("hist0-640MeV-p.png");
69 
70  // for (UInt_t i = 0; i < 4; i++) {
71  // f[i]->Close();
72  // }
73  return cst;
74 }