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 |
|
---|
44 | ClassImp(MGCamDisplay);
|
---|
45 |
|
---|
46 | enum
|
---|
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 | //
|
---|
57 | void 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 | /*
|
---|
76 | FIXME: crashed the destructor
|
---|
77 |
|
---|
78 | fList->Add(but1);
|
---|
79 | fList->Add(but2);
|
---|
80 | */
|
---|
81 |
|
---|
82 | but1->Associate(this);
|
---|
83 | but2->Associate(this);
|
---|
84 | but3->Associate(this);
|
---|
85 |
|
---|
86 | TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 15, 0);
|
---|
87 | fList->Add(laybut);
|
---|
88 |
|
---|
89 | fTab1->AddFrame(group);
|
---|
90 | fTab1->AddFrame(but3, laybut);
|
---|
91 | }
|
---|
92 |
|
---|
93 | // --------------------------------------------------------------------------
|
---|
94 | //
|
---|
95 | // Setup Task and parameter list for hillas calculation,
|
---|
96 | // preprocess tasks and read in first event (process)
|
---|
97 | //
|
---|
98 | MGeomCam *MGCamDisplay::SetupTaskList()
|
---|
99 | {
|
---|
100 | MTaskList *tlist = GetTaskList();
|
---|
101 | MParList *plist = GetParList();
|
---|
102 |
|
---|
103 | MCerPhotCalc *ncalc = new MCerPhotCalc;
|
---|
104 | MClone *clone = new MClone("MCerPhotEvt");
|
---|
105 | MImgCleanStd *clean = new MImgCleanStd;
|
---|
106 | MHillasCalc *hcalc = new MHillasCalc;
|
---|
107 |
|
---|
108 | tlist->AddToList(ncalc);
|
---|
109 | tlist->AddToList(clone);
|
---|
110 | tlist->AddToList(clean);
|
---|
111 | tlist->AddToList(hcalc);
|
---|
112 |
|
---|
113 | MGeomCamMagic *geom = new MGeomCamMagic;
|
---|
114 | MPedestalCam *pedest = new MPedestalCam;
|
---|
115 |
|
---|
116 | plist->AddToList(geom);
|
---|
117 | plist->AddToList(pedest);
|
---|
118 |
|
---|
119 | fInitOk = fEvtLoop->PreProcess();
|
---|
120 |
|
---|
121 | if (fInitOk)
|
---|
122 | GetTaskList()->Process();
|
---|
123 |
|
---|
124 | return geom;
|
---|
125 | }
|
---|
126 |
|
---|
127 | // --------------------------------------------------------------------------
|
---|
128 | //
|
---|
129 | // Constructor.
|
---|
130 | //
|
---|
131 | MGCamDisplay::MGCamDisplay(const char *filename,
|
---|
132 | const TGWindow *p, const TGWindow *main,
|
---|
133 | UInt_t w, UInt_t h)
|
---|
134 | : MGEvtDisplay(filename, "Events", p, main, w, h), fDisplay(NULL)
|
---|
135 | {
|
---|
136 | //
|
---|
137 | // Setup Task list for hillas calculation
|
---|
138 | //
|
---|
139 | MGeomCam *geom = SetupTaskList();
|
---|
140 |
|
---|
141 | //
|
---|
142 | // Add missing setup elements to GUI
|
---|
143 | //
|
---|
144 | AddSetupElements();
|
---|
145 |
|
---|
146 | //
|
---|
147 | // Show camera display for the actual geometry
|
---|
148 | //
|
---|
149 | fDisplay = new MCamDisplay(geom);
|
---|
150 | fDisplay->Draw();
|
---|
151 |
|
---|
152 | fList->Add(fDisplay);
|
---|
153 |
|
---|
154 | //
|
---|
155 | // Map the window, set up the layout, etc.
|
---|
156 | //
|
---|
157 | SetWMSizeHints(450, 400, 1000, 1000, 10, 10 ); // set the smallest and biggest size of the Main frame
|
---|
158 |
|
---|
159 | MapSubwindows();
|
---|
160 |
|
---|
161 | Layout();
|
---|
162 |
|
---|
163 | SetWindowName("Hillas Event Display");
|
---|
164 | SetIconName("Hillas");
|
---|
165 |
|
---|
166 | UpdateDisplay();
|
---|
167 | UpdateNumOfEvts();
|
---|
168 | UpdateEventCounter();
|
---|
169 |
|
---|
170 | MapWindow();
|
---|
171 | }
|
---|
172 |
|
---|
173 | // --------------------------------------------------------------------------
|
---|
174 | //
|
---|
175 | // Update event display:
|
---|
176 | // dependent on the setup either the uncleaned or cleand data is shown
|
---|
177 | // together with the hillas ellipse or not.
|
---|
178 | //
|
---|
179 | void MGCamDisplay::UpdateDisplay()
|
---|
180 | {
|
---|
181 | if (!fInitOk)
|
---|
182 | return;
|
---|
183 |
|
---|
184 | const MParList *plist = fEvtLoop->GetParList();
|
---|
185 |
|
---|
186 | //
|
---|
187 | // Show Hillas ellipse
|
---|
188 | //
|
---|
189 | MHillas *hillas = (MHillas*)plist->FindObject("MHillas");
|
---|
190 |
|
---|
191 | hillas->Print();
|
---|
192 | if (fDisplayHillas)
|
---|
193 | {
|
---|
194 | fCanvas->cd();
|
---|
195 | hillas->Draw();
|
---|
196 | }
|
---|
197 | else
|
---|
198 | hillas->Clear();
|
---|
199 |
|
---|
200 | //
|
---|
201 | // Display the requested event. This does a Canvas update, too.
|
---|
202 | //
|
---|
203 | MCerPhotEvt *evt = NULL;
|
---|
204 | if (fDisplayRaw)
|
---|
205 | {
|
---|
206 | //
|
---|
207 | // Get a clone of MCerPhotEvt which is made before the image cleaning
|
---|
208 | //
|
---|
209 | const MClone *clone = (MClone*)GetTaskList()->FindObject("MClone");
|
---|
210 | evt = (MCerPhotEvt*)clone->GetClone();
|
---|
211 | }
|
---|
212 | else
|
---|
213 | {
|
---|
214 | //
|
---|
215 | // Get MCerPhotEvt which containes the cleaned data
|
---|
216 | //
|
---|
217 | evt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
|
---|
218 | }
|
---|
219 |
|
---|
220 | fDisplay->DrawPhotNum(evt);
|
---|
221 | }
|
---|
222 |
|
---|
223 | // --------------------------------------------------------------------------
|
---|
224 | //
|
---|
225 | // Process the messages from the setup GUI elements.
|
---|
226 | //
|
---|
227 | Bool_t MGCamDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
228 | {
|
---|
229 | switch(GET_MSG(msg))
|
---|
230 | {
|
---|
231 | case kC_COMMAND:
|
---|
232 | switch(GET_SUBMSG(msg))
|
---|
233 | {
|
---|
234 | case kCM_CHECKBUTTON:
|
---|
235 | switch (parm1)
|
---|
236 | {
|
---|
237 | case M_CBUT_HILLAS:
|
---|
238 | fDisplayHillas = !fDisplayHillas;
|
---|
239 | UpdateDisplay();
|
---|
240 | return kTRUE;
|
---|
241 | }
|
---|
242 | break;
|
---|
243 |
|
---|
244 | case kCM_RADIOBUTTON:
|
---|
245 | switch (parm1)
|
---|
246 | {
|
---|
247 | case M_RBUT_RAW:
|
---|
248 | fDisplayRaw = kTRUE;
|
---|
249 | UpdateDisplay();
|
---|
250 | return kTRUE;
|
---|
251 |
|
---|
252 | case M_RBUT_CLEAN:
|
---|
253 | fDisplayRaw = kFALSE;
|
---|
254 | UpdateDisplay();
|
---|
255 | return kTRUE;
|
---|
256 | }
|
---|
257 | break;
|
---|
258 | }
|
---|
259 | break;
|
---|
260 | }
|
---|
261 | return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
|
---|
262 | }
|
---|
263 |
|
---|