{ gROOT->Reset(); gStyle->SetPalette(1); // Set the "COLZ" palette to a nice one TFile myFile("tutorial.root"); // Open the file TTree* myTree = (TTree*) myFile.Get("Muon"); // Get the Muon tree from the file // Draw examples: TCanvas c1; // Open a new canvas myTree->Draw("muon_pt"); // Simple draw of the muon_pt parameter TCanvas c2; // Open a new canvas myTree->Draw("muon_pt", "muon_nSel==2"); // Apply a cut to the draw TCanvas c3; // Open a new canvas myTree->Draw("muon_pt", "muon_nSel==2", "C"); // Apply draw options (smooth curve) TCanvas c4; // Open a new canvas // Plot eta vs. phi correlation: // "PSR" - plot using Pseudorapidity/Phi coordinates (X axis is phi) // "COLZ" - A box is drawn for each cell with a color scale varying with contents myTree->Draw("muon_eta:muon_phi", "muon_nParticle>0 && muon_chi2<1", "PSR COLZ"); TCanvas c5; // Open a new canvas // Plot pT of first[0] versus the pT of second[1] muon divided by the combined pt // "BOX" - A box diagram myTree->Draw("muon_pt[0]/(muon_pt[0]+muon_pt[1]):muon_pt[1]/(muon_pt[0]+muon_pt[1])", "muon_nParticle==2", "BOX"); TCanvas c6; // Open a new canvas c6.SetGrid(); // Plot a grid on this canvas // Dump the contents of the draw into a histogram for future manipulation: // "goff" - Do not plot to the screen, just dump to histogram myTree->Draw("muon_pt/1000>>h_pt", "muon_pt<60000", "goff"); // Manipulate the histogram: h_pt->SetFillColor(kGreen); // Set fill color h_pt->SetTitle("P_{T} distribution"); // Set histogram title h_pt->SetXTitle("P_{T} [GeV]"); // Set the X title gStyle->SetOptFit(1); // Draw the fit parameters on the histogram h_pt->Fit("landau"); // Fit to a landau distribution h_pt->Draw(); // Draw the histogram myFile.Close(); // Close file }