{"metadata":{"language_info":{"name":"c++","codemirror_mode":"text/x-c++src","mimetype":" text/x-c++src","file_extension":".C"},"kernelspec":{"name":"root","display_name":"ROOT C++","language":"c++"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"// Let's start with setting some ROOT style parameters:\n// You do not need to know what they mean, but can directly use these settings\n\ngStyle->SetOptStat(kFALSE);\ngStyle->SetPalette(1);\n\ngStyle->SetTextFont(42);\n\ngStyle->SetTitleStyle(0000);\ngStyle->SetTitleBorderSize(0);\ngStyle->SetTitleFont(42);\ngStyle->SetTitleFontSize(0.055);\n\ngStyle->SetTitleFont(42, \"xyz\");\ngStyle->SetTitleSize(0.5, \"xyz\");\ngStyle->SetLabelFont(42, \"xyz\");\ngStyle->SetLabelSize(0.45, \"xyz\");","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"// We are currently in the CutLang/binder directory.  Let's move to the CutLang/runs directory:\ngSystem->cd(\"../runs/\");\n// Let's open the histoOut-exHistos.root file \nTFile f(\"histoOut-exHistos.root\");\n// Let's see what is in there\nf.ls();","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"// There is a ROOT directory (TDirectory) called presel.\n// Let's go inside\nf.cd(\"presel\");\n// ... and check what is there\nf.ls()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"/* \nThere are lots of histograms in the presel directory.  \nSome of them are 1-dimensional (TH1D), which have only one variable.\nHere, the histograms hjet1pt, hjet2pt, hjet3pt, hjet4pt are plotting the transverse moementa of the 1st, 2nd, 3rd and 4th jet in the events.\nWe will plot these histograms on top of each other.\nThose histograms can be accessed with their names.  In C++, they are pointer.\nThere is also a 2-dimensional histogram hmetjet1pt.  We will get to that one shortly. \n*/\n\n// We start with setting the style of the histograms.\n// Let's increase the line width of the histograms.\nhjet1pt->SetLineWidth(2);\nhjet2pt->SetLineWidth(2);\nhjet3pt->SetLineWidth(2);\nhjet4pt->SetLineWidth(2);\n\n// Now let's set the colors.\n// Information about ROOT colors: https://root.cern.ch/doc/master/classTColor.html\n// Set the histogram line color:\nhjet1pt->SetLineColor(kMagenta+1);\nhjet2pt->SetLineColor(kBlue);\nhjet3pt->SetLineColor(kRed+1);\nhjet4pt->SetLineColor(kGreen+2);\n\n// Set the histogram fill color:\nhjet1pt->SetFillColor(kMagenta+1);\nhjet2pt->SetFillColor(kBlue);\nhjet3pt->SetFillColor(kRed+1);\nhjet4pt->SetFillColor(kGreen+2);\n\n// Let's get even more fancy and fill \"in style\"\n// https://root.cern.ch/root/html528/TMarker.html\nhjet1pt->SetFillStyle(3003);\nhjet2pt->SetFillStyle(3003);\nhjet3pt->SetFillStyle(3003);\nhjet4pt->SetFillStyle(3003);\n\n// One can also plot markers with different styles, but we won't do it here.\n// https://root.cern.ch/root/html528/TMarker.html\n\n// Set the histogram title\nhjet4pt->SetTitle(\"Jet p_{T}\");\n// Set the x-axis title and font properties\nhjet4pt->GetXaxis()->SetTitle(\"p_{T} (GeV)\");\nhjet4pt->GetXaxis()->SetTitleOffset(1.25);\nhjet4pt->GetXaxis()->SetTitleSize(0.05);\nhjet4pt->GetXaxis()->SetLabelSize(0.045);\nhjet4pt->GetXaxis()->SetNdivisions(8, 5, 0);\n// Set the y-axis title and font properties\nhjet4pt->GetYaxis()->SetTitle(\"number of events\");\nhjet4pt->GetYaxis()->SetTitleOffset(1.4);\nhjet4pt->GetYaxis()->SetTitleSize(0.05);\nhjet4pt->GetYaxis()->SetLabelSize(0.045);","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"// To plot our histogram, we first need a canvas.\nTCanvas c1(\"c1\", \"c1\", 620, 500);\n// ... and we need to make wide margins for all the axis titles to fit in:\nc1.SetBottomMargin(0.15);\nc1.SetLeftMargin(0.15);\nc1.SetRightMargin(0.15);","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"// Now we can plot the histograms.  We start with the distribution which has the highest y-axis value, so everything can fit into the frame.\n// If you want to understand this better, you can start with drawing hjet1pt, then the others\nhjet4pt->Draw();\nhjet3pt->Draw(\"same\");\nhjet2pt->Draw(\"same\");\nhjet1pt->Draw(\"same\");\n// The histogram will be drawn on the TCanvas c1.  Now we can draw the canvas:\nc1.Draw()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"// In order the see which histogram corresponds to which distribution, we need a legend.\n// This is how we make one:\nTLegend l1(0.65, 0.67, 0.88, 0.87);\nl1.SetBorderSize(0);\nl1.SetFillStyle(0000);\nl1.AddEntry(hjet1pt,\"jet 1 p_{T}\", \"f\");\nl1.AddEntry(hjet2pt,\"jet 2 p_{T}\", \"f\");\nl1.AddEntry(hjet3pt,\"jet 3 p_{T}\", \"f\");\nl1.AddEntry(hjet4pt,\"jet 4 p_{T}\", \"f\");\nl1.Draw(\"same\");","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"// We re-draw the canvas c1 in order to see the legend:\nc1.Draw()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"// Now let's take the 2D histogram hmetjet1pt.  It shows missing transverse energy versus the 1st jet pT.\n// Let's set the axis titles.\nhmetjet1pt->GetXaxis()->SetTitle(\"MET (GeV)\");\nhmetjet1pt->GetYaxis()->SetTitle(\"jet 1 p_{T} (GeV)\");\nhmetjet1pt->GetZaxis()->SetTitle(\"number of events\");","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"// We need a different canvas for the new histogram\nTCanvas c2(\"c2\", \"c2\", 620, 500);\nc2.SetBottomMargin(0.15);\nc2.SetLeftMargin(0.15);\nc2.SetRightMargin(0.15);","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"// Let's draw the histogram.  The colz option draws the histogram with the nice colors and the z-axis bar.\n// You can learn about drawing options from https://root.cern/doc/master/classTHistPainter.html\n// and perhaps try a few for fun\nhmetjet1pt->Draw(\"colz\");\n// As usual, we need to draw the canvas separately\nc2.Draw()","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}