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

Last change on this file since 2765 was 2498, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 8.3 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 /*
97 * Create GUI for image cleaning
98 */
99 fImgClean = new MImgCleanStd;
100 fImgClean->CreateGui(frame, laygrp);
101 fList->Add(fImgClean);
102}
103
104MAnalysis::MAnalysis(/*const TGWindow *main,*/ const TGWindow *p,
105 const UInt_t w, const UInt_t h)
106: MBrowser(/*main,*/ p, w, h)
107{
108 AddButtons();
109 AddSetupTab();
110
111 MapSubwindows();
112
113 Layout();
114
115 SetWindowName("Analysis Window");
116 SetIconName("Analysis");
117
118 MapWindow();
119}
120
121// ======================================================================
122
123#include "MStatusDisplay.h"
124#include "MParList.h"
125#include "MTaskList.h"
126#include "MGeomCamMagic.h"
127#include "MPedestalCam.h"
128#include "MHHillas.h"
129#include "MHStarMap.h"
130#include "MReadMarsFile.h"
131#include "MMcPedestalCopy.h" // MMcPedestalCopy
132#include "MMcPedestalNSBAdd.h" // MMcPedestalNSB
133#include "MCerPhotCalc.h"
134#include "MImgCleanStd.h"
135#include "MBlindPixelCalc.h"
136#include "MHillasCalc.h"
137#include "MHillasSrcCalc.h"
138#include "MSrcPosCam.h"
139#include "MFillH.h"
140#include "MEvtLoop.h"
141#include "MHillas.h"
142#include "MGeomApply.h"
143
144void MAnalysis::CalculateHillas()
145{
146 //
147 // This is a demonstration program which calculates the Hillas
148 // parameter out of a Magic root file.
149
150 const Bool_t displhillas = kTRUE;//fCheckButton1->GetState();
151 const Bool_t displstarmap = kTRUE;//fCheckButton2->GetState();
152
153 //
154 // Create a empty Parameter List and an empty Task List
155 // The tasklist is identified in the eventloop by its name
156 //
157 MParList plist;
158
159 MTaskList tlist;
160 plist.AddToList(&tlist);
161
162 //
163 // The geometry container must be created by yourself to make sure
164 // that you don't choos a wrong geometry by chance
165 //
166 MGeomCamMagic geomcam;
167 plist.AddToList(&geomcam);
168
169 MSrcPosCam source;
170 plist.AddToList(&source);
171 /*
172 MSrcPosCam source("Source");
173 source.SetXY(0, 0);
174 plist.AddToList(&source);
175
176 MSrcPosCam antisrc("AntiSrc");
177 antisrc.SetXY(240, 0);
178 plist.AddToList(&antisrc);
179 */
180
181 //
182 // Now setup the tasks and tasklist:
183 //
184 // 1) read in the data from a magic root file MReadTree
185 // 2) calculate number of cerenkov photons MCerPhotCalc
186 // 3) clean the image MImgCleanStd
187 // 4) calculate hillas MHillasCalc
188 // 5) fill the hillas into the histograms MFillH
189 //
190
191 //
192 // The first argument is the tree you want to read.
193 // Events: Cosmic ray events
194 // PedEvents: Pedestal Events
195 // CalEvents: Calibration Events
196 //
197 MReadMarsFile read("Events", fInputFile);
198 //read.DisableAutoScheme();
199
200 MGeomApply apply;
201 MMcPedestalCopy pcopy;
202 MMcPedestalNSBAdd pdnsb;
203 MCerPhotCalc ncalc;
204 MBlindPixelCalc blind;
205 MHillasCalc hcalc;
206 MHillasSrcCalc csrc1;
207 /*
208 MHillasSrcCalc csrc1("Source", "HillasSource");
209 MHillasSrcCalc csrc2("AntiSrc", "HillasAntiSrc");
210 */
211
212 MFillH hfill("MHHillas", "MHillas");
213 MFillH hfill2("MHHillasExt", "MHillasSrc");
214 MFillH hfill2s("MHHillasSrc", "MHillasSrc");
215 MFillH hfill3("MHNewImagePar", "MNewImagePar");
216 MFillH sfill("MHStarMap", "MHillas");
217 /*
218 MFillH hfill2s("HistSource [MHHillasSrc]", "HillasSource");
219 MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
220 */
221
222 tlist.AddToList(&read);
223 tlist.AddToList(&apply);
224 tlist.AddToList(&pcopy);
225 tlist.AddToList(&pdnsb);
226 tlist.AddToList(&ncalc);
227 tlist.AddToList(fImgClean);
228 tlist.AddToList(&blind);
229 tlist.AddToList(&hcalc);
230 tlist.AddToList(&csrc1);
231 //tlist.AddToList(&csrc2);
232
233 if (displhillas)
234 {
235 tlist.AddToList(&hfill);
236 tlist.AddToList(&hfill2);
237 tlist.AddToList(&hfill2s);
238 tlist.AddToList(&hfill3);
239 }
240
241 if (displstarmap)
242 tlist.AddToList(&sfill);
243
244 //
245 // Create and setup the eventloop
246 //
247 MEvtLoop evtloop;
248 evtloop.SetParList(&plist);
249
250 //
251 // Add ProgressBar to window
252 //
253 TGProgressBar *bar = NULL;
254 if (displhillas || displstarmap)
255 {
256 MStatusDisplay *d=new MStatusDisplay;
257 evtloop.SetDisplay(d);
258 }
259 else
260 {
261 bar = CreateProgressBar(fTop2);
262 evtloop.SetProgressBar(bar);
263 }
264
265
266 //
267 // Execute your analysis
268 //
269 /*Bool_t rc =*/ evtloop.Eventloop();
270
271 //
272 // Remove progressbar from window
273 //
274 if (bar)
275 DestroyProgressBar(bar);
276
277 /*
278 if (!rc)
279 return;
280
281 //
282 // After the analysis is finished we can display the histograms
283 //
284 if (displhillas)
285 {
286 plist.FindObject("MHHillas")->DrawClone();
287 plist.FindObject("MHHillasExt")->DrawClone();
288 plist.FindObject("MHHillasSrc")->DrawClone();
289 plist.FindObject("MHNewImagePar")->DrawClone();
290 }
291
292 if (displstarmap)
293 plist.FindObject("MHStarMap")->DrawClone();
294
295 cout << endl;
296 cout << "Calculation of Hillas Parameters finished without error!" << endl;
297 */
298}
299
300// ======================================================================
301
302Bool_t MAnalysis::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
303{
304 // Process events generated by the buttons in the frame.
305
306 if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
307 return MBrowser::ProcessMessage(msg, parm1, parm2);
308
309 switch (parm1)
310 {
311 case kButHillas:
312 if (!InputFileSelected())
313 {
314 DisplError("No Input (root) File selected!");
315 return kTRUE;
316 }
317
318 switch (parm1)
319 {
320 case kButHillas:
321 CalculateHillas();
322 return kTRUE;
323 }
324 return kTRUE;
325 }
326
327 return MBrowser::ProcessMessage(msg, parm1, parm2);
328}
Note: See TracBrowser for help on using the repository browser.