#!/usr/bin/env python # coding: utf-8 # In[1]: # imports to write dynamic markdown contents import os from IPython.display import display, Markdown, Latex from IPython.display import HTML # In[2]: # turn off/on code for the result HTML page display(Markdown('*For the result HTML page:* ')) HTML('''
''') # ECCE style works with any ECCE software distribution via [Singularity container](https://github.com/ECCE-EIC/Singularity). Or use your own `ROOT` plus simply download the style files to local folder from [`ECCEStyle.C`](https://raw.githubusercontent.com/ECCE-EIC/macros/master/common/ECCEStyle.C) and [`ECCEStyle.h`](https://raw.githubusercontent.com/ECCE-EIC/macros/master/common/ECCEStyle.h). # # And here is example `ROOT` C++ macro to make an ECCE style plot: # # ```c++ # # { # TCanvas c; # TH1F h1("h1","H1;Mass [GeV];Counts [/ GeV];",20,0,20); # TH1F h2("h2","H2;Mass [GeV];Counts [/ GeV];",20,0,20); # for (int i = 0;i<1000;i++){h1.Fill(gRandom->Gaus(7,2));} # for (int i = 0;i<1000;i++){h1.Fill(gRandom->Exp(.5)*20);} # for (int i = 0;i<1000;i++){h2.Fill(gRandom->Exp(.5)*20);} # h1.Draw("e1"); # h2.Draw("same"); # h2.SetFillColor(5); # h1.Draw("e1same"); # # TLegend leg(.55,.70,.85,.93); # leg.AddEntry("","#it{#bf{ECCE}} Simulation",""); # leg.AddEntry("","e+p 18+275 GeV",""); # leg.AddEntry(&h1,"Data","LP"); # leg.AddEntry(&h2,"MC","F"); # leg.Draw(); # c.RedrawAxis(); # c.Print("test_style.pdf"); # c.Print("test_style.png"); # # TCanvas c2; # c2.SetRightMargin(.2); # TF2 f2("f2","exp(-x/5)*sin(y)",-5,5,-5,5); # //f2.SetContour(100); # f2.SetNpx(100); # f2.SetNpy(100); # f2.Draw("surf2z"); # f2.GetXaxis()->SetTitle("X"); # f2.GetYaxis()->SetTitle("Y"); # f2.GetZaxis()->SetTitle("Z"); # c2.Print("test_style_f2.pdf"); # c2.Print("test_style_f2.png"); # } # # # ``` # In[3]: os.environ["ROOT_INCLUDE_PATH"] = os.getenv("ROOT_INCLUDE_PATH") + ":/cvmfs/eic.opensciencegrid.org/ecce/gcc-8.3/release/release_new/new/rootmacros" # In[4]: import ROOT OFFLINE_MAIN = os.getenv("OFFLINE_MAIN") if OFFLINE_MAIN is not None: display(Markdown(f"via sPHENIX software distribution at `{OFFLINE_MAIN}`")) # In[5]: get_ipython().run_cell_magic('cpp', '-d', '\n#include \n// #include \n') # In[6]: get_ipython().run_cell_magic('cpp', '', '\n// SetsPhenixStyle();\nSetECCEStyle();\n') # In[7]: get_ipython().run_cell_magic('cpp', '', '\n\n TCanvas c;\n TH1F h1("h1","H1;Mass [GeV];Counts [/ GeV];",20,0,20);\n TH1F h2("h2","H2;Mass [GeV];Counts [/ GeV];",20,0,20);\n for (int i = 0;i<1000;i++){h1.Fill(gRandom->Gaus(7,2));}\n for (int i = 0;i<1000;i++){h1.Fill(gRandom->Exp(.5)*20);}\n for (int i = 0;i<1000;i++){h2.Fill(gRandom->Exp(.5)*20);}\n h1.Draw("e1");\n h2.Draw("same");\n h2.SetFillColor(5);\n h1.Draw("e1same");\n\n TLegend leg(.55,.70,.85,.93);\n leg.AddEntry("","#it{#bf{ECCE}} Simulation","");\n leg.AddEntry("","e+p 18+275 GeV","");\n leg.AddEntry(&h1,"Data","LP");\n leg.AddEntry(&h2,"MC","F");\n leg.Draw();\n c.RedrawAxis();\n c.Print("test_style.pdf");\n c.Print("test_style.png");\n c.Draw();\n') # In[8]: get_ipython().run_cell_magic('cpp', '', '\n\n TCanvas c2;\n c2.SetRightMargin(.2);\n TF2 f2("f2","exp(-x/5)*sin(y)",-5,5,-5,5);\n //f2.SetContour(100);\n f2.SetNpx(100);\n f2.SetNpy(100);\n f2.Draw("surf2z");\n f2.GetXaxis()->SetTitle("X");\n f2.GetYaxis()->SetTitle("Y");\n f2.GetZaxis()->SetTitle("Z");\n c2.Print("test_style_f2.pdf");\n c2.Print("test_style_f2.png");\n c2.Draw();\n')