Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:32

0001 // Draw Longitudinal Shower Profile
0002 
0003 #include "TH1D.h"
0004 #include "TFile.h"
0005 #include "THStack.h"
0006 #include "TCanvas.h"
0007 #include "TString.h"
0008 #include "TLegend.h"
0009 
0010 
0011 TCanvas *cmpL() {
0012 
0013   //TString dataDir("/net/llrdata1.in2p3.fr/data/DATA/data.harpo/BH5D/");
0014   TString dataDir("./");
0015 
0016   TString dataFile[2];
0017   dataFile[0]  =  "gflash00.root";
0018   dataFile[1]  =  "gflash01.root";
0019 
0020 
0021   TFile *f[2];
0022   TProfile *p[2];
0023   //  UInt_t col[] = { kRed, kBlue, kGreen, kViolet };
0024   UInt_t col[] = { kRed, kGreen, kBlue, kViolet };
0025   //  UInt_t mark[] = { 20, 32, 21, 22};
0026   UInt_t mark[] = { 20, 21, 32, 22};
0027 //
0028    THStack *hs = new THStack("hs","");
0029 
0030    for (UInt_t i = 0; i < 2; i++) {
0031      TString tmp = dataDir + dataFile[i];
0032      f[i] = TFile::Open(tmp);
0033      if (!f[i]) return 0;
0034      p[i] = (TProfile *) (f[i])->Get("p0");
0035      //ShiftUp(p[i],0.0);
0036    // histogram
0037      p[i]->SetFillColor(col[i]);
0038      p[i]->SetLineStyle(i+2);
0039      p[i]->SetLineColor(col[i]);
0040      p[i]->SetLineWidth(2);
0041      p[i]->SetMarkerStyle(mark[i]);
0042      p[i]->SetMarkerColor(col[i]);
0043      p[i]->SetMarkerSize(1.5);
0044      hs->Add(p[i]);
0045    }
0046    TCanvas *cst = new TCanvas("cst","stacked hists",10,10,800,700);
0047    //gPad->SetGrid();
0048    hs->Draw("p,nostack");
0049    hs->SetTitle("Longitudinal Profile");
0050    hs->GetXaxis()->SetTitle("Depth (RadLen)");
0051    hs->GetYaxis()->SetTitle("E/E_{tot} (%/RadLen)");
0052 
0053    cst->RedrawAxis();
0054    cst->Update();
0055 
0056    TLegend* legend = new TLegend(0.79,0.84,0.94,0.94);
0057    legend->AddEntry(p[0],"full ","p");
0058    legend->AddEntry(p[1],"gflash","p");
0059    legend->Draw();
0060    cst->Update();
0061 
0062    //img->FromPad(c, 10, 10, 300, 200);
0063 
0064    // TImage *img = TImage::Create();
0065 
0066    // img->FromPad(cst);
0067 
0068    // img->WriteImage("hist0-640MeV-p.png");
0069 
0070    // for (UInt_t i = 0; i < 4; i++) {
0071    // f[i]->Close();
0072    // }
0073    return cst;
0074 }