Ignore:
Timestamp:
07/16/02 13:24:59 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/macros/plot.C

    r1353 r1410  
    2424\* ======================================================================== */
    2525
     26// -------------------------------------------------------------------------
     27//
     28//  plot.C
     29//
     30//  This macro shows how to fill and display a histogram using Mars
     31//
    2632void plot()
    2733{
    28     //
    29     // This is a demonstration program which calculates the Hillas
    30     // parameter out of a Magic root file.
    31 
    3234    //
    3335    // Create a empty Parameter List and an empty Task List
     
    4345    // ---------------------------------
    4446    //
    45     // The first argument is the tree you want to read.
    46     //   Events:     Cosmic ray events
    47     //   PedEvents:  Pedestal Events
    48     //   CalEvents:  Calibration Events
    49     //
     47
     48    // First Task: Read file with image parameters
     49    // (created with the star.C macro)
    5050    MReadMarsFile  read("Events", "star.root");
    5151    read.DisableAutoScheme();
    5252    tlist.AddToList(&read);
    5353
     54    // Create a filter for Gammas
    5455    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
    5556    tlist.AddToList(&fgamma);
    5657
     58    // Create a filter for Non-Gammas
    5759    MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
    5860    tlist.AddToList(&fhadrons);
     
    6668    MBinning bins("BinningMH3X");
    6769    bins.SetEdgesLog(50, 100, 20000);
     70    plist.AddToList(&bins);
    6871    //
    69     // -------------------------------------------------
     72    // -------------------------------------------------------
    7073
     74    // Create a histogram for the data from gammas and from non-gammas
    7175    MH3 h3g(var);
    7276    MH3 h3h(var);
    7377
     78    // Add the histograms to the parameter container list
    7479    plist.AddToList(&h3g);
    7580    plist.AddToList(&h3h);
    7681
    77     plist.AddToList(&bins);
    78 
     82    // Create a task which fills one histogram with the gamma-data
    7983    MFillH fillg(&h3g);
    8084    fillg.SetFilter(&fgamma);
    8185    tlist.AddToList(&fillg);
    8286
     87    // Create a task which fills the other histogram with the non-gamma-data
    8388    MFillH fillh(&h3h);
    8489    fillh.SetFilter(&fhadrons);
     
    99104    tlist.PrintStatistics();
    100105
     106    // Create a default canvas called Plot and set the
     107    // x-axis to logarithmic scale
    101108    MH::MakeDefCanvas("Plot");
     109    gPad->SetLogx();
     110
     111    // Setup some style options of the two histograms
     112    // and draw a copy of both
    102113    h3h.GetHist().SetLineColor(kRed);
    103114    h3h.GetHist().SetFillStyle(4000);
     
    105116    h3h.GetHist().DrawCopy("same");
    106117
     118    // Now create a new histogram, fill it with the division of the
     119    // two histograms and draw also a copy of it
    107120    TH1D h;
    108121    MH::SetBinning(&h, &bins);
     
    111124    h.SetFillStyle(4000);
    112125    h.DrawCopy("same");
    113 
    114     gPad->SetLogx();
    115126}
Note: See TracChangeset for help on using the changeset viewer.