source: trunk/Mars/mmain/MAnalysis.cc@ 19875

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