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

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