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