source: trunk/MagicSoft/Mars/macros/plot2.C@ 3378

Last change on this file since 3378 was 1543, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.8 KB
Line 
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// -------------------------------------------------------------------------
27//
28// plot.C
29//
30// This macro shows how to fill and display a 2D histogram using Mars
31//
32void plot2()
33{
34 //
35 // Create a empty Parameter List and an empty Task List
36 // The tasklist is identified in the eventloop by its name
37 //
38 MParList plist;
39
40 MTaskList tlist;
41 plist.AddToList(&tlist);
42
43 //
44 // Now setup the tasks and tasklist:
45 // ---------------------------------
46 //
47
48 // First Task: read in a file created with star.C
49 MReadMarsFile read("Events", "star.root");
50 read.DisableAutoScheme();
51 tlist.AddToList(&read);
52
53 // Create a filter for the gamma events
54 MFParticleId fgamma("MMcEvt", '=', kGAMMA);
55 tlist.AddToList(&fgamma);
56
57 // Create a filter for the non-gamma events
58 MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
59 tlist.AddToList(&fhadrons);
60
61 // -------------------------------------------------------
62 //
63 // set the name of the variable to plot and the binning
64 //
65 MGeomCamMagic cam;
66 plist.AddToList(&cam);
67
68 TString vary("MHillas.fWidth*MGeomCam.fConvMm2Deg");
69 TString varx("MHillas.fLength*MGeomCam.fConvMm2Deg");
70
71 MBinning binsy("BinningMH3Y");
72 MBinning binsx("BinningMH3X");
73 binsy.SetEdges(11, 0, 0.3);
74 binsx.SetEdges(11, 0, 0.6);
75 plist.AddToList(&binsx);
76 plist.AddToList(&binsy);
77 //
78 // -------------------------------------------------
79
80 // Create two 2D histograms and add them to the list
81 MH3 h3g(varx, vary);
82 MH3 h3h(varx, vary);
83
84 plist.AddToList(&h3g);
85 plist.AddToList(&h3h);
86
87 // Create a task to fill one histogram with the gamma data
88 MFillH fillg(&h3g);
89 fillg.SetFilter(&fgamma);
90 tlist.AddToList(&fillg);
91
92 // Create a task to fill the other one with the non gamma data
93 MFillH fillh(&h3h);
94 fillh.SetFilter(&fhadrons);
95 tlist.AddToList(&fillh);
96
97 //
98 // Create and setup the eventloop
99 //
100 MEvtLoop evtloop;
101 evtloop.SetParList(&plist);
102
103 //
104 // Execute your analysis
105 //
106 MProgressBar bar;
107 evtloop.SetProgressBar(&bar);
108 if (!evtloop.Eventloop())
109 return;
110
111 tlist.PrintStatistics();
112
113 // Create a default canvas
114 MH::MakeDefCanvas("Plot");
115
116 // setup some style options
117 h3h.GetHist().SetMarkerColor(kRed);
118 h3h.GetHist().SetLineColor(kRed);
119 h3h.GetHist().SetFillStyle(4000);
120
121 // show a contour plot of both histograms
122 h3h.GetHist().DrawCopy("cont3");
123 h3g.GetHist().DrawCopy("cont3same");
124
125 return;
126
127 //
128 // Use this (or something similar) if you want to plot the profile
129 // histograms
130 //
131 TProfile *p = ((TH2&)h3g.GetHist()).ProfileX();
132 p->Draw("same");
133 p->SetBit(kCanDelete);
134
135 TProfile *p = ((TH2&)h3h.GetHist()).ProfileX();
136 p->SetLineColor(kRed);
137 p->SetFillStyle(4000);
138 p->Draw("same");
139 p->SetBit(kCanDelete);
140}
Note: See TracBrowser for help on using the repository browser.