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