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