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

Last change on this file since 2227 was 2227, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 8.9 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@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
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 "MHillas.h" // MHillas
35#include "MParList.h" // MParList::AddToList
36#include "MEvtLoop.h" // MEvtLoop::GetParList
37#include "MTaskList.h" // MTaskList::AddToList
38#include "MHCamera.h" // MHCamera
39#include "MHillasCalc.h" // MHillasCalc
40#include "MHillasSrcCalc.h" // MHillasSrcCalc
41#include "MPedestalCam.h" // MPedestalCam
42#include "MCerPhotAnal.h" // MCerPhotAnal
43#include "MMcPedestalCopy.h" // MMcPedestalCopy
44#include "MMcPedestalNSBAdd.h" // MMcPedestalNSBAdd
45#include "MBlindPixelCalc.h" // MBlindPixelCalc
46#include "MImgCleanStd.h" // MImgCleanStd
47#include "MGeomCamMagic.h" // MGeomMagicCam
48#include "MRawEvtData.h" // MRawEvtData
49
50ClassImp(MGCamDisplay);
51
52enum
53{
54 kRButRawEvt,
55 kRButCleanedEvt,
56 kCButHillas
57};
58
59// --------------------------------------------------------------------------
60//
61// Add Setup elements to GUI.
62//
63void MGCamDisplay::AddSetupElements()
64{
65 //
66 // Create gui elements for vertical frame
67 //
68 TGGroupFrame *grp = new TGGroupFrame(fTab1, "Display");
69 TGVButtonGroup *group = new TGVButtonGroup(grp);
70 fList->Add(group);
71
72 TGRadioButton *but1 = new TGRadioButton(group, "Raw Events", kRButRawEvt);
73 TGRadioButton *but2 = new TGRadioButton(group, "Cleaned Events", kRButCleanedEvt);
74 TGCheckButton *but3 = new TGCheckButton(grp, "Display Ellipse", kCButHillas);
75
76 but2->SetState(kButtonDown);
77 but3->SetState(kButtonDown);
78
79 fDisplayRaw = kFALSE;
80 fDisplayHillas = kTRUE;
81
82 /*
83 WARNING:
84 Bacause of some strage and hidden dependencies the
85 GetMainFrame call in the destructor of TGButton may fail if some
86 of the other gui elements are deleted first.
87 AddFirst adds the buttons at the beginning of the deletion list,
88 this seems to work.
89 */
90 fList->AddFirst(but1);
91 fList->AddFirst(but2);
92
93 but1->Associate(this);
94 but2->Associate(this);
95 but3->Associate(this);
96
97 TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 15, 0);
98 fList->Add(laybut);
99
100 grp->AddFrame(group);
101 grp->AddFrame(but3, laybut);
102
103 TGLayoutHints *laygrp1 = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 10, 10, 5, 0);
104 TGLayoutHints *laygrp2 = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 10, 10, 5, 5);
105
106 fTab1->AddFrame(grp, laygrp1);
107 ((MGTask*)GetTaskList()->FindObject("MImgCleanStd"))->CreateGui(fTab1, laygrp2);
108}
109
110// --------------------------------------------------------------------------
111//
112// Setup Task and parameter list for hillas calculation,
113// preprocess tasks and read in first event (process)
114//
115MGeomCam *MGCamDisplay::SetupTaskList()
116{
117 MTaskList *tlist = GetTaskList();
118 MParList *plist = GetParList();
119
120 MMcPedestalCopy *pcopy = new MMcPedestalCopy;
121 MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
122 MCerPhotAnal *ncalc = new MCerPhotAnal;
123 MClone *clone = new MClone("MCerPhotEvt");
124 MImgCleanStd *clean = new MImgCleanStd;
125 MBlindPixelCalc *blind = new MBlindPixelCalc;
126 MHillasCalc *hcalc = new MHillasCalc;
127 MHillasSrcCalc *scalc = new MHillasSrcCalc;
128
129 tlist->AddToList(pcopy);
130 tlist->AddToList(pdnsb);
131 tlist->AddToList(ncalc);
132 tlist->AddToList(clone);
133 tlist->AddToList(clean);
134 tlist->AddToList(blind);
135 tlist->AddToList(hcalc);
136 tlist->AddToList(scalc);
137
138 MGeomCamMagic *geom = new MGeomCamMagic;
139 MPedestalCam *pedest = new MPedestalCam;
140 MRawEvtData *event = new MRawEvtData;
141
142 plist->AddToList(geom);
143 plist->AddToList(pedest);
144 plist->AddToList(event);
145
146 return geom;
147}
148
149// --------------------------------------------------------------------------
150//
151// Constructor.
152//
153MGCamDisplay::MGCamDisplay(const char *filename, const TGWindow *p,
154 UInt_t w, UInt_t h)
155: MGEvtDisplay(filename, "Events", p, w, h)
156{
157 //
158 // Setup Task list for hillas calculation
159 //
160 MGeomCam *geom = SetupTaskList();
161
162 //
163 // Add missing setup elements to GUI
164 //
165 AddSetupElements();
166
167 fCanvas2[0] = fCanvas;
168 fCanvas2[1] = AddTab("Errors");
169 fCanvas2[2] = AddTab("Phot/Err");
170 fCanvas2[3] = AddTab("Levels");
171 fCanvas2[4] = AddTab("Pedestals");
172
173 //
174 // Show camera display for the actual geometry
175 //
176 for (int i=0; i<5; i++)
177 {
178 fCanvas2[i]->cd();
179 fDisplay[i] = new MHCamera(*geom);
180 fDisplay[i]->Draw();
181 fDisplay[i]->AddNotify(*(MCamEvent*)GetParList()->FindObject("MRawEvtData"));
182 fCanvas2[i]->Update();
183 fList->Add(fDisplay[i]);
184 }
185
186 ReadFirstEvent();
187
188 //
189 // Map the window, set up the layout, etc.
190 //
191 MapSubwindows();
192
193 Layout();
194
195 SetWindowName("Image Event Display");
196 SetIconName("Image");
197
198 MapWindow();
199}
200
201// --------------------------------------------------------------------------
202//
203// Update event display:
204// dependent on the setup either the uncleaned or cleand data is shown
205// together with the hillas ellipse or not.
206//
207#include <iostream>
208void MGCamDisplay::UpdateDisplay()
209{
210 if (!IsInitOk())
211 return;
212
213 const MParList *plist = fEvtLoop->GetParList();
214
215 //
216 // Show Hillas ellipse
217 //
218 MHillas *hillas = (MHillas*)plist->FindObject("MHillas");
219
220 hillas->Print();
221 plist->FindObject("MHillasExt")->Print();
222 plist->FindObject("MHillasSrc")->Print();
223 plist->FindObject("MNewImagePar")->Print();
224
225 //
226 // Display the requested event. This does a Canvas update, too.
227 //
228 MCerPhotEvt *evt = NULL;
229 if (fDisplayRaw)
230 {
231 // Get a clone of MCerPhotEvt which is made before the image cleaning
232 const MClone *clone = (MClone*)GetTaskList()->FindObject("MClone");
233 evt = (MCerPhotEvt*)clone->GetClone();
234 }
235 else
236 {
237 // Get MCerPhotEvt which containes the cleaned data
238 evt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
239 }
240
241 const MImgCleanStd *clean = (MImgCleanStd*)GetTaskList()->FindObject("MImgCleanStd");
242 const MPedestalCam *ped = (MPedestalCam*)plist->FindObject("MPedestalCam");
243
244 fDisplay[0]->SetCamContent((MCamEvent&)*evt, 0);
245 fDisplay[1]->SetCamContent((MCamEvent&)*evt, 1);
246 fDisplay[2]->SetCamContent((MCamEvent&)*evt, 2);
247 fDisplay[3]->FillLevels(*evt, *clean);
248 fDisplay[4]->SetCamContent((MCamEvent&)*ped);
249
250 if (fDisplayHillas)
251 for (int i=0; i<5; i++)
252 {
253 fCanvas2[i]->cd();
254 hillas->Draw();
255 fCanvas2[i]->Update();
256 }
257 else
258 {
259 hillas->Clear();
260 for (int i=0; i<5; i++)
261 {
262 fCanvas2[i]->Modified();
263 fCanvas2[i]->Update();
264 }
265 }
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.