source: trunk/MagicSoft/Mars/mmain/MEventDisplay.cc@ 8611

Last change on this file since 8611 was 8611, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 23.3 KB
Line 
1/* ======================================================================== *\
2! $Name: not supported by cvs2svn $:$Id: MEventDisplay.cc,v 1.60 2007-06-26 16:59:21 tbretz Exp $
3! --------------------------------------------------------------------------
4!
5! *
6! * This file is part of MARS, the MAGIC Analysis and Reconstruction
7! * Software. It is distributed to you in the hope that it can be a useful
8! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9! * It is distributed WITHOUT ANY WARRANTY.
10! *
11! * Permission to use, copy, modify and distribute this software and its
12! * documentation for any purpose is hereby granted without fee,
13! * provided that the above copyright notice appear in all copies and
14! * that both that copyright notice and this permission notice appear
15! * in supporting documentation. It is provided "as is" without express
16! * or implied warranty.
17! *
18!
19!
20! Author(s): Thomas Bretz, 10/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
21!
22! Copyright: MAGIC Software Development, 2000-2006
23!
24!
25\* ======================================================================== */
26#include "MEventDisplay.h"
27
28//
29// C-lib
30//
31#include <stdlib.h> // atoi
32
33//
34// root
35//
36#include <TFile.h> // TFile
37#include <TTree.h> // TTree
38#include <TList.h> // TList::Add
39#include <TStyle.h> // gStyle->SetOptStat
40#include <TCanvas.h> // TCanvas::cd
41#include <TSystem.h> // TSystem::BaseName
42
43//
44// root GUI
45//
46#include <TGLabel.h> // TGLabel
47#include <TGButton.h> // TGPictureButton
48#include <TG3DLine.h> // TGHorizontal3DLine
49#include <TGTextEntry.h> // TGTextEntry
50#include <TGButtonGroup.h> // TGVButtonGroup
51#include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
52
53//
54// General
55//
56#include "MGList.h" // MGList
57
58#include "MLog.h"
59#include "MLogManip.h"
60
61#include "MParList.h" // MParList::AddToList
62#include "MEvtLoop.h" // MEvtLoop::GetParList
63#include "MTaskList.h" // MTaskList::AddToList
64
65//
66// Tasks
67//
68#include "MReadMarsFile.h" // MReadMarsFile
69#include "MGeomApply.h" // MGeomApply
70#include "MPedestalSubtract.h" // MPedestalSubtract
71#include "MFDataMember.h" // MFDataMember
72#include "MFEvtNumber.h" // MFEvtNumber
73#include "MMcPedestalCopy.h" // MMcPedestalCopy
74#include "MMcPedestalNSBAdd.h" // MMcPedestalNSBAdd
75
76#include "MSignalCalc.h" // MPedestalCalc
77#include "MTaskEnv.h" // MTaskEnv
78#include "MExtractTimeAndChargeDigitalFilter.h"
79#include "MImgCleanStd.h" // MImgCleanStd
80#include "MHillasCalc.h" // MHillasCalc
81#include "MCalibrationRelTimeCalc.h" // MCalibrationRelTimeCalc
82#include "MCalibrationPatternDecode.h" // MCalibrationPatternDecode
83#include "MPrint.h"
84#include "MBadPixelsCalc.h" // MBadPixelsCalc
85#include "MBadPixelsTreat.h" // MBadPixelsTreat
86#include "MFillH.h" // MFillH
87#include "MMcCalibrationUpdate.h" // MMcCalibrationUpdate
88#include "MCalibrateData.h" // MCalibrateData
89#include "MMuonSearchParCalc.h" // MMuonSearchParCalc
90#include "MMuonCalibParCalc.h" // MMuonCalibParCalc
91#include "MContinue.h" // MContinue
92//#include "MMcTriggerLvl2Calc.h" // MMcTriggerLvl2Calc
93
94//
95// Container
96//
97#include "MHillas.h" // MHillas::Print(const MGeomCam&)
98#include "MHillasExt.h" // MHillasExt::Print(const MGeomCam&)
99#include "MHillasSrc.h" // MHillasSrc::Print(const MGeomCam&)
100#include "MImagePar.h" // MImagePar::Print(const MGeomCam&)
101#include "MNewImagePar.h" // MNewImagePar::Print(const MGeomCam&)
102#include "MHEvent.h" // MHEvent
103#include "MHCamera.h" // MHCamera
104#include "MRawEvtData.h" // MRawEvtData
105#include "MArrivalTimeCam.h" // MArrivalTimeCam
106#include "MBadPixelsCam.h" // MBadPixelsCam
107#include "MPedPhotCam.h" // MPedPhotCam
108#include "MCalibrationChargeCam.h" // MCalibrationChargeCam
109#include "MMuonSearchPar.h" // MMuonCalibPar
110//#include "MMcTriggerLvl2.h" // MMcTriggerLvl2
111
112using namespace std;
113
114ClassImp(MEventDisplay);
115
116// --------------------------------------------------------------------------
117//
118// Constructor.
119//
120MEventDisplay::MEventDisplay(const char *fname) : MStatusDisplay(), fEvtLoop(0)
121{
122 //
123 // Setup Task list for hillas calculation
124 //
125 SetupTaskList("Events", fname);
126
127 //
128 // Add MEventDisplay GUI elements to the display
129 //
130 AddUserFrame(fname);
131
132 //
133 // Show new part of the window, resize to correct aspect ratio
134 //
135 // FIXME: This should be done by MStatusDisplay automatically
136 Resize(768, 576 + fUserFrame->GetDefaultHeight());//TMath::Nint(GetWidth()*1.2), TMath::Nint(GetHeight()*1.2 + fUserFrame->GetDefaultHeight()));
137 SetWindowName("Event Display");
138 MapSubwindows();
139
140 //
141 // Readin first event and display it
142 //
143 if (fEvtLoop)
144 ReadFirstEvent();
145
146 SetNoContextMenu(kFALSE);
147}
148
149// --------------------------------------------------------------------------
150//
151// Destructor: PostProcess eventloop, delete eventloop with all containers
152//
153MEventDisplay::~MEventDisplay()
154{
155 if (fEvtLoop)
156 {
157 fEvtLoop->PostProcess();
158 delete fEvtLoop;
159 }
160}
161
162Int_t MEventDisplay::GetFileType(const char *tree, const char *fname) const
163{
164 TFile f(fname, "READ");
165 TTree *t = (TTree*)f.Get(tree);
166 if (!t)
167 return -1;
168
169 if (t->FindBranch("MSignalCam."))
170 return 1;
171
172 if (t->FindBranch("MRawEvtData."))
173 return 2;
174
175 return -2;
176}
177
178// --------------------------------------------------------------------------
179//
180// Setup Task and parameter list for hillas calculation,
181// preprocess tasks and read in first event (process)
182//
183void MEventDisplay::SetupTaskList(const char *tname, const char *fname)
184{
185// MCalibrationChargeCam *ccam=0;
186// MPedPhotCam *pcam=0;
187
188 MBadPixelsCam *badpix = new MBadPixelsCam;
189
190 const Int_t type = GetFileType(tname, fname);
191 switch (type)
192 {
193 case 1: gLog << all << "Calibrated Data File detected..." << endl; break;
194 case 2: gLog << all << "Raw Data File detected..." << endl; break;
195 case -2: gLog << err << "File type unknown... abort." << endl; return;
196 case -1: gLog << err << "Tree " << tname << " not found... abort." << endl; return;
197 }
198
199 //
200 // Setup an empty job, with a reader task only.
201 // All tasks and parameter containers are deleted automatically
202 // (via SetOwner())
203 //
204 MTaskList *tlist = new MTaskList;
205 tlist->SetOwner();
206
207 MParList *plist = new MParList;
208 plist->SetOwner();
209 plist->AddToList(tlist);
210 plist->AddToList(badpix);
211
212 MReadMarsFile *read = new MReadMarsFile(tname, fname);
213 read->DisableAutoScheme();
214 tlist->AddToList(read);
215
216 MFEvtNumber *evtnum = new MFEvtNumber;
217 tlist->AddToList(evtnum);
218
219 MContinue *contevt = new MContinue(evtnum);
220 contevt->SetInverted();
221 tlist->AddToList(contevt);
222
223 MGeomApply *apl = new MGeomApply;
224 tlist->AddToList(apl);
225
226
227 //MArrivalTime *atime = new MArrivalTime;
228 //plist->AddToList(atime);
229
230 MHEvent *evt01 = new MHEvent(MHEvent::kEvtSignalDensity);
231 MHEvent *evt02 = new MHEvent(MHEvent::kEvtSignalDensity);
232 MHEvent *evt03 = new MHEvent(type==1?MHEvent::kEvtPedPhot:MHEvent::kEvtPedestal);
233 MHEvent *evt04 = new MHEvent(type==1?MHEvent::kEvtPedPhotRMS:MHEvent::kEvtPedestalRMS);
234 MHEvent *evt06a= new MHEvent(MHEvent::kEvtCleaningData);
235 MHEvent *evt06b= new MHEvent(MHEvent::kEvtCleaningLevels);
236 //MHEvent *evt07 = new MHEvent(MHEvent::kEvtIdxMax);
237 MHEvent *evt08 = new MHEvent(MHEvent::kEvtArrTime);
238 MHEvent *evt09 = new MHEvent(MHEvent::kEvtArrTimeCleaned);
239 //MHEvent *evt09 = new MHEvent(MHEvent::kEvtTrigPix);
240 MHEvent *evt10 = new MHEvent(MHEvent::kEvtIslandIndex);
241
242 evt01->SetName("Signal");
243 evt02->SetName("Cleaned");
244 evt03->SetName("Ped");
245 evt04->SetName("PedRMS");
246 evt06a->SetName("CleanData");
247 evt06b->SetName("Levels");
248 //evt07->SetName("MaxSliceIdx");
249 evt08->SetName("ArrTime");
250 evt09->SetName("Time");
251 evt10->SetName("Islands");
252
253 evt01->SetMinimum(0);
254 evt03->SetMinimum(0);
255 evt04->SetMinimum(0);
256 evt06a->SetMinimum(0);
257
258 // This makes sure, that the containers are deleted...
259 plist->AddToList(evt01);
260 plist->AddToList(evt02);
261 plist->AddToList(evt03);
262 plist->AddToList(evt04);
263 plist->AddToList(evt06a);
264 plist->AddToList(evt06b);
265 //plist->AddToList(evt07);
266 plist->AddToList(evt08);
267 plist->AddToList(evt09);
268 plist->AddToList(evt10);
269
270 MExtractTimeAndChargeDigitalFilter *digf = new MExtractTimeAndChargeDigitalFilter;
271 digf->SetNameWeightsFile("msignal/cosmics_weights46.dat");
272
273 MTaskEnv *taskenv1=new MTaskEnv("ExtractSignal");
274 taskenv1->SetDefault(digf);
275 taskenv1->SetOwner();
276
277 MSignalCalc *nanal = new MSignalCalc;
278 MFillH *fill01 = new MFillH(evt01, "MSignalCam", "MFillH01");
279 MImgCleanStd *clean = new MImgCleanStd;
280 MFillH *fill02 = new MFillH(evt02, "MSignalCam", "MFillH02");
281 MFillH *fill03 = new MFillH(evt03, type==1?"MPedPhotFundamental":"MPedestalCam", "MFillH03");
282 MFillH *fill04 = new MFillH(evt04, type==1?"MPedPhotFromExtractorRndm":"MPedestalCam", "MFillH04");
283 MFillH *fill06a = new MFillH(evt06a, "MCameraData", "MFillH06a");
284 MFillH *fill06b = new MFillH(evt06b, "MCameraData", "MFillH06b");
285 MHillasCalc *hcalc = new MHillasCalc;
286 //MMcTriggerLvl2Calc *trcal = new MMcTriggerLvl2Calc;
287 //MFillH *fill09 = new MFillH(evt09, "MMcTriggerLvl2", "MFillH09");
288 MFillH *fill10 = new MFillH(evt10, "MSignalCam", "MFillH10");
289
290 MBadPixelsCalc *bcalc = new MBadPixelsCalc;
291 MBadPixelsTreat *btreat = new MBadPixelsTreat;
292 btreat->SetProcessTimes(kFALSE);
293 if (type==1)
294 {
295 bcalc->SetNamePedPhotCam("MPedPhotFromExtractor");
296 btreat->AddNamePedPhotCam("MPedPhotFromExtractorRndm");
297 clean->SetNamePedPhotCam("MPedPhotFromExtractorRndm");
298 }
299
300 // If no pedestal or no calibration file is availble
301 if (type==2)
302 {
303 MFilter *f1=new MFDataMember("MRawRunHeader.fRunType", '>', 255.5);
304 f1->SetName("MFMonteCarlo");
305
306 MMcPedestalCopy *pcopy = new MMcPedestalCopy;
307 MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
308
309 MCalibrationPatternDecode *decode = new MCalibrationPatternDecode;
310
311 MPedestalSubtract *pedsub1 = new MPedestalSubtract;
312 MPedestalSubtract *pedsub2 = new MPedestalSubtract;
313 pedsub2->SetNamePedestalCam();
314
315 MMcCalibrationUpdate* mcupd = new MMcCalibrationUpdate;
316 mcupd->SetOuterPixelsGainScaling(kFALSE);
317
318 MCalibrateData* calib = new MCalibrateData;
319 calib->SetCalibrationMode(MCalibrateData::kFlatCharge);
320 calib->SetPedestalFlag(MCalibrateData::kEvent);
321
322 // MPedestalCam is extracted using the simple MSignalCalc!
323
324 // MC
325 mcupd->SetFilter(f1);
326 //trcal->SetFilter(f1);
327
328 // TaskList
329 tlist->AddToList(f1);
330 tlist->AddToList(pcopy);
331 tlist->AddToList(pdnsb);
332
333 tlist->AddToList(decode);
334
335 tlist->AddToList(pedsub1); // Produce arrays
336 tlist->AddToList(nanal); // Estimate pedestal!
337 tlist->AddToList(pedsub2); // subtract pedestal
338
339 tlist->AddToList(taskenv1); // Calculates MExtractedSignalCam, MArrivalTimeCam
340 tlist->AddToList(mcupd);
341 tlist->AddToList(calib); // MExtractedSignalCam --> MSignalCam
342
343 //tlist->AddToList(bcalc); // Produce MBadPixelsCam
344 //tlist->AddToList(btreat); // Treat MBadPixelsCam
345 }
346
347 tlist->AddToList(fill01);
348 tlist->AddToList(clean);
349 tlist->AddToList(fill02);
350 if (type==2)
351 tlist->AddToList(fill03);
352 tlist->AddToList(fill04);
353 tlist->AddToList(fill06a);
354 tlist->AddToList(fill06b);
355 tlist->AddToList(fill10);
356 if (type==2)
357 {
358 //MFillH *fill07 = new MFillH(evt07, "MRawEvtData", "MFillH7");
359 MFillH *fill08 = new MFillH(evt08, "MArrivalTimeCam", "MFillH8");
360 //tlist->AddToList(fill07);
361 tlist->AddToList(fill08);
362
363 //tlist->AddToList(trcal);
364 //tlist->AddToList(fill09);
365 }
366 if (type==1)
367 {
368 MFillH *fill08 = new MFillH(evt08, "MSignalCam", "MFillH8");
369 MFillH *fill09 = new MFillH(evt09, "MSignalCam", "MFillH9");
370 tlist->AddToList(fill08);
371 tlist->AddToList(fill09);
372 }
373 tlist->AddToList(hcalc);
374
375 // --------------------------------------------------
376 // Muon Analysis
377 MMuonSearchParCalc *muscalc = new MMuonSearchParCalc;
378 MMuonCalibParCalc *mcalc = new MMuonCalibParCalc;
379 MFillH *fillmuon = new MFillH("MHSingleMuon", "", "FillMuon");
380 fillmuon->SetNameTab("Muon");
381 tlist->AddToList(muscalc);
382 tlist->AddToList(fillmuon);
383 tlist->AddToList(mcalc);
384
385 // --------------------------------------------------
386 // Cut to steer the display
387 MContinue *cont0=new MContinue("", "Cut");
388 cont0->SetAllowEmpty();
389 tlist->AddToList(cont0);
390
391 //
392 // Now distribute Display to all tasks
393 //
394 fEvtLoop = new MEvtLoop(gSystem->BaseName(fname));
395 fEvtLoop->SetOwner();
396 fEvtLoop->SetParList(plist);
397 fEvtLoop->SetDisplay(this);
398 fEvtLoop->ReadEnv("mars.rc");
399
400}
401
402// --------------------------------------------------------------------------
403//
404// Add the top part of the frame: This is filename and treename display
405//
406void MEventDisplay::AddTopFramePart1(TGCompositeFrame *frame,
407 const char *filename,
408 const char *treename)
409{
410 //
411 // --- the top1 part of the window ---
412 //
413 TGHorizontalFrame *top1 = new TGHorizontalFrame(frame, 1, 1);
414 fList->Add(top1);
415
416 //
417 // create gui elements
418 //
419 TGLabel *file = new TGLabel(top1, new TGString(Form("%s#%s", filename, treename)));
420 fList->Add(file);
421
422 //
423 // layout and add gui elements in/to frame
424 //
425 TGLayoutHints *laystd = new TGLayoutHints(kLHintsCenterX, 5, 5);
426 fList->Add(laystd);
427
428 top1->AddFrame(file, laystd);
429
430 //
431 // --- the top1 part of the window ---
432 //
433 TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 1, 1);
434 fList->Add(top2);
435
436 //
437 // layout and add frames
438 //
439 TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5);
440 fList->Add(laytop1);
441 frame->AddFrame(top1, laytop1);
442 frame->AddFrame(top2, laytop1);
443}
444
445// --------------------------------------------------------------------------
446//
447// Add the second part of the top frame: This are the event number controls
448//
449void MEventDisplay::AddTopFramePart2(TGCompositeFrame *frame)
450{
451 //
452 // --- the top2 part of the window ---
453 //
454 TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 1, 1);
455 fList->Add(top2);
456
457 //
458 // Create the gui elements
459 //
460 TGTextButton *prevevt = new TGTextButton(top2, " << ", kEvtPrev);
461 prevevt->Associate(this);
462
463 TGLabel *evtnr = new TGLabel(top2, new TGString("Event:"));
464
465 TGTextEntry *entry=new TGTextEntry(top2, new TGTextBuffer(100), kEvtNumber);
466 entry->Resize(60, entry->GetDefaultHeight());
467 entry->Associate(this);
468
469 fNumOfEvts = new TGLabel(top2, "of .");
470
471 TGTextButton *nextevt = new TGTextButton (top2, " >> ", kEvtNext);
472 nextevt->Associate(this);
473
474 //
475 // Add gui elements to 'atotodel'
476 //
477 fList->Add(prevevt);
478 fList->Add(evtnr);
479 fList->Add(entry);
480 fList->Add(fNumOfEvts);
481 fList->Add(nextevt);
482
483 //
484 // add the gui elements to the frame
485 //
486 TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 5);
487 fList->Add(laystd);
488
489 top2->AddFrame(prevevt, laystd);
490 top2->AddFrame(evtnr, laystd);
491 top2->AddFrame(entry, laystd);
492 top2->AddFrame(fNumOfEvts, laystd);
493 top2->AddFrame(nextevt, laystd);
494
495 TGLayoutHints *laystd2 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5, 5);
496 fList->Add(laystd2);
497 frame->AddFrame(top2, laystd2);
498
499 //
500 // Add trailing line...
501 //
502 TGHorizontal3DLine *line = new TGHorizontal3DLine(frame);
503 TGLayoutHints *layline = new TGLayoutHints(kLHintsExpandX);
504 fList->Add(line);
505 fList->Add(layline);
506 frame->AddFrame(line, layline);
507}
508
509// --------------------------------------------------------------------------
510//
511// Add the user frame part of the display
512//
513void MEventDisplay::AddUserFrame(const char* filename)
514{
515 fUserFrame->ChangeOptions(kHorizontalFrame);
516
517 TGCompositeFrame *vf1 = new TGVerticalFrame(fUserFrame, 1, 1);
518 TGCompositeFrame *vf2 = new TGVerticalFrame(fUserFrame, 1, 1);
519
520 AddTopFramePart1(vf1, filename, "Events");
521 AddTopFramePart2(vf1);
522
523 // create root embedded canvas and add it to the tab
524 TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas("Slices", vf2, vf1->GetDefaultHeight()*3/2, vf1->GetDefaultHeight(), 0);
525 vf2->AddFrame(ec);
526 fList->Add(ec);
527
528 // set background and border mode of the canvas
529 fCanvas = ec->GetCanvas();
530 fCanvas->SetBorderMode(0);
531 gROOT->GetListOfCanvases()->Add(fCanvas);
532 //fCanvas->SetBorderSize(1);
533 //fCanvas->SetBit(kNoContextMenu);
534 //fCanvas->SetFillColor(16);
535
536 TGLayoutHints *lay = new TGLayoutHints(kLHintsExpandX);
537 fUserFrame->AddFrame(vf1, lay);
538 fUserFrame->AddFrame(vf2);
539}
540
541// --------------------------------------------------------------------------
542//
543// Checks if the event number is valid, and if so reads the new event
544// and updates the display
545//
546void MEventDisplay::ReadinEvent(Int_t dir)
547{
548 MParList *plist = (MParList*) fEvtLoop->GetParList();
549 MTaskList *tlist = (MTaskList*) fEvtLoop->GetTaskList();
550 MGeomCam *geom = (MGeomCam*) plist->FindObject("MGeomCam");
551 MRawEvtData *raw = (MRawEvtData*)plist->FindObject("MRawEvtData");
552
553 //
554 // Read first event.
555 //
556 MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
557
558 const Int_t num = reader->GetNumEntry();
559
560 Int_t rc;
561 do
562 {
563 if (dir<0 && !reader->DecEventNum())
564 {
565 reader->SetEventNum(num);
566 return;
567 }
568 if (dir>0 && !reader->IncEventNum())
569 {
570 reader->SetEventNum(num);
571 return;
572 }
573
574 rc = tlist->Process();
575 if (rc==kFALSE || rc==kERROR)
576 return;
577
578 reader->DecEventNum();
579
580 // Define other continue conditions
581 if (raw && raw->GetNumPixels()<1)
582 rc = kCONTINUE;
583
584 } while (rc==kCONTINUE && dir!=0);
585
586 //
587 // Cleare the 'FADC canvas'
588 //
589 fCanvas->Clear();
590 fCanvas->Modified();
591 fCanvas->Update();
592
593 //
594 // Print parameters
595 //
596 *fLog << all;
597 fLog->Separator(Form("Entry %d", reader->GetNumEntry()+1));
598 ((MHillas*) plist->FindObject("MHillas"))->Print(*geom);
599 ((MHillasExt*) plist->FindObject("MHillasExt"))->Print(*geom);
600 ((MHillasSrc*) plist->FindObject("MHillasSrc"))->Print(*geom);
601 plist->FindObject("MImagePar")->Print();
602 ((MNewImagePar*)plist->FindObject("MNewImagePar"))->Print(*geom);
603 plist->FindObject("MMuonCalibPar")->Print();
604 ((MMuonSearchPar*)plist->FindObject("MMuonSearchPar"))->Print(*geom);
605
606 //
607 // UpdateDisplay
608 //
609 gStyle->SetOptStat(1101);
610 Update();
611
612 TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
613 entry->SetText(Form("%d", reader->GetNumEntry()+1));
614}
615
616// --------------------------------------------------------------------------
617//
618// Read first event to get display booted
619//
620void MEventDisplay::ReadFirstEvent()
621{
622 const Int_t rc = fEvtLoop->PreProcess();
623 if (rc==kFALSE || rc==kERROR)
624 return;
625
626 UnLock();
627
628 //
629 // Get parlist
630 //
631 MParList *plist = (MParList*)fEvtLoop->GetParList();
632
633 //
634 // Add Geometry tab
635 //
636 AddGeometryTabs();
637
638 //
639 // Now read event...
640 //
641 // FIXME: Can we safly replace ReadinEvent() by RedinEvent(1)?
642 ReadinEvent();
643
644
645 MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
646 TGString *txt = new TGString(Form("of %d", reader->GetEntries()));
647 fNumOfEvts->SetText(txt);
648
649 //
650 // Draw ellipse on top of all pads
651 //
652 TObject *hillas1 = plist->FindObject("MHillas");
653 TObject *hillas2 = plist->FindObject("MHillasSrc");
654 TObject *hillas3 = plist->FindObject("MHillasExt");
655 TObject *hmuon = plist->FindObject("MMuonSearchPar");
656 for (int i=1; i<7;i++)
657 {
658 TCanvas *c = GetCanvas(i);
659 c->GetPad(1)->cd(1);
660 hmuon->Draw();
661 hillas1->Draw();
662 hillas2->Draw();
663 hillas3->Draw();
664 }
665}
666
667// --------------------------------------------------------------------------
668//
669// Adds the geometry tab
670//
671void MEventDisplay::AddGeometryTabs()
672{
673 MGeomCam *geom = (MGeomCam*)fEvtLoop->GetParList()->FindObject("MGeomCam");
674 if (!geom)
675 return;
676
677 TCanvas &c1=AddTab("Geometry");
678
679 MHCamera *cam = new MHCamera(*geom);
680 cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
681 cam->Draw("pixelindex");
682
683 c1.Modified();
684 c1.Update();
685
686 TCanvas &c2=AddTab("Sectors");
687
688 cam = new MHCamera(*geom);
689 cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
690 cam->Draw("sectorindex");
691
692 c2.Modified();
693 c2.Update();
694}
695
696// --------------------------------------------------------------------------
697//
698// ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
699//
700// Processes information from all GUI items.
701// Selecting an item usually generates an event with 4 parameters.
702// The first two are packed into msg (first and second bytes).
703// The other two are parm1 and parm2.
704//
705Bool_t MEventDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
706{
707 switch (GET_MSG(msg))
708 {
709 case kC_TEXTENTRY:
710 switch(GET_SUBMSG(msg))
711 {
712 case kTE_ENTER:
713 switch(GET_SUBMSG(msg))
714 {
715 case kTE_ENTER:
716 {
717 TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
718 MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
719 if (reader->SetEventNum(atoi(entry->GetText())-1))
720 ReadinEvent();
721 }
722 return kTRUE;
723 }
724 return kTRUE;
725 }
726 break;
727
728 case kC_COMMAND:
729 switch (GET_SUBMSG(msg))
730 {
731 case kCM_TAB:
732 {
733 //
734 // Set name for 'FADC canvas'. The name is the anchor for MHCamera.
735 // and clear the canvas
736 TCanvas *c = GetCanvas(mp1);
737 if (!c)
738 break;
739 MHEvent *o = (MHEvent*)fEvtLoop->GetParList()->FindObject(c->GetName());
740 if (!o)
741 break;
742 fCanvas->SetName(Form("%p;%p;PixelContent", o->GetHist(), c->GetPad(1)->GetPad(1)));
743 }
744 break;
745
746 case kCM_BUTTON:
747 switch (mp1)
748 {
749 case kEvtPrev:
750 ReadinEvent(-1);
751 return kTRUE;
752
753 case kEvtNext:
754 ReadinEvent(+1);
755 return kTRUE;
756 }
757 return kTRUE;
758 }
759 break;
760 }
761
762 return MStatusDisplay::ProcessMessage(msg, mp1, mp2);
763}
Note: See TracBrowser for help on using the repository browser.