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

Last change on this file since 1337 was 1214, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 7.6 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("Source");
166 source.SetXY(0, 0);
167
168 MSrcPosCam antisrc("AntiSrc");
169 antisrc.SetXY(240, 0);
170
171 plist.AddToList(&source);
172 plist.AddToList(&antisrc);
173
174 //
175 // Now setup the tasks and tasklist:
176 //
177 // 1) read in the data from a magic root file MReadTree
178 // 2) calculate number of cerenkov photons MCerPhotCalc
179 // 3) clean the image MImgCleanStd
180 // 4) calculate hillas MHillasCalc
181 // 5) fill the hillas into the histograms MFillH
182 //
183
184 //
185 // The first argument is the tree you want to read.
186 // Events: Cosmic ray events
187 // PedEvents: Pedestal Events
188 // CalEvents: Calibration Events
189 //
190 MReadMarsFile read("Events", fInputFile);
191
192 MMcPedestalCopy pcopy;
193 MMcPedestalNSBAdd pdnsb;
194 MCerPhotCalc ncalc;
195 MBlindPixelCalc blind;
196 MHillasCalc hcalc;
197 MHillasSrcCalc csrc1("Source", "HillasSource");
198 MHillasSrcCalc csrc2("AntiSource", "HillasAntiSrc");
199
200 MFillH hfill("MHHillas", "MHillas");
201 MFillH sfill("MHStarMap", "MHillas");
202
203 MFillH hfill2s("HistSource [MHHillasSrc]", "HillasSource");
204 MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
205
206 tlist.AddToList(&read);
207 tlist.AddToList(&pcopy);
208 tlist.AddToList(&pdnsb);
209 tlist.AddToList(&ncalc);
210 tlist.AddToList(fImgClean);
211 tlist.AddToList(&blind);
212 tlist.AddToList(&hcalc);
213 tlist.AddToList(&csrc1);
214 tlist.AddToList(&csrc2);
215
216 if (displhillas)
217 {
218 tlist.AddToList(&hfill);
219 tlist.AddToList(&hfill2s);
220 tlist.AddToList(&hfill2a);
221 }
222
223 if (displstarmap)
224 tlist.AddToList(&sfill);
225
226 //
227 // Create and setup the eventloop
228 //
229 MEvtLoop evtloop;
230 evtloop.SetParList(&plist);
231
232 //
233 // Add ProgressBar to window
234 //
235 TGProgressBar *bar = CreateProgressBar(fTop2);
236 read.SetProgressBar(bar);
237 evtloop.SetProgressBar(bar);
238
239 //
240 // Execute your analysis
241 //
242 Bool_t rc = evtloop.Eventloop();
243
244 //
245 // Remove progressbar from window
246 //
247 DestroyProgressBar(bar);
248
249 if (!rc)
250 return;
251 //
252 // After the analysis is finished we can display the histograms
253 //
254 if (displhillas)
255 {
256 plist.FindObject("MHHillas")->DrawClone();
257 plist.FindObject("HistSource")->DrawClone();
258 plist.FindObject("HistAntiSrc")->DrawClone();
259 }
260
261 if (displstarmap)
262 plist.FindObject("MHStarMap")->DrawClone();
263
264 cout << endl;
265 cout << "Calculation of Hillas Parameters finished without error!" << endl;
266}
267
268// ======================================================================
269
270Bool_t MAnalysis::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
271{
272 // Process events generated by the buttons in the frame.
273
274 if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
275 return MBrowser::ProcessMessage(msg, parm1, parm2);
276
277 switch (parm1)
278 {
279 case kButHillas:
280 if (!InputFileSelected())
281 {
282 DisplError("No Input (root) File selected!");
283 return kTRUE;
284 }
285
286 switch (parm1)
287 {
288 case kButHillas:
289 CalculateHillas();
290 return kTRUE;
291 }
292 return kTRUE;
293 }
294
295 return MBrowser::ProcessMessage(msg, parm1, parm2);
296}
Note: See TracBrowser for help on using the repository browser.