ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RootMacros/rootlogon.C
Revision: 1.1
Committed: Sat Sep 6 18:58:12 2008 UTC (16 years, 8 months ago) by anderson
Content type: text/plain
Branch: MAIN
Log Message:
Example rootlogon script to load other scripts

File Contents

# User Rev Content
1 anderson 1.1 {
2     /* If a rootlogon.C file exists in the same
3     * directory as where ROOT is being started,
4     * all commands in it will be run first.
5     * Michael Anderson, July 2007
6     */
7    
8     const char* defaultFileToOpen = "PhotonJet20-200.root";
9     //const char* defaultFileToOpen = "PhotonJet200-500.root";
10     //const char* defaultFileToOpen = "JetET110.root";
11     //const char* defaultFileToOpen = "single_electron.root";
12     //const char* defaultFileToOpen = "single_pi0.root";
13    
14     gROOT->SetStyle("Plain");
15    
16     // Change settings on plotting histograms
17     //gStyle->SetOptStat(111111); // This will cause overflow and underflow to be shown
18     gStyle->SetOptFit(); // Show fitting values in legend
19     //gStyle->SetHistLineWidth(2); // Set the line width to 2 pixels
20     //gStyle->SetTitleFontSize(0.035); // Shrink Histogram Title Size
21     //gStyle->SetPalette(1); // Make 2D plots pretty ->Draw("colz")
22    
23     // Load macros so that you can call them
24     // from the command line within ROOT.
25     // Can load other scripts in other directories with something like:
26     // G__loadfile("~/RootMacros/entryCount.C");
27     G__loadfile("~/RootMacros/entryCount.C"); // Counts entries in histograms
28     G__loadfile("~/RootMacros/PlotFromTTree.C"); // Plots from TTree into histogram
29     G__loadfile("~/RootMacros/Plot2hists1D.C"); // Plots 2 histograms onto same plot
30     G__loadfile("~/RootMacros/Plot3hists1D.C"); // Plots 3 histograms onto same plot
31     G__loadfile("~/RootMacros/Divide2hists1D.C");// Divides 2 histograms and plots result
32     G__loadfile("~/RootMacros/setAxes.C"); // Sets the x and y axis titles for 1-D and 2-D histograms
33     G__loadfile("~/RootMacros/setTitleAxes.C"); // Sets the main and axis titles for 1-D and 2-D histograms
34     G__loadfile("~/RootMacros/ProfileBeforeNAfter.C");
35     G__loadfile("~/RootMacros/PlotMeanVsXaxis.C");
36    
37     // Load a root file - Must be done before making canvas & histograms
38     cout << "Trying to open default file, " << defaultFileToOpen << endl;
39     TFile *file1 = new TFile(defaultFileToOpen);
40     if (file1.IsZombie()) {
41     cout << "You can set a default file to open in the rootlogon.C" << endl;
42     }
43    
44     // Create a default canvas and histogram of 640x480 pixels
45     // These are used by PlotFromTTree.C, Plot2hists1D.C
46     TCanvas *c1 = new TCanvas("c1","testCanvas",640,480);
47     TH1 *h1 = new TH1F("h1","Blah",20,-5,5);
48     TH1 *h2 = new TH1F("h2","Blah",20,-5,5);
49     TH2F *h2d = new TH2F("h2d","Blah",20,-5,5,20,-5,5);
50    
51     // Run other logon scripts
52     //gROOT->Macro("rootlogon-CmsTDR.C");
53     }