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 9/2001 <mailto:tbretz@uni-sw.gwdg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | #include "MAnalysis.h"
|
---|
26 |
|
---|
27 | #include <iostream.h>
|
---|
28 |
|
---|
29 | #include <TGLabel.h> // TGlabel
|
---|
30 | #include <TGButton.h> // TGTextButton
|
---|
31 | #include <TGTextEntry.h> // TGNumberEntry
|
---|
32 |
|
---|
33 | #include "MGList.h"
|
---|
34 | #include "MImgCleanStd.h" // MImgCleanStd
|
---|
35 |
|
---|
36 | ClassImp(MAnalysis)
|
---|
37 |
|
---|
38 | enum {
|
---|
39 | kButHillas = 0x100
|
---|
40 | };
|
---|
41 |
|
---|
42 | void MAnalysis::AddButtons()
|
---|
43 | {
|
---|
44 | TGTextButton *hillas = new TGTextButton(fTop2, "Calculate Standard Hillas", kButHillas);
|
---|
45 |
|
---|
46 | hillas->Associate(this);
|
---|
47 |
|
---|
48 | fList->Add(hillas);
|
---|
49 |
|
---|
50 | TGLayoutHints *laybut = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10, 10, 5, 5);
|
---|
51 | fList->Add(laybut);
|
---|
52 |
|
---|
53 | fTop2->AddFrame(hillas, laybut);
|
---|
54 | }
|
---|
55 |
|
---|
56 | void MAnalysis::AddSetupTab()
|
---|
57 | {
|
---|
58 | //
|
---|
59 | // Create Setup Tab
|
---|
60 | //
|
---|
61 | TGCompositeFrame *frame = CreateNewTab("Setup");
|
---|
62 |
|
---|
63 | TGGroupFrame *grp = new TGGroupFrame(frame, "Setup Display");
|
---|
64 | fList->Add(grp);
|
---|
65 |
|
---|
66 | //
|
---|
67 | // Align the lines:
|
---|
68 | // - top, left
|
---|
69 | // - padding: top=20, bottom=0, left=20, right=0
|
---|
70 | //
|
---|
71 | TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 10, 10, 10);
|
---|
72 | fList->Add(laybut);
|
---|
73 |
|
---|
74 | //
|
---|
75 | // Create check buttons for the first two lines
|
---|
76 | //
|
---|
77 | fCheckButton1 = new TGCheckButton(grp, "Display Hillas Histograms when finished"); //, M_CHECK_DISPLHIL);
|
---|
78 | fCheckButton2 = new TGCheckButton(grp, "Display Star Map Histogram when finished"); //, M_CHECK_DISPLHIL);
|
---|
79 |
|
---|
80 | fList->AddFirst(fCheckButton1);
|
---|
81 | fList->AddFirst(fCheckButton2);
|
---|
82 |
|
---|
83 | //
|
---|
84 | // Create first two lines with the checkbuttons
|
---|
85 | //
|
---|
86 | grp->AddFrame(fCheckButton1, laybut);
|
---|
87 | grp->AddFrame(fCheckButton2, laybut);
|
---|
88 |
|
---|
89 | TGLayoutHints *laygrp = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 20, 20, 20);
|
---|
90 | fList->Add(laygrp);
|
---|
91 |
|
---|
92 | frame->AddFrame(grp, laygrp);
|
---|
93 |
|
---|
94 | /*
|
---|
95 | * Create GUI for image cleaning
|
---|
96 | */
|
---|
97 | fImgClean = new MImgCleanStd;
|
---|
98 | fImgClean->CreateGui(frame, laygrp);
|
---|
99 | fList->Add(fImgClean);
|
---|
100 | }
|
---|
101 |
|
---|
102 | MAnalysis::MAnalysis(const TGWindow *main, const TGWindow *p,
|
---|
103 | const UInt_t w, const UInt_t h)
|
---|
104 | : MBrowser(main, p, w, h)
|
---|
105 | {
|
---|
106 | AddButtons();
|
---|
107 | AddSetupTab();
|
---|
108 |
|
---|
109 | MapSubwindows();
|
---|
110 |
|
---|
111 | Layout();
|
---|
112 |
|
---|
113 | SetWindowName("Analysis Window");
|
---|
114 | SetIconName("Analysis");
|
---|
115 |
|
---|
116 | MapWindow();
|
---|
117 | }
|
---|
118 |
|
---|
119 | // ======================================================================
|
---|
120 |
|
---|
121 | #include "MParList.h"
|
---|
122 | #include "MTaskList.h"
|
---|
123 | #include "MGeomCamMagic.h"
|
---|
124 | #include "MPedestalCam.h"
|
---|
125 | #include "MHHillas.h"
|
---|
126 | #include "MHStarMap.h"
|
---|
127 | #include "MReadMarsFile.h"
|
---|
128 | #include "MMcPedestalCopy.h" // MMcPedestalCopy
|
---|
129 | #include "MMcPedestalNSBAdd.h" // MMcPedestalNSB
|
---|
130 | #include "MCerPhotCalc.h"
|
---|
131 | #include "MImgCleanStd.h"
|
---|
132 | #include "MHillasCalc.h"
|
---|
133 | #include "MFillH.h"
|
---|
134 | #include "MEvtLoop.h"
|
---|
135 | #include "MHillas.h"
|
---|
136 |
|
---|
137 | void MAnalysis::CalculateHillas()
|
---|
138 | {
|
---|
139 | //
|
---|
140 | // This is a demonstration program which calculates the Hillas
|
---|
141 | // parameter out of a Magic root file.
|
---|
142 |
|
---|
143 | const Bool_t displhillas = fCheckButton1->GetState();
|
---|
144 | const Bool_t displstarmap = fCheckButton2->GetState();
|
---|
145 |
|
---|
146 | //
|
---|
147 | // Create a empty Parameter List and an empty Task List
|
---|
148 | // The tasklist is identified in the eventloop by its name
|
---|
149 | //
|
---|
150 | MParList plist;
|
---|
151 |
|
---|
152 | MTaskList tlist;
|
---|
153 | plist.AddToList(&tlist);
|
---|
154 |
|
---|
155 | //
|
---|
156 | // The geometry container must be created by yourself to make sure
|
---|
157 | // that you don't choos a wrong geometry by chance
|
---|
158 | //
|
---|
159 | MGeomCamMagic geomcam;
|
---|
160 | plist.AddToList(&geomcam);
|
---|
161 |
|
---|
162 | MPedestalCam pedest;
|
---|
163 | plist.AddToList(&pedest);
|
---|
164 |
|
---|
165 | //
|
---|
166 | // Now setup the tasks and tasklist:
|
---|
167 | //
|
---|
168 | // 1) read in the data from a magic root file MReadTree
|
---|
169 | // 2) calculate number of cerenkov photons MCerPhotCalc
|
---|
170 | // 3) clean the image MImgCleanStd
|
---|
171 | // 4) calculate hillas MHillasCalc
|
---|
172 | // 5) fill the hillas into the histograms MFillH
|
---|
173 | //
|
---|
174 |
|
---|
175 | //
|
---|
176 | // The first argument is the tree you want to read.
|
---|
177 | // Events: Cosmic ray events
|
---|
178 | // PedEvents: Pedestal Events
|
---|
179 | // CalEvents: Calibration Events
|
---|
180 | //
|
---|
181 | MReadMarsFile read("Events", fInputFile);
|
---|
182 |
|
---|
183 | MMcPedestalCopy pcopy;
|
---|
184 | MMcPedestalNSBAdd pdnsb;
|
---|
185 | MCerPhotCalc ncalc;
|
---|
186 | MHillasCalc hcalc;
|
---|
187 |
|
---|
188 | tlist.AddToList(&read);
|
---|
189 | tlist.AddToList(&pcopy);
|
---|
190 | tlist.AddToList(&pdnsb);
|
---|
191 | tlist.AddToList(&ncalc);
|
---|
192 | tlist.AddToList(fImgClean);
|
---|
193 | tlist.AddToList(&hcalc);
|
---|
194 |
|
---|
195 | MFillH hfill("MHillas", "MHHillas");
|
---|
196 | MFillH sfill("MHillas", "MHStarMap");
|
---|
197 |
|
---|
198 | if (displhillas)
|
---|
199 | tlist.AddToList(&hfill);
|
---|
200 |
|
---|
201 | if (displstarmap)
|
---|
202 | tlist.AddToList(&sfill);
|
---|
203 |
|
---|
204 | //
|
---|
205 | // Create and setup the eventloop
|
---|
206 | //
|
---|
207 | MEvtLoop evtloop;
|
---|
208 | evtloop.SetParList(&plist);
|
---|
209 |
|
---|
210 | //
|
---|
211 | // Add ProgressBar to window
|
---|
212 | //
|
---|
213 | TGProgressBar *bar = CreateProgressBar(fTop2);
|
---|
214 | read.SetProgressBar(bar);
|
---|
215 | evtloop.SetProgressBar(bar);
|
---|
216 |
|
---|
217 | //
|
---|
218 | // Execute your analysis
|
---|
219 | //
|
---|
220 | Bool_t rc = evtloop.Eventloop();
|
---|
221 |
|
---|
222 | //
|
---|
223 | // Remove progressbar from window
|
---|
224 | //
|
---|
225 | DestroyProgressBar(bar);
|
---|
226 |
|
---|
227 | if (!rc)
|
---|
228 | return;
|
---|
229 | //
|
---|
230 | // After the analysis is finished we can display the histograms
|
---|
231 | //
|
---|
232 | if (displhillas)
|
---|
233 | plist.FindObject("MHHillas")->DrawClone();
|
---|
234 |
|
---|
235 | if (displstarmap)
|
---|
236 | plist.FindObject("MHStarMap")->DrawClone();
|
---|
237 |
|
---|
238 | cout << endl;
|
---|
239 | cout << "Calculation of Hillas Parameters finished without error!" << endl;
|
---|
240 | }
|
---|
241 |
|
---|
242 | // ======================================================================
|
---|
243 |
|
---|
244 | Bool_t MAnalysis::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
245 | {
|
---|
246 | // Process events generated by the buttons in the frame.
|
---|
247 |
|
---|
248 | if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
|
---|
249 | return MBrowser::ProcessMessage(msg, parm1, parm2);
|
---|
250 |
|
---|
251 | switch (parm1)
|
---|
252 | {
|
---|
253 | case kButHillas:
|
---|
254 | if (!InputFileSelected())
|
---|
255 | {
|
---|
256 | DisplError("No Input (root) File selected!");
|
---|
257 | return kTRUE;
|
---|
258 | }
|
---|
259 |
|
---|
260 | switch (parm1)
|
---|
261 | {
|
---|
262 | case kButHillas:
|
---|
263 | CalculateHillas();
|
---|
264 | return kTRUE;
|
---|
265 | }
|
---|
266 | return kTRUE;
|
---|
267 | }
|
---|
268 |
|
---|
269 | return MBrowser::ProcessMessage(msg, parm1, parm2);
|
---|
270 | }
|
---|