source: trunk/MagicSoft/Simulation/Detector/include-MFadc/MGFadcSignal.cxx@ 385

Last change on this file since 385 was 378, checked in by harald, 25 years ago
This is the startpoint for the further development of the FADC system. This implementation of the class MFadc is based on the implementation of the class MTRigger (see ../include-MTrigger ).
File size: 8.6 KB
Line 
1//
2//
3//
4#include "MGFadcSignal.hxx"
5
6#include "TPavesText.h"
7#include "TObjArray.h"
8#include "TCanvas.h"
9
10#include "TLine.h"
11
12MGFadcSignal::MGFadcSignal(const MMcEvt *McInfo,
13 const TObjArray *aList,
14 Float_t trigTime,
15 const TGWindow *p, const TGWindow *main,
16 UInt_t w, UInt_t h, UInt_t options) :
17 TGTransientFrame(p, main, w, h, options)
18{
19 // Default constructor
20 //
21 // Create a frame to show the signals.
22 //
23 //
24 fTrigTime = trigTime ;
25
26 iAnaSigs = aList->GetEntries() ;
27
28 iPage = 1 ;
29
30 //
31 // at the beginning copy the aList into Liste
32 //
33
34 ListeA = new TObjArray( *aList ) ;
35
36 Liste = new TObjArray( *ListeA ) ;
37
38
39 //
40 // First of all the Menus in the menubar
41 //
42
43 fMenuFile = new TGPopupMenu(gClient->GetRoot());
44 fMenuFile->AddEntry("Open...", M_FILE_OPEN);
45 fMenuFile->AddEntry("Save", M_FILE_SAVE);
46 fMenuFile->AddEntry("Save as...", M_FILE_SAVEAS);
47 fMenuFile->AddEntry("Close", M_FILE_CLOSE);
48 fMenuFile->AddSeparator();
49 fMenuFile->AddEntry("Print", M_FILE_PRINT);
50 fMenuFile->AddSeparator();
51 fMenuFile->AddEntry("Exit", M_FILE_EXIT );
52
53 fMenuFile->DisableEntry(M_FILE_OPEN);
54 fMenuFile->DisableEntry(M_FILE_SAVE);
55 fMenuFile->DisableEntry(M_FILE_SAVEAS);
56 fMenuFile->DisableEntry(M_FILE_CLOSE);
57 fMenuFile->DisableEntry(M_FILE_PRINT);
58 fMenuFile->DisableEntry(M_FILE_EXIT);
59
60 fMenuFile->Associate(this);
61
62 //
63 // create the menu bar
64 //
65
66 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
67 fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
68
69 AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
70 0, 0, 1, 1));
71
72 //
73 // create the information frame
74 //
75
76 Char_t winf[100];
77 fMcInfo = new TGCompositeFrame(this, 60, 20, kHorizontalFrame | kLHintsTop |kSunkenFrame );
78 sprintf ( winf,"Particle: %d", McInfo->GetPartId() );
79 fMcInfo->AddFrame(new TGLabel (fMcInfo, winf ),
80 new TGLayoutHints(kLHintsTop | kLHintsLeft ,
81 10, 10, 10, 10));
82
83 sprintf ( winf,"Energy: %6.1f [GeV]", McInfo->GetEnergy() );
84 fMcInfo->AddFrame(new TGLabel (fMcInfo, winf ),
85 new TGLayoutHints(kLHintsTop | kLHintsLeft ,
86 10, 10, 10, 10));
87
88 sprintf ( winf,"Theta: %6.1f [deg]", McInfo->GetTheta()* 57.2974 );
89 fMcInfo->AddFrame(new TGLabel (fMcInfo, winf ),
90 new TGLayoutHints(kLHintsTop | kLHintsLeft ,
91 10, 10, 10, 10));
92
93 sprintf ( winf,"Impact: %6.1f [m]", McInfo->GetImpact()/100. );
94 fMcInfo->AddFrame(new TGLabel (fMcInfo, winf ),
95 new TGLayoutHints(kLHintsTop | kLHintsLeft ,
96 10, 10, 10, 10));
97
98 AddFrame(fMcInfo, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
99 0, 0, 1, 0));
100
101 //
102 // build the canvas (here we will plot the histograms
103 //
104
105 fCanvasWindow = new TRootEmbeddedCanvas("test",this, 800, 500);
106 fContainer = new TGCompositeFrame(fCanvasWindow->GetViewPort(), 10, 10,
107 kHorizontalFrame, GetWhitePixel());
108 fContainer->SetLayoutManager(new TGTileLayout(fContainer, 7));
109 fCanvasWindow->SetContainer(fContainer);
110
111 tcan = fCanvasWindow->GetCanvas() ;
112
113 AddFrame(fCanvasWindow, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
114 0, 0, 2, 2));
115
116
117 //
118 // build the control frame
119 //
120 fControl = new TGCompositeFrame(this, 60, 20, kHorizontalFrame | kLHintsTop |kSunkenFrame );
121
122 fPrevChannels = new TGTextButton(fControl, "Previous Channels", M_PREV_CHANNELS);
123 fPrevChannels->Associate(this);
124 fPrevChannels->SetToolTipText("To see the previous sample of chanels");
125 fControl->AddFrame(fPrevChannels,
126 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
127
128
129 lPage = new TGLabel (fControl, "--") ;
130 fControl->AddFrame(lPage,
131 new TGLayoutHints(kLHintsTop | kLHintsLeft ,
132 5, 0, 10, 5));
133 sprintf ( winf,"/");
134 fControl->AddFrame(new TGLabel (fControl, "/" ),
135 new TGLayoutHints(kLHintsTop | kLHintsLeft ,
136 0, 0, 10, 5));
137
138 lPageAll = new TGLabel (fControl, "--") ;
139 fControl->AddFrame(lPageAll,
140 new TGLayoutHints(kLHintsTop | kLHintsLeft ,
141 0, 5, 10, 5));
142
143 fNextChannels = new TGTextButton(fControl, "Next Channels", M_NEXT_CHANNELS);
144 fNextChannels->Associate(this);
145 fNextChannels->SetToolTipText("To see the next sample of chanels");
146 fControl->AddFrame(fNextChannels,
147 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
148
149
150 fAnalog = new TGTextButton(fControl, "analog", M_ANALOG);
151 fAnalog->Associate(this);
152 fAnalog->SetToolTipText("Display of analog signals");
153 fControl->AddFrame(fAnalog,
154 new TGLayoutHints(kLHintsTop | kLHintsLeft, 50, 5, 5, 5));
155
156
157 fDigital = new TGTextButton(fControl, "digital", M_DIGITAL);
158 fDigital->Associate(this);
159 fDigital->SetToolTipText("Display of digital signals");
160 fControl->AddFrame(fDigital,
161 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
162
163
164 fBeide = new TGTextButton(fControl, "both", M_BEIDE);
165 fBeide->Associate(this);
166 fBeide->SetToolTipText("Display the analog and digital signals");
167 fControl->AddFrame(fBeide,
168 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
169
170
171
172 AddFrame(fControl, new TGLayoutHints(kLHintsExpandX,
173 0, 0, 1, 0));
174
175
176 //
177 // the close button line
178 //
179
180 fFrame = new TGCompositeFrame(this, 60, 20, kHorizontalFrame |
181 kSunkenFrame);
182
183 fCloseButton = new TGTextButton(fFrame, "Close", M_BUTTON_CLOSE);
184 fCloseButton->Associate(this);
185 fCloseButton->SetToolTipText("Close and skip to the next event!");
186 fFrame->AddFrame(fCloseButton,
187 new TGLayoutHints(kLHintsTop | kLHintsLeft, 100, 5, 5, 5));
188
189
190 fExitButton = new TGTextButton(fFrame, "Stop Job", M_BUTTON_EXIT);
191 fExitButton->Associate(this);
192 fExitButton->SetToolTipText("Shut down this job!");
193 fFrame->AddFrame(fExitButton,
194 new TGLayoutHints(kLHintsTop | kLHintsLeft, 200, 5, 5, 5));
195
196 AddFrame(fFrame, new TGLayoutHints(kLHintsBottom | kLHintsExpandX,
197 0, 0, 1, 0));
198
199 SetWindowName("MGFadcSignal");
200
201 MapSubwindows();
202
203 // we need to use GetDefault...() to initialize the layout algorithm...
204 Resize(GetDefaultSize());
205
206 // Resize (1000,650);
207
208 MapWindow();
209
210 DisplayChannels ( Liste) ;
211
212 gClient->WaitFor(this);
213}
214
215
216MGFadcSignal::~MGFadcSignal() {
217 delete fMenuBar ;
218 delete fMenuFile;
219
220 delete fContainer ;
221 delete fCanvasWindow ;
222
223 delete fCloseButton ;
224 delete fExitButton ;
225 delete fFrame ;
226}
227
228void MGFadcSignal::CloseWindow() {
229 delete this ;
230}
231
232
233void MGFadcSignal::DisplayChannels ( TObjArray *disList ) {
234
235 Int_t imax ;
236
237 if ( iPage == 0 ) {
238 printf ("Warning from DisplayChannels: Page 0 don't exist!!\n");
239 iPage = 1 ;
240 return ;
241 }
242
243 if ( (iPage-1)*16 >= (imax = disList->GetEntries()) ) {
244 printf ("Warning from DisplayChannels: PageNumber to big!\n");
245 iPage=iPage-1 ;
246 return;
247 }
248
249 Char_t wort[4] ;
250 sprintf ( wort, "%d", iPage) ;
251 lPage->SetText ( new TGString ( wort ) ) ;
252 sprintf ( wort, "%d", imax/16 + 1 ) ;
253 lPageAll->SetText ( new TGString ( wort ) ) ;
254
255
256 tcan->Clear() ;
257 tcan->Divide(4,4) ;
258
259 Int_t ifirst, ilast ;
260
261 ifirst = (iPage-1)*16 ;
262 ilast = iPage*16 ;
263
264 if ( ilast > imax ) {
265 ilast = imax ;
266 }
267
268 Int_t ic = 1 ;
269 for (Int_t ih=ifirst; ih<ilast; ih++ ) {
270 tcan->cd(ic++);
271 disList->At(ih)->Draw() ;
272
273 TLine *linie = new TLine( fTrigTime, 0., fTrigTime, 20. ) ;
274 linie->Draw() ;
275 }
276
277
278
279 tcan->Modified();
280 tcan->Update();
281
282
283
284}
285
286// ========================================
287// ========================================
288// ========================================
289
290Bool_t MGFadcSignal::ProcessMessage(Long_t msg, Long_t parm1, Long_t) {
291 // Handle messages send to the TestMainFrame object. E.g. all menu button
292 // messages.
293
294 // printf (" processmessage \n" ) ;
295
296 switch (GET_MSG(msg)) {
297
298 case kC_COMMAND:
299 switch (GET_SUBMSG(msg)) {
300
301 case kCM_MENU:
302 printf("Pointer over menu entry, id=%ld\n", parm1);
303 break;
304
305
306 case kCM_BUTTON:
307 switch ( parm1 ) {
308
309 case M_BUTTON_CLOSE:
310 CloseWindow() ;
311 break;
312
313 case M_BUTTON_EXIT:
314 exit (1234) ;
315 break;
316
317 case M_PREV_CHANNELS:
318 iPage = iPage - 1 ;
319 DisplayChannels (Liste) ;
320 break;
321
322 case M_NEXT_CHANNELS:
323 iPage = iPage + 1 ;
324 DisplayChannels (Liste) ;
325 break;
326
327 case M_ANALOG:
328 Liste = new TObjArray( *ListeA ) ;
329 DisplayChannels (Liste) ;
330 break;
331
332 case M_DIGITAL:
333 break;
334
335 case M_BEIDE:
336 //
337 // to draw the analog and the digital signal
338 //
339 break;
340 }
341
342 return kFALSE;
343 }
344 return kFALSE;
345 }
346 return kTRUE;
347}
348
349
350
351
352
353
354
355
Note: See TracBrowser for help on using the repository browser.