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

Last change on this file since 1030 was 1030, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 6.5 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 (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 "MClone.h" // MClone
33#include "MHillas.h" // MHillas
34#include "MParList.h" // MParList::AddToList
35#include "MEvtLoop.h" // MEvtLoop::GetParList
36#include "MTaskList.h" // MTaskList::AddToList
37#include "MCamDisplay.h" // MCamDisplay
38#include "MHillasCalc.h" // MHillasCalc
39#include "MPedestalCam.h" // MPedestalCam
40#include "MCerPhotCalc.h" // MCerPhotCalc
41#include "MImgCleanStd.h" // MImgCleanStd
42#include "MGeomCamMagic.h" // MGeomMagicCam
43
44ClassImp(MGCamDisplay);
45
46enum
47{
48 M_RBUT_RAW = 0x1000,
49 M_RBUT_CLEAN = 0x1001,
50 M_CBUT_HILLAS = 0x1002
51};
52
53// --------------------------------------------------------------------------
54//
55// Add Setup elements to GUI.
56//
57void MGCamDisplay::AddSetupElements()
58{
59 //
60 // Create gui elements for vertical frame
61 //
62 TGVButtonGroup *group = new TGVButtonGroup(fTab1);
63 fList->Add(group);
64
65 TGRadioButton *but1 = new TGRadioButton(group, "Raw Events", M_RBUT_RAW);
66 TGRadioButton *but2 = new TGRadioButton(group, "Cleaned Events", M_RBUT_CLEAN);
67 TGCheckButton *but3 = new TGCheckButton(fTab1, "Display Ellipse", M_CBUT_HILLAS);
68
69 but2->SetState(kButtonDown);
70 but3->SetState(kButtonDown);
71
72 fDisplayRaw = kFALSE;
73 fDisplayHillas = kTRUE;
74
75 /* FXIME:
76 fList->Add(but1);
77 fList->Add(but2);
78 */
79
80 but1->Associate(this);
81 but2->Associate(this);
82 but3->Associate(this);
83
84 TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 15, 0);
85 fList->Add(laybut);
86
87 fTab1->AddFrame(group);
88 fTab1->AddFrame(but3, laybut);
89}
90
91// --------------------------------------------------------------------------
92//
93// Setup Task and parameter list for hillas calculation,
94// preprocess tasks and read in first event (process)
95//
96MGeomCam *MGCamDisplay::SetupTaskList()
97{
98 MTaskList *tlist = GetTaskList();
99 MParList *plist = GetParList();
100
101 MCerPhotCalc *ncalc = new MCerPhotCalc;
102 MClone *clone = new MClone("MCerPhotEvt");
103 MImgCleanStd *clean = new MImgCleanStd;
104 MHillasCalc *hcalc = new MHillasCalc;
105
106 tlist->AddToList(ncalc);
107 tlist->AddToList(clone);
108 tlist->AddToList(clean);
109 tlist->AddToList(hcalc);
110
111 MGeomCamMagic *geom = new MGeomCamMagic;
112 MPedestalCam *pedest = new MPedestalCam;
113
114 plist->AddToList(geom);
115 plist->AddToList(pedest);
116
117 return geom;
118}
119
120// --------------------------------------------------------------------------
121//
122// Constructor.
123//
124MGCamDisplay::MGCamDisplay(const char *filename,
125 const TGWindow *p, const TGWindow *main,
126 UInt_t w, UInt_t h)
127: MGEvtDisplay(filename, "Events", p, main, w, h), fDisplay(NULL)
128{
129 //
130 // Setup Task list for hillas calculation
131 //
132 MGeomCam *geom = SetupTaskList();
133
134 //
135 // Add missing setup elements to GUI
136 //
137 AddSetupElements();
138
139 //
140 // Show camera display for the actual geometry
141 //
142 fDisplay = new MCamDisplay(geom);
143 fDisplay->Draw();
144 fList->Add(fDisplay);
145
146 ReadFirstEvent();
147
148 //
149 // Map the window, set up the layout, etc.
150 //
151 SetWMSizeHints(450, 400, 1000, 1000, 10, 10 ); // set the smallest and biggest size of the Main frame
152
153 MapSubwindows();
154
155 Layout();
156
157 SetWindowName("Hillas Event Display");
158 SetIconName("Hillas");
159
160 MapWindow();
161}
162
163// --------------------------------------------------------------------------
164//
165// Update event display:
166// dependent on the setup either the uncleaned or cleand data is shown
167// together with the hillas ellipse or not.
168//
169void MGCamDisplay::UpdateDisplay()
170{
171 if (!IsInitOk())
172 return;
173
174 const MParList *plist = fEvtLoop->GetParList();
175
176 //
177 // Show Hillas ellipse
178 //
179 MHillas *hillas = (MHillas*)plist->FindObject("MHillas");
180
181 hillas->Print();
182 if (fDisplayHillas)
183 {
184 fCanvas->cd();
185 hillas->Draw();
186 }
187 else
188 hillas->Clear();
189
190 //
191 // Display the requested event. This does a Canvas update, too.
192 //
193 MCerPhotEvt *evt = NULL;
194 if (fDisplayRaw)
195 {
196 //
197 // Get a clone of MCerPhotEvt which is made before the image cleaning
198 //
199 const MClone *clone = (MClone*)GetTaskList()->FindObject("MClone");
200 evt = (MCerPhotEvt*)clone->GetClone();
201 }
202 else
203 {
204 //
205 // Get MCerPhotEvt which containes the cleaned data
206 //
207 evt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
208 }
209
210 fDisplay->DrawPhotNum(evt);
211}
212
213// --------------------------------------------------------------------------
214//
215// Process the messages from the setup GUI elements.
216//
217Bool_t MGCamDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
218{
219 switch(GET_MSG(msg))
220 {
221 case kC_COMMAND:
222 switch(GET_SUBMSG(msg))
223 {
224 case kCM_CHECKBUTTON:
225 switch (parm1)
226 {
227 case M_CBUT_HILLAS:
228 fDisplayHillas = !fDisplayHillas;
229 UpdateDisplay();
230 return kTRUE;
231 }
232 break;
233
234 case kCM_RADIOBUTTON:
235 switch (parm1)
236 {
237 case M_RBUT_RAW:
238 fDisplayRaw = kTRUE;
239 UpdateDisplay();
240 return kTRUE;
241
242 case M_RBUT_CLEAN:
243 fDisplayRaw = kFALSE;
244 UpdateDisplay();
245 return kTRUE;
246 }
247 break;
248 }
249 break;
250 }
251 return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
252}
253
Note: See TracBrowser for help on using the repository browser.