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

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