source: trunk/MagicSoft/Mars/macros/MagicHillas.C@ 1222

Last change on this file since 1222 was 1222, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.7 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 12/2000 (tbretz@uni-sw.gwdg.de)
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25
26void MagicHillas(const char *filename="~/data/gamma*.root")
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 // Uncomment this two line if you want to use MHillasExt instead
43 // of MHillas
44 //
45 //MHillasExt hext;
46 //plist.AddToList(&hext);
47
48 //
49 // The geometry container must be created by yourself to make sure
50 // that you don't choos a wrong geometry by chance
51 //
52 MGeomCamMagic geomcam;
53 plist.AddToList(&geomcam);
54
55 //
56 // Setup binning for your histograms.
57 //
58 MBinning binswidth("BinningWidth");
59 binswidth.SetEdges(100, 0, 1); // 100 bins from 0 to 1 deg
60
61 MBinning binslength("BinningLength");
62 binslength.SetEdges(100, 0, 1); // 100 bins from 0 to 1 deg
63
64 MBinning binsalpha("BinningAlpha");
65 binsalpha.SetEdges(90, 0, 90); // 90 bins from 0 to 90 deg
66
67 MBinning binsdist("BinningDist");
68 binsdist.SetEdges(100, 0, 2); // 100 bins from 0 to 2 deg
69
70 plist.AddToList(&binswidth);
71 plist.AddToList(&binslength);
72 plist.AddToList(&binsalpha);
73 plist.AddToList(&binsdist);
74
75 //
76 // Craete the object which hlods the source positions in the camera
77 // plain in respect to which the image parameters will be calculated.
78 // For real data the containers will be filled by a task.
79 //
80 MSrcPosCam source("Source")
81 source.SetXY(0, 0);
82
83 MSrcPosCam antisrc("AntiSrc");
84 antisrc.SetXY(240, 0);
85
86 plist.AddToList(&source);
87 plist.AddToList(&antisrc);
88
89 //
90 // Now setup the tasks and tasklist:
91 // ---------------------------------
92 //
93 // The first argument is the tree you want to read.
94 // Events: Cosmic ray events
95 // PedEvents: Pedestal Events
96 // CalEvents: Calibration Events
97 //
98 MReadMarsFile read("Events", filename);
99
100 MMcPedestalCopy pcopy;
101 MMcPedestalNSBAdd pnsb;
102 MCerPhotCalc ncalc;
103 MImgCleanStd clean;
104 MBlindPixelCalc blind;
105 MHillasCalc hcalc;
106 MHillasSrcCalc csrc1("Source", "HillasSource");
107 MHillasSrcCalc csrc2("AntiSrc", "HillasAntiSrc");
108
109 MFillH hfill("MHHillas", "MHillas");
110 MFillH sfill("MHStarMap", "MHillas");
111 MFillH hfill2s("HistSource [MHHillasSrc]", "HillasSource");
112 MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
113
114 MWriteRootFile write("hillas.root");
115 write.AddContainer("MHillas", "Hillas");
116 write.AddContainer("HillasSource", "Hillas");
117 write.AddContainer("HillasAntiSrc", "Hillas");
118 write.AddContainer("MHStarMap");
119
120 /*
121 MWriteAsciiFile write("hillas.txt");
122 write.AddContainer("MHillas", "fLength");
123 write.AddContainer("MHillas", "fConc");
124 write.AddContainer("MHillas");
125 */
126
127 tlist.AddToList(&read);
128 tlist.AddToList(&pcopy);
129 tlist.AddToList(&pnsb);
130 tlist.AddToList(&ncalc);
131 tlist.AddToList(&clean);
132 tlist.AddToList(&blind);
133 tlist.AddToList(&hcalc);
134 tlist.AddToList(&csrc1);
135 tlist.AddToList(&csrc2);
136 tlist.AddToList(&hfill);
137 tlist.AddToList(&sfill);
138 tlist.AddToList(&hfill2s);
139 tlist.AddToList(&hfill2a);
140 tlist.AddToList(&write);
141
142 //
143 // Create and setup the eventloop
144 //
145 MEvtLoop evtloop;
146 evtloop.SetParList(&plist);
147
148 //
149 // Execute your analysis
150 //
151 if (!evtloop.Eventloop(5))
152 return;
153
154 tlist.PrintStatistics();
155
156 //
157 // After the analysis is finished we can display the histograms
158 //
159 plist.FindObject("MHHillas")->DrawClone();
160 plist.FindObject("HistSource")->DrawClone();
161 plist.FindObject("HistAntiSrc")->DrawClone();
162 plist.FindObject("MHStarMap")->DrawClone();
163}
Note: See TracBrowser for help on using the repository browser.