source: trunk/MagicSoft/Simulation/Detector/include-MTrigger/MGTriggerSignal.cxx@ 18477

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