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