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