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): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
|
---|
19 | ! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | #include "MGFadcDisp.h"
|
---|
27 |
|
---|
28 | #include <stdlib.h>
|
---|
29 | #include <iostream.h>
|
---|
30 |
|
---|
31 | #include <TGButton.h> // TGPictureButton
|
---|
32 | #include <TGLabel.h> // TGLabel
|
---|
33 | #include <TGSplitter.h> // TGHorizontal3DLine
|
---|
34 | #include <TGTab.h> // TGTab
|
---|
35 | #include <TGListBox.h> // TGListBox
|
---|
36 | #include <TGSlider.h> // TGVSlider
|
---|
37 | #include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
|
---|
38 | #include <TCanvas.h>
|
---|
39 | #include <TGTextEntry.h>
|
---|
40 | #include <TGMsgBox.h>
|
---|
41 |
|
---|
42 |
|
---|
43 | #include "MParList.h"
|
---|
44 | #include "MRawRunHeader.h"
|
---|
45 | #include "MRawEvtHeader.h"
|
---|
46 | #include "MTime.h"
|
---|
47 | #include "MRawEvtData.h"
|
---|
48 | #include "MRawCrateArray.h"
|
---|
49 | #include "MReadTree.h"
|
---|
50 | #include "MRawEvtPixelIter.h"
|
---|
51 |
|
---|
52 | ClassImp(MGFadcDisp)
|
---|
53 |
|
---|
54 |
|
---|
55 | MGFadcDisp::MGFadcDisp(char *filename, char *treename,
|
---|
56 | const TGWindow *p, const TGWindow *main,
|
---|
57 | UInt_t w, UInt_t h )
|
---|
58 | : TGTransientFrame(p, main, w, h )
|
---|
59 | {
|
---|
60 | // default constructor
|
---|
61 |
|
---|
62 | // first connect the file with this Object
|
---|
63 |
|
---|
64 | pList = new MParList();
|
---|
65 |
|
---|
66 | fRunHeader = new MRawRunHeader();
|
---|
67 | pList->AddToList(fRunHeader);
|
---|
68 |
|
---|
69 | fEvtHeader = new MRawEvtHeader();
|
---|
70 | pList->AddToList(fEvtHeader);
|
---|
71 | fEvtTime = new MTime();
|
---|
72 | pList->AddToList(fEvtTime);
|
---|
73 | fEvtData = new MRawEvtData();
|
---|
74 | pList->AddToList(fEvtData);
|
---|
75 | fEvtCrate = new MRawCrateArray();
|
---|
76 | pList->AddToList(fEvtCrate);
|
---|
77 |
|
---|
78 |
|
---|
79 | fReadTree = new MReadTree ( treename, filename ) ;
|
---|
80 | fReadTree->PreProcess( pList ) ;
|
---|
81 |
|
---|
82 | //
|
---|
83 | // the top part of the window
|
---|
84 | //
|
---|
85 | fFrameTop = new TGVerticalFrame (this, 300, 100 ) ;
|
---|
86 |
|
---|
87 | fTop1 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
|
---|
88 |
|
---|
89 | fLabelFile = new TGLabel(fTop1, new TGString("File:") );
|
---|
90 | fTop1->AddFrame( fLabelFile, new TGLayoutHints (kLHintsLeft, 10, 10, 10, 10)) ;
|
---|
91 |
|
---|
92 | fNameFile = new TGLabel(fTop1, new TGString( filename ) );
|
---|
93 | fTop1->AddFrame( fNameFile, new TGLayoutHints (kLHintsLeft, 10, 10, 10, 10)) ;
|
---|
94 |
|
---|
95 | fLabelTree = new TGLabel(fTop1, new TGString("Tree:") );
|
---|
96 | fTop1->AddFrame( fLabelTree, new TGLayoutHints (kLHintsLeft, 10, 10, 10, 10)) ;
|
---|
97 |
|
---|
98 | fNameTree = new TGLabel(fTop1, new TGString( treename ) );
|
---|
99 | fTop1->AddFrame( fNameTree, new TGLayoutHints (kLHintsLeft, 10, 10, 10, 10)) ;
|
---|
100 |
|
---|
101 | fFrameTop->AddFrame(fTop1,new TGLayoutHints (kLHintsTop ) ) ;
|
---|
102 |
|
---|
103 | fTop2 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
|
---|
104 |
|
---|
105 | fButtonPrevEvt = new TGTextButton (fTop2, "<< Previous Event", M_PREVEVT ) ;
|
---|
106 | fButtonPrevEvt->Associate(this) ;
|
---|
107 | fTop2->AddFrame (fButtonPrevEvt, new TGLayoutHints (kLHintsLeft, 10, 10, 10, 10 ) ) ;
|
---|
108 |
|
---|
109 | fLabelEvtNr = new TGLabel(fTop2, new TGString("Event: ") );
|
---|
110 | fTop2->AddFrame( fLabelEvtNr, new TGLayoutHints (kLHintsLeft, 10, 10, 10, 10)) ;
|
---|
111 |
|
---|
112 | fTxtEvtNr = new TGTextEntry(fTop2, fTxtBufEvtNr = new TGTextBuffer(100), M_EVTNUMBER);
|
---|
113 | fTxtEvtNr->Resize(60, fTxtEvtNr->GetDefaultHeight());
|
---|
114 | fTxtEvtNr->Associate(this) ;
|
---|
115 | fTop2->AddFrame(fTxtEvtNr, new TGLayoutHints(kLHintsTop | kLHintsLeft,
|
---|
116 | 5, 5, 5, 5));
|
---|
117 |
|
---|
118 | char wortdummy[100] ;
|
---|
119 | sprintf (wortdummy, "out of %d Events", fReadTree->GetEntries() ) ;
|
---|
120 | fLabelTotNr = new TGLabel(fTop2, new TGString( wortdummy ) );
|
---|
121 | fTop2->AddFrame( fLabelTotNr, new TGLayoutHints (kLHintsLeft, 10, 10, 10, 10)) ;
|
---|
122 |
|
---|
123 | fButtonNextEvt = new TGTextButton (fTop2, "Next Event >>", M_NEXTEVT ) ;
|
---|
124 | fButtonNextEvt->Associate(this) ;
|
---|
125 | fTop2->AddFrame (fButtonNextEvt, new TGLayoutHints (kLHintsLeft, 10, 10, 10, 10 ) ) ;
|
---|
126 |
|
---|
127 |
|
---|
128 | fFrameTop->AddFrame(fTop2,new TGLayoutHints ( kLHintsCenterX ) ) ;
|
---|
129 |
|
---|
130 |
|
---|
131 |
|
---|
132 | AddFrame(fFrameTop, new TGLayoutHints (kLHintsTop | kLHintsCenterX ) ) ;
|
---|
133 |
|
---|
134 | // a line between top and mid frame
|
---|
135 |
|
---|
136 | fLineSep1 = new TGHorizontal3DLine(this) ;
|
---|
137 | AddFrame(fLineSep1, new TGLayoutHints(kLHintsTop | kLHintsExpandX) );
|
---|
138 |
|
---|
139 | //
|
---|
140 | // the middle part of the window
|
---|
141 | //
|
---|
142 |
|
---|
143 | fFrameMid = new TGHorizontalFrame (this, 300, 100 ) ;
|
---|
144 |
|
---|
145 | // the left part is the control tab enviroment
|
---|
146 |
|
---|
147 | fTabControl = new TGTab(fFrameMid, 300, 300);
|
---|
148 | TGCompositeFrame *tControl = fTabControl->AddTab("PixelList");
|
---|
149 | tControl->ChangeOptions ( kHorizontalFrame ) ;
|
---|
150 |
|
---|
151 |
|
---|
152 | fPixelList = new TGListBox(tControl, M_PIXELLIST ) ;
|
---|
153 | fPixelList->Associate(this) ;
|
---|
154 | tControl->AddFrame(fPixelList, new TGLayoutHints(kLHintsExpandY | kLHintsLeft, 5, 5, 5, 5 ) ) ;
|
---|
155 | fPixelList->Resize(80, 230 ) ;
|
---|
156 |
|
---|
157 | fMid1 = new TGVerticalFrame (tControl, 300, 100 ) ;
|
---|
158 |
|
---|
159 |
|
---|
160 | fButtonPrevPix = new TGTextButton (fMid1, "<< Prev Pixel", 9999 ) ;
|
---|
161 | fMid1->AddFrame(fButtonPrevPix, new TGLayoutHints(kLHintsRight) ) ;
|
---|
162 |
|
---|
163 | fPixSlider = new TGVSlider (fMid1, 200, kSlider1 | kScaleBoth, 9999 );
|
---|
164 | fPixSlider->Associate(this);
|
---|
165 | fPixSlider->SetRange(0, 576);
|
---|
166 | fMid1->AddFrame(fPixSlider, new TGLayoutHints(kLHintsCenterX | kLHintsExpandY));
|
---|
167 |
|
---|
168 | fButtonNextPix = new TGTextButton (fMid1, "Next Pixel >>", 9999 ) ;
|
---|
169 | fMid1->AddFrame(fButtonNextPix, new TGLayoutHints(kLHintsRight) ) ;
|
---|
170 |
|
---|
171 | tControl->AddFrame(fMid1, new TGLayoutHints(kLHintsRight | kLHintsExpandY, 5, 5, 5, 5)) ;
|
---|
172 |
|
---|
173 | fFrameMid-> AddFrame(fTabControl, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 10, 10, 10 ,10 ) );
|
---|
174 |
|
---|
175 | // the right part is the display tab enviroment
|
---|
176 |
|
---|
177 | fTabDisplay = new TGTab(fFrameMid, 300, 300);
|
---|
178 | TGCompositeFrame *tDisplay = fTabDisplay->AddTab("Digital Scope");
|
---|
179 |
|
---|
180 | fECanDigScope = new TRootEmbeddedCanvas("fECanDigScope", tDisplay, 400, 400 ) ;
|
---|
181 | tDisplay->AddFrame( fECanDigScope, new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY ) ) ;
|
---|
182 |
|
---|
183 | fCan = fECanDigScope->GetCanvas() ;
|
---|
184 |
|
---|
185 |
|
---|
186 | fFrameMid-> AddFrame(fTabDisplay, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY | kLHintsExpandX , 10, 10, 10 ,10 ) );
|
---|
187 |
|
---|
188 |
|
---|
189 | AddFrame(fFrameMid, new TGLayoutHints (kLHintsExpandY | kLHintsExpandX ) ) ;
|
---|
190 |
|
---|
191 | // a line between mid and low frame
|
---|
192 |
|
---|
193 | fLineSep2 = new TGHorizontal3DLine(this) ;
|
---|
194 | AddFrame(fLineSep2, new TGLayoutHints(kLHintsTop | kLHintsExpandX) );
|
---|
195 |
|
---|
196 | // the low part of the window
|
---|
197 | //
|
---|
198 | fFrameLow = new TGHorizontalFrame (this, 300, 100 ) ;
|
---|
199 |
|
---|
200 |
|
---|
201 | fButtonPrint = new TGTextButton(fFrameLow, "Print", M_PRINT) ;
|
---|
202 | fButtonPrint->Associate(this) ;
|
---|
203 | fFrameLow->AddFrame( fButtonPrint, new TGLayoutHints(kLHintsLeft , 10, 10, 10, 10 ) ) ;
|
---|
204 |
|
---|
205 | fButtonClose = new TGTextButton(fFrameLow, "Close", M_CLOSE) ;
|
---|
206 | fButtonClose->Associate(this) ;
|
---|
207 | fFrameLow->AddFrame( fButtonClose, new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10 ) ) ;
|
---|
208 |
|
---|
209 |
|
---|
210 | AddFrame(fFrameLow, new TGLayoutHints (kLHintsTop ) ) ;
|
---|
211 |
|
---|
212 | //
|
---|
213 | // Map the window, set up the layout, etc.
|
---|
214 | //
|
---|
215 | SetWMSizeHints(450, 400, 1000, 1000, 10, 10 ) ; // set the smallest and biggest size of the Main frame
|
---|
216 |
|
---|
217 | MapSubwindows();
|
---|
218 |
|
---|
219 | Layout();
|
---|
220 |
|
---|
221 | SetWindowName("FadcDisplay");
|
---|
222 | SetIconName("FadcDisp");
|
---|
223 |
|
---|
224 | MapWindow();
|
---|
225 |
|
---|
226 | //
|
---|
227 | // fReadTree the first event and update the window
|
---|
228 | //
|
---|
229 | fReadTree->GetEvent() ;
|
---|
230 | CreatePixelList() ;
|
---|
231 | UpdateEventCounter() ;
|
---|
232 |
|
---|
233 | }
|
---|
234 |
|
---|
235 |
|
---|
236 | MGFadcDisp::~MGFadcDisp()
|
---|
237 | {
|
---|
238 | // close the file
|
---|
239 |
|
---|
240 | fReadTree->PostProcess() ;
|
---|
241 |
|
---|
242 | delete fRunHeader ;
|
---|
243 | delete fEvtHeader ;
|
---|
244 | delete fEvtTime ;
|
---|
245 | delete fEvtData ;
|
---|
246 | delete fEvtCrate ;
|
---|
247 |
|
---|
248 | delete pList ;
|
---|
249 |
|
---|
250 | delete fReadTree ;
|
---|
251 |
|
---|
252 | // destruct the graphical members
|
---|
253 |
|
---|
254 | delete fButtonPrint ;
|
---|
255 | delete fButtonClose ;
|
---|
256 |
|
---|
257 | // delete fCan ;
|
---|
258 | delete fECanDigScope ;
|
---|
259 | delete fTabDisplay ;
|
---|
260 |
|
---|
261 | delete fPixSlider ;
|
---|
262 | delete fButtonPrevPix ;
|
---|
263 | delete fButtonNextPix ;
|
---|
264 | delete fMid1 ;
|
---|
265 | delete fPixelList;
|
---|
266 | delete fTabControl ;
|
---|
267 |
|
---|
268 | delete fLabelEvtNr ;
|
---|
269 | delete fLabelTotNr ;
|
---|
270 | //delete fTxtBufEvtNr ;
|
---|
271 | delete fTxtEvtNr ;
|
---|
272 | delete fButtonNextEvt ;
|
---|
273 | delete fButtonPrevEvt ;
|
---|
274 | delete fLabelTree ;
|
---|
275 | delete fNameTree ;
|
---|
276 | delete fNameFile ;
|
---|
277 | delete fLabelFile ;
|
---|
278 | delete fTop2 ;
|
---|
279 | delete fTop1 ;
|
---|
280 |
|
---|
281 | delete fFrameLow ;
|
---|
282 | delete fLineSep2 ;
|
---|
283 | delete fFrameMid ;
|
---|
284 | delete fLineSep1 ;
|
---|
285 | delete fFrameTop ;
|
---|
286 | }
|
---|
287 |
|
---|
288 |
|
---|
289 | void MGFadcDisp::CloseWindow()
|
---|
290 | {
|
---|
291 | // Got close message for this MainFrame. Calls parent CloseWindow()
|
---|
292 | // (which destroys the window) and terminate the application.
|
---|
293 | // The close message is generated by the window manager when its close
|
---|
294 | // window menu item is selected.
|
---|
295 |
|
---|
296 | delete this ;
|
---|
297 | }
|
---|
298 |
|
---|
299 |
|
---|
300 | void MGFadcDisp::CreatePixelList(Int_t lastsel)
|
---|
301 | {
|
---|
302 | //
|
---|
303 | // after a new event is read in one has to update
|
---|
304 | // the list of pixels in the fPixelList (TGListBox)
|
---|
305 | //
|
---|
306 |
|
---|
307 | //
|
---|
308 | // put the selection of the last event in memory
|
---|
309 | //
|
---|
310 | MRawEvtPixelIter pixel(fEvtData);
|
---|
311 | while (pixel.Next())
|
---|
312 | {
|
---|
313 | char wortdummy[100] ;
|
---|
314 | sprintf(wortdummy, "%d", pixel.GetPixelId());
|
---|
315 | fPixelList->AddEntry(wortdummy, pixel.GetPixelId());
|
---|
316 | }
|
---|
317 |
|
---|
318 | fPixelList->MapSubwindows();
|
---|
319 | fPixelList->Layout();
|
---|
320 |
|
---|
321 | //
|
---|
322 | // check if the pixel from last event also occurs in this event
|
---|
323 | //
|
---|
324 | fCan->Clear() ;
|
---|
325 | fCan->cd() ;
|
---|
326 |
|
---|
327 | if (lastsel<0 || !pixel.Jump(lastsel))
|
---|
328 | {
|
---|
329 | pixel.Reset();
|
---|
330 | lastsel=pixel.GetPixelId();
|
---|
331 |
|
---|
332 | }
|
---|
333 |
|
---|
334 | char wortdummy[100] ;
|
---|
335 | sprintf(wortdummy, "GRAPH%d", lastsel);
|
---|
336 | fEvtData->Draw(wortdummy);
|
---|
337 | fPixelList->Select(lastsel, kTRUE);
|
---|
338 |
|
---|
339 | fCan->Modified();
|
---|
340 | fCan->Update();
|
---|
341 | }
|
---|
342 |
|
---|
343 | void MGFadcDisp::UpdateEventCounter()
|
---|
344 | {
|
---|
345 | // Update the event counter
|
---|
346 |
|
---|
347 | char wortdummy[256] ;
|
---|
348 |
|
---|
349 | sprintf (wortdummy, "%d", fReadTree->GetEventNum() ) ;
|
---|
350 |
|
---|
351 | fTxtEvtNr->SetText(wortdummy) ;
|
---|
352 | }
|
---|
353 |
|
---|
354 | void MGFadcDisp::ReadinEvent(UInt_t iEvt)
|
---|
355 | {
|
---|
356 | Int_t buttons = 4;
|
---|
357 | Int_t retval = 0 ;
|
---|
358 |
|
---|
359 | // first check if the new event is in the range of possible events
|
---|
360 |
|
---|
361 | if ( iEvt >= fReadTree->GetEntries() )
|
---|
362 | {
|
---|
363 | new TGMsgBox(fClient->GetRoot(), this,
|
---|
364 | "WARNING!",
|
---|
365 | "The event number is out of range!!!",
|
---|
366 | kMBIconExclamation, buttons, &retval);
|
---|
367 | }
|
---|
368 | else
|
---|
369 | {
|
---|
370 | const Int_t lastsel = fPixelList->GetSelected();
|
---|
371 |
|
---|
372 | fPixelList->RemoveEntries(0, fEvtData->GetNumPixels());
|
---|
373 |
|
---|
374 | fReadTree->SetEventNum(iEvt);
|
---|
375 | fReadTree->GetEvent();
|
---|
376 |
|
---|
377 | CreatePixelList(lastsel);
|
---|
378 | }
|
---|
379 |
|
---|
380 | UpdateEventCounter();
|
---|
381 | }
|
---|
382 |
|
---|
383 | Bool_t MGFadcDisp::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
384 | {
|
---|
385 | //------------------------------------------------------------------
|
---|
386 | //
|
---|
387 | // ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
|
---|
388 | //
|
---|
389 | // Processes information from all GUI items.
|
---|
390 | // Selecting an item usually generates an event with 4 parameters.
|
---|
391 | // The first two are packed into msg (first and second bytes).
|
---|
392 | // The other two are parm1 and parm2.
|
---|
393 | //
|
---|
394 | //------------------------------------------------------------------
|
---|
395 | char wortdummy[256] ;
|
---|
396 | Int_t buttons = 4, retval = 0 ;
|
---|
397 |
|
---|
398 | switch(GET_MSG(msg))
|
---|
399 | {
|
---|
400 | case kC_COMMAND:
|
---|
401 |
|
---|
402 | switch(GET_SUBMSG(msg))
|
---|
403 | {
|
---|
404 |
|
---|
405 | case kCM_BUTTON:
|
---|
406 |
|
---|
407 | switch (parm1)
|
---|
408 | {
|
---|
409 | case M_PREVEVT:
|
---|
410 | ReadinEvent(fReadTree->GetEventNum()-1 ) ;
|
---|
411 | break;
|
---|
412 |
|
---|
413 | case M_NEXTEVT:
|
---|
414 | ReadinEvent(fReadTree->GetEventNum()+1 ) ;
|
---|
415 | break;
|
---|
416 |
|
---|
417 |
|
---|
418 | case M_PRINT:
|
---|
419 | new TGMsgBox(fClient->GetRoot(), this,
|
---|
420 | "INFORMATION!",
|
---|
421 | "Your are invited to program that!!",
|
---|
422 | kMBIconExclamation, buttons, &retval);
|
---|
423 |
|
---|
424 | break ;
|
---|
425 |
|
---|
426 | case M_CLOSE:
|
---|
427 | CloseWindow() ;
|
---|
428 | break;
|
---|
429 |
|
---|
430 | }
|
---|
431 |
|
---|
432 | case kCM_LISTBOX:
|
---|
433 | switch (parm1)
|
---|
434 | {
|
---|
435 | case M_PIXELLIST:
|
---|
436 | sprintf(wortdummy, "GRAPH%d", fPixelList->GetSelected());
|
---|
437 |
|
---|
438 | fCan->Clear() ;
|
---|
439 | fCan->cd() ;
|
---|
440 |
|
---|
441 | fEvtData->Draw(wortdummy) ;
|
---|
442 |
|
---|
443 | fCan->Modified() ;
|
---|
444 | fCan->Update() ;
|
---|
445 | break;
|
---|
446 | }
|
---|
447 | break;
|
---|
448 |
|
---|
449 | }
|
---|
450 |
|
---|
451 | case kC_TEXTENTRY:
|
---|
452 |
|
---|
453 | switch(GET_SUBMSG(msg))
|
---|
454 | {
|
---|
455 | case kTE_TEXTCHANGED:
|
---|
456 | break ;
|
---|
457 |
|
---|
458 | case kTE_ENTER:
|
---|
459 | {
|
---|
460 | const char *txt = fTxtEvtNr->GetText();
|
---|
461 | ReadinEvent(atoi(txt));
|
---|
462 | }
|
---|
463 | break;
|
---|
464 | }
|
---|
465 | break;
|
---|
466 |
|
---|
467 | default:
|
---|
468 | break;
|
---|
469 | }
|
---|
470 |
|
---|
471 | return kTRUE ;
|
---|
472 | }
|
---|