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

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