source: trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc@ 1834

Last change on this file since 1834 was 1668, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 8.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 10/2001 <mailto:tbretz@uni-sw.gwdg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25#include "MGCamDisplay.h"
26
27#include <TList.h> // TList::Add
28#include <TCanvas.h> // TCanvas::cd
29#include <TGButton.h> // TGPictureButton
30#include <TGButtonGroup.h> // TGVButtonGroup
31
32#include "MGTask.h" // MGTask::CreateGui
33#include "MClone.h" // MClone
34#include "MHillasExt.h" // MHillasExt
35#include "MParList.h" // MParList::AddToList
36#include "MEvtLoop.h" // MEvtLoop::GetParList
37#include "MTaskList.h" // MTaskList::AddToList
38#include "MCamDisplay.h" // MCamDisplay
39#include "MHillasCalc.h" // MHillasCalc
40#include "MPedestalCam.h" // MPedestalCam
41#include "MCerPhotCalc.h" // MCerPhotCalc
42#include "MMcPedestalCopy.h" // MMcPedestalCopy
43#include "MMcPedestalNSBAdd.h" // MMcPedestalNSBAdd
44#include "MBlindPixelCalc.h" // MBlindPixelCalc
45#include "MImgCleanStd.h" // MImgCleanStd
46#include "MGeomCamMagic.h" // MGeomMagicCam
47
48ClassImp(MGCamDisplay);
49
50enum
51{
52 kRButRawEvt,
53 kRButCleanedEvt,
54 kCButHillas
55};
56
57// --------------------------------------------------------------------------
58//
59// Add Setup elements to GUI.
60//
61void MGCamDisplay::AddSetupElements()
62{
63 //
64 // Create gui elements for vertical frame
65 //
66 TGGroupFrame *grp = new TGGroupFrame(fTab1, "Display");
67 TGVButtonGroup *group = new TGVButtonGroup(grp);
68 fList->Add(group);
69
70 TGRadioButton *but1 = new TGRadioButton(group, "Raw Events", kRButRawEvt);
71 TGRadioButton *but2 = new TGRadioButton(group, "Cleaned Events", kRButCleanedEvt);
72 TGCheckButton *but3 = new TGCheckButton(grp, "Display Ellipse", kCButHillas);
73
74 but2->SetState(kButtonDown);
75 but3->SetState(kButtonDown);
76
77 fDisplayRaw = kFALSE;
78 fDisplayHillas = kTRUE;
79
80 /*
81 WARNING:
82 Bacause of some strage and hidden dependencies the
83 GetMainFrame call in the destructor of TGButton may fail if some
84 of the other gui elements are deleted first.
85 AddFirst adds the buttons at the beginning of the deletion list,
86 this seems to work.
87 */
88 fList->AddFirst(but1);
89 fList->AddFirst(but2);
90
91 but1->Associate(this);
92 but2->Associate(this);
93 but3->Associate(this);
94
95 TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 15, 0);
96 fList->Add(laybut);
97
98 grp->AddFrame(group);
99 grp->AddFrame(but3, laybut);
100
101 TGLayoutHints *laygrp1 = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 10, 10, 5, 0);
102 TGLayoutHints *laygrp2 = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 10, 10, 5, 5);
103
104 fTab1->AddFrame(grp, laygrp1);
105 ((MGTask*)GetTaskList()->FindObject("MImgCleanStd"))->CreateGui(fTab1, laygrp2);
106}
107
108// --------------------------------------------------------------------------
109//
110// Setup Task and parameter list for hillas calculation,
111// preprocess tasks and read in first event (process)
112//
113MGeomCam *MGCamDisplay::SetupTaskList()
114{
115 MTaskList *tlist = GetTaskList();
116 MParList *plist = GetParList();
117
118 MMcPedestalCopy *pcopy = new MMcPedestalCopy;
119 MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
120 MCerPhotCalc *ncalc = new MCerPhotCalc;
121 MClone *clone = new MClone("MCerPhotEvt");
122 MImgCleanStd *clean = new MImgCleanStd;
123 MBlindPixelCalc *blind = new MBlindPixelCalc;
124 MHillasCalc *hcalc = new MHillasCalc;
125
126 tlist->AddToList(pcopy);
127 tlist->AddToList(pdnsb);
128 tlist->AddToList(ncalc);
129 tlist->AddToList(clone);
130 tlist->AddToList(clean);
131 tlist->AddToList(blind);
132 tlist->AddToList(hcalc);
133
134 MGeomCamMagic *geom = new MGeomCamMagic;
135 MPedestalCam *pedest = new MPedestalCam;
136 MHillasExt *hext = new MHillasExt;
137
138 plist->AddToList(geom);
139 plist->AddToList(pedest);
140 plist->AddToList(hext);
141
142 return geom;
143}
144
145// --------------------------------------------------------------------------
146//
147// Constructor.
148//
149MGCamDisplay::MGCamDisplay(const char *filename,
150 const TGWindow *p, /*const TGWindow *main,*/
151 UInt_t w, UInt_t h)
152: MGEvtDisplay(filename, "Events", p, /*main,*/ w, h), fDisplay(NULL)
153{
154 //
155 // Setup Task list for hillas calculation
156 //
157 MGeomCam *geom = SetupTaskList();
158
159 //
160 // Add missing setup elements to GUI
161 //
162 AddSetupElements();
163
164 TCanvas *canv2 = AddTab("Errors");
165 TCanvas *canv3 = AddTab("Phot/Err");
166 TCanvas *canv4 = AddTab("Levels");
167 TCanvas *canv5 = AddTab("Pedestals");
168
169 //
170 // Show camera display for the actual geometry
171 //
172 fDisplay = new MCamDisplay(geom);
173 fDisplay2 = new MCamDisplay(geom);
174 fDisplay3 = new MCamDisplay(geom);
175 fDisplay4 = new MCamDisplay(geom);
176 fDisplay5 = new MCamDisplay(geom);
177
178 fList->Add(fDisplay);
179 fList->Add(fDisplay2);
180 fList->Add(fDisplay3);
181 fList->Add(fDisplay4);
182 fList->Add(fDisplay5);
183
184 fCanvas->cd();
185 fDisplay->Draw();
186 canv2->cd();
187 fDisplay2->Draw();
188 canv3->cd();
189 fDisplay3->Draw();
190 canv4->cd();
191 fDisplay4->Draw();
192 canv5->cd();
193 fDisplay5->Draw();
194
195
196 ReadFirstEvent();
197
198 //
199 // Map the window, set up the layout, etc.
200 //
201 MapSubwindows();
202
203 Layout();
204
205 SetWindowName("Hillas Event Display");
206 SetIconName("Hillas");
207
208 MapWindow();
209}
210
211// --------------------------------------------------------------------------
212//
213// Update event display:
214// dependent on the setup either the uncleaned or cleand data is shown
215// together with the hillas ellipse or not.
216//
217void MGCamDisplay::UpdateDisplay()
218{
219 if (!IsInitOk())
220 return;
221
222 const MParList *plist = fEvtLoop->GetParList();
223
224 //
225 // Show Hillas ellipse
226 //
227 MHillas *hillas = (MHillas*)plist->FindObject("MHillas");
228
229 hillas->Print();
230 if (fDisplayHillas)
231 {
232 fCanvas->cd();
233 hillas->Draw();
234 }
235 else
236 hillas->Clear();
237
238 //
239 // Display the requested event. This does a Canvas update, too.
240 //
241 MCerPhotEvt *evt = NULL;
242 if (fDisplayRaw)
243 {
244 //
245 // Get a clone of MCerPhotEvt which is made before the image cleaning
246 //
247 const MClone *clone = (MClone*)GetTaskList()->FindObject("MClone");
248 evt = (MCerPhotEvt*)clone->GetClone();
249 }
250 else
251 {
252 //
253 // Get MCerPhotEvt which containes the cleaned data
254 //
255 evt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
256 }
257
258 const MImgCleanStd *clean = (MImgCleanStd*)GetTaskList()->FindObject("MImgCleanStd");
259 const MPedestalCam *ped = (MPedestalCam*)plist->FindObject("MPedestalCam");
260
261 fDisplay->DrawPhotNum(evt);
262 fDisplay2->DrawErrorPhot(evt);
263 fDisplay3->DrawRatio(evt);
264 fDisplay4->DrawLevels(evt, *clean);
265 fDisplay5->DrawPedestals(ped);
266}
267
268// --------------------------------------------------------------------------
269//
270// Process the messages from the setup GUI elements.
271//
272Bool_t MGCamDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
273{
274 switch(GET_MSG(msg))
275 {
276 case kC_COMMAND:
277 switch(GET_SUBMSG(msg))
278 {
279 case kCM_CHECKBUTTON:
280 switch (parm1)
281 {
282 case kCButHillas:
283 fDisplayHillas = !fDisplayHillas;
284 UpdateDisplay();
285 return kTRUE;
286 }
287 break;
288
289 case kCM_RADIOBUTTON:
290 switch (parm1)
291 {
292 case kRButRawEvt:
293 fDisplayRaw = kTRUE;
294 UpdateDisplay();
295 return kTRUE;
296
297 case kRButCleanedEvt:
298 fDisplayRaw = kFALSE;
299 UpdateDisplay();
300 return kTRUE;
301 }
302 break;
303 }
304 break;
305 }
306 return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
307}
308
Note: See TracBrowser for help on using the repository browser.