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

Last change on this file since 1086 was 1086, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 6.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-2001
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 "MReadTree.h"
128#include "MCerPhotCalc.h"
129#include "MImgCleanStd.h"
130#include "MHillasCalc.h"
131#include "MFillH.h"
132#include "MEvtLoop.h"
133#include "MHillas.h"
134
135void MAnalysis::CalculateHillas()
136{
137 //
138 // This is a demonstration program which calculates the Hillas
139 // parameter out of a Magic root file.
140
141 const Bool_t displhillas = fCheckButton1->GetState();
142 const Bool_t displstarmap = fCheckButton2->GetState();
143
144 //
145 // Create a empty Parameter List and an empty Task List
146 // The tasklist is identified in the eventloop by its name
147 //
148 MParList plist;
149
150 MTaskList tlist;
151 plist.AddToList(&tlist);
152
153 //
154 // The geometry container must be created by yourself to make sure
155 // that you don't choos a wrong geometry by chance
156 //
157 MGeomCamMagic geomcam;
158 plist.AddToList(&geomcam);
159
160 MPedestalCam pedest;
161 plist.AddToList(&pedest);
162
163 //
164 // Now setup the tasks and tasklist:
165 //
166 // 1) read in the data from a magic root file MReadTree
167 // 2) calculate number of cerenkov photons MCerPhotCalc
168 // 3) clean the image MImgCleanStd
169 // 4) calculate hillas MHillasCalc
170 // 5) fill the hillas into the histograms MFillH
171 //
172
173 //
174 // The first argument is the tree you want to read.
175 // Events: Cosmic ray events
176 // PedEvents: Pedestal Events
177 // CalEvents: Calibration Events
178 //
179 MReadTree read("Events", fInputFile);
180
181 MCerPhotCalc ncalc;
182 MHillasCalc hcalc;
183
184 tlist.AddToList(&read);
185 tlist.AddToList(&ncalc);
186 tlist.AddToList(fImgClean);
187 tlist.AddToList(&hcalc);
188
189 MFillH hfill("MHillas", "MHHillas");
190 MFillH sfill("MHillas", "MHStarMap");
191
192 if (displhillas)
193 tlist.AddToList(&hfill);
194
195 if (displstarmap)
196 tlist.AddToList(&sfill);
197
198 //
199 // Create and setup the eventloop
200 //
201 MEvtLoop evtloop;
202 evtloop.SetParList(&plist);
203
204 //
205 // Add ProgressBar to window
206 //
207 TGProgressBar *bar = CreateProgressBar(fTop2);
208 read.SetProgressBar(bar);
209 evtloop.SetProgressBar(bar);
210
211 //
212 // Execute your analysis
213 //
214 Bool_t rc = evtloop.Eventloop();
215
216 //
217 // Remove progressbar from window
218 //
219 DestroyProgressBar(bar);
220
221 if (!rc)
222 return;
223 //
224 // After the analysis is finished we can display the histograms
225 //
226 if (displhillas)
227 plist.FindObject("MHHillas")->DrawClone();
228
229 if (displstarmap)
230 plist.FindObject("MHStarMap")->DrawClone();
231
232 cout << endl;
233 cout << "Calculation of Hillas Parameters finished without error!" << endl;
234}
235
236// ======================================================================
237
238Bool_t MAnalysis::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
239{
240 // Process events generated by the buttons in the frame.
241
242 if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
243 return MBrowser::ProcessMessage(msg, parm1, parm2);
244
245 switch (parm1)
246 {
247 case kButHillas:
248 if (!InputFileSelected())
249 {
250 DisplError("No Input (root) File selected!");
251 return kTRUE;
252 }
253
254 switch (parm1)
255 {
256 case kButHillas:
257 CalculateHillas();
258 return kTRUE;
259 }
260 return kTRUE;
261 }
262
263 return MBrowser::ProcessMessage(msg, parm1, parm2);
264}
Note: See TracBrowser for help on using the repository browser.