source: trunk/MagicSoft/Simulation/Corsika/GuiSimone/MainFrameSimone.cxx@ 9435

Last change on this file since 9435 was 778, checked in by domingo, 24 years ago
Version of GuiSimone for a "single file per run" output of Mmcs. The "previous" event command is not operational at present. May need some further thinking...
File size: 40.2 KB
Line 
1//
2////////////////////////////////////////////////////////////////////////////
3//
4// GuiSimone
5//
6// Graphic User Interface for Simone (SIMultaed ONe Event)
7//
8// Modification May 2001 by C.Domingo over the existing program:
9// The header file MainFrameSimone.hxx has been changed: the ifsteam fCerFile
10// and the string variable fCerFileName are now global
11// Some procedures in MainFrameSimone have been adapted to the "one
12// file per run" Mmcs output
13//
14// GuiSimone reads Mmcs output files (one file per run version) and
15// displays several histograms for each run and/or each event. Selection
16// of files is made through a window (frame) and graphics are displayed
17// in other windows (subframes)
18//
19// The ROOT package is needed
20//
21////////////////////////////////////////////////////////////////////////////
22//
23//
24
25#define START_DIRECTORY "/dat1"
26#define S_ISDIR(m) (((m)&(0170000)) == (0040000))
27#define PI 3.1415926
28
29#include <TApplication.h>
30#include <TGMsgBox.h>
31
32#include "MainFrameSimone.hxx"
33
34char NtupName[5][20] = {"WaveLen", "PosY:PosX", "Height", "Time", "DireY:DireX" } ;
35
36
37MainFrameSimone::MainFrameSimone(const TGWindow *p, UInt_t w, UInt_t h)
38 : TGMainFrame(p, w, h)
39{
40 sprintf (fInputPath, "\0" ) ;
41 fNumEvents = 0 ;
42
43 fEvtNb = 0 ;
44
45 //
46 // set up the NTuples
47 //
48 fNtup = new TNtuple ("fNtup", "Ntuple with Run distributions",
49 "PartID:Energy:CoreX:CoreY:Theta:Phi:FirstInt") ;
50
51 fNtupEvt = new TNtuple ("fNtupEvt", "Ntuple with Event distributions",
52 "WaveLen:PosX:PosY:Height:Time:DireX:DireY") ;
53
54 //
55 // Create a main frame with a number of different buttons.
56 //
57
58 //
59 // First create the MenuBar.
60 //
61
62 fLayMenuBar = new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX,
63 2, 2, 2, 2 ) ;
64 fLayMenuItem = new TGLayoutHints ( kLHintsTop | kLHintsLeft ,
65 0, 4, 0, 0 ) ;
66
67
68 fFileMenu = new TGPopupMenu ( fClient->GetRoot() ) ;
69 fFileMenu->AddEntry ("Exit", M_FILE_EXIT ) ;
70
71
72 //
73 // the button messages are handled by main frame (this)
74 //
75 fFileMenu->Associate(this) ;
76
77 fMenuBar = new TGMenuBar ( this, 1, 1, kHorizontalFrame ) ;
78 fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem ) ;
79
80 AddFrame(fMenuBar, fLayMenuBar ) ;
81
82
83 //
84 // create the Tab
85 //
86
87 fFrame = new TGCompositeFrame (this, 300,300, kHorizontalFrame ) ;
88
89 fLayTab = new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX , 5, 5, 5, 5 ) ;
90 fTab = new TGTab ( fFrame, 400, 400 ) ;
91
92 TGCompositeFrame *tf = fTab->AddTab("Input") ;
93 fTabF1 = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ;
94
95 tf->AddFrame(fTabF1, fLayTab ) ;
96
97 fTabF1a = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ;
98 tf->AddFrame(fTabF1a, new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
99
100 fTabF1b = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ;
101 tf->AddFrame(fTabF1b, new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5 ) ) ;
102
103 fDir = new TGListBox(fTabF1, -1) ;
104 fDir->Resize(350,20) ;
105 char temp[100] ;
106 // sprintf ( temp, "%s", START_DIRECTORY ) ;
107 sprintf ( temp, "%s", gSystem->WorkingDirectory() ) ;
108 fDir->AddEntry(temp, 1) ;
109 fTabF1->AddFrame( fDir, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
110
111
112 fPicCdup = fClient->GetPicture("tb_uplevel.xpm") ;
113 fCdup = new TGPictureButton(fTabF1, fPicCdup, M_CDIR_UP ) ;
114 fCdup->SetToolTipText("One Level up!") ;
115 fCdup->Associate(this) ;
116 fTabF1->AddFrame (fCdup, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
117
118 fPicList = fClient->GetPicture("tb_list.xpm") ;
119 fListMode = new TGPictureButton(fTabF1, fPicList, M_LIST_MODE ) ;
120 fListMode->SetToolTipText("List Mode") ;
121 fListMode->Associate(this) ;
122 fListMode->SetState(kButtonUp) ;
123 fListMode->AllowStayDown(kTRUE) ;
124 fTabF1->AddFrame (fListMode, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
125
126 fPicDetail = fClient->GetPicture("tb_details.xpm") ;
127 fDetail = new TGPictureButton(fTabF1, fPicDetail, M_DETAIL_MODE ) ;
128 fDetail->SetToolTipText("Details Mode") ;
129 fDetail->Associate(this) ;
130 fDetail->SetState(kButtonEngaged) ;
131 fDetail->AllowStayDown(kTRUE) ;
132 fTabF1->AddFrame (fDetail, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
133
134
135 fSelectButton = new TGTextButton(fTabF1b, "Select", M_BUTTON_SELECT );
136 fSelectButton->SetToolTipText("To select a Cerenkov data output file from Mmcs!");
137 fSelectButton->SetState(kButtonDisabled);
138 fSelectButton->Associate(this) ;
139
140 fTabF1b->AddFrame(fSelectButton,
141 new TGLayoutHints(kLHintsTop | kLHintsCenterX, 5, 5, 5, 5) ) ;
142
143 fFileView = new TGListView(fTabF1b, 540, 380 ) ;
144 fFileCont = new TGFileContainer(fFileView->GetViewPort(), 100, 100,
145 kVerticalFrame, fgWhitePixel) ;
146
147 fFileCont->Associate(this) ;
148 fFileView->GetViewPort()->SetBackgroundColor(fgWhitePixel) ;
149 fFileView->SetContainer(fFileCont) ;
150 fFileCont->SetFilter("*") ;
151 // fFileCont->ChangeDirectory(START_DIRECTORY) ;
152 fFileCont->ChangeDirectory(gSystem->WorkingDirectory()) ;
153 fFileView->SetViewMode(kLVDetails);
154 fFileCont->Sort(kSortByName) ;
155
156 fTabF1b->AddFrame(fFileView, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5) ) ;
157
158 //
159 // create Tab 2
160 //
161
162 tf = fTab->AddTab("Run Dist") ;
163 fTabF2 = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ;
164
165 tf->AddFrame(fTabF2, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5)) ;
166
167 // create the vertical subframes
168
169 fTabF2a = new TGCompositeFrame (fTabF2, 100, 100, kHorizontalFrame) ;
170 fTabF2->AddFrame(fTabF2a, fLayTab ) ;
171
172 fTabF2b = new TGCompositeFrame (fTabF2, 300, 300, kHorizontalFrame) ;
173 fTabF2->AddFrame(fTabF2b,
174 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |kLHintsExpandY, 5, 5, 5, 5 ) ) ;
175
176 fTabF2c = new TGCompositeFrame (fTabF2, 100, 100, kHorizontalFrame) ;
177 fTabF2->AddFrame(fTabF2c,new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
178
179 // create the entries in first subframe
180
181 fLabelInput = new TGLabel(fTabF2a, new TGString("Title:") );
182 fTabF2a->AddFrame( fLabelInput, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
183
184 fDir2 = new TGListBox(fTabF2a, -1) ;
185 fDir2->Resize(350,20) ;
186 sprintf ( temp, "%s", fInputPath ) ;
187 fDir2->AddEntry(temp, 1) ;
188 fTabF2a->AddFrame( fDir2, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5 ) ) ;
189
190 fLabelNumEvts = new TGLabel(fTabF2a, new TGString("Number of Events:") );
191 fTabF2a->AddFrame( fLabelNumEvts, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
192
193 fDirNum = new TGListBox(fTabF2a, -1) ;
194 fDirNum->Resize(50,20) ;
195 fTabF2a->AddFrame( fDirNum,
196 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5 ) ) ;
197
198 fButtonPrint = new TGTextButton(fTabF2a, "Print", M_BUTTON_PRINT );
199 fButtonPrint->Associate(this) ;
200 fTabF2a->AddFrame (fButtonPrint, new TGLayoutHints(kLHintsTop | kLHintsLeft, 50, 50, 5, 5) );
201
202 // create the entries in the second subframe
203
204 fCanvasRun = new TRootEmbeddedCanvas("fCanvasRun", fTabF2b, 300, 300 ) ;
205 fTabF2b->AddFrame(fCanvasRun, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
206
207 // create the entries in the third subframe
208
209 fButtonPartID = new TGTextButton(fTabF2c, "PartId", M_BUTTON_PARTID );
210 fButtonPartID->Associate(this) ;
211 fTabF2c->AddFrame (fButtonPartID, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
212
213 fButtonEnergy = new TGTextButton(fTabF2c, "Energy", M_BUTTON_ENERGY );
214 fButtonEnergy->Associate(this) ;
215 fTabF2c->AddFrame (fButtonEnergy, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
216
217 fButtonCore = new TGTextButton(fTabF2c, "Core", M_BUTTON_CORE );
218 fButtonCore->Associate(this) ;
219 fTabF2c->AddFrame (fButtonCore, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
220
221 fButtonTheta = new TGTextButton(fTabF2c, "Theta", M_BUTTON_THETA );
222 fButtonTheta->Associate(this) ;
223 fTabF2c->AddFrame (fButtonTheta, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
224
225 fButtonPhi = new TGTextButton(fTabF2c, " Phi ", M_BUTTON_PHI );
226 fButtonPhi->Associate(this) ;
227 fTabF2c->AddFrame (fButtonPhi, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
228
229 fButtonFirst = new TGTextButton(fTabF2c, "FirstInt", M_BUTTON_FIRSTINT );
230 fButtonFirst->Associate(this) ;
231 fTabF2c->AddFrame (fButtonFirst, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
232
233 //
234 // create Tab 3
235 //
236
237 tf = fTab->AddTab("Event Dist") ;
238 fTabF3 = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ;
239
240 tf->AddFrame(fTabF3, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5)) ;
241
242
243 // create the vertical subframes
244
245 fTabF3a = new TGCompositeFrame (fTabF3, 100, 100, kHorizontalFrame) ;
246 fTabF3->AddFrame(fTabF3a, fLayTab ) ;
247
248 fTabF3b = new TGCompositeFrame (fTabF3, 300, 300, kHorizontalFrame) ;
249 fTabF3->AddFrame(fTabF3b,
250 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |kLHintsExpandY, 5, 5, 5, 5 ) ) ;
251
252 fTabF3c = new TGCompositeFrame (fTabF3, 100, 100, kHorizontalFrame) ;
253 fTabF3->AddFrame(fTabF3c,new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
254
255 // create the entries in first subframe
256
257 fLabel3 = new TGLabel(fTabF3a, new TGString("Input:") );
258 fTabF3a->AddFrame( fLabel3, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
259
260 fDir3 = new TGListBox(fTabF3a, -1) ;
261 fDir3->Resize(350,20) ;
262 sprintf ( temp, "%s", fInputPath ) ;
263 fDir3->AddEntry(temp, 1) ;
264 fTabF3a->AddFrame( fDir3, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5 ) ) ;
265
266 fLabel4 = new TGLabel(fTabF3a, new TGString("EventNb:") );
267 fTabF3a->AddFrame( fLabel4, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
268
269 fDirEvtNb = new TGListBox(fTabF3a, -1) ;
270 fDirEvtNb->Resize(50,20) ;
271 fTabF3a->AddFrame( fDirEvtNb,
272 new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5 ) ) ;
273
274 fButtonPrev = new TGTextButton(fTabF3a, "Prev", M_BUTTON_PREV );
275 fButtonPrev->Associate(this) ;
276 fTabF3a->AddFrame (fButtonPrev, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
277
278 fButtonNext = new TGTextButton(fTabF3a, "Next", M_BUTTON_NEXT );
279 fButtonNext->Associate(this) ;
280 fTabF3a->AddFrame (fButtonNext, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
281
282
283 //
284 // create the entries in the second subframe
285 //
286
287 fTabF3bI = new TGCompositeFrame (fTabF3b, 300, 300, kVerticalFrame) ;
288 fTabF3b->AddFrame(fTabF3bI,
289 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 5, 5, 5 ) ) ;
290
291
292 fTabF3bII = new TGCompositeFrame (fTabF3b, 300, 300, kVerticalFrame) ;
293 fTabF3b->AddFrame(fTabF3bII,
294 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 5, 5, 5 ) ) ;
295
296 fTabF3bIII = new TGCompositeFrame (fTabF3b, 300, 300, kVerticalFrame) ;
297 fTabF3b->AddFrame(fTabF3bIII,
298 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5 ) ) ;
299
300 fLabelId = new TGLabel(fTabF3bI, new TGString("PartId:") );
301 fTabF3bI->AddFrame( fLabelId, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 11, 5 ) ) ;
302
303 fLabelEner = new TGLabel(fTabF3bI, new TGString("Energy:") );
304 fTabF3bI->AddFrame( fLabelEner, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 11, 5 ) ) ;
305
306 fLabelNbPhot = new TGLabel(fTabF3bI, new TGString("NbPhot:") );
307 fTabF3bI->AddFrame( fLabelNbPhot, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 11, 5 ) ) ;
308
309 fLabelCoreX = new TGLabel(fTabF3bI, new TGString("CoreX:") );
310 fTabF3bI->AddFrame( fLabelCoreX, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 11, 5 ) ) ;
311
312 fLabelCoreY = new TGLabel(fTabF3bI, new TGString("CoreY:") );
313 fTabF3bI->AddFrame( fLabelCoreY, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 11, 5 ) ) ;
314
315 fLabelTheta = new TGLabel(fTabF3bI, new TGString("Theta:") );
316 fTabF3bI->AddFrame( fLabelTheta, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 11, 5 ) ) ;
317
318 fLabelPhi = new TGLabel(fTabF3bI, new TGString("Phi:") );
319 fTabF3bI->AddFrame( fLabelPhi, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 11, 5 ) ) ;
320
321 fLabelDireX = new TGLabel(fTabF3bI, new TGString("DireX:") );
322 fTabF3bI->AddFrame( fLabelDireX, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 11, 5 ) ) ;
323
324 fLabelDireY = new TGLabel(fTabF3bI, new TGString("DireY:") );
325 fTabF3bI->AddFrame( fLabelDireY, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 11, 5 ) ) ;
326
327
328 //
329 // huschel
330 //
331
332 fInfoId = new TGTextEntry ( fTabF3bII , fTextId = new TGTextBuffer(20) ) ;
333 fTabF3bII->AddFrame ( fInfoId, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
334 fInfoId->Resize( 70, fInfoId->GetDefaultHeight() ) ;
335
336 fInfoEner = new TGTextEntry ( fTabF3bII , fTextEner = new TGTextBuffer(20) ) ;
337 fTabF3bII->AddFrame ( fInfoEner, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
338 fInfoEner->Resize( 70, fInfoEner->GetDefaultHeight() ) ;
339
340 fInfoNbPhot = new TGTextEntry ( fTabF3bII , fTextNbPhot = new TGTextBuffer(20) ) ;
341 fTabF3bII->AddFrame ( fInfoNbPhot, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
342 fInfoNbPhot->Resize( 70, fInfoNbPhot->GetDefaultHeight() ) ;
343
344 fInfoCoreX = new TGTextEntry ( fTabF3bII , fTextCoreX = new TGTextBuffer(20) ) ;
345 fTabF3bII->AddFrame ( fInfoCoreX, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
346 fInfoCoreX->Resize( 70, fInfoCoreX->GetDefaultHeight() ) ;
347
348 fInfoCoreY = new TGTextEntry ( fTabF3bII , fTextCoreY = new TGTextBuffer(20) ) ;
349 fTabF3bII->AddFrame ( fInfoCoreY, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
350 fInfoCoreY->Resize( 70, fInfoCoreY->GetDefaultHeight() ) ;
351
352 fInfoTheta = new TGTextEntry ( fTabF3bII , fTextTheta = new TGTextBuffer(20) ) ;
353 fTabF3bII->AddFrame ( fInfoTheta, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
354 fInfoTheta->Resize( 70, fInfoTheta->GetDefaultHeight() ) ;
355
356 fInfoPhi = new TGTextEntry ( fTabF3bII , fTextPhi = new TGTextBuffer(20) ) ;
357 fTabF3bII->AddFrame ( fInfoPhi, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
358 fInfoPhi->Resize( 70, fInfoPhi->GetDefaultHeight() ) ;
359
360 fInfoDireX = new TGTextEntry ( fTabF3bII , fTextDireX = new TGTextBuffer(20) ) ;
361 fTabF3bII->AddFrame ( fInfoDireX, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
362 fInfoDireX->Resize( 70, fInfoDireX->GetDefaultHeight() ) ;
363
364 fInfoDireY = new TGTextEntry ( fTabF3bII , fTextDireY = new TGTextBuffer(20) ) ;
365 fTabF3bII->AddFrame ( fInfoDireY, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
366 fInfoDireY->Resize( 70, fInfoDireY->GetDefaultHeight() ) ;
367
368
369
370 fCanvasEvt = new TRootEmbeddedCanvas("fCanvasEvt", fTabF3bIII, 300, 300 ) ;
371 fTabF3bIII->AddFrame(fCanvasEvt, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
372
373
374 // create the entries in the third subframe
375
376 //
377 // set up the Radio Button
378 //
379
380 fRadioEvt[0] = new TGRadioButton(fTabF3c, new TGHotString("WaveLen") , M_BUTTON_WAVELEN );
381 fRadioEvt[1] = new TGRadioButton(fTabF3c, new TGHotString("Position"), M_BUTTON_POSIT );
382 fRadioEvt[2] = new TGRadioButton(fTabF3c, new TGHotString("Height") , M_BUTTON_HEIGHT );
383 fRadioEvt[3] = new TGRadioButton(fTabF3c, new TGHotString("Time") , M_BUTTON_TIME );
384 fRadioEvt[4] = new TGRadioButton(fTabF3c, new TGHotString("Direction"),M_BUTTON_DIRE);
385
386 for (Int_t i = 0; i < 5; i++ ) {
387 fTabF3c->AddFrame(fRadioEvt[i], new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 10, 2, 2) );
388 fRadioEvt[i]->Associate(this);
389 }
390
391 fRadioEvt[0]->SetState(kButtonDown) ;
392
393
394
395 //
396 // create Tab 4
397 //
398
399 tf = fTab->AddTab("Control") ;
400 fTabF4 = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ;
401
402 fButton1 = new TGTextButton(fTabF4, "&Exit", M_CTRL_EXIT);
403 fButton2 = new TGTextButton(fTabF4, "Working Directory", M_CTRL_PWD);
404 fButton3 = new TGTextButton(fTabF4, "Input Path", M_CTRL_PATH);
405
406 fButton1->Associate(this) ;
407 fButton2->Associate(this) ;
408 fButton3->Associate(this) ;
409
410 fLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 10, 10);
411
412 fTabF4->AddFrame (fButton1, fLayout ) ;
413 fTabF4->AddFrame (fButton2, fLayout ) ;
414 fTabF4->AddFrame (fButton3, fLayout ) ;
415
416 tf->AddFrame(fTabF4, fLayTab) ;
417
418 fFrame->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) );
419
420 AddFrame(fFrame, new TGLayoutHints (kLHintsExpandX|kLHintsExpandY) ) ;
421
422 //
423 //
424 //
425
426 MapSubwindows();
427
428 Layout();
429
430 SetWindowName("MainSimone");
431 SetIconName("MainSimone");
432
433 MapWindow();
434}
435
436// ======================================================================
437// ======================================================================
438
439MainFrameSimone::~MainFrameSimone() {
440
441 // first delete all entries in the tab frames
442
443 // Tab 1
444
445 delete fFileView, fFileCont ;
446 delete fCdup, fListMode, fDetail ;
447 delete fDir, fSelectButton ;
448 delete fTabF1a, fTabF1b ;
449
450 // Tab 2
451
452 delete fButtonTheta, fButtonPhi, fButtonFirst;
453 delete fButtonPartID, fButtonEnergy, fButtonCore;
454 delete fCanvasRun ;
455 delete fButtonPrint ;
456 delete fDir2, fDirNum ;
457 delete fLabelInput, fLabelNumEvts ;
458 delete fTabF2a, fTabF2b, fTabF2c ;
459
460 // Tab 3
461
462 delete fRadioEvt[0], fRadioEvt[1], fRadioEvt[2], fRadioEvt[3], fRadioEvt[4];
463 delete fButtonPrev, fButtonNext ;
464 delete fCanvasEvt;
465 delete fLabelTheta, fLabelPhi, fLabelDireX, fLabelDireY ;
466 delete fLabelCoreX, fLabelCoreY ;
467 delete fLabelNbPhot ;
468 delete fLabelId, fLabelEner ;
469 delete fDir3, fDirEvtNb ;
470 delete fLabel3, fLabel4;
471 delete fTabF3bI, fTabF3bII, fTabF3bIII ;
472 delete fTabF3a, fTabF3b, fTabF3c ;
473
474 // Tab4
475
476 delete fButton1 ;
477 delete fButton2 ;
478 delete fButton3 ;
479 delete fFrame, fTab, fTabF1, fTabF2, fTabF4 ;
480
481
482 // then delete the rest of the main frame
483
484 delete fFileMenu, fMenuBar;
485 delete fTabF1, fTabF2, fTabF3, fTabF4 ;
486 delete fFrame, fTab;
487
488 delete fLayout, fLayMenuBar, fLayMenuItem, fLayTab ;
489
490 delete fPicCdup, fPicList, fPicDetail ;
491
492
493 delete fNtup, fNtupEvt ;
494
495
496}
497
498// ======================================================================
499// ======================================================================
500
501void MainFrameSimone::CloseWindow()
502{
503 // Got close message for this MainFrame. Calls parent CloseWindow()
504 // (which destroys the window) and terminate the application.
505 // The close message is generated by the window manager when its close
506 // window menu item is selected.
507
508 TGMainFrame::CloseWindow();
509 gROOT->GetApplication()->Terminate(0) ;
510
511}
512
513// ======================================================================
514// ======================================================================
515//
516////////////////////////////////////////////////////////////////////////////
517//
518// Modification by C.Domingo May 2001
519//
520// Procedure CerFileExist NOT used at present
521//
522////////////////////////////////////////////////////////////////////////////
523//
524
525Bool_t MainFrameSimone::CerFileExist(Char_t *dir)
526{
527 Char_t testfile[110] ;
528 FILE *unit ;
529
530 sprintf (testfile, "%s/%s/cer000001",
531 gSystem->WorkingDirectory(), dir ) ;
532 //
533 // try to open the testfile
534 //
535
536 if ( (unit = fopen (testfile, "r" )) == 0 ) {
537 //
538 // doesn't exist --> kFALSE
539 return (kFALSE) ;
540 }
541 else {
542 fclose ( unit ) ;
543
544 return ( kTRUE ) ;
545 }
546
547}
548
549// ======================================================================
550// ======================================================================
551
552Bool_t MainFrameSimone::DrawRunParam (Char_t *paraName) {
553
554 TCanvas *canvas = fCanvasRun->GetCanvas();
555
556 canvas->cd() ;
557
558 if ( CheckNtup() )
559 {
560 fNtup->Draw(paraName) ;
561 canvas->Modified() ;
562 canvas->Update() ;
563
564 return(kTRUE) ;
565 }
566 else
567 {
568 canvas->Clear() ;
569 canvas->Modified() ;
570 canvas->Update() ;
571 }
572 return (kFALSE) ;
573}
574
575
576// ======================================================================
577// ======================================================================
578
579Bool_t MainFrameSimone::DrawEvtParam () {
580
581 TCanvas *canvas = fCanvasEvt->GetCanvas();
582
583 canvas->cd() ;
584
585 char paraName[20] ;
586
587 for ( Int_t i=0 ; i<5 ; i++ ) {
588 if ( fRadioEvt[i]->GetState() == kButtonDown) {
589 sprintf( paraName, "%s\0", NtupName[i] ) ;
590 break ;
591 }
592 }
593
594 if ( fNtupEvt->GetEntries() > 0 ) {
595
596 fNtupEvt->Draw(paraName) ;
597 canvas->Modified() ;
598 canvas->Update() ;
599
600 return(kTRUE) ;
601 }
602 else {
603
604 canvas->Clear() ;
605 canvas->Modified() ;
606 canvas->Update() ;
607
608 return (kFALSE) ;
609 }
610}
611
612// ======================================================================
613// ======================================================================
614//
615////////////////////////////////////////////////////////////////////////////
616//
617// Modification by C.Domingo May 2001
618//
619// The fNtupFile is now the cerenkov FILE (not the directory where the
620// Cerenkov files are stored) which contains the information of a
621// complete RUN
622//
623////////////////////////////////////////////////////////////////////////////
624//
625
626Bool_t MainFrameSimone::CheckNtup()
627{
628 Int_t buttons = 4, retval ;
629
630 if ( ! strcmp( fInputPath, "\0") ) {
631
632
633 new TGMsgBox(fClient->GetRoot(), this,
634 "Warning",
635 "No Cerenkov Input File specified\n Do this before!!",
636 kMBIconExclamation, buttons, &retval);
637
638 return (kFALSE) ;
639 }
640
641
642 if ( ! strcmp ( fCerFileName, fNtupFile ) ) {
643 return (kTRUE) ;
644 }
645 else {
646
647 if ( ReadDataToNtup() ) {
648 return (kTRUE) ;
649 }
650 }
651
652 return (kFALSE) ;
653}
654
655// ======================================================================
656// ======================================================================
657//
658////////////////////////////////////////////////////////////////////////////
659//
660// Modification by C.Domingo May 2001
661//
662// Major changes to procedure ReadDataToNtup
663// One simone.root file per each RUN file is generated now
664// One cerenkov file is read instead of all cerenkov files in a given directory
665// All events in the cerenkov file selected are read, and all the photons of these
666// events are skipped to proceed to next event
667//
668//
669////////////////////////////////////////////////////////////////////////////
670//
671Bool_t MainFrameSimone::ReadDataToNtup()
672{
673 FILE *unit ;
674 Char_t rootfile[256] ;
675 Char_t datname[256] ;
676
677 Float_t lambda ;
678 Float_t energyofevent ;
679 Int_t iPhotonInShower ;
680
681 COREventHeader Event ;
682 CORParticle Photon ;
683
684 Int_t buttons = 4, retval ;
685
686 fNtup->Reset() ;
687
688 sprintf (rootfile, "%s/simone%s.root", fInputPath, fRunSuffix ) ;
689
690 //
691 // check if there is a file simone######.root in the directory fInputPath
692 //
693 // if the file is there open it an read the ntuple in,
694 // else open the selected cerenkov file and fill the histograms and store
695 // the ntuple as simone######.root in the directory fInputPath
696 //
697
698 if ( ( unit = fopen (rootfile, "r" )) != 0 ) {
699 fclose (unit) ;
700
701 //
702 // open the file as a root file
703 //
704
705 TFile *hfile = new TFile ( rootfile ) ;
706
707 //
708 // connect the ntuple from the file
709 //
710
711 fNtup = (TNtuple *) hfile->Get("fNtup") ;
712
713 fNtup->Read("fNtup") ;
714
715 //
716 // close the root file
717 //
718
719 //hfile->Close() ;
720
721 //delete hfile ;
722
723 fNumEvents = (Int_t) fNtup->GetEntries() ;
724
725 sprintf ( datname, "%d", fNumEvents ) ;
726
727 fDirNum->RemoveEntry(1) ;
728 fDirNum->AddEntry(datname,1) ;
729 fDirNum->MapSubwindows() ;
730 fDirNum->Layout() ;
731 }
732 else {
733 //
734 // create the root file
735 //
736
737 TFile *hfile = new TFile ( rootfile, "NEW" ) ;
738
739
740 fNumEvents = 0 ;
741
742 fCerFile.open( fCerFileName );
743
744 if ( fCerFile.bad() ) {
745 new TGMsgBox(fClient->GetRoot(), this,
746 "Warning",
747 "Could not open Cerenkov file\n file = bad (sataus)",
748 kMBIconExclamation, buttons, &retval);
749 return (kFALSE) ;
750 }
751
752 // Dirty trick to read run header, as by chance it has the same structure
753 // of an event header
754
755 Event.read(fCerFile) ;
756
757 // Now reading the events truly
758
759 while ( ! (fCerFile.eof() || fCerFile.bad() ) ) {
760
761 Event.read( fCerFile );
762 energyofevent = Event.get_energy() ;
763 if (energyofevent == 0) break ;
764 fNumEvents++ ;
765
766 //
767 // Inform about progress
768 //
769
770 if (!( fNumEvents %1000) ) {
771 sprintf ( datname, "%d", fNumEvents ) ;
772
773 fDirNum->RemoveEntry(1) ;
774 fDirNum->AddEntry(datname,1) ;
775 fDirNum->MapSubwindows() ;
776 fDirNum->Layout() ;
777 }
778
779 //
780 // fill Ntuple
781 //
782
783 fNtup->Fill( Event.get_primary() ,
784 Event.get_energy() ,
785 Event.get_coreX(),
786 Event.get_coreY(),
787 Event.get_theta(),
788 Event.get_phi(),
789 Event.get_firstInt() ) ;
790
791 //
792 // loop over the particles (cerenkov photons) in
793 // the file
794 //
795
796 iPhotonInShower = 0 ;
797
798 while( ! (fCerFile.eof() || fCerFile.bad() )) {
799
800 //
801 // read in the particles
802 //
803
804 Photon.read ( fCerFile ) ;
805
806 //
807 // only if the wavelength lambda is greater than
808 // 1.0 it is a real cerenkov photon
809 //
810 lambda = Photon.get_wl() ;
811
812 // Photon.print() ;
813
814 if ( lambda < 1.0 ) {
815 // here we got to the next event reading in all the ZERO
816 // from the file
817 while ( lambda < 1. && ! (fCerFile.eof() || fCerFile.bad() ) ) {
818
819 Photon.read ( fCerFile ) ;
820 lambda = Photon.get_wl() ;
821 // cout << lambda << endl ;
822 }
823
824 // go back in the file, because when the zeroes have finished
825 // the following record has already been read as it were
826 // a cerenkov foton. The pointer should be repositioned to
827 // read the event end record
828
829 fCerFile.seekg( -28, ios::cur ) ;
830
831 // read in the event end record. Again, it has the same structure (by
832 // chance) thant the event header
833
834 Event.read( fCerFile );
835
836 break ;
837 }
838
839 iPhotonInShower++ ;
840
841 }
842
843 // cout << " Event " << fNumEvents << ": Photons " << iPhotonInShower << endl ;
844
845 }
846
847 fCerFile.close();
848
849 //
850 // Refresh information on the screen window
851 //
852
853 sprintf ( datname, "%d", fNumEvents ) ;
854
855 fDirNum->RemoveEntry(1) ;
856 fDirNum->AddEntry(datname,1) ;
857 fDirNum->MapSubwindows() ;
858 fDirNum->Layout() ;
859
860 //
861 // write Ntuple to the file
862 //
863
864 fNtup->Write() ;
865
866 //
867 // write the root file
868 //
869
870 hfile->Write();
871
872 delete hfile ;
873 }
874
875 //
876 // set some value of this class
877 //
878
879 sprintf ( fNtupFile, "%s", fCerFileName) ;
880
881 return (kTRUE) ;
882}
883
884
885// ======================================================================
886// ======================================================================
887//
888////////////////////////////////////////////////////////////////////////////
889//
890// Modification by C.Domingo May 2001
891//
892// Major changes to procedure ReadInEvt
893// Reads the photons from inside the selected cerenkov file (which contains
894// generated for a given run) instead of opening one file per event
895// Checks if it must read the first event of a file, in such a case the
896// file is open
897//
898////////////////////////////////////////////////////////////////////////////
899//
900
901Bool_t MainFrameSimone::ReadinEvt()
902{
903 Int_t buttons =4 , retval ;
904
905 Char_t wort[256] ;
906 FILE *unit ;
907
908 COREventHeader Event ;
909 CORParticle Photon ;
910
911 Int_t iPhotonInShower ;
912 Float_t lambda ;
913
914 //
915 // check the input Path
916 //
917
918 if ( ! strcmp( fInputPath, "\0") ) {
919
920 new TGMsgBox(fClient->GetRoot(), this,
921 "Warning",
922 "No Cerenkov Input File specified\n Do this before!!",
923 kMBIconExclamation, buttons, &retval);
924
925 return (kFALSE) ;
926 }
927
928 if ( fEvtNb == 0 ) {
929 printf ("Don't press the Prev Button at the first time!!\n") ;
930 return (kFALSE) ;
931 }
932
933 fNtupEvt->Reset() ;
934
935 //
936 // if first event, open the file and read run header
937 //
938
939 if ( fEvtNb == 1) {
940 fCerFile.open( fCerFileName );
941 if ( fCerFile.bad() ) {
942
943 new TGMsgBox(fClient->GetRoot(), this,
944 "ERROR",
945 "Can't open the cer file!!",
946 kMBIconExclamation, buttons, &retval);
947
948 return (kFALSE) ;
949 }
950
951 // Dirty trick to read run header (see comment in RaedDataToNtup for
952 // further details)
953
954 Event.read(fCerFile) ;
955
956 }
957
958 //
959 // For all events, read in event header
960 //
961
962 Event.read( fCerFile );
963
964 //
965 // Check for RUN end (an ENDRUN record will return a 0 value of the energy)
966 //
967
968 if (Event.get_energy() == 0) {
969 new TGMsgBox(fClient->GetRoot(), this,
970 "Information",
971 "End of file detected",
972 kMBIconAsterisk, buttons, &retval);
973 fCerFile.close () ;
974 return (kFALSE) ;
975 }
976
977 //
978 // fill the information labels
979 //
980
981 sprintf( wort," %8.0f", Event.get_primary() ) ;
982 fInfoId->SetText( wort ) ;
983
984 sprintf( wort," %9.1f", Event.get_energy() ) ;
985 fInfoEner->SetText( wort ) ;
986
987 sprintf( wort," %9.1f", Event.get_coreX() ) ;
988 fInfoCoreX->SetText( wort ) ;
989
990 sprintf( wort," %9.1f", Event.get_coreY() ) ;
991 fInfoCoreY->SetText( wort ) ;
992
993 sprintf( wort," %9.1f", Event.get_theta()*180./PI ) ;
994 fInfoTheta->SetText( wort ) ;
995
996 sprintf( wort," %9.1f", Event.get_phi()*180./PI ) ;
997 fInfoPhi->SetText( wort ) ;
998
999 sprintf( wort," %9.3f", Event.get_direX() ) ;
1000 fInfoDireX->SetText( wort ) ;
1001
1002 sprintf( wort," %9.3f", Event.get_direY() ) ;
1003 fInfoDireY->SetText( wort ) ;
1004
1005 //
1006 // loop over the particles
1007 //
1008
1009 iPhotonInShower = 0 ;
1010
1011 while( ! (fCerFile.eof() || fCerFile.bad() )) {
1012
1013 //
1014 // read in the particles
1015 //
1016
1017 Photon.read ( fCerFile ) ;
1018
1019 //
1020 // only if the wavelength lambda is greater than
1021 // 1.0 it is a real cerenkov photon
1022
1023 lambda = Photon.get_wl() ;
1024
1025 if ( lambda >= 1.0 ) {
1026 iPhotonInShower++ ;
1027 fNtupEvt->Fill(Photon.get_wl(),
1028 Photon.get_x(),
1029 Photon.get_y(),
1030 Photon.get_h(),
1031 Photon.get_t(),
1032 Photon.get_u(),
1033 Photon.get_v() ) ;
1034 }
1035
1036 // here we got to the next event reading in all the ZERO
1037 // from the file
1038
1039 else {
1040 while ( lambda < 1. && ! (fCerFile.eof() || fCerFile.bad() ) ) {
1041 Photon.read ( fCerFile ) ;
1042 lambda = Photon.get_wl() ;
1043 }
1044
1045 // go back in the file, because when the zeroes have finished
1046 // the following record has already been read as it were
1047 // a cerenkov foton. The pointer should be repositioned to
1048 // read the event end record
1049
1050 fCerFile.seekg( -28, ios::cur ) ;
1051
1052 // read in the event end record. Again, it has the same structure (by
1053 // chance) thant the event header
1054
1055 Event.read( fCerFile );
1056 break ;
1057 }
1058
1059 }
1060
1061 //
1062 // close the file
1063 //
1064
1065 sprintf( wort," %10d", iPhotonInShower ) ;
1066 fInfoNbPhot->SetText( wort ) ;
1067
1068 // fCerFile.close();
1069
1070 // sprintf( wort," %10d", iPhotonInShower ) ;
1071 // fInfoNbPhot->SetText( wort ) ;
1072
1073 return (kTRUE) ;
1074}
1075
1076
1077// ======================================================================
1078// ======================================================================
1079//
1080////////////////////////////////////////////////////////////////////////////
1081//
1082// Modification by C.Domingo May 2001
1083//
1084// Minor changes to procedure ProcessMessage
1085// case M_BUTTON_SELECT takes into account that we no longer select
1086// directories, but files.
1087// case M_BUTTON_PREV functionality has (temporarily) been removed
1088// case kCT_ITEMDBLCLICK takes into account that we deal with are going to
1089// select cerenkov files, not directories containing them. Test for detection
1090// of possible cerenkov files is added.
1091//
1092////////////////////////////////////////////////////////////////////////////
1093//
1094
1095Bool_t MainFrameSimone::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
1096{
1097 Int_t buttons = 4, retval = 0 ;
1098 Char_t wort[100] ;
1099 Char_t wort2[10] ;
1100 Char_t testfile[100] ;
1101 Char_t extens[5] ;
1102 Char_t idcer[5] ;
1103 Char_t command[110] ;
1104
1105 TGFileItem *item ; // to process items in the file view container
1106 void *np = NULL ; // null pointer
1107
1108 TCanvas *canvas = fCanvasRun->GetCanvas();
1109
1110 // Process events generated by the buttons in the frame.
1111
1112 switch (GET_MSG(msg)) {
1113 case kC_COMMAND:
1114 switch (GET_SUBMSG(msg)) {
1115 case kCM_BUTTON:
1116
1117 switch (parm1) {
1118 case M_CDIR_UP :
1119 sprintf ( fInputPath, "\0") ;
1120 fSelectButton->SetState(kButtonDisabled) ;
1121
1122 fDir2->RemoveEntry(1) ;
1123 fDir2->AddEntry(fInputPath,1) ;
1124 fDir2->MapSubwindows() ;
1125 fDir2->Layout() ;
1126
1127 fDir3->RemoveEntry(1) ;
1128 fDir3->AddEntry(fInputPath,1) ;
1129 fDir3->MapSubwindows() ;
1130 fDir3->Layout() ;
1131
1132
1133 sprintf (wort2, "\0" ) ;
1134 fDirEvtNb->RemoveEntry(1) ;
1135 fDirEvtNb->AddEntry( wort2, 1 ) ;
1136 fDirEvtNb->MapSubwindows() ;
1137 fDirEvtNb->Layout() ;
1138
1139
1140
1141 //
1142 // goto the parent directory
1143 //
1144 gSystem->ChangeDirectory("..") ;
1145 fDir->RemoveEntry(1) ;
1146 sprintf (wort, "%s", gSystem->WorkingDirectory() ) ;
1147 fDir->AddEntry(wort,1) ;
1148 fDir->MapSubwindows() ;
1149 fDir->Layout() ;
1150 fFileCont->ChangeDirectory( wort ) ;
1151 fFileCont->DisplayDirectory() ;
1152
1153 break ;
1154
1155 case M_LIST_MODE:
1156 fFileView->SetViewMode(kLVList) ;
1157 fDetail->SetState(kButtonUp) ;
1158 break ;
1159
1160 case M_DETAIL_MODE:
1161 fFileView->SetViewMode(kLVDetails) ;
1162 fListMode->SetState(kButtonUp) ;
1163 break ;
1164
1165 case M_BUTTON_SELECT:
1166
1167 if ( fFileCont->NumSelected() == 1 ) {
1168 //
1169 // one file selected
1170 //
1171 item = (TGFileItem *) fFileCont->GetNextSelected(&np) ;
1172
1173 // cout << "fCerFileName =" << fCerFileName ;
1174
1175 //
1176 // Check if fCerFile is already declared and open
1177 // If so, close it before selecting next file
1178 //
1179
1180 if (fCerFileName != "\0" && fCerFile )
1181 fCerFile.close();
1182
1183 //
1184 // Compose the InputPath name and the Cerenkov filename
1185 //
1186
1187 sprintf (fInputPath, "%s",
1188 gSystem->WorkingDirectory() ) ;
1189
1190 sprintf (fCerFileName, "%s/%s" ,
1191 gSystem->WorkingDirectory(),
1192 item->GetItemName()->GetString()) ;
1193
1194 //cout << fInputPath << endl;
1195 //cout << fCerFileName << endl ;
1196
1197 //
1198 // Refresh values in the frames
1199 //
1200
1201 fDir2->RemoveEntry(1) ;
1202 fDir2->AddEntry(fCerFileName,1) ;
1203 fDir2->MapSubwindows() ;
1204 fDir2->Layout() ;
1205
1206 fDir3->RemoveEntry(1) ;
1207 fDir3->AddEntry(fCerFileName,1) ;
1208 fDir3->MapSubwindows() ;
1209 fDir3->Layout() ;
1210
1211 fEvtNb = 0 ;
1212 sprintf (wort2, "%d", fEvtNb ) ;
1213 fDirEvtNb->RemoveEntry(1) ;
1214 fDirEvtNb->AddEntry( wort2, 1 ) ;
1215 fDirEvtNb->MapSubwindows() ;
1216 fDirEvtNb->Layout() ;
1217
1218 }
1219 break;
1220
1221 case M_BUTTON_PRINT:
1222 canvas->Print("simone.ps") ;
1223 gSystem->Exec("lpr simone.ps") ;
1224 gSystem->Exec("rm -f simone.ps") ;
1225 break;
1226
1227 case M_BUTTON_PARTID:
1228 DrawRunParam("PartID") ;
1229 break ;
1230
1231 case M_BUTTON_ENERGY:
1232 DrawRunParam("log10(Energy)") ;
1233 break;
1234
1235 case M_BUTTON_CORE:
1236 DrawRunParam("CoreY:CoreX") ;
1237 break;
1238
1239 case M_BUTTON_THETA:
1240 DrawRunParam("Theta") ;
1241 break;
1242
1243 case M_BUTTON_PHI:
1244 DrawRunParam("Phi") ;
1245 break;
1246
1247 case M_BUTTON_FIRSTINT:
1248 DrawRunParam("FirstInt") ;
1249 break;
1250
1251
1252 case M_BUTTON_PREV:
1253// fEvtNb-- ;
1254//
1255 if (fEvtNb < 1 ) {
1256 fEvtNb++ ;
1257
1258 }
1259//
1260// sprintf (wort2, "%d", fEvtNb ) ;
1261// fDirEvtNb->RemoveEntry(1) ;
1262// fDirEvtNb->AddEntry( wort2, 1 ) ;
1263// fDirEvtNb->MapSubwindows() ;
1264// fDirEvtNb->Layout() ;
1265//
1266// ReadinEvt() ;
1267//
1268// DrawEvtParam() ;
1269//
1270//
1271// Do nothing !!
1272//
1273 new TGMsgBox(fClient->GetRoot(), this,
1274 "Warning",
1275 "This button is not operational at present!!",
1276 kMBIconExclamation, buttons, &retval);
1277
1278 break;
1279//
1280//
1281 case M_BUTTON_NEXT:
1282 fEvtNb++ ;
1283
1284 sprintf (wort2, "%d", fEvtNb ) ;
1285 fDirEvtNb->RemoveEntry(1) ;
1286 fDirEvtNb->AddEntry( wort2, 1 ) ;
1287 fDirEvtNb->MapSubwindows() ;
1288 fDirEvtNb->Layout() ;
1289
1290 ReadinEvt() ;
1291
1292 DrawEvtParam() ;
1293
1294 break;
1295
1296 case M_CTRL_EXIT:
1297 CloseWindow() ;
1298 break;
1299
1300 case M_CTRL_PWD:
1301 printf ("WorkingDirectory -> %s <- \n", gSystem->WorkingDirectory() ) ;
1302 break ;
1303
1304 case M_CTRL_PATH:
1305 printf ("Input Path: -> %s <- \n", fInputPath ) ;
1306 break ;
1307 }
1308
1309 break;
1310
1311 case kCM_CHECKBUTTON:
1312
1313 break;
1314
1315 case kCM_RADIOBUTTON:
1316 if (parm1 >= M_BUTTON_WAVELEN && parm1 <= M_BUTTON_DIRE)
1317 {
1318 for (Int_t i=0; i<5; ++i)
1319 if (fRadioEvt[i]->WidgetId() != parm1)
1320 fRadioEvt[i]->SetState(kButtonUp);
1321 }
1322
1323 DrawEvtParam() ;
1324
1325 break;
1326
1327
1328 case kCM_MENU:
1329 switch (parm1) {
1330 case M_FILE_EXIT:
1331 CloseWindow() ;
1332 break;
1333
1334 }
1335 break ;
1336
1337 default:
1338 break;
1339
1340 }
1341
1342 case kC_CONTAINER:
1343 switch (GET_SUBMSG(msg)) {
1344
1345 // case kCT_ITEMCLICK:
1346 // printf ("itemclick\n");
1347 // break;
1348
1349
1350 case kCT_ITEMDBLCLICK:
1351 //
1352 // process the double click in the file view container
1353 //
1354
1355 if ( parm1 == kButton1) {
1356 if ( fFileCont->NumSelected() == 1 ) {
1357 //
1358 // one file selected
1359 //
1360 item = (TGFileItem *) fFileCont->GetNextSelected(&np) ;
1361
1362 if ( S_ISDIR(item->GetType()) ) { // file is directory
1363
1364 sprintf (wort, "%s", item->GetItemName()->GetString()) ;
1365
1366 sprintf (fInputPath,"\0") ;
1367 fSelectButton->SetState(kButtonDisabled) ;
1368 fDir2->RemoveEntry(1) ;
1369 fDir2->AddEntry(fInputPath,1) ;
1370 fDir2->MapSubwindows() ;
1371 fDir2->Layout() ;
1372
1373 fDir3->RemoveEntry(1) ;
1374 fDir3->AddEntry(fInputPath,1) ;
1375 fDir3->MapSubwindows() ;
1376 fDir3->Layout() ;
1377
1378 sprintf (wort2, "\0" ) ;
1379 fDirEvtNb->RemoveEntry(1) ;
1380 fDirEvtNb->AddEntry( wort2, 1 ) ;
1381 fDirEvtNb->MapSubwindows() ;
1382 fDirEvtNb->Layout() ;
1383
1384 //
1385 // goto directory
1386 //
1387 fFileCont->ChangeDirectory ( wort ) ;
1388 gSystem->ChangeDirectory( wort ) ;
1389
1390 sprintf (wort, "%s", gSystem->WorkingDirectory() ) ;
1391 fDir->RemoveEntry(1) ;
1392 fDir->AddEntry( wort, 1 ) ;
1393 fDir->MapSubwindows() ;
1394 fDir->Layout() ;
1395
1396 }
1397 else { // item is a file
1398 sprintf (testfile, "%s", item->GetItemName()->GetString() ) ;
1399
1400 //
1401 // Is it a Cerenkov file?
1402 //
1403
1404 for (Int_t i = 0 ; i<5; i++)
1405 idcer[i] = '\0' ;
1406 for (Int_t i = 0 ; i<10; i++)
1407 fRunSuffix[i]= '\0' ;
1408
1409 strncpy (idcer, &testfile[0], 3 ) ;
1410 if ( ! strcmp (idcer , "cer" ) ) {
1411 for ( Int_t i=3; 15; i++) {
1412 if ( testfile[i] == '\0') {
1413 strncpy (fRunSuffix, &testfile[3], i-3 ) ;
1414 break ;
1415 }
1416 }
1417
1418 // cout << "fRunSuffix = "<< fRunSuffix << endl ;
1419
1420 fSelectButton->SetState(kButtonUp) ;
1421
1422 new TGMsgBox(fClient->GetRoot(), this,
1423 "Information",
1424 "This file probably contains CERENKOV events\n click on the SELECT button to chose it!",
1425 kMBIconAsterisk, buttons, &retval);
1426 }
1427
1428 else {
1429
1430 fSelectButton->SetState(kButtonDisabled) ;
1431
1432 //
1433 // determine the file type by extensions
1434 //
1435
1436 for (Int_t i = 0 ; i<5; i++)
1437 extens[i] = '\0' ;
1438
1439 for ( Int_t i=0; testfile[i] != '\0'; i++) {
1440 if ( testfile[i] == '.') {
1441 strncpy (extens, &testfile[i+1], 4 ) ;
1442 break ;
1443 }
1444 }
1445
1446 //
1447 // postscript file
1448 //
1449
1450 if ( ! strcmp(extens, "ps") ) {
1451 sprintf ( command, "gv %s/%s &",
1452 gSystem->WorkingDirectory(),
1453 testfile ) ;
1454 gSystem->Exec(command) ;
1455 break ;
1456 }
1457
1458 }
1459
1460
1461 }
1462 }
1463 }
1464 else if ( parm1 == kButton3) { // right mouse double click
1465 printf ("huschel kButton3\n");
1466 }
1467
1468 break;
1469
1470 }
1471 break ;
1472
1473
1474 default:
1475 break;
1476
1477 }
1478
1479 return kTRUE;
1480
1481}
1482
1483
Note: See TracBrowser for help on using the repository browser.