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