source: tags/Mars-V0.9.2/macros/MagicHillas.C

Last change on this file was 3957, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.9 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 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25///////////////////////////////////////////////////////////////////////////
26//
27// MagicHillas.C
28// =============
29//
30// This is a demonstration program which calculates image (Hillas +)
31// parameters using as input a Merpp output file (raw data).
32// All parameters are written to an output file called hillas.root. Also
33// filles histograms are displayed.
34// For the calculation an arbitrary signal extractor (MCerPhotAnal2/Calc)
35// is used.
36//
37///////////////////////////////////////////////////////////////////////////
38
39void MagicHillas(const char *filename="~/data/Gamma_20_N*.root")
40{
41 //
42 // Create a empty Parameter List and an empty Task List
43 // The tasklist is identified in the eventloop by its name
44 //
45 MParList plist;
46
47 MTaskList tlist;
48 plist.AddToList(&tlist);
49
50 //
51 // Use this if you want to change the binning of one of
52 // the histograms. You can use:
53 // BinningConc, BinningConc1, BinningAsym, BinningM3Long,
54 // BinningM3Trans, BinningWidth, BinningLength, BinningDist,
55 // BinningHeadTail, BinningAlpha, BinningSize, BinningDelta,
56 // BinningPixels and BinningCamera
57 //
58 // For more information see MBinning and the corresponding
59 // histograms
60 //
61 // MBinning binsalpha("BinningAlpha");
62 // binsalpha.SetEdges(90, 0, 90); // 90 bins from 0 to 90 deg
63 // plist.AddToList(&binsalpha);
64
65 // MBinning binssize("BinningSize");
66 // binssize.SetEdgesLog(50, 1, 1e7);
67 // plist.AddToList(&binssize);
68
69 //
70 // Craete the object which hlods the source positions in the camera
71 // plain in respect to which the image parameters will be calculated.
72 // For real data the containers will be filled by a task.
73 //
74 MSrcPosCam source;
75 source.SetReadyToSave();
76 plist.AddToList(&source);
77
78 //
79 // Now setup the tasks and tasklist:
80 // ---------------------------------
81 //
82 // The first argument is the tree you want to read.
83 // Events: Cosmic ray events
84 // PedEvents: Pedestal Events
85 // CalEvents: Calibration Events
86 //
87 MReadMarsFile read("Events", filename);
88 read.DisableAutoScheme();
89
90 // Setup a task which makes sure that all used arrays have
91 // the correct size
92 MGeomApply geomapl;
93
94 // tasks used if MC files are detected to calculate pedestals
95 MMcPedestalCopy pcopy;
96 MMcPedestalNSBAdd pnsb;
97
98 // calculate the signal in a very simple way
99 // for real adat files use MCerPhotAnal2 instead which also
100 // calculates the pedestal.
101 MCerPhotCalc ncalc;
102 //
103 // Alternative photon calculation:
104 // Example: use only 2nd to 6th FADC slices for photon calculation:
105 //
106 // const Float_t x[15]={0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
107 // const TArrayF w(15,(Float_t*)x);
108 // ncalc.SetWeights(w);
109 //
110
111 // setup image cleaning and blind pixel treatment
112 MImgCleanStd clean;
113 MBlindPixelCalc blind;
114
115 //
116 // Instead of unmapping the pixels you can also (The use of this
117 // class is deprecated, it will be replaced by MBadPixels*)
118 //
119 // blind.SetUseInterpolation();
120 // blind.SetUseCetralPixel();
121 //
122
123 // setup tasks to calculate image parameters
124 MHillasCalc hcalc;
125 MHillasSrcCalc csrc1;
126
127 // setup tasks to fill histograms
128 MFillH hfill1("MHHillas", "MHillas");
129 MFillH hfill2("MHHillasExt");
130 MFillH hfill3("MHStarMap", "MHillas");
131 MFillH hfill4("HistExtSource [MHHillasExt]", "MHillasSrc");
132 MFillH hfill5("HistSource [MHHillasSrc]", "MHillasSrc");
133 MFillH hfill6("MHNewImagePar");
134
135 // setup task to write containers to a file
136 MWriteRootFile write("hillas.root");
137 write.AddContainer("MHStarMap");
138 write.AddContainer("MHHillas");
139 write.AddContainer("MHHillasExt");
140 write.AddContainer("HistSource");
141 write.AddContainer("HistExtSource");
142 write.AddContainer("MHNewImagePar");
143
144 // Setup the contents of zour tasklist
145 tlist.AddToList(&read);
146 tlist.AddToList(&geomapl);
147 tlist.AddToList(&pcopy);
148 tlist.AddToList(&pnsb);
149 tlist.AddToList(&ncalc);
150 tlist.AddToList(&clean);
151 tlist.AddToList(&blind);
152
153 tlist.AddToList(&hcalc);
154 tlist.AddToList(&csrc1);
155
156 tlist.AddToList(&hfill1);
157 tlist.AddToList(&hfill2);
158 tlist.AddToList(&hfill3);
159 tlist.AddToList(&hfill4);
160 tlist.AddToList(&hfill5);
161 tlist.AddToList(&hfill6);
162 tlist.AddToList(&write);
163
164 //
165 // Create and setup the eventloop
166 //
167 MEvtLoop evtloop;
168 evtloop.SetParList(&plist);
169
170 //
171 // Execute your analysis
172 //
173 MProgressBar bar;
174 evtloop.SetProgressBar(&bar);
175 if (!evtloop.Eventloop())
176 return;
177
178 tlist.PrintStatistics();
179
180 //
181 // After the analysis is finished we can display the histograms
182 //
183 plist.FindObject("MHHillas")->DrawClone();
184 plist.FindObject("MHHillasExt")->DrawClone();
185 plist.FindObject("MHStarMap")->DrawClone();
186 plist.FindObject("HistSource")->DrawClone();
187 plist.FindObject("HistExtSource")->DrawClone();
188 plist.FindObject("MHNewImagePar")->DrawClone();
189}
190
Note: See TracBrowser for help on using the repository browser.