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

Last change on this file since 1388 was 1384, checked in by tbretz, 22 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 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 "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 "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 GetMaiFrame 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
137 plist->AddToList(geom);
138 plist->AddToList(pedest);
139
140 return geom;
141}
142
143// --------------------------------------------------------------------------
144//
145// Constructor.
146//
147MGCamDisplay::MGCamDisplay(const char *filename,
148 const TGWindow *p, const TGWindow *main,
149 UInt_t w, UInt_t h)
150: MGEvtDisplay(filename, "Events", p, main, w, h), fDisplay(NULL)
151{
152 //
153 // Setup Task list for hillas calculation
154 //
155 MGeomCam *geom = SetupTaskList();
156
157 //
158 // Add missing setup elements to GUI
159 //
160 AddSetupElements();
161
162 //
163 // Show camera display for the actual geometry
164 //
165 fCanvas->cd();
166 fDisplay = new MCamDisplay(geom);
167 fDisplay->Draw();
168 fList->Add(fDisplay);
169
170 ReadFirstEvent();
171
172 //
173 // Map the window, set up the layout, etc.
174 //
175 MapSubwindows();
176
177 Layout();
178
179 SetWindowName("Hillas Event Display");
180 SetIconName("Hillas");
181
182 MapWindow();
183}
184
185// --------------------------------------------------------------------------
186//
187// Update event display:
188// dependent on the setup either the uncleaned or cleand data is shown
189// together with the hillas ellipse or not.
190//
191void MGCamDisplay::UpdateDisplay()
192{
193 if (!IsInitOk())
194 return;
195
196 const MParList *plist = fEvtLoop->GetParList();
197
198 //
199 // Show Hillas ellipse
200 //
201 MHillas *hillas = (MHillas*)plist->FindObject("MHillas");
202
203 hillas->Print();
204 if (fDisplayHillas)
205 {
206 fCanvas->cd();
207 hillas->Draw();
208 }
209 else
210 hillas->Clear();
211
212 //
213 // Display the requested event. This does a Canvas update, too.
214 //
215 MCerPhotEvt *evt = NULL;
216 if (fDisplayRaw)
217 {
218 //
219 // Get a clone of MCerPhotEvt which is made before the image cleaning
220 //
221 const MClone *clone = (MClone*)GetTaskList()->FindObject("MClone");
222 evt = (MCerPhotEvt*)clone->GetClone();
223 }
224 else
225 {
226 //
227 // Get MCerPhotEvt which containes the cleaned data
228 //
229 evt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
230 }
231
232 fDisplay->DrawPhotNum(evt);
233}
234
235// --------------------------------------------------------------------------
236//
237// Process the messages from the setup GUI elements.
238//
239Bool_t MGCamDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
240{
241 switch(GET_MSG(msg))
242 {
243 case kC_COMMAND:
244 switch(GET_SUBMSG(msg))
245 {
246 case kCM_CHECKBUTTON:
247 switch (parm1)
248 {
249 case kCButHillas:
250 fDisplayHillas = !fDisplayHillas;
251 UpdateDisplay();
252 return kTRUE;
253 }
254 break;
255
256 case kCM_RADIOBUTTON:
257 switch (parm1)
258 {
259 case kRButRawEvt:
260 fDisplayRaw = kTRUE;
261 UpdateDisplay();
262 return kTRUE;
263
264 case kRButCleanedEvt:
265 fDisplayRaw = kFALSE;
266 UpdateDisplay();
267 return kTRUE;
268 }
269 break;
270 }
271 break;
272 }
273 return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
274}
275
Note: See TracBrowser for help on using the repository browser.