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