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