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

Last change on this file since 2205 was 2178, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 8.7 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 "MCamDisplay.h" // MCamDisplay
39#include "MHillasCalc.h" // MHillasCalc
40#include "MHillasSrcCalc.h" // MHillasSrcCalc
41#include "MPedestalCam.h" // MPedestalCam
42#include "MCerPhotCalc.h" // MCerPhotCalc
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 MCerPhotCalc *ncalc = new MCerPhotCalc;
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 MCamDisplay(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//
207void MGCamDisplay::UpdateDisplay()
208{
209 if (!IsInitOk())
210 return;
211
212 const MParList *plist = fEvtLoop->GetParList();
213
214 //
215 // Show Hillas ellipse
216 //
217 MHillas *hillas = (MHillas*)plist->FindObject("MHillas");
218
219 hillas->Print();
220 plist->FindObject("MHillasExt")->Print();
221 plist->FindObject("MHillasSrc")->Print();
222 plist->FindObject("MNewImagePar")->Print();
223
224 if (fDisplayHillas)
225 {
226 fCanvas->cd();
227 hillas->Draw();
228 }
229 else
230 hillas->Clear();
231
232 //
233 // Display the requested event. This does a Canvas update, too.
234 //
235 MCerPhotEvt *evt = NULL;
236 if (fDisplayRaw)
237 {
238 // Get a clone of MCerPhotEvt which is made before the image cleaning
239 const MClone *clone = (MClone*)GetTaskList()->FindObject("MClone");
240 evt = (MCerPhotEvt*)clone->GetClone();
241 }
242 else
243 {
244 // Get MCerPhotEvt which containes the cleaned data
245 evt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
246 }
247
248 const MImgCleanStd *clean = (MImgCleanStd*)GetTaskList()->FindObject("MImgCleanStd");
249 const MPedestalCam *ped = (MPedestalCam*)plist->FindObject("MPedestalCam");
250
251 fDisplay[0]->Fill((MCamEvent&)*evt, 0);
252 fDisplay[1]->Fill((MCamEvent&)*evt, 1);
253 fDisplay[2]->Fill((MCamEvent&)*evt, 2);
254 fDisplay[3]->FillLevels(*evt, *clean);
255 fDisplay[4]->Fill((MCamEvent&)*ped);
256
257 for (int i=0; i<5; i++)
258 {
259 fCanvas2[i]->Modified();
260 fCanvas2[i]->Update();
261 }
262}
263
264// --------------------------------------------------------------------------
265//
266// Process the messages from the setup GUI elements.
267//
268Bool_t MGCamDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
269{
270 switch(GET_MSG(msg))
271 {
272 case kC_COMMAND:
273 switch(GET_SUBMSG(msg))
274 {
275 case kCM_CHECKBUTTON:
276 switch (parm1)
277 {
278 case kCButHillas:
279 fDisplayHillas = !fDisplayHillas;
280 UpdateDisplay();
281 return kTRUE;
282 }
283 break;
284
285 case kCM_RADIOBUTTON:
286 switch (parm1)
287 {
288 case kRButRawEvt:
289 fDisplayRaw = kTRUE;
290 UpdateDisplay();
291 return kTRUE;
292
293 case kRButCleanedEvt:
294 fDisplayRaw = kFALSE;
295 UpdateDisplay();
296 return kTRUE;
297 }
298 break;
299 }
300 break;
301 }
302 return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
303}
304
Note: See TracBrowser for help on using the repository browser.