| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | ! Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | void plot()
|
|---|
| 27 | {
|
|---|
| 28 | //
|
|---|
| 29 | // This is a demonstration program which calculates the Hillas
|
|---|
| 30 | // parameter out of a Magic root file.
|
|---|
| 31 |
|
|---|
| 32 | //
|
|---|
| 33 | // Create a empty Parameter List and an empty Task List
|
|---|
| 34 | // The tasklist is identified in the eventloop by its name
|
|---|
| 35 | //
|
|---|
| 36 | MParList plist;
|
|---|
| 37 |
|
|---|
| 38 | MTaskList tlist;
|
|---|
| 39 | plist.AddToList(&tlist);
|
|---|
| 40 |
|
|---|
| 41 | //
|
|---|
| 42 | // Now setup the tasks and tasklist:
|
|---|
| 43 | // ---------------------------------
|
|---|
| 44 | //
|
|---|
| 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 | //
|
|---|
| 50 | MReadMarsFile read("Events", "star.root");
|
|---|
| 51 | read.DisableAutoScheme();
|
|---|
| 52 | tlist.AddToList(&read);
|
|---|
| 53 |
|
|---|
| 54 | MFParticleId fgamma("MMcEvt", '=', kGAMMA);
|
|---|
| 55 | tlist.AddToList(&fgamma);
|
|---|
| 56 |
|
|---|
| 57 | MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
|
|---|
| 58 | tlist.AddToList(&fhadrons);
|
|---|
| 59 |
|
|---|
| 60 | // -------------------------------------------------------
|
|---|
| 61 | //
|
|---|
| 62 | // set the name of the variable to plot and the binning
|
|---|
| 63 | //
|
|---|
| 64 | TString var("MHillas.fSize");
|
|---|
| 65 |
|
|---|
| 66 | MBinning bins("BinningMH3X");
|
|---|
| 67 | bins.SetEdgesLog(50, 100, 20000);
|
|---|
| 68 | //
|
|---|
| 69 | // -------------------------------------------------
|
|---|
| 70 |
|
|---|
| 71 | MH3 h3g(var);
|
|---|
| 72 | MH3 h3h(var);
|
|---|
| 73 |
|
|---|
| 74 | plist.AddToList(&h3g);
|
|---|
| 75 | plist.AddToList(&h3h);
|
|---|
| 76 |
|
|---|
| 77 | plist.AddToList(&bins);
|
|---|
| 78 |
|
|---|
| 79 | MFillH fillg(&h3g);
|
|---|
| 80 | fillg.SetFilter(&fgamma);
|
|---|
| 81 | tlist.AddToList(&fillg);
|
|---|
| 82 |
|
|---|
| 83 | MFillH fillh(&h3h);
|
|---|
| 84 | fillh.SetFilter(&fhadrons);
|
|---|
| 85 | tlist.AddToList(&fillh);
|
|---|
| 86 |
|
|---|
| 87 | //
|
|---|
| 88 | // Create and setup the eventloop
|
|---|
| 89 | //
|
|---|
| 90 | MEvtLoop evtloop;
|
|---|
| 91 | evtloop.SetParList(&plist);
|
|---|
| 92 |
|
|---|
| 93 | //
|
|---|
| 94 | // Execute your analysis
|
|---|
| 95 | //
|
|---|
| 96 | if (!evtloop.Eventloop())
|
|---|
| 97 | return;
|
|---|
| 98 |
|
|---|
| 99 | tlist.PrintStatistics();
|
|---|
| 100 |
|
|---|
| 101 | MH::MakeDefCanvas("Plot");
|
|---|
| 102 | h3h.GetHist().SetLineColor(kRed);
|
|---|
| 103 | h3h.GetHist().SetFillStyle(4000);
|
|---|
| 104 | h3g.GetHist().DrawCopy();
|
|---|
| 105 | h3h.GetHist().DrawCopy("same");
|
|---|
| 106 |
|
|---|
| 107 | TH1D h;
|
|---|
| 108 | MH::SetBinning(&h, &bins);
|
|---|
| 109 | h.Divide(&h3g.GetHist(), &h3h.GetHist());
|
|---|
| 110 | h.SetLineColor(kGreen);
|
|---|
| 111 | h.SetFillStyle(4000);
|
|---|
| 112 | h.DrawCopy("same");
|
|---|
| 113 |
|
|---|
| 114 | gPad->SetLogx();
|
|---|
| 115 | }
|
|---|