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