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