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