1 | //
|
---|
2 | //
|
---|
3 | //
|
---|
4 | #define START_DIRECTORY "/dat1"
|
---|
5 | #define S_ISDIR(m) (((m)&(0170000)) == (0040000))
|
---|
6 |
|
---|
7 | #include <TApplication.h>
|
---|
8 | #include <TGMsgBox.h>
|
---|
9 |
|
---|
10 | #include "MainFrameSimone.hxx"
|
---|
11 |
|
---|
12 |
|
---|
13 | MainFrameSimone::MainFrameSimone(const TGWindow *p, UInt_t w, UInt_t h)
|
---|
14 | : TGMainFrame(p, w, h)
|
---|
15 | {
|
---|
16 | sprintf (fInputPath, "\0" ) ;
|
---|
17 | fNumEvents = 0 ;
|
---|
18 |
|
---|
19 | fEvtNb = 0 ;
|
---|
20 |
|
---|
21 | //
|
---|
22 | // set up the NTuples
|
---|
23 | //
|
---|
24 | fNtup = new TNtuple ("fNtup", "Ntuple with Run distributions",
|
---|
25 | "PartID:Energy:CoreX:CoreY:Theta:Phi:FirstInt") ;
|
---|
26 |
|
---|
27 | fNtupEvt = new TNtuple ("fNtupEvt", "Ntuple with Event distributions",
|
---|
28 | "WaveLen:PosX:PoxY:Height:Time:DireX:DireY") ;
|
---|
29 |
|
---|
30 |
|
---|
31 | //
|
---|
32 | // Create a main frame with a number of different buttons.
|
---|
33 | //
|
---|
34 |
|
---|
35 | //
|
---|
36 | // First create the MenuBar.
|
---|
37 | //
|
---|
38 |
|
---|
39 | fLayMenuBar = new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX,
|
---|
40 | 2, 2, 2, 2 ) ;
|
---|
41 | fLayMenuItem = new TGLayoutHints ( kLHintsTop | kLHintsLeft ,
|
---|
42 | 0, 4, 0, 0 ) ;
|
---|
43 |
|
---|
44 |
|
---|
45 | fFileMenu = new TGPopupMenu ( fClient->GetRoot() ) ;
|
---|
46 | fFileMenu->AddEntry ("Exit", M_FILE_EXIT ) ;
|
---|
47 |
|
---|
48 |
|
---|
49 | //
|
---|
50 | // the button messages are handled by main frame (this)
|
---|
51 | //
|
---|
52 | fFileMenu->Associate(this) ;
|
---|
53 |
|
---|
54 | fMenuBar = new TGMenuBar ( this, 1, 1, kHorizontalFrame ) ;
|
---|
55 | fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem ) ;
|
---|
56 |
|
---|
57 | AddFrame(fMenuBar, fLayMenuBar ) ;
|
---|
58 |
|
---|
59 |
|
---|
60 | //
|
---|
61 | // create the Tab
|
---|
62 | //
|
---|
63 |
|
---|
64 | fFrame = new TGCompositeFrame (this, 300,300, kHorizontalFrame ) ;
|
---|
65 |
|
---|
66 | fLayTab = new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX , 5, 5, 5, 5 ) ;
|
---|
67 | fTab = new TGTab ( fFrame, 400, 400 ) ;
|
---|
68 |
|
---|
69 | TGCompositeFrame *tf = fTab->AddTab("Input") ;
|
---|
70 | fTabF1 = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ;
|
---|
71 |
|
---|
72 | tf->AddFrame(fTabF1, fLayTab ) ;
|
---|
73 |
|
---|
74 | fTabF1a = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ;
|
---|
75 | tf->AddFrame(fTabF1a, new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
|
---|
76 |
|
---|
77 | fTabF1b = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ;
|
---|
78 | tf->AddFrame(fTabF1b, new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5 ) ) ;
|
---|
79 |
|
---|
80 | fDir = new TGListBox(fTabF1, -1) ;
|
---|
81 | fDir->Resize(350,20) ;
|
---|
82 | char temp[100] ;
|
---|
83 | // sprintf ( temp, "%s", START_DIRECTORY ) ;
|
---|
84 | sprintf ( temp, "%s", gSystem->WorkingDirectory() ) ;
|
---|
85 | fDir->AddEntry(temp, 1) ;
|
---|
86 | fTabF1->AddFrame( fDir, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
|
---|
87 |
|
---|
88 |
|
---|
89 | fPicCdup = fClient->GetPicture("tb_uplevel.xpm") ;
|
---|
90 | fCdup = new TGPictureButton(fTabF1, fPicCdup, M_CDIR_UP ) ;
|
---|
91 | fCdup->SetToolTipText("One Level up!") ;
|
---|
92 | fCdup->Associate(this) ;
|
---|
93 | fTabF1->AddFrame (fCdup, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
|
---|
94 |
|
---|
95 | fPicList = fClient->GetPicture("tb_list.xpm") ;
|
---|
96 | fListMode = new TGPictureButton(fTabF1, fPicList, M_LIST_MODE ) ;
|
---|
97 | fListMode->SetToolTipText("List Mode") ;
|
---|
98 | fListMode->Associate(this) ;
|
---|
99 | fListMode->SetState(kButtonUp) ;
|
---|
100 | fListMode->AllowStayDown(kTRUE) ;
|
---|
101 | fTabF1->AddFrame (fListMode, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
|
---|
102 |
|
---|
103 | fPicDetail = fClient->GetPicture("tb_details.xpm") ;
|
---|
104 | fDetail = new TGPictureButton(fTabF1, fPicDetail, M_DETAIL_MODE ) ;
|
---|
105 | fDetail->SetToolTipText("Details Mode") ;
|
---|
106 | fDetail->Associate(this) ;
|
---|
107 | fDetail->SetState(kButtonEngaged) ;
|
---|
108 | fDetail->AllowStayDown(kTRUE) ;
|
---|
109 | fTabF1->AddFrame (fDetail, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ;
|
---|
110 |
|
---|
111 |
|
---|
112 | fSelectButton = new TGTextButton(fTabF1b, "Select", M_BUTTON_SELECT );
|
---|
113 | fSelectButton->SetToolTipText("To select a path with Mmcs data files!");
|
---|
114 | fSelectButton->SetState(kButtonDisabled);
|
---|
115 | fSelectButton->Associate(this) ;
|
---|
116 |
|
---|
117 | fTabF1b->AddFrame(fSelectButton,
|
---|
118 | new TGLayoutHints(kLHintsTop | kLHintsCenterX, 5, 5, 5, 5) ) ;
|
---|
119 |
|
---|
120 | fFileView = new TGListView(fTabF1b, 540, 380 ) ;
|
---|
121 | fFileCont = new TGFileContainer(fFileView->GetViewPort(), 100, 100,
|
---|
122 | kVerticalFrame, fgWhitePixel) ;
|
---|
123 |
|
---|
124 | fFileCont->Associate(this) ;
|
---|
125 | fFileView->GetViewPort()->SetBackgroundColor(fgWhitePixel) ;
|
---|
126 | fFileView->SetContainer(fFileCont) ;
|
---|
127 | fFileCont->SetFilter("*") ;
|
---|
128 | // fFileCont->ChangeDirectory(START_DIRECTORY) ;
|
---|
129 | fFileCont->ChangeDirectory(gSystem->WorkingDirectory()) ;
|
---|
130 | fFileView->SetViewMode(kLVDetails);
|
---|
131 | fFileCont->Sort(kSortByName) ;
|
---|
132 |
|
---|
133 | fTabF1b->AddFrame(fFileView, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5) ) ;
|
---|
134 |
|
---|
135 | //
|
---|
136 | // create Tab 2
|
---|
137 | //
|
---|
138 |
|
---|
139 | tf = fTab->AddTab("Run Dist") ;
|
---|
140 | fTabF2 = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ;
|
---|
141 |
|
---|
142 | tf->AddFrame(fTabF2, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5)) ;
|
---|
143 |
|
---|
144 | // create the vertical subframes
|
---|
145 |
|
---|
146 | fTabF2a = new TGCompositeFrame (fTabF2, 100, 100, kHorizontalFrame) ;
|
---|
147 | fTabF2->AddFrame(fTabF2a, fLayTab ) ;
|
---|
148 |
|
---|
149 | fTabF2b = new TGCompositeFrame (fTabF2, 300, 300, kHorizontalFrame) ;
|
---|
150 | fTabF2->AddFrame(fTabF2b,
|
---|
151 | new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |kLHintsExpandY, 5, 5, 5, 5 ) ) ;
|
---|
152 |
|
---|
153 | fTabF2c = new TGCompositeFrame (fTabF2, 100, 100, kHorizontalFrame) ;
|
---|
154 | fTabF2->AddFrame(fTabF2c,new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
|
---|
155 |
|
---|
156 | // create the entries in first subframe
|
---|
157 |
|
---|
158 | fLabelInput = new TGLabel(fTabF2a, new TGString("Title:") );
|
---|
159 | fTabF2a->AddFrame( fLabelInput, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
|
---|
160 |
|
---|
161 | fDir2 = new TGListBox(fTabF2a, -1) ;
|
---|
162 | fDir2->Resize(350,20) ;
|
---|
163 | sprintf ( temp, "%s", fInputPath ) ;
|
---|
164 | fDir2->AddEntry(temp, 1) ;
|
---|
165 | fTabF2a->AddFrame( fDir2, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5 ) ) ;
|
---|
166 |
|
---|
167 | fLabelNumEvts = new TGLabel(fTabF2a, new TGString("Number of Events:") );
|
---|
168 | fTabF2a->AddFrame( fLabelNumEvts, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
|
---|
169 |
|
---|
170 | fDirNum = new TGListBox(fTabF2a, -1) ;
|
---|
171 | fDirNum->Resize(50,20) ;
|
---|
172 | fTabF2a->AddFrame( fDirNum,
|
---|
173 | new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5 ) ) ;
|
---|
174 |
|
---|
175 | fButtonPrint = new TGTextButton(fTabF2a, "Print", M_BUTTON_PRINT );
|
---|
176 | fButtonPrint->Associate(this) ;
|
---|
177 | fTabF2a->AddFrame (fButtonPrint, new TGLayoutHints(kLHintsTop | kLHintsLeft, 50, 50, 5, 5) );
|
---|
178 |
|
---|
179 | // create the entries in the second subframe
|
---|
180 |
|
---|
181 | fCanvasRun = new TRootEmbeddedCanvas("fCanvasRun", fTabF2b, 300, 300 ) ;
|
---|
182 | fTabF2b->AddFrame(fCanvasRun, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
|
---|
183 |
|
---|
184 | // create the entries in the third subframe
|
---|
185 |
|
---|
186 | fButtonPartID = new TGTextButton(fTabF2c, "PartId", M_BUTTON_PARTID );
|
---|
187 | fButtonPartID->Associate(this) ;
|
---|
188 | fTabF2c->AddFrame (fButtonPartID, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
189 |
|
---|
190 | fButtonEnergy = new TGTextButton(fTabF2c, "Energy", M_BUTTON_ENERGY );
|
---|
191 | fButtonEnergy->Associate(this) ;
|
---|
192 | fTabF2c->AddFrame (fButtonEnergy, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
193 |
|
---|
194 | fButtonCore = new TGTextButton(fTabF2c, "Core", M_BUTTON_CORE );
|
---|
195 | fButtonCore->Associate(this) ;
|
---|
196 | fTabF2c->AddFrame (fButtonCore, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
197 |
|
---|
198 | fButtonTheta = new TGTextButton(fTabF2c, "Theta", M_BUTTON_THETA );
|
---|
199 | fButtonTheta->Associate(this) ;
|
---|
200 | fTabF2c->AddFrame (fButtonTheta, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
201 |
|
---|
202 | fButtonPhi = new TGTextButton(fTabF2c, " Phi ", M_BUTTON_PHI );
|
---|
203 | fButtonPhi->Associate(this) ;
|
---|
204 | fTabF2c->AddFrame (fButtonPhi, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
205 |
|
---|
206 | fButtonFirst = new TGTextButton(fTabF2c, "FirstInt", M_BUTTON_FIRSTINT );
|
---|
207 | fButtonFirst->Associate(this) ;
|
---|
208 | fTabF2c->AddFrame (fButtonFirst, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
209 |
|
---|
210 | //
|
---|
211 | // create Tab 3
|
---|
212 | //
|
---|
213 |
|
---|
214 | tf = fTab->AddTab("Event Dist") ;
|
---|
215 | fTabF3 = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ;
|
---|
216 |
|
---|
217 | tf->AddFrame(fTabF3, fLayTab) ;
|
---|
218 |
|
---|
219 |
|
---|
220 | // create the vertical subframes
|
---|
221 |
|
---|
222 | fTabF3a = new TGCompositeFrame (fTabF3, 100, 100, kHorizontalFrame) ;
|
---|
223 | fTabF3->AddFrame(fTabF3a, fLayTab ) ;
|
---|
224 |
|
---|
225 | fTabF3b = new TGCompositeFrame (fTabF3, 300, 300, kHorizontalFrame) ;
|
---|
226 | fTabF3->AddFrame(fTabF3b,
|
---|
227 | new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |kLHintsExpandY, 5, 5, 5, 5 ) ) ;
|
---|
228 |
|
---|
229 | fTabF3c = new TGCompositeFrame (fTabF3, 100, 100, kHorizontalFrame) ;
|
---|
230 | fTabF3->AddFrame(fTabF3c,new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
|
---|
231 |
|
---|
232 | // create the entries in first subframe
|
---|
233 |
|
---|
234 | fLabel3 = new TGLabel(fTabF3a, new TGString("Input:") );
|
---|
235 | fTabF3a->AddFrame( fLabel3, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
|
---|
236 |
|
---|
237 | fDir3 = new TGListBox(fTabF3a, -1) ;
|
---|
238 | fDir3->Resize(350,20) ;
|
---|
239 | sprintf ( temp, "%s", fInputPath ) ;
|
---|
240 | fDir3->AddEntry(temp, 1) ;
|
---|
241 | fTabF3a->AddFrame( fDir3, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5 ) ) ;
|
---|
242 |
|
---|
243 | fLabel4 = new TGLabel(fTabF3a, new TGString("EventNb:") );
|
---|
244 | fTabF3a->AddFrame( fLabel4, new TGLayoutHints(kLHintsTop | kLHintsLeft , 5, 5, 5, 5 ) ) ;
|
---|
245 |
|
---|
246 | fDirEvtNb = new TGListBox(fTabF3a, -1) ;
|
---|
247 | fDirEvtNb->Resize(50,20) ;
|
---|
248 | fTabF3a->AddFrame( fDirEvtNb,
|
---|
249 | new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5 ) ) ;
|
---|
250 |
|
---|
251 | fButtonPrev = new TGTextButton(fTabF3a, "Prev", M_BUTTON_PREV );
|
---|
252 | fButtonPrev->Associate(this) ;
|
---|
253 | fTabF3a->AddFrame (fButtonPrev, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
|
---|
254 |
|
---|
255 | fButtonNext = new TGTextButton(fTabF3a, "Next", M_BUTTON_NEXT );
|
---|
256 | fButtonNext->Associate(this) ;
|
---|
257 | fTabF3a->AddFrame (fButtonNext, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 5, 5) );
|
---|
258 |
|
---|
259 |
|
---|
260 | //
|
---|
261 | // create the entries in the second subframe
|
---|
262 |
|
---|
263 |
|
---|
264 | fCanvasEvt = new TRootEmbeddedCanvas("fCanvasEvt", fTabF3b, 300, 300 ) ;
|
---|
265 | fTabF3b->AddFrame(fCanvasEvt, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY | kLHintsExpandX, 5, 5, 5, 5 ) ) ;
|
---|
266 |
|
---|
267 |
|
---|
268 | // create the entries in the third subframe
|
---|
269 |
|
---|
270 | fButtonWave = new TGTextButton(fTabF3c, "Wavelength", M_BUTTON_WAVELEN );
|
---|
271 | fButtonWave->Associate(this) ;
|
---|
272 | fTabF3c->AddFrame (fButtonWave, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
273 |
|
---|
274 | fButtonPosit = new TGTextButton(fTabF3c, "Position", M_BUTTON_POSIT );
|
---|
275 | fButtonPosit->Associate(this) ;
|
---|
276 | fTabF3c->AddFrame (fButtonPosit, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
277 |
|
---|
278 | fButtonHeight = new TGTextButton(fTabF3c, "Height", M_BUTTON_HEIGHT );
|
---|
279 | fButtonHeight->Associate(this) ;
|
---|
280 | fTabF3c->AddFrame (fButtonHeight, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
281 |
|
---|
282 | fButtonTime = new TGTextButton(fTabF3c, "Time", M_BUTTON_TIME );
|
---|
283 | fButtonTime->Associate(this) ;
|
---|
284 | fTabF3c->AddFrame (fButtonTime, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
285 |
|
---|
286 | fButtonDire = new TGTextButton(fTabF3c, "Direction", M_BUTTON_DIRE );
|
---|
287 | fButtonDire->Associate(this) ;
|
---|
288 | fTabF3c->AddFrame (fButtonDire, new TGLayoutHints(kLHintsBottom | kLHintsLeft, 2, 2, 2, 2) );
|
---|
289 |
|
---|
290 | //
|
---|
291 | // create Tab 4
|
---|
292 | //
|
---|
293 |
|
---|
294 | tf = fTab->AddTab("Control") ;
|
---|
295 | fTabF4 = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ;
|
---|
296 |
|
---|
297 | fButton1 = new TGTextButton(fTabF4, "&Exit", M_CTRL_EXIT);
|
---|
298 | fButton2 = new TGTextButton(fTabF4, "Working Directory", M_CTRL_PWD);
|
---|
299 | fButton3 = new TGTextButton(fTabF4, "Input Path", M_CTRL_PATH);
|
---|
300 |
|
---|
301 | fButton1->Associate(this) ;
|
---|
302 | fButton2->Associate(this) ;
|
---|
303 | fButton3->Associate(this) ;
|
---|
304 |
|
---|
305 | fLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 10, 10);
|
---|
306 |
|
---|
307 | fTabF4->AddFrame (fButton1, fLayout ) ;
|
---|
308 | fTabF4->AddFrame (fButton2, fLayout ) ;
|
---|
309 | fTabF4->AddFrame (fButton3, fLayout ) ;
|
---|
310 |
|
---|
311 | tf->AddFrame(fTabF4, fLayTab) ;
|
---|
312 |
|
---|
313 | fFrame->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) );
|
---|
314 |
|
---|
315 | AddFrame(fFrame, new TGLayoutHints (kLHintsExpandX|kLHintsExpandY) ) ;
|
---|
316 |
|
---|
317 | //
|
---|
318 | //
|
---|
319 | //
|
---|
320 |
|
---|
321 | MapSubwindows();
|
---|
322 |
|
---|
323 | Layout();
|
---|
324 |
|
---|
325 | SetWindowName("MainSimone");
|
---|
326 | SetIconName("MainSimone");
|
---|
327 |
|
---|
328 | MapWindow();
|
---|
329 | }
|
---|
330 |
|
---|
331 | // ======================================================================
|
---|
332 | // ======================================================================
|
---|
333 |
|
---|
334 | MainFrameSimone::~MainFrameSimone() {
|
---|
335 |
|
---|
336 | delete fButton1 ;
|
---|
337 | delete fButton2 ;
|
---|
338 | delete fFrame, fTab, fTabF1, fTabF2, fTabF4 ;
|
---|
339 | delete fTabF1a, fTabF1b ;
|
---|
340 | delete fDir, fCdup, fListMode, fDetail ;
|
---|
341 | delete fFileCont, fFileView ;
|
---|
342 | delete fFileMenu, fMenuBar;
|
---|
343 | delete fLayout, fLayMenuBar, fLayMenuItem, fLayTab ;
|
---|
344 |
|
---|
345 | delete fPicCdup, fPicList, fPicDetail ;
|
---|
346 |
|
---|
347 | }
|
---|
348 |
|
---|
349 | // ======================================================================
|
---|
350 | // ======================================================================
|
---|
351 |
|
---|
352 | void MainFrameSimone::CloseWindow()
|
---|
353 | {
|
---|
354 | // Got close message for this MainFrame. Calls parent CloseWindow()
|
---|
355 | // (which destroys the window) and terminate the application.
|
---|
356 | // The close message is generated by the window manager when its close
|
---|
357 | // window menu item is selected.
|
---|
358 |
|
---|
359 | TGMainFrame::CloseWindow();
|
---|
360 | gROOT->GetApplication()->Terminate(0) ;
|
---|
361 |
|
---|
362 | }
|
---|
363 |
|
---|
364 | // ======================================================================
|
---|
365 | // ======================================================================
|
---|
366 |
|
---|
367 | Bool_t MainFrameSimone::CerFileExist(Char_t *dir)
|
---|
368 | {
|
---|
369 | Char_t testfile[110] ;
|
---|
370 | FILE *unit ;
|
---|
371 |
|
---|
372 | sprintf (testfile, "%s/%s/cer000001",
|
---|
373 | gSystem->WorkingDirectory(), dir ) ;
|
---|
374 | //
|
---|
375 | // try to open the testfile
|
---|
376 | //
|
---|
377 |
|
---|
378 | if ( (unit = fopen (testfile, "r" )) == 0 ) {
|
---|
379 | //
|
---|
380 | // doesn't exist --> kFALSE
|
---|
381 | return (kFALSE) ;
|
---|
382 | }
|
---|
383 | else {
|
---|
384 | fclose ( unit ) ;
|
---|
385 |
|
---|
386 | return ( kTRUE ) ;
|
---|
387 | }
|
---|
388 |
|
---|
389 | }
|
---|
390 |
|
---|
391 | // ======================================================================
|
---|
392 | // ======================================================================
|
---|
393 |
|
---|
394 | Bool_t MainFrameSimone::DrawRunParam (Char_t *paraName) {
|
---|
395 |
|
---|
396 | TCanvas *canvas = fCanvasRun->GetCanvas();
|
---|
397 |
|
---|
398 | canvas->cd() ;
|
---|
399 |
|
---|
400 | if ( CheckNtup() )
|
---|
401 | {
|
---|
402 | fNtup->Draw(paraName) ;
|
---|
403 | canvas->Modified() ;
|
---|
404 | canvas->Update() ;
|
---|
405 |
|
---|
406 | return(kTRUE) ;
|
---|
407 | }
|
---|
408 | else
|
---|
409 | printf("No Ntuple exist!!\n");
|
---|
410 |
|
---|
411 | return (kFALSE) ;
|
---|
412 | }
|
---|
413 |
|
---|
414 | // ======================================================================
|
---|
415 | // ======================================================================
|
---|
416 |
|
---|
417 | Bool_t MainFrameSimone::CheckNtup()
|
---|
418 | {
|
---|
419 | if ( ! strcmp( fInputPath, "\0") ) {
|
---|
420 | printf ("No InputPath specified!! Do this before!!\n") ;
|
---|
421 | return (kFALSE) ;
|
---|
422 | }
|
---|
423 |
|
---|
424 |
|
---|
425 | if ( ! strcmp ( fInputPath, fNtupPath ) ) {
|
---|
426 | return (kTRUE) ;
|
---|
427 | }
|
---|
428 | else {
|
---|
429 |
|
---|
430 | if ( ReadDataToNtup() ) {
|
---|
431 | return (kTRUE) ;
|
---|
432 | }
|
---|
433 | }
|
---|
434 |
|
---|
435 | return (kFALSE) ;
|
---|
436 | }
|
---|
437 |
|
---|
438 | // ======================================================================
|
---|
439 | // ======================================================================
|
---|
440 |
|
---|
441 | Bool_t MainFrameSimone::ReadDataToNtup()
|
---|
442 | {
|
---|
443 | FILE *unit ;
|
---|
444 | Char_t rootfile[256] ;
|
---|
445 | Char_t cername[256] ;
|
---|
446 | Char_t datname[256] ;
|
---|
447 |
|
---|
448 | ifstream cerfile ;
|
---|
449 |
|
---|
450 | COREventHeader Event ;
|
---|
451 |
|
---|
452 | printf("readin the input path: %s \n", fInputPath ) ;
|
---|
453 |
|
---|
454 | fNtup->Reset() ;
|
---|
455 |
|
---|
456 | sprintf (rootfile, "%s/simone.root", fInputPath ) ;
|
---|
457 |
|
---|
458 | //
|
---|
459 | // check if there is a file simone.root in the directory fInputPath
|
---|
460 | //
|
---|
461 | // if the file is there open it an read the ntuple in,
|
---|
462 | // else open all cerenkov files and fill the histograms and store
|
---|
463 | // the ntuple as simone.root in the directory fInputPath
|
---|
464 | //
|
---|
465 |
|
---|
466 | if ( ( unit = fopen (rootfile, "r" )) != 0 ) {
|
---|
467 | fclose (unit) ;
|
---|
468 |
|
---|
469 | //
|
---|
470 | // open the file as a root file
|
---|
471 | //
|
---|
472 |
|
---|
473 | TFile *hfile = new TFile ( rootfile ) ;
|
---|
474 |
|
---|
475 | //
|
---|
476 | // connect the ntuple from the file
|
---|
477 | //
|
---|
478 |
|
---|
479 | fNtup = (TNtuple *) hfile->Get("fNtup") ;
|
---|
480 |
|
---|
481 | fNtup->Read("fNtup") ;
|
---|
482 |
|
---|
483 | //
|
---|
484 | // close the root file
|
---|
485 | //
|
---|
486 |
|
---|
487 | //hfile->Close() ;
|
---|
488 |
|
---|
489 | //delete hfile ;
|
---|
490 |
|
---|
491 |
|
---|
492 |
|
---|
493 | fNumEvents = (Int_t) fNtup->GetEntries() ;
|
---|
494 |
|
---|
495 | sprintf ( datname, "%d", fNumEvents ) ;
|
---|
496 |
|
---|
497 | fDirNum->RemoveEntry(1) ;
|
---|
498 | fDirNum->AddEntry(datname,1) ;
|
---|
499 | fDirNum->MapSubwindows() ;
|
---|
500 | fDirNum->Layout() ;
|
---|
501 | }
|
---|
502 | else {
|
---|
503 | //
|
---|
504 | // create the root file
|
---|
505 | //
|
---|
506 |
|
---|
507 | TFile *hfile = new TFile ( rootfile, "NEW" ) ;
|
---|
508 |
|
---|
509 |
|
---|
510 | for (int i_cer = 1; i_cer <= 100000; i_cer++ ) {
|
---|
511 |
|
---|
512 | // inform about progress
|
---|
513 |
|
---|
514 | if (!( i_cer %1000) )
|
---|
515 | {
|
---|
516 | cout << i_cer << endl ;
|
---|
517 | sprintf ( datname, "%d", fNumEvents ) ;
|
---|
518 |
|
---|
519 | fDirNum->RemoveEntry(1) ;
|
---|
520 | fDirNum->AddEntry(datname,1) ;
|
---|
521 | fDirNum->MapSubwindows() ;
|
---|
522 | fDirNum->Layout() ;
|
---|
523 | }
|
---|
524 |
|
---|
525 |
|
---|
526 | // create the file names
|
---|
527 |
|
---|
528 | sprintf ( cername, "%s/cer%06d", fInputPath, i_cer ) ;
|
---|
529 | sprintf ( datname, "%s/dat%06d", fInputPath, i_cer ) ;
|
---|
530 |
|
---|
531 | // try to open the files
|
---|
532 |
|
---|
533 | cerfile.open( cername );
|
---|
534 |
|
---|
535 | if ( cerfile.bad() ) {
|
---|
536 |
|
---|
537 | fNumEvents = i_cer -1 ;
|
---|
538 |
|
---|
539 | sprintf ( datname, "%d", fNumEvents ) ;
|
---|
540 |
|
---|
541 | fDirNum->RemoveEntry(1) ;
|
---|
542 | fDirNum->AddEntry(datname,1) ;
|
---|
543 | fDirNum->MapSubwindows() ;
|
---|
544 | fDirNum->Layout() ;
|
---|
545 |
|
---|
546 | break ;
|
---|
547 | }
|
---|
548 |
|
---|
549 | Event.read( cerfile );
|
---|
550 |
|
---|
551 | //
|
---|
552 | // fill Ntuple
|
---|
553 | //
|
---|
554 |
|
---|
555 | fNtup->Fill( Event.get_primary() ,
|
---|
556 | Event.get_energy() ,
|
---|
557 | Event.get_coreX(),
|
---|
558 | Event.get_coreY(),
|
---|
559 | Event.get_theta(),
|
---|
560 | Event.get_phi(),
|
---|
561 | Event.get_firstInt() ) ;
|
---|
562 |
|
---|
563 |
|
---|
564 | cerfile.close();
|
---|
565 |
|
---|
566 | }
|
---|
567 |
|
---|
568 | //
|
---|
569 | // write Ntuple to the file
|
---|
570 | //
|
---|
571 | fNtup->Write() ;
|
---|
572 |
|
---|
573 | //
|
---|
574 | // write the root file
|
---|
575 | //
|
---|
576 | hfile->Write();
|
---|
577 |
|
---|
578 | delete hfile ;
|
---|
579 | }
|
---|
580 |
|
---|
581 |
|
---|
582 | //
|
---|
583 | // set some value of this class
|
---|
584 | //
|
---|
585 | sprintf ( fNtupPath, "%s", fInputPath) ;
|
---|
586 |
|
---|
587 | return (kTRUE) ;
|
---|
588 | }
|
---|
589 |
|
---|
590 | // ======================================================================
|
---|
591 | // ======================================================================
|
---|
592 |
|
---|
593 | Bool_t MainFrameSimone::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
|
---|
594 | {
|
---|
595 | Int_t retval = 0 ;
|
---|
596 | Char_t wort[100] ;
|
---|
597 | Char_t wort2[10] ;
|
---|
598 | Char_t testfile[100] ;
|
---|
599 | Char_t extens[5] ;
|
---|
600 | Char_t command[110] ;
|
---|
601 |
|
---|
602 | TGFileItem *item ; // to process items in the file view container
|
---|
603 | void *np = NULL ; // null pointer
|
---|
604 |
|
---|
605 | TCanvas *canvas = fCanvasRun->GetCanvas();
|
---|
606 |
|
---|
607 | // Process events generated by the buttons in the frame.
|
---|
608 |
|
---|
609 | switch (GET_MSG(msg)) {
|
---|
610 | case kC_COMMAND:
|
---|
611 | switch (GET_SUBMSG(msg)) {
|
---|
612 | case kCM_BUTTON:
|
---|
613 |
|
---|
614 | switch (parm1) {
|
---|
615 | case M_CDIR_UP :
|
---|
616 | sprintf ( fInputPath, "\0") ;
|
---|
617 | fSelectButton->SetState(kButtonDisabled) ;
|
---|
618 |
|
---|
619 | fDir2->RemoveEntry(1) ;
|
---|
620 | fDir2->AddEntry(fInputPath,1) ;
|
---|
621 | fDir2->MapSubwindows() ;
|
---|
622 | fDir2->Layout() ;
|
---|
623 |
|
---|
624 | fDir3->RemoveEntry(1) ;
|
---|
625 | fDir3->AddEntry(fInputPath,1) ;
|
---|
626 | fDir3->MapSubwindows() ;
|
---|
627 | fDir3->Layout() ;
|
---|
628 |
|
---|
629 |
|
---|
630 | sprintf (wort2, "\0" ) ;
|
---|
631 | fDirEvtNb->RemoveEntry(1) ;
|
---|
632 | fDirEvtNb->AddEntry( wort2, 1 ) ;
|
---|
633 | fDirEvtNb->MapSubwindows() ;
|
---|
634 | fDirEvtNb->Layout() ;
|
---|
635 |
|
---|
636 |
|
---|
637 |
|
---|
638 | //
|
---|
639 | // goto the parent directory
|
---|
640 | //
|
---|
641 | gSystem->ChangeDirectory("..") ;
|
---|
642 | fDir->RemoveEntry(1) ;
|
---|
643 | sprintf (wort, "%s", gSystem->WorkingDirectory() ) ;
|
---|
644 | fDir->AddEntry(wort,1) ;
|
---|
645 | fDir->MapSubwindows() ;
|
---|
646 | fDir->Layout() ;
|
---|
647 | fFileCont->ChangeDirectory( wort ) ;
|
---|
648 | fFileCont->DisplayDirectory() ;
|
---|
649 |
|
---|
650 | break ;
|
---|
651 |
|
---|
652 | case M_LIST_MODE:
|
---|
653 | fFileView->SetViewMode(kLVList) ;
|
---|
654 | fDetail->SetState(kButtonUp) ;
|
---|
655 | break ;
|
---|
656 |
|
---|
657 | case M_DETAIL_MODE:
|
---|
658 | fFileView->SetViewMode(kLVDetails) ;
|
---|
659 | fListMode->SetState(kButtonUp) ;
|
---|
660 | break ;
|
---|
661 |
|
---|
662 | case M_BUTTON_SELECT:
|
---|
663 |
|
---|
664 | if ( fFileCont->NumSelected() == 1 ) {
|
---|
665 | //
|
---|
666 | // one file selected
|
---|
667 | //
|
---|
668 | item = (TGFileItem *) fFileCont->GetNextSelected(&np) ;
|
---|
669 |
|
---|
670 | if ( S_ISDIR(item->GetType()) ) { // file is directory
|
---|
671 |
|
---|
672 | sprintf (fInputPath, "%s/%s",
|
---|
673 | gSystem->WorkingDirectory(),
|
---|
674 | item->GetItemName()->GetString()) ;
|
---|
675 |
|
---|
676 | fDir2->RemoveEntry(1) ;
|
---|
677 | fDir2->AddEntry(fInputPath,1) ;
|
---|
678 | fDir2->MapSubwindows() ;
|
---|
679 | fDir2->Layout() ;
|
---|
680 |
|
---|
681 | fDir3->RemoveEntry(1) ;
|
---|
682 | fDir3->AddEntry(fInputPath,1) ;
|
---|
683 | fDir3->MapSubwindows() ;
|
---|
684 | fDir3->Layout() ;
|
---|
685 |
|
---|
686 | fEvtNb = 0 ;
|
---|
687 | sprintf (wort2, "%d", fEvtNb ) ;
|
---|
688 | fDirEvtNb->RemoveEntry(1) ;
|
---|
689 | fDirEvtNb->AddEntry( wort2, 1 ) ;
|
---|
690 | fDirEvtNb->MapSubwindows() ;
|
---|
691 | fDirEvtNb->Layout() ;
|
---|
692 |
|
---|
693 | }
|
---|
694 | }
|
---|
695 | break;
|
---|
696 |
|
---|
697 | case M_BUTTON_PRINT:
|
---|
698 | canvas->Print("simone.ps") ;
|
---|
699 | gSystem->Exec("lpr simone.ps") ;
|
---|
700 | gSystem->Exec("rm -f simone.ps") ;
|
---|
701 | break;
|
---|
702 |
|
---|
703 | case M_BUTTON_PARTID:
|
---|
704 | DrawRunParam("PartID") ;
|
---|
705 | break ;
|
---|
706 |
|
---|
707 | case M_BUTTON_ENERGY:
|
---|
708 | DrawRunParam("log10(Energy)") ;
|
---|
709 | break;
|
---|
710 |
|
---|
711 | case M_BUTTON_CORE:
|
---|
712 | DrawRunParam("CoreY:CoreX") ;
|
---|
713 | break;
|
---|
714 |
|
---|
715 | case M_BUTTON_THETA:
|
---|
716 | DrawRunParam("Theta") ;
|
---|
717 | break;
|
---|
718 |
|
---|
719 | case M_BUTTON_PHI:
|
---|
720 | DrawRunParam("Phi") ;
|
---|
721 | break;
|
---|
722 |
|
---|
723 | case M_BUTTON_FIRSTINT:
|
---|
724 | DrawRunParam("FirstInt") ;
|
---|
725 | break;
|
---|
726 |
|
---|
727 |
|
---|
728 |
|
---|
729 | case M_BUTTON_PREV:
|
---|
730 | fEvtNb-- ;
|
---|
731 |
|
---|
732 |
|
---|
733 |
|
---|
734 | sprintf (wort2, "%d", fEvtNb ) ;
|
---|
735 | fDirEvtNb->RemoveEntry(1) ;
|
---|
736 | fDirEvtNb->AddEntry( wort2, 1 ) ;
|
---|
737 | fDirEvtNb->MapSubwindows() ;
|
---|
738 | fDirEvtNb->Layout() ;
|
---|
739 | break;
|
---|
740 |
|
---|
741 |
|
---|
742 | case M_BUTTON_NEXT:
|
---|
743 | fEvtNb++ ;
|
---|
744 |
|
---|
745 | sprintf (wort2, "%d", fEvtNb ) ;
|
---|
746 | fDirEvtNb->RemoveEntry(1) ;
|
---|
747 | fDirEvtNb->AddEntry( wort2, 1 ) ;
|
---|
748 | fDirEvtNb->MapSubwindows() ;
|
---|
749 | fDirEvtNb->Layout() ;
|
---|
750 | break;
|
---|
751 |
|
---|
752 |
|
---|
753 | case M_CTRL_EXIT:
|
---|
754 | CloseWindow() ;
|
---|
755 | break;
|
---|
756 |
|
---|
757 | case M_CTRL_PWD:
|
---|
758 | printf ("WorkingDirectory -> %s <- \n", gSystem->WorkingDirectory() ) ;
|
---|
759 | break ;
|
---|
760 |
|
---|
761 | case M_CTRL_PATH:
|
---|
762 | printf ("Input Path: -> %s <- \n", fInputPath ) ;
|
---|
763 | break ;
|
---|
764 | }
|
---|
765 |
|
---|
766 | break;
|
---|
767 |
|
---|
768 | case kCM_CHECKBUTTON:
|
---|
769 |
|
---|
770 | break;
|
---|
771 |
|
---|
772 | case kCM_RADIOBUTTON:
|
---|
773 | break;
|
---|
774 |
|
---|
775 |
|
---|
776 | case kCM_MENU:
|
---|
777 | switch (parm1) {
|
---|
778 | case M_FILE_EXIT:
|
---|
779 | CloseWindow() ;
|
---|
780 | break;
|
---|
781 |
|
---|
782 | }
|
---|
783 | break ;
|
---|
784 |
|
---|
785 | default:
|
---|
786 | break;
|
---|
787 |
|
---|
788 | }
|
---|
789 |
|
---|
790 | case kC_CONTAINER:
|
---|
791 | switch (GET_SUBMSG(msg)) {
|
---|
792 |
|
---|
793 | // case kCT_ITEMCLICK:
|
---|
794 | // printf ("itemclick\n");
|
---|
795 | // break;
|
---|
796 |
|
---|
797 |
|
---|
798 | case kCT_ITEMDBLCLICK:
|
---|
799 | //
|
---|
800 | // process the double click in the file view container
|
---|
801 | //
|
---|
802 |
|
---|
803 | if ( parm1 == kButton1) {
|
---|
804 | if ( fFileCont->NumSelected() == 1 ) {
|
---|
805 | //
|
---|
806 | // one file selected
|
---|
807 | //
|
---|
808 | item = (TGFileItem *) fFileCont->GetNextSelected(&np) ;
|
---|
809 |
|
---|
810 | if ( S_ISDIR(item->GetType()) ) { // file is directory
|
---|
811 |
|
---|
812 | sprintf (wort, "%s", item->GetItemName()->GetString()) ;
|
---|
813 |
|
---|
814 | //
|
---|
815 | // check if in this directory the file cer000001 exits
|
---|
816 | // if it exists, do not open the stuff
|
---|
817 | //
|
---|
818 |
|
---|
819 | if ( CerFileExist( wort ) ) {
|
---|
820 | printf ("Warning: Cer files in directory\n") ;
|
---|
821 | fSelectButton->SetState(kButtonUp) ;
|
---|
822 | }
|
---|
823 | else {
|
---|
824 | sprintf (fInputPath,"\0") ;
|
---|
825 | fSelectButton->SetState(kButtonDisabled) ;
|
---|
826 | fDir2->RemoveEntry(1) ;
|
---|
827 | fDir2->AddEntry(fInputPath,1) ;
|
---|
828 | fDir2->MapSubwindows() ;
|
---|
829 | fDir2->Layout() ;
|
---|
830 |
|
---|
831 | fDir3->RemoveEntry(1) ;
|
---|
832 | fDir3->AddEntry(fInputPath,1) ;
|
---|
833 | fDir3->MapSubwindows() ;
|
---|
834 | fDir3->Layout() ;
|
---|
835 |
|
---|
836 | sprintf (wort2, "\0" ) ;
|
---|
837 | fDirEvtNb->RemoveEntry(1) ;
|
---|
838 | fDirEvtNb->AddEntry( wort2, 1 ) ;
|
---|
839 | fDirEvtNb->MapSubwindows() ;
|
---|
840 | fDirEvtNb->Layout() ;
|
---|
841 |
|
---|
842 | //
|
---|
843 | // goto directory
|
---|
844 | //
|
---|
845 | fFileCont->ChangeDirectory ( wort ) ;
|
---|
846 | gSystem->ChangeDirectory( wort ) ;
|
---|
847 |
|
---|
848 | sprintf (wort, "%s", gSystem->WorkingDirectory() ) ;
|
---|
849 | fDir->RemoveEntry(1) ;
|
---|
850 | fDir->AddEntry( wort, 1 ) ;
|
---|
851 | fDir->MapSubwindows() ;
|
---|
852 | fDir->Layout() ;
|
---|
853 | }
|
---|
854 |
|
---|
855 | }
|
---|
856 | else { // item is a file
|
---|
857 | sprintf (testfile, "%s", item->GetItemName()->GetString() ) ;
|
---|
858 |
|
---|
859 | //
|
---|
860 | // determine the file type by extensions
|
---|
861 | //
|
---|
862 |
|
---|
863 | for (Int_t i = 0 ; i<5; i++)
|
---|
864 | extens[i] = '\0' ;
|
---|
865 |
|
---|
866 | for ( Int_t i=0; testfile[i] != '\0'; i++) {
|
---|
867 | if ( testfile[i] == '.') {
|
---|
868 | strncpy (extens, &testfile[i+1], 4 ) ;
|
---|
869 | break ;
|
---|
870 | }
|
---|
871 | }
|
---|
872 |
|
---|
873 | //
|
---|
874 | // postscript file
|
---|
875 | //
|
---|
876 |
|
---|
877 | if ( ! strcmp(extens, "ps") ) {
|
---|
878 | sprintf ( command, "gv %s/%s &",
|
---|
879 | gSystem->WorkingDirectory(),
|
---|
880 | testfile ) ;
|
---|
881 | gSystem->Exec(command) ;
|
---|
882 | break ;
|
---|
883 | }
|
---|
884 |
|
---|
885 |
|
---|
886 |
|
---|
887 |
|
---|
888 | }
|
---|
889 | }
|
---|
890 | }
|
---|
891 | else if ( parm1 == kButton3) { // right mouse double click
|
---|
892 | printf ("huschel kButton3\n");
|
---|
893 | }
|
---|
894 |
|
---|
895 | break;
|
---|
896 |
|
---|
897 | }
|
---|
898 | break ;
|
---|
899 |
|
---|
900 |
|
---|
901 | default:
|
---|
902 | break;
|
---|
903 | }
|
---|
904 | return kTRUE;
|
---|
905 | }
|
---|
906 |
|
---|
907 |
|
---|