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

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