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

Last change on this file since 8785 was 8632, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 25.8 KB
Line 
1/* ======================================================================== *\
2! $Name: not supported by cvs2svn $:$Id: MEventDisplay.cc,v 1.62 2007-07-03 14:18:03 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(756), 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
521void MEventDisplay::AddMiddleFrame(TGCompositeFrame *frame)
522{
523 //
524 // Create the gui elements
525 //
526 TGCheckButton *imgpar = new TGCheckButton(frame, "ImgPar", kShowImgPar);
527 imgpar->SetState(kButtonDown);
528 imgpar->Associate(this);
529 fList->Add(imgpar);
530
531 TGCheckButton *muon = new TGCheckButton(frame, "Muon", kShowMuon);
532 muon->Associate(this);
533 muon->SetState(kButtonDown);
534 fList->Add(muon);
535
536 //
537 // add the gui elements to the frame
538 //
539// TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 5);
540// fList->Add(laystd);
541// top2->AddFrame(prevevt, laystd);
542
543 frame->AddFrame(imgpar);
544 frame->AddFrame(muon);
545}
546
547// --------------------------------------------------------------------------
548//
549// Add the user frame part of the display
550//
551void MEventDisplay::AddUserFrame(const char* filename)
552{
553 fUserFrame->ChangeOptions(kHorizontalFrame);
554
555 TGCompositeFrame *vf1 = new TGVerticalFrame(fUserFrame, 1, 1);
556 TGCompositeFrame *vf2 = new TGVerticalFrame(fUserFrame, 1, 1);
557 TGCompositeFrame *hor = new TGHorizontalFrame(vf1, 1, 1);
558 TGCompositeFrame *ver = new TGVerticalFrame(hor, 1, 1);
559 TGCompositeFrame *vfb = new TGVerticalFrame(hor, 1, 1);
560
561 TGHorizontal3DLine *line = new TGHorizontal3DLine(vf1);
562 TGLayoutHints *expx = new TGLayoutHints(kLHintsExpandX);
563 TGLayoutHints *right = new TGLayoutHints(kLHintsRight|kLHintsTop);
564 fList->Add(line);
565 fList->Add(expx);
566 fList->Add(right);
567
568 hor->AddFrame(ver);
569 hor->AddFrame(vfb, right);
570
571 AddMiddleFrame(vfb);
572
573 //
574 // Add trailing line...
575 //
576 vf1->AddFrame(hor, expx);
577 vf1->AddFrame(line, expx);
578
579 AddTopFramePart1(ver, filename, "Events");
580 AddTopFramePart2(ver);
581
582 // create root embedded canvas and add it to the tab
583 TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas("Slices", vf2, vf1->GetDefaultHeight()*3/2, vf1->GetDefaultHeight(), 0);
584 vf2->AddFrame(ec);
585 fList->Add(ec);
586
587 // set background and border mode of the canvas
588 fCanvas = ec->GetCanvas();
589 fCanvas->SetBorderMode(0);
590 gROOT->GetListOfCanvases()->Add(fCanvas);
591 //fCanvas->SetBorderSize(1);
592 //fCanvas->SetBit(kNoContextMenu);
593 //fCanvas->SetFillColor(16);
594
595 fUserFrame->AddFrame(vf1, expx);
596 fUserFrame->AddFrame(vf2);
597}
598
599// --------------------------------------------------------------------------
600//
601// Checks if the event number is valid, and if so reads the new event
602// and updates the display
603//
604void MEventDisplay::ReadinEvent(Int_t dir)
605{
606 MParList *plist = (MParList*) fEvtLoop->GetParList();
607 MTaskList *tlist = (MTaskList*) fEvtLoop->GetTaskList();
608 MGeomCam *geom = (MGeomCam*) plist->FindObject("MGeomCam");
609 MRawEvtData *raw = (MRawEvtData*)plist->FindObject("MRawEvtData");
610
611 //
612 // Read first event.
613 //
614 MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
615
616 const Int_t num = reader->GetNumEntry();
617
618 Int_t rc;
619 do
620 {
621 if (dir<0 && !reader->DecEventNum())
622 {
623 reader->SetEventNum(num);
624 return;
625 }
626 if (dir>0 && !reader->IncEventNum())
627 {
628 reader->SetEventNum(num);
629 return;
630 }
631
632 rc = tlist->Process();
633 if (rc==kFALSE || rc==kERROR)
634 return;
635
636 reader->DecEventNum();
637
638 // Define other continue conditions
639 if (raw && raw->GetNumPixels()<1)
640 rc = kCONTINUE;
641
642 } while (rc==kCONTINUE && dir!=0);
643
644 //
645 // Cleare the 'FADC canvas'
646 //
647 fCanvas->Clear();
648 fCanvas->Modified();
649 fCanvas->Update();
650
651 //
652 // Print parameters
653 //
654 *fLog << all;
655 fLog->Separator(Form("Entry %d", reader->GetNumEntry()+1));
656 ((MHillas*) plist->FindObject("MHillas"))->Print(*geom);
657 ((MHillasExt*) plist->FindObject("MHillasExt"))->Print(*geom);
658 ((MHillasSrc*) plist->FindObject("MHillasSrc"))->Print(*geom);
659 plist->FindObject("MImagePar")->Print();
660 ((MNewImagePar*)plist->FindObject("MNewImagePar"))->Print(*geom);
661 plist->FindObject("MMuonCalibPar")->Print();
662 ((MMuonSearchPar*)plist->FindObject("MMuonSearchPar"))->Print(*geom);
663
664 //
665 // UpdateDisplay
666 //
667 gStyle->SetOptStat(1101);
668 Update();
669
670 TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
671 entry->SetText(Form("%d", reader->GetNumEntry()+1));
672}
673
674void MEventDisplay::ShowHide()
675{
676 TGCheckButton *but1 = (TGCheckButton*)fList->FindWidget(kShowMuon);
677 TGCheckButton *but2 = (TGCheckButton*)fList->FindWidget(kShowImgPar);
678
679 const Bool_t imgpar = but1 && but1->IsDown();
680 const Bool_t muon = but2 && but2->IsDown();
681
682 //
683 // Get parlist
684 //
685 MParList *plist = fEvtLoop->GetParList();
686 if (!plist)
687 return;
688
689 //
690 // Draw ellipse on top of all pads
691 //
692 const Int_t n = 5;
693
694 TObject *obj[n] = {
695 plist->FindObject("MHillas"),
696 plist->FindObject("MHillasSrc"),
697 plist->FindObject("MHillasExt"),
698 plist->FindObject("MSrcPosCam"),
699 plist->FindObject("MMuonSearchPar")
700 };
701
702 const Bool_t state[n] = {
703 imgpar,
704 imgpar,
705 imgpar,
706 imgpar,
707 muon,
708 };
709
710
711 for (int i=1; i<7; i++)
712 {
713 TCanvas *c = GetCanvas(i);
714 c->GetPad(1)->cd(1);
715
716 TList *list = gPad->GetListOfPrimitives();
717
718 for (int j=0;j<n; j++)
719 if (obj[j])
720 if (state[j] && !list->FindObject(obj[j]))
721 list->Add(obj[j]);
722 else
723 list->Remove(obj[j]);
724
725 gPad->Modified(kTRUE);
726 }
727}
728
729// --------------------------------------------------------------------------
730//
731// Read first event to get display booted
732//
733void MEventDisplay::ReadFirstEvent()
734{
735 const Int_t rc = fEvtLoop->PreProcess();
736 if (rc==kFALSE || rc==kERROR)
737 return;
738
739 UnLock();
740
741 //
742 // Add Geometry tab
743 //
744 AddGeometryTabs();
745
746 //
747 // Now read event...
748 //
749 // FIXME: Can we safly replace ReadinEvent() by RedinEvent(1)?
750 ReadinEvent();
751
752
753 MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
754 TGString *txt = new TGString(Form("of %d", reader->GetEntries()));
755 fNumOfEvts->SetText(txt);
756
757 ShowHide();
758}
759
760// --------------------------------------------------------------------------
761//
762// Adds the geometry tab
763//
764void MEventDisplay::AddGeometryTabs()
765{
766 MGeomCam *geom = (MGeomCam*)fEvtLoop->GetParList()->FindObject("MGeomCam");
767 if (!geom)
768 return;
769
770 TCanvas &c1=AddTab("Geometry");
771
772 MHCamera *cam = new MHCamera(*geom);
773 cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
774 cam->Draw("pixelindex");
775
776 c1.Modified();
777 c1.Update();
778
779 TCanvas &c2=AddTab("Sectors");
780
781 cam = new MHCamera(*geom);
782 cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
783 cam->Draw("sectorindex");
784
785 c2.Modified();
786 c2.Update();
787}
788
789// --------------------------------------------------------------------------
790//
791// ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
792//
793// Processes information from all GUI items.
794// Selecting an item usually generates an event with 4 parameters.
795// The first two are packed into msg (first and second bytes).
796// The other two are parm1 and parm2.
797//
798Bool_t MEventDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
799{
800 switch (GET_MSG(msg))
801 {
802 case kC_TEXTENTRY:
803 switch(GET_SUBMSG(msg))
804 {
805 case kTE_ENTER:
806 switch(GET_SUBMSG(msg))
807 {
808 case kTE_ENTER:
809 {
810 TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
811 MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
812 if (reader->SetEventNum(atoi(entry->GetText())-1))
813 ReadinEvent();
814 }
815 return kTRUE;
816 }
817 return kTRUE;
818 }
819 break;
820
821 case kC_COMMAND:
822 switch (GET_SUBMSG(msg))
823 {
824 case kCM_TAB:
825 {
826 //
827 // Set name for 'FADC canvas'. The name is the anchor for MHCamera.
828 // and clear the canvas
829 TCanvas *c = GetCanvas(mp1);
830 if (!c)
831 break;
832 MHEvent *o = (MHEvent*)fEvtLoop->GetParList()->FindObject(c->GetName());
833 if (!o)
834 break;
835 fCanvas->SetName(Form("%p;%p;PixelContent", o->GetHist(), c->GetPad(1)->GetPad(1)));
836 }
837 break;
838
839 case kCM_BUTTON:
840 switch (mp1)
841 {
842 case kEvtPrev:
843 ReadinEvent(-1);
844 return kTRUE;
845
846 case kEvtNext:
847 ReadinEvent(+1);
848 return kTRUE;
849 }
850 return kTRUE;
851
852 case kCM_CHECKBUTTON:
853 switch (mp1)
854 {
855 case kShowMuon:
856 case kShowImgPar:
857 ShowHide();
858 return kTRUE;
859 }
860 return kTRUE;
861 }
862 break;
863 }
864
865 return MStatusDisplay::ProcessMessage(msg, mp1, mp2);
866}
Note: See TracBrowser for help on using the repository browser.