Changeset 1410 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
07/16/02 13:24:59 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/macros
Files:
4 edited

Legend:

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

    r1337 r1410  
    2525 \* ======================================================================== */
    2626
     27// -------------------------------------------------------------------------
     28//
     29//  This macro demonstrates one way of gamma hadron separation using the
     30//  composite probability method. To use it you need a star-file (which is
     31//  a file ouput by the star.C macro containing image parameters)
     32//
    2733void comprob()
    2834{
     
    3743    plist.AddToList(&tlist);
    3844
    39     // First task in list: read mars file
     45    // First task in list: read the star file (reference data)
    4046    MReadMarsFile read("Events", "star.root");
    4147    read.DisableAutoScheme();
    4248    tlist.AddToList(&read);
    4349
     50    //
    4451    // Task to do the composite analysis of Hillas parameters:
     52    // Add(rule, number of bins, lower limit, upper limit)
     53    // For the meaning of the rule see MDataChain
     54    //
    4555    MHCompProb compprob(500);
    4656    compprob.Add("MHillas.fWidth",              500,    0, 160);
     
    5969    MFillH fill(&compprob, "MMcEvt");
    6070
    61     // Energy filter:
     71    // Use this if you want to do it for a fixed energy range:
    6272    /*
    6373     MF filter("MMcEvt.fEnergy < 100");
     
    93103    plist.Replace(&tlist2);
    94104
    95     // First task in list: read mars file
     105    // First task in list: read star file (test data)
    96106    MReadMarsFile read2("Events", "star2.root");
    97107    read2.DisableAutoScheme();
     
    110120        return;
    111121
     122    //
     123    // Display the hadroness histograms and print some informations on
     124    // the console window
     125    //
    112126    plist.FindObject("MHHadroness")->DrawClone();
    113127    plist.FindObject("MHHadroness")->Print();
  • 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}
  • trunk/MagicSoft/Mars/macros/plot2.C

    r1354 r1410  
    2424\* ======================================================================== */
    2525
     26// -------------------------------------------------------------------------
     27//
     28//  plot.C
     29//
     30//  This macro shows how to fill and display a 2D histogram using Mars
     31//
    2632void plot2()
    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 in a file created with star.C
    5049    MReadMarsFile  read("Events", "star.root");
    5150    read.DisableAutoScheme();
    5251    tlist.AddToList(&read);
    5352
     53    // Create a filter for the gamma events
    5454    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
    5555    tlist.AddToList(&fgamma);
    5656
     57    // Create a filter for the non-gamma events
    5758    MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
    5859    tlist.AddToList(&fhadrons);
     
    7273    binsy.SetEdges(11, 0, 0.3);
    7374    binsx.SetEdges(11, 0, 0.6);
    74 
     75    plist.AddToList(&binsx);
     76    plist.AddToList(&binsy);
    7577    //
    7678    // -------------------------------------------------
    7779
     80    // Create two 2D histograms and add them to the list
    7881    MH3 h3g(varx, vary);
    7982    MH3 h3h(varx, vary);
     
    8285    plist.AddToList(&h3h);
    8386
    84     plist.AddToList(&binsx);
    85     plist.AddToList(&binsy);
    86 
     87    // Create a task to fill one histogram with the gamma data
    8788    MFillH fillg(&h3g);
    8889    fillg.SetFilter(&fgamma);
    8990    tlist.AddToList(&fillg);
    9091
     92    // Create a task to fill the other one with the non gamma data
    9193    MFillH fillh(&h3h);
    9294    fillh.SetFilter(&fhadrons);
     
    107109    tlist.PrintStatistics();
    108110
     111    // Create a default canvas
    109112    MH::MakeDefCanvas("Plot");
     113
     114    // setup some style options
    110115    h3h.GetHist().SetMarkerColor(kRed);
    111116    h3h.GetHist().SetLineColor(kRed);
    112117    h3h.GetHist().SetFillStyle(4000);
     118
     119    // show a contour plot of both histograms
    113120    h3h.GetHist().DrawCopy("cont3");
    114121    h3g.GetHist().DrawCopy("cont3same");
     
    116123    return;
    117124
     125    //
     126    // Use this (or something similar) if you want to plot the profile
     127    // histograms
     128    //
    118129    TProfile *p = ((TH2&)h3g.GetHist()).ProfileX();
    119130    p->Draw("same");
  • trunk/MagicSoft/Mars/macros/star.C

    r1337 r1410  
    7979    // ---------------------------------
    8080    //
    81     // The first argument is the tree you want to read.
    82     //   Events:     Cosmic ray events
    83     //   PedEvents:  Pedestal Events
    84     //   CalEvents:  Calibration Events
    85     //
    8681    MReadMarsFile read("Events");
    8782    read.AddFile("~/data/Gamma_0_7_1011*.root");
Note: See TracChangeset for help on using the changeset viewer.