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