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 | #include "MEventDisplay.h"
|
---|
25 |
|
---|
26 | //
|
---|
27 | // C-lib
|
---|
28 | //
|
---|
29 | #include <stdlib.h> // atoi
|
---|
30 |
|
---|
31 | //
|
---|
32 | // root
|
---|
33 | //
|
---|
34 | #include <TFile.h> // TFile
|
---|
35 | #include <TList.h> // TList::Add
|
---|
36 | #include <TStyle.h> // gStyle->SetOptStat
|
---|
37 | #include <TCanvas.h> // TCanvas::cd
|
---|
38 |
|
---|
39 | //
|
---|
40 | // root GUI
|
---|
41 | //
|
---|
42 | #include <TGLabel.h> // TGLabel
|
---|
43 | #include <TGButton.h> // TGPictureButton
|
---|
44 | #include <TG3DLine.h> // TGHorizontal3DLine
|
---|
45 | #include <TGTextEntry.h> // TGTextEntry
|
---|
46 | #include <TGButtonGroup.h> // TGVButtonGroup
|
---|
47 | #include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
|
---|
48 |
|
---|
49 | //
|
---|
50 | // General
|
---|
51 | //
|
---|
52 | #include "MGList.h" // MGList
|
---|
53 |
|
---|
54 | #include "MParList.h" // MParList::AddToList
|
---|
55 | #include "MEvtLoop.h" // MEvtLoop::GetParList
|
---|
56 | #include "MTaskList.h" // MTaskList::AddToList
|
---|
57 |
|
---|
58 | //
|
---|
59 | // Tasks
|
---|
60 | //
|
---|
61 | #include "MReadMarsFile.h" // MReadMarsFile
|
---|
62 | #include "MGeomApply.h" // MGeomApply
|
---|
63 | #include "MFDataMember.h" // MFDataMember
|
---|
64 | #include "MMcPedestalCopy.h" // MMcPedestalCopy
|
---|
65 | #include "MMcPedestalNSBAdd.h" // MMcPedestalNSBAdd
|
---|
66 |
|
---|
67 | #include "MCerPhotAnal2.h" // MCerPhotAnal2
|
---|
68 | #include "MImgCleanStd.h" // MImgCleanStd
|
---|
69 | #include "MHillasCalc.h" // MHillasCalc
|
---|
70 | #include "MHillasSrcCalc.h" // MHillasSrcCalc
|
---|
71 | #include "MBlindPixelCalc.h" // MBlindPixelCalc
|
---|
72 | #include "MArrivalTimeCalc.h" // MArrivalTimeCalc
|
---|
73 | #include "MFillH.h" // MFillH
|
---|
74 | #include "MExtractSignal.h" // MExtractsignal
|
---|
75 | #include "MMcCalibrationUpdate.h" // MMcCalibrationUpdate
|
---|
76 | #include "MCalibrate.h" // MCalibrate
|
---|
77 |
|
---|
78 | //
|
---|
79 | // Container
|
---|
80 | //
|
---|
81 | #include "MHillas.h" // MHillas::Print(const MGeomCam&)
|
---|
82 | #include "MHillasExt.h" // MHillasExt::Print(const MGeomCam&)
|
---|
83 | #include "MHillasSrc.h" // MHillasSrc::Print(const MGeomCam&)
|
---|
84 | #include "MHEvent.h" // MHEvent
|
---|
85 | #include "MHCamera.h" // MHCamera
|
---|
86 | #include "MRawEvtData.h" // MRawEvtData
|
---|
87 | #include "MArrivalTimeCam.h" // MArrivalTimeCam
|
---|
88 | #include "MBadPixelsCam.h" // MBadPixelsCam
|
---|
89 | #include "MPedPhotCam.h" // MPedPhotCam
|
---|
90 | #include "MCalibrationChargeCam.h" // MCalibrationChargeCam
|
---|
91 |
|
---|
92 | ClassImp(MEventDisplay);
|
---|
93 |
|
---|
94 | // --------------------------------------------------------------------------
|
---|
95 | //
|
---|
96 | // Constructor.
|
---|
97 | //
|
---|
98 | MEventDisplay::MEventDisplay(const char *fname, const char *pname, const char *cname) : MStatusDisplay()
|
---|
99 | {
|
---|
100 | //
|
---|
101 | // Setup Task list for hillas calculation
|
---|
102 | //
|
---|
103 | SetupTaskList("Events", fname, pname, cname);
|
---|
104 |
|
---|
105 | //
|
---|
106 | // Add MEventDisplay GUI elements to the display
|
---|
107 | //
|
---|
108 | AddUserFrame(fname);
|
---|
109 |
|
---|
110 | //
|
---|
111 | // Show new part of the window, resize to correct aspect ratio
|
---|
112 | //
|
---|
113 | // FIXME: This should be done by MStatusDisplay automatically
|
---|
114 | Resize(GetWidth(), GetHeight() + fUserFrame->GetDefaultHeight());
|
---|
115 | SetWindowName("Event Display");
|
---|
116 | MapSubwindows();
|
---|
117 |
|
---|
118 | //
|
---|
119 | // Readin first event and display it
|
---|
120 | //
|
---|
121 | ReadFirstEvent();
|
---|
122 | }
|
---|
123 |
|
---|
124 | // --------------------------------------------------------------------------
|
---|
125 | //
|
---|
126 | // Destructor: PostProcess eventloop, delete eventloop with all containers
|
---|
127 | //
|
---|
128 | MEventDisplay::~MEventDisplay()
|
---|
129 | {
|
---|
130 | fEvtLoop->PostProcess();
|
---|
131 | delete fEvtLoop;
|
---|
132 | }
|
---|
133 |
|
---|
134 | // --------------------------------------------------------------------------
|
---|
135 | //
|
---|
136 | // Setup Task and parameter list for hillas calculation,
|
---|
137 | // preprocess tasks and read in first event (process)
|
---|
138 | //
|
---|
139 | void MEventDisplay::SetupTaskList(const char *tname, const char *fname,
|
---|
140 | const char *pname, const char *cname)
|
---|
141 | {
|
---|
142 | MCalibrationChargeCam *ccam=0;
|
---|
143 | MPedPhotCam *pcam=0;
|
---|
144 |
|
---|
145 | MBadPixelsCam *badpix = new MBadPixelsCam;
|
---|
146 |
|
---|
147 | TFile file(pname, "READ");
|
---|
148 | if (!file.IsZombie())
|
---|
149 | pcam = new MPedPhotCam;
|
---|
150 | if (pcam)
|
---|
151 | {
|
---|
152 | if (pcam->Read()<=0)
|
---|
153 | {
|
---|
154 | delete pcam;
|
---|
155 | pcam = NULL;
|
---|
156 | }
|
---|
157 |
|
---|
158 | if (file.FindKey("MBadPixelsCam"))
|
---|
159 | {
|
---|
160 | MBadPixelsCam bad;
|
---|
161 | if (bad.Read()>0)
|
---|
162 | badpix->Merge(bad);
|
---|
163 | }
|
---|
164 | }
|
---|
165 | file.Close();
|
---|
166 | file.Open(cname, "READ");
|
---|
167 | if (!file.IsZombie())
|
---|
168 | ccam = new MCalibrationChargeCam;
|
---|
169 | if (ccam)
|
---|
170 | {
|
---|
171 | if (ccam->Read()<=0)
|
---|
172 | {
|
---|
173 | delete ccam;
|
---|
174 | ccam = NULL;
|
---|
175 | }
|
---|
176 |
|
---|
177 | if (file.FindKey("MBadPixelsCam"))
|
---|
178 | {
|
---|
179 | MBadPixelsCam bad;
|
---|
180 | if (bad.Read()>0)
|
---|
181 | badpix->Merge(bad);
|
---|
182 | }
|
---|
183 | }
|
---|
184 | file.Close();
|
---|
185 |
|
---|
186 | //
|
---|
187 | // Setup an empty job, with a reader task only.
|
---|
188 | // All tasks and parameter containers are deleted automatically
|
---|
189 | // (via SetOwner())
|
---|
190 | //
|
---|
191 | MTaskList *tlist = new MTaskList;
|
---|
192 | tlist->SetOwner();
|
---|
193 |
|
---|
194 | MReadMarsFile *read = new MReadMarsFile(tname, fname);
|
---|
195 | read->DisableAutoScheme();
|
---|
196 | tlist->AddToList(read);
|
---|
197 |
|
---|
198 | MGeomApply *apl = new MGeomApply;
|
---|
199 | tlist->AddToList(apl);
|
---|
200 |
|
---|
201 | MParList *plist = new MParList;
|
---|
202 | plist->SetOwner();
|
---|
203 | plist->AddToList(tlist);
|
---|
204 | plist->AddToList(badpix);
|
---|
205 | if (pcam)
|
---|
206 | plist->AddToList(pcam);
|
---|
207 | if (ccam)
|
---|
208 | plist->AddToList(ccam);
|
---|
209 |
|
---|
210 | fEvtLoop = new MEvtLoop;
|
---|
211 | fEvtLoop->SetOwner();
|
---|
212 | fEvtLoop->SetParList(plist);
|
---|
213 |
|
---|
214 | MHEvent *evt1 = new MHEvent(MHEvent::kEvtSignalRaw);
|
---|
215 | MHEvent *evt2 = new MHEvent(MHEvent::kEvtSignalRaw);
|
---|
216 | MHEvent *evt3 = new MHEvent(MHEvent::kEvtPedestal);
|
---|
217 | MHEvent *evt4 = new MHEvent(MHEvent::kEvtPedestalRMS);
|
---|
218 | MHEvent *evt5 = new MHEvent(MHEvent::kEvtRelativeSignal);
|
---|
219 | MHEvent *evt6 = new MHEvent(MHEvent::kEvtCleaningLevels);
|
---|
220 | MHEvent *evt7 = new MHEvent(MHEvent::kEvtIdxMax);
|
---|
221 | MHEvent *evt8 = new MHEvent(MHEvent::kEvtArrTime);
|
---|
222 |
|
---|
223 | evt1->SetName("Signal");
|
---|
224 | evt2->SetName("Cleaned");
|
---|
225 | evt3->SetName("Pedestal");
|
---|
226 | evt4->SetName("PedRMS");
|
---|
227 | evt5->SetName("Signal/PedRMS");
|
---|
228 | evt6->SetName("CleanLevels");
|
---|
229 | evt7->SetName("Max Slice Idx");
|
---|
230 | evt8->SetName("Arrival Time");
|
---|
231 |
|
---|
232 | // This makes sure, that the containers are deleted...
|
---|
233 | plist->AddToList(evt1);
|
---|
234 | plist->AddToList(evt2);
|
---|
235 | plist->AddToList(evt3);
|
---|
236 | plist->AddToList(evt4);
|
---|
237 | plist->AddToList(evt5);
|
---|
238 | plist->AddToList(evt6);
|
---|
239 | plist->AddToList(evt7);
|
---|
240 | plist->AddToList(evt8);
|
---|
241 |
|
---|
242 | MCerPhotAnal2 *nanal = new MCerPhotAnal2;
|
---|
243 | MFillH *fill1 = new MFillH(evt1, "MCerPhotEvt", "MFillH1");
|
---|
244 | MImgCleanStd *clean = new MImgCleanStd;
|
---|
245 | MFillH *fill2 = new MFillH(evt2, "MCerPhotEvt", "MFillH2");
|
---|
246 | MFillH *fill3 = new MFillH(evt3, "MPedPhotCam", "MFillH3");
|
---|
247 | MFillH *fill4 = new MFillH(evt4, "MPedPhotCam", "MFillH4");
|
---|
248 | MFillH *fill5 = new MFillH(evt5, "MCameraData", "MFillH5");
|
---|
249 | MFillH *fill6 = new MFillH(evt6, "MCameraData", "MFillH6");
|
---|
250 | MBlindPixelCalc *blind = new MBlindPixelCalc;
|
---|
251 | MHillasCalc *hcalc = new MHillasCalc;
|
---|
252 | MHillasSrcCalc *scalc = new MHillasSrcCalc;
|
---|
253 |
|
---|
254 | // If no pedestal or no calibration file is availble
|
---|
255 | if (!pcam || !ccam)
|
---|
256 | {
|
---|
257 | MFilter *f1=new MFDataMember("MRawRunHeader.fRunType", '>', 255.5);
|
---|
258 | MFilter *f2=new MFDataMember("MRawRunHeader.fRunType", '<', 255.5);
|
---|
259 | f1->SetName("MFMonteCarlo");
|
---|
260 | f2->SetName("MFRealData");
|
---|
261 |
|
---|
262 | MMcPedestalCopy *pcopy = new MMcPedestalCopy;
|
---|
263 | MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
|
---|
264 |
|
---|
265 | MExtractSignal* extra = new MExtractSignal();
|
---|
266 | extra->SetRange(5, 9, 5, 9);
|
---|
267 |
|
---|
268 | MMcCalibrationUpdate* mcupd = new MMcCalibrationUpdate;
|
---|
269 | mcupd->SetOuterPixelsGainScaling(kFALSE);
|
---|
270 |
|
---|
271 | MCalibrate* mccal = new MCalibrate;
|
---|
272 |
|
---|
273 | // MC
|
---|
274 | extra->SetFilter(f1);
|
---|
275 | mcupd->SetFilter(f1);
|
---|
276 | mccal->SetFilter(f1);
|
---|
277 |
|
---|
278 | // Data
|
---|
279 | nanal->SetFilter(f2);
|
---|
280 |
|
---|
281 | // TaskList
|
---|
282 | tlist->AddToList(f1);
|
---|
283 | tlist->AddToList(f2);
|
---|
284 | tlist->AddToList(pcopy);
|
---|
285 | tlist->AddToList(pdnsb);
|
---|
286 |
|
---|
287 | tlist->AddToList(extra);
|
---|
288 | tlist->AddToList(mcupd);
|
---|
289 | tlist->AddToList(mccal);
|
---|
290 |
|
---|
291 | tlist->AddToList(nanal);
|
---|
292 | }
|
---|
293 | else
|
---|
294 | {
|
---|
295 | MCalibrate* calib = new MCalibrate;
|
---|
296 | tlist->AddToList(calib);
|
---|
297 | }
|
---|
298 |
|
---|
299 | tlist->AddToList(fill1);
|
---|
300 | tlist->AddToList(clean);
|
---|
301 | tlist->AddToList(fill2);
|
---|
302 | tlist->AddToList(fill3);
|
---|
303 | tlist->AddToList(fill4);
|
---|
304 | tlist->AddToList(fill5);
|
---|
305 | tlist->AddToList(fill6);
|
---|
306 | tlist->AddToList(blind);
|
---|
307 | tlist->AddToList(hcalc);
|
---|
308 | tlist->AddToList(scalc);
|
---|
309 | if (!pcam || !ccam)
|
---|
310 | {
|
---|
311 | MArrivalTimeCalc *tcalc = new MArrivalTimeCalc;
|
---|
312 | MFillH *fill7 = new MFillH(evt7, "MRawEvtData", "MFillH7");
|
---|
313 | MFillH *fill8 = new MFillH(evt8, "MArrivalTimeCam", "MFillH8");
|
---|
314 | tlist->AddToList(tcalc);
|
---|
315 | tlist->AddToList(fill7);
|
---|
316 | tlist->AddToList(fill8);
|
---|
317 | }
|
---|
318 |
|
---|
319 | //
|
---|
320 | // Now distribute Display to all tasks
|
---|
321 | //
|
---|
322 | tlist->SetDisplay(this);
|
---|
323 | }
|
---|
324 |
|
---|
325 | // --------------------------------------------------------------------------
|
---|
326 | //
|
---|
327 | // Add the top part of the frame: This is filename and treename display
|
---|
328 | //
|
---|
329 | void MEventDisplay::AddTopFramePart1(TGCompositeFrame *frame,
|
---|
330 | const char *filename,
|
---|
331 | const char *treename)
|
---|
332 | {
|
---|
333 | //
|
---|
334 | // --- the top1 part of the window ---
|
---|
335 | //
|
---|
336 | TGHorizontalFrame *top1 = new TGHorizontalFrame(frame, 1, 1);
|
---|
337 | fList->Add(top1);
|
---|
338 |
|
---|
339 | //
|
---|
340 | // create gui elements
|
---|
341 | //
|
---|
342 | TGLabel *file = new TGLabel(top1, new TGString(Form("%s#%s", filename, treename)));
|
---|
343 | fList->Add(file);
|
---|
344 |
|
---|
345 | //
|
---|
346 | // layout and add gui elements in/to frame
|
---|
347 | //
|
---|
348 | TGLayoutHints *laystd = new TGLayoutHints(kLHintsCenterX, 5, 5);
|
---|
349 | fList->Add(laystd);
|
---|
350 |
|
---|
351 | top1->AddFrame(file, laystd);
|
---|
352 |
|
---|
353 | //
|
---|
354 | // --- the top1 part of the window ---
|
---|
355 | //
|
---|
356 | TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 1, 1);
|
---|
357 | fList->Add(top2);
|
---|
358 |
|
---|
359 | //
|
---|
360 | // layout and add frames
|
---|
361 | //
|
---|
362 | TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5);
|
---|
363 | fList->Add(laytop1);
|
---|
364 | frame->AddFrame(top1, laytop1);
|
---|
365 | frame->AddFrame(top2, laytop1);
|
---|
366 | }
|
---|
367 |
|
---|
368 | // --------------------------------------------------------------------------
|
---|
369 | //
|
---|
370 | // Add the second part of the top frame: This are the event number controls
|
---|
371 | //
|
---|
372 | void MEventDisplay::AddTopFramePart2(TGCompositeFrame *frame)
|
---|
373 | {
|
---|
374 | //
|
---|
375 | // --- the top2 part of the window ---
|
---|
376 | //
|
---|
377 | TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 1, 1);
|
---|
378 | fList->Add(top2);
|
---|
379 |
|
---|
380 | //
|
---|
381 | // Create the gui elements
|
---|
382 | //
|
---|
383 | TGTextButton *prevevt = new TGTextButton(top2, " << ", kEvtPrev);
|
---|
384 | prevevt->Associate(this);
|
---|
385 |
|
---|
386 | TGLabel *evtnr = new TGLabel(top2, new TGString("Event:"));
|
---|
387 |
|
---|
388 | TGTextEntry *entry=new TGTextEntry(top2, new TGTextBuffer(100), kEvtNumber);
|
---|
389 | entry->Resize(60, entry->GetDefaultHeight());
|
---|
390 | entry->Associate(this);
|
---|
391 |
|
---|
392 | fNumOfEvts = new TGLabel(top2, "of .");
|
---|
393 |
|
---|
394 | TGTextButton *nextevt = new TGTextButton (top2, " >> ", kEvtNext);
|
---|
395 | nextevt->Associate(this);
|
---|
396 |
|
---|
397 | //
|
---|
398 | // Add gui elements to 'atotodel'
|
---|
399 | //
|
---|
400 | fList->Add(prevevt);
|
---|
401 | fList->Add(evtnr);
|
---|
402 | fList->Add(entry);
|
---|
403 | fList->Add(fNumOfEvts);
|
---|
404 | fList->Add(nextevt);
|
---|
405 |
|
---|
406 | //
|
---|
407 | // add the gui elements to the frame
|
---|
408 | //
|
---|
409 | TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 5);
|
---|
410 | fList->Add(laystd);
|
---|
411 |
|
---|
412 | top2->AddFrame(prevevt, laystd);
|
---|
413 | top2->AddFrame(evtnr, laystd);
|
---|
414 | top2->AddFrame(entry, laystd);
|
---|
415 | top2->AddFrame(fNumOfEvts, laystd);
|
---|
416 | top2->AddFrame(nextevt, laystd);
|
---|
417 |
|
---|
418 | TGLayoutHints *laystd2 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5, 5);
|
---|
419 | fList->Add(laystd2);
|
---|
420 | frame->AddFrame(top2, laystd2);
|
---|
421 |
|
---|
422 | //
|
---|
423 | // Add trailing line...
|
---|
424 | //
|
---|
425 | TGHorizontal3DLine *line = new TGHorizontal3DLine(frame);
|
---|
426 | TGLayoutHints *layline = new TGLayoutHints(kLHintsExpandX);
|
---|
427 | fList->Add(line);
|
---|
428 | fList->Add(layline);
|
---|
429 | frame->AddFrame(line, layline);
|
---|
430 | }
|
---|
431 |
|
---|
432 | // --------------------------------------------------------------------------
|
---|
433 | //
|
---|
434 | // Add the user frame part of the display
|
---|
435 | //
|
---|
436 | void MEventDisplay::AddUserFrame(const char* filename)
|
---|
437 | {
|
---|
438 | fUserFrame->ChangeOptions(kHorizontalFrame);
|
---|
439 |
|
---|
440 | TGCompositeFrame *vf1 = new TGVerticalFrame(fUserFrame, 1, 1);
|
---|
441 | TGCompositeFrame *vf2 = new TGVerticalFrame(fUserFrame, 1, 1);
|
---|
442 |
|
---|
443 | AddTopFramePart1(vf1, filename, "Events");
|
---|
444 | AddTopFramePart2(vf1);
|
---|
445 |
|
---|
446 | // create root embedded canvas and add it to the tab
|
---|
447 | TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas("Slices", vf2, vf1->GetDefaultHeight()*3/2, vf1->GetDefaultHeight(), 0);
|
---|
448 | vf2->AddFrame(ec);
|
---|
449 | fList->Add(ec);
|
---|
450 |
|
---|
451 | // set background and border mode of the canvas
|
---|
452 | fCanvas = ec->GetCanvas();
|
---|
453 | fCanvas->SetBorderMode(0);
|
---|
454 | gROOT->GetListOfCanvases()->Add(fCanvas);
|
---|
455 | //fCanvas->SetBorderSize(1);
|
---|
456 | //fCanvas->SetBit(kNoContextMenu);
|
---|
457 | //fCanvas->SetFillColor(16);
|
---|
458 |
|
---|
459 | TGLayoutHints *lay = new TGLayoutHints(kLHintsExpandX);
|
---|
460 | fUserFrame->AddFrame(vf1, lay);
|
---|
461 | fUserFrame->AddFrame(vf2);
|
---|
462 | }
|
---|
463 |
|
---|
464 | // --------------------------------------------------------------------------
|
---|
465 | //
|
---|
466 | // Checks if the event number is valid, and if so reads the new event
|
---|
467 | // and updates the display
|
---|
468 | //
|
---|
469 | void MEventDisplay::ReadinEvent(Int_t dir)
|
---|
470 | {
|
---|
471 | MParList *plist = (MParList*) fEvtLoop->GetParList();
|
---|
472 | MTaskList *tlist = (MTaskList*) fEvtLoop->GetTaskList();
|
---|
473 | MGeomCam *geom = (MGeomCam*) plist->FindObject("MGeomCam");
|
---|
474 | MRawEvtData *raw = (MRawEvtData*)plist->FindObject("MRawEvtData");
|
---|
475 |
|
---|
476 | //
|
---|
477 | // Read first event.
|
---|
478 | //
|
---|
479 | MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
|
---|
480 |
|
---|
481 | const Int_t num = reader->GetNumEntry();
|
---|
482 |
|
---|
483 | do
|
---|
484 | {
|
---|
485 | if (dir<0 && !reader->DecEventNum())
|
---|
486 | {
|
---|
487 | reader->SetEventNum(num);
|
---|
488 | return;
|
---|
489 | }
|
---|
490 | if (dir>0 && !reader->IncEventNum())
|
---|
491 | {
|
---|
492 | reader->SetEventNum(num);
|
---|
493 | return;
|
---|
494 | }
|
---|
495 |
|
---|
496 | if (!tlist->Process())
|
---|
497 | return;
|
---|
498 |
|
---|
499 | reader->DecEventNum();
|
---|
500 |
|
---|
501 | } while (raw && raw->GetNumPixels()<1 && dir!=0);
|
---|
502 |
|
---|
503 | //
|
---|
504 | // Cleare the 'FADC canvas'
|
---|
505 | //
|
---|
506 | fCanvas->Clear();
|
---|
507 | fCanvas->Modified();
|
---|
508 | fCanvas->Update();
|
---|
509 |
|
---|
510 | //
|
---|
511 | // Print parameters
|
---|
512 | //
|
---|
513 | ((MHillas*) plist->FindObject("MHillas"))->Print(*geom);
|
---|
514 | ((MHillasExt*)plist->FindObject("MHillasExt"))->Print(*geom);
|
---|
515 | ((MHillasSrc*)plist->FindObject("MHillasSrc"))->Print(*geom);
|
---|
516 | plist->FindObject("MNewImagePar")->Print();
|
---|
517 |
|
---|
518 | //
|
---|
519 | // UpdateDisplay
|
---|
520 | //
|
---|
521 | gStyle->SetOptStat(1101);
|
---|
522 | Update();
|
---|
523 |
|
---|
524 | TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
|
---|
525 | entry->SetText(Form("%d", reader->GetNumEntry()+1));
|
---|
526 | }
|
---|
527 |
|
---|
528 | // --------------------------------------------------------------------------
|
---|
529 | //
|
---|
530 | // Read first event to get display booted
|
---|
531 | //
|
---|
532 | void MEventDisplay::ReadFirstEvent()
|
---|
533 | {
|
---|
534 | if (!fEvtLoop->PreProcess())
|
---|
535 | return;
|
---|
536 |
|
---|
537 | //
|
---|
538 | // Get parlist
|
---|
539 | //
|
---|
540 | MParList *plist = (MParList*)fEvtLoop->GetParList();
|
---|
541 |
|
---|
542 | //
|
---|
543 | // Add Geometry tab
|
---|
544 | //
|
---|
545 | AddGeometryTabs();
|
---|
546 |
|
---|
547 | //
|
---|
548 | // Now read event...
|
---|
549 | //
|
---|
550 | ReadinEvent();
|
---|
551 |
|
---|
552 | MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
|
---|
553 | TGString *txt = new TGString(Form("of %d", reader->GetEntries()));
|
---|
554 | fNumOfEvts->SetText(txt);
|
---|
555 |
|
---|
556 | //
|
---|
557 | // Draw ellipse on top of all pads
|
---|
558 | //
|
---|
559 | TObject *hillas = plist->FindObject("MHillas");
|
---|
560 | for (int i=1; i<7;i++)
|
---|
561 | {
|
---|
562 | TCanvas *c = GetCanvas(i);
|
---|
563 | c->GetPad(1)->cd(1);
|
---|
564 | hillas->Draw();
|
---|
565 | }
|
---|
566 | }
|
---|
567 |
|
---|
568 | // --------------------------------------------------------------------------
|
---|
569 | //
|
---|
570 | // Adds the geometry tab
|
---|
571 | //
|
---|
572 | void MEventDisplay::AddGeometryTabs()
|
---|
573 | {
|
---|
574 | MGeomCam *geom = (MGeomCam*)fEvtLoop->GetParList()->FindObject("MGeomCam");
|
---|
575 | if (!geom)
|
---|
576 | return;
|
---|
577 |
|
---|
578 | TCanvas &c1=AddTab("Geometry");
|
---|
579 |
|
---|
580 | MHCamera *cam = new MHCamera(*geom);
|
---|
581 | cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
|
---|
582 | cam->Draw("pixelindex");
|
---|
583 |
|
---|
584 | c1.Modified();
|
---|
585 | c1.Update();
|
---|
586 |
|
---|
587 | TCanvas &c2=AddTab("Sectors");
|
---|
588 |
|
---|
589 | cam = new MHCamera(*geom);
|
---|
590 | cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
|
---|
591 | cam->Draw("sectorindex");
|
---|
592 |
|
---|
593 | c2.Modified();
|
---|
594 | c2.Update();
|
---|
595 | }
|
---|
596 |
|
---|
597 | // --------------------------------------------------------------------------
|
---|
598 | //
|
---|
599 | // ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
600 | //
|
---|
601 | // Processes information from all GUI items.
|
---|
602 | // Selecting an item usually generates an event with 4 parameters.
|
---|
603 | // The first two are packed into msg (first and second bytes).
|
---|
604 | // The other two are parm1 and parm2.
|
---|
605 | //
|
---|
606 | Bool_t MEventDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
---|
607 | {
|
---|
608 | switch (GET_MSG(msg))
|
---|
609 | {
|
---|
610 | case kC_TEXTENTRY:
|
---|
611 | switch(GET_SUBMSG(msg))
|
---|
612 | {
|
---|
613 | case kTE_ENTER:
|
---|
614 | switch(GET_SUBMSG(msg))
|
---|
615 | {
|
---|
616 | case kTE_ENTER:
|
---|
617 | {
|
---|
618 | TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
|
---|
619 | MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
|
---|
620 | if (reader->SetEventNum(atoi(entry->GetText())-1))
|
---|
621 | ReadinEvent();
|
---|
622 | }
|
---|
623 | return kTRUE;
|
---|
624 | }
|
---|
625 | return kTRUE;
|
---|
626 | }
|
---|
627 | break;
|
---|
628 |
|
---|
629 | case kC_COMMAND:
|
---|
630 | switch (GET_SUBMSG(msg))
|
---|
631 | {
|
---|
632 | case kCM_TAB:
|
---|
633 | {
|
---|
634 | //
|
---|
635 | // Set name for 'FADC canvas'. The name is the anchor for MHCamera.
|
---|
636 | // and clear the canvas
|
---|
637 | TCanvas *c = GetCanvas(mp1);
|
---|
638 | if (!c)
|
---|
639 | break;
|
---|
640 | MHEvent *o = (MHEvent*)fEvtLoop->GetParList()->FindObject(c->GetName());
|
---|
641 | if (!o)
|
---|
642 | break;
|
---|
643 | fCanvas->SetName(Form("%p;%p;PixelContent", o->GetHist(), c->GetPad(1)));
|
---|
644 | }
|
---|
645 | break;
|
---|
646 |
|
---|
647 | case kCM_BUTTON:
|
---|
648 | switch (mp1)
|
---|
649 | {
|
---|
650 | case kEvtPrev:
|
---|
651 | ReadinEvent(-1);
|
---|
652 | return kTRUE;
|
---|
653 |
|
---|
654 | case kEvtNext:
|
---|
655 | ReadinEvent(+1);
|
---|
656 | return kTRUE;
|
---|
657 | }
|
---|
658 | return kTRUE;
|
---|
659 | }
|
---|
660 | break;
|
---|
661 | }
|
---|
662 |
|
---|
663 | return MStatusDisplay::ProcessMessage(msg, mp1, mp2);
|
---|
664 | }
|
---|