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