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@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
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 |
|
---|
48 | ClassImp(MGCamDisplay);
|
---|
49 |
|
---|
50 | enum
|
---|
51 | {
|
---|
52 | kRButRawEvt,
|
---|
53 | kRButCleanedEvt,
|
---|
54 | kCButHillas
|
---|
55 | };
|
---|
56 |
|
---|
57 | // --------------------------------------------------------------------------
|
---|
58 | //
|
---|
59 | // Add Setup elements to GUI.
|
---|
60 | //
|
---|
61 | void 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 | GetMainFrame 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 | //
|
---|
113 | MGeomCam *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 | //
|
---|
147 | MGCamDisplay::MGCamDisplay(const char *filename, const TGWindow *p,
|
---|
148 | UInt_t w, UInt_t h)
|
---|
149 | : MGEvtDisplay(filename, "Events", p, w, h)
|
---|
150 | {
|
---|
151 | //
|
---|
152 | // Setup Task list for hillas calculation
|
---|
153 | //
|
---|
154 | MGeomCam *geom = SetupTaskList();
|
---|
155 |
|
---|
156 | //
|
---|
157 | // Add missing setup elements to GUI
|
---|
158 | //
|
---|
159 | AddSetupElements();
|
---|
160 |
|
---|
161 | fCanvas2[0] = fCanvas;
|
---|
162 | fCanvas2[1] = AddTab("Errors");
|
---|
163 | fCanvas2[2] = AddTab("Phot/Err");
|
---|
164 | fCanvas2[3] = AddTab("Levels");
|
---|
165 | fCanvas2[4] = AddTab("Pedestals");
|
---|
166 |
|
---|
167 | //
|
---|
168 | // Show camera display for the actual geometry
|
---|
169 | //
|
---|
170 | for (int i=0; i<5; i++)
|
---|
171 | {
|
---|
172 | fCanvas2[i]->cd();
|
---|
173 | fDisplay[i] = new MCamDisplay(geom);
|
---|
174 | fDisplay[i]->Draw();
|
---|
175 | fCanvas2[i]->Update();
|
---|
176 | fList->Add(fDisplay[i]);
|
---|
177 | }
|
---|
178 |
|
---|
179 | ReadFirstEvent();
|
---|
180 |
|
---|
181 | //
|
---|
182 | // Map the window, set up the layout, etc.
|
---|
183 | //
|
---|
184 | MapSubwindows();
|
---|
185 |
|
---|
186 | Layout();
|
---|
187 |
|
---|
188 | SetWindowName("Image Event Display");
|
---|
189 | SetIconName("Image");
|
---|
190 |
|
---|
191 | MapWindow();
|
---|
192 | }
|
---|
193 |
|
---|
194 | // --------------------------------------------------------------------------
|
---|
195 | //
|
---|
196 | // Update event display:
|
---|
197 | // dependent on the setup either the uncleaned or cleand data is shown
|
---|
198 | // together with the hillas ellipse or not.
|
---|
199 | //
|
---|
200 | void MGCamDisplay::UpdateDisplay()
|
---|
201 | {
|
---|
202 | if (!IsInitOk())
|
---|
203 | return;
|
---|
204 |
|
---|
205 | const MParList *plist = fEvtLoop->GetParList();
|
---|
206 |
|
---|
207 | //
|
---|
208 | // Show Hillas ellipse
|
---|
209 | //
|
---|
210 | MHillas *hillas = (MHillas*)plist->FindObject("MHillas");
|
---|
211 |
|
---|
212 | plist->FindObject("MHillasExt")->Print();
|
---|
213 | plist->FindObject("MNewImagePar")->Print();
|
---|
214 |
|
---|
215 | hillas->Print();
|
---|
216 | if (fDisplayHillas)
|
---|
217 | {
|
---|
218 | fCanvas->cd();
|
---|
219 | hillas->Draw();
|
---|
220 | }
|
---|
221 | else
|
---|
222 | hillas->Clear();
|
---|
223 |
|
---|
224 | //
|
---|
225 | // Display the requested event. This does a Canvas update, too.
|
---|
226 | //
|
---|
227 | MCerPhotEvt *evt = NULL;
|
---|
228 | if (fDisplayRaw)
|
---|
229 | {
|
---|
230 | // Get a clone of MCerPhotEvt which is made before the image cleaning
|
---|
231 | const MClone *clone = (MClone*)GetTaskList()->FindObject("MClone");
|
---|
232 | evt = (MCerPhotEvt*)clone->GetClone();
|
---|
233 | }
|
---|
234 | else
|
---|
235 | {
|
---|
236 | // Get MCerPhotEvt which containes the cleaned data
|
---|
237 | evt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
|
---|
238 | }
|
---|
239 |
|
---|
240 | const MImgCleanStd *clean = (MImgCleanStd*)GetTaskList()->FindObject("MImgCleanStd");
|
---|
241 | const MPedestalCam *ped = (MPedestalCam*)plist->FindObject("MPedestalCam");
|
---|
242 |
|
---|
243 | fDisplay[0]->FillPhotNum(*evt);
|
---|
244 | fDisplay[1]->FillErrorPhot(*evt);
|
---|
245 | fDisplay[2]->FillRatio(*evt);
|
---|
246 | fDisplay[3]->FillLevels(*evt, *clean);
|
---|
247 | fDisplay[4]->FillPedestals(*ped);
|
---|
248 |
|
---|
249 | for (int i=0; i<5; i++)
|
---|
250 | {
|
---|
251 | fCanvas2[i]->Modified();
|
---|
252 | fCanvas2[i]->Update();
|
---|
253 | }
|
---|
254 | }
|
---|
255 |
|
---|
256 | // --------------------------------------------------------------------------
|
---|
257 | //
|
---|
258 | // Process the messages from the setup GUI elements.
|
---|
259 | //
|
---|
260 | Bool_t MGCamDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
261 | {
|
---|
262 | switch(GET_MSG(msg))
|
---|
263 | {
|
---|
264 | case kC_COMMAND:
|
---|
265 | switch(GET_SUBMSG(msg))
|
---|
266 | {
|
---|
267 | case kCM_CHECKBUTTON:
|
---|
268 | switch (parm1)
|
---|
269 | {
|
---|
270 | case kCButHillas:
|
---|
271 | fDisplayHillas = !fDisplayHillas;
|
---|
272 | UpdateDisplay();
|
---|
273 | return kTRUE;
|
---|
274 | }
|
---|
275 | break;
|
---|
276 |
|
---|
277 | case kCM_RADIOBUTTON:
|
---|
278 | switch (parm1)
|
---|
279 | {
|
---|
280 | case kRButRawEvt:
|
---|
281 | fDisplayRaw = kTRUE;
|
---|
282 | UpdateDisplay();
|
---|
283 | return kTRUE;
|
---|
284 |
|
---|
285 | case kRButCleanedEvt:
|
---|
286 | fDisplayRaw = kFALSE;
|
---|
287 | UpdateDisplay();
|
---|
288 | return kTRUE;
|
---|
289 | }
|
---|
290 | break;
|
---|
291 | }
|
---|
292 | break;
|
---|
293 | }
|
---|
294 | return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
|
---|
295 | }
|
---|
296 |
|
---|