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

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