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

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