source: trunk/MagicSoft/Mars/mmain/MAnalysis.cc@ 2314

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