1 |
//------------------------------------------------------------------------------------------------------------------------------------------------------- |
2 |
// |
3 |
// FEventViewer.c version 1.03 (2006-04-04) |
4 |
// |
5 |
// Shows PAMELA events - Emiliano Mocchiutti |
6 |
// |
7 |
//------------------------------------------------------------------------------------------------------------------------------------------------------- |
8 |
// |
9 |
// |
10 |
// Standard use: |
11 |
// |
12 |
// bash> EventViewer |
13 |
// |
14 |
// For further informations use: |
15 |
// |
16 |
// EventViewer --help |
17 |
// |
18 |
// or |
19 |
// |
20 |
// EventViewer --version |
21 |
// |
22 |
//------------------------------------------------------------------------------------------------------------------------------------------------------- |
23 |
// |
24 |
// Changelog: |
25 |
// |
26 |
// 1.02 - 1.03 (2006-04-04): Make it possible to select events with the calorimeter also when generating level1 from level0. |
27 |
// |
28 |
// 1.01 - 1.02 (2006-03-22): Read calorimeter ADC2MIP flight conversion file. Do not install FEventviewer.cxx! |
29 |
// |
30 |
// 1.00 - 1.01 (2006-03-09): Flight version, read unique YODA file. Many capabilities disabled at the moment (reads only LEVEL0 data). |
31 |
// |
32 |
// 0.00 - 1.00 (2006-03-09): Clone of EventViewer.c v9r01. |
33 |
// |
34 |
#include <math.h> |
35 |
#include <stdio.h> |
36 |
// |
37 |
#include <iostream> |
38 |
#include <iomanip> |
39 |
#include <fstream> |
40 |
#if (__GNUC__ == 3) && (__GNUC_MINOR__ == 2) |
41 |
char* operator+( std::streampos&, char* ); |
42 |
#endif |
43 |
// |
44 |
#include <TObjectTable.h> |
45 |
#include <TGClient.h> |
46 |
#include <TGButton.h> |
47 |
#include <TGComboBox.h> |
48 |
#include <TGLabel.h> |
49 |
#include <TGTextEntry.h> |
50 |
#include <TGFrame.h> |
51 |
#include <TGButtonGroup.h> |
52 |
#include <TGProgressBar.h> |
53 |
#include <TGMsgBox.h> |
54 |
#include <TGComboBox.h> |
55 |
// |
56 |
#include <TTree.h> |
57 |
#include <TClassEdit.h> |
58 |
#include <TObject.h> |
59 |
#include <TList.h> |
60 |
#include <TSystem.h> |
61 |
#include <TSystemDirectory.h> |
62 |
#include <TString.h> |
63 |
#include <TFile.h> |
64 |
#include <TClass.h> |
65 |
#include <TCanvas.h> |
66 |
#include <TH1.h> |
67 |
#include <TH1F.h> |
68 |
#include <TH2D.h> |
69 |
#include <TLatex.h> |
70 |
#include <TPad.h> |
71 |
#include <TPaveLabel.h> |
72 |
#include <TLine.h> |
73 |
#include <TPolyLine.h> |
74 |
#include <TChain.h> |
75 |
#include <TApplication.h> |
76 |
#include <TVirtualX.h> |
77 |
#include <TGClient.h> |
78 |
#include <TGWindow.h> |
79 |
#include <TEllipse.h> |
80 |
#include <TArrow.h> |
81 |
#include <TStyle.h> |
82 |
// |
83 |
#include <PamelaRun.h> |
84 |
#include <physics/trigger/TriggerEvent.h> |
85 |
extern void stringcopy(TString&, const TString&, Int_t, Int_t); |
86 |
extern void stringappend(TString&, const TString&); |
87 |
#include <FEVpathtoc.h> |
88 |
// |
89 |
#include <FEVpamevcontrol.h> |
90 |
#include <FEVdetector.h> |
91 |
#include <FEventViewer.h> |
92 |
#include <feventvstruct.h> |
93 |
// |
94 |
using namespace std; |
95 |
// |
96 |
Bool_t existfile(TString filename){ |
97 |
ifstream myfile; |
98 |
myfile.open(filename.Data()); |
99 |
if ( !myfile ){ |
100 |
return(false); |
101 |
}; |
102 |
myfile.close(); |
103 |
return(true); |
104 |
} |
105 |
|
106 |
// |
107 |
// MAIN ROUTINE |
108 |
// |
109 |
void ShowEvent(TString filename="help", TString selfile="", TString outDir = ""){ |
110 |
Int_t ctrlword = 509; |
111 |
Int_t FORCELEV = -1; |
112 |
TString startingdir = gSystem->WorkingDirectory(); |
113 |
// |
114 |
TApplication app("app",0,0); |
115 |
// |
116 |
Bool_t firsttime = true; |
117 |
// |
118 |
Bool_t popup = false; |
119 |
// |
120 |
gROOT->GetListOfCanvases()->Delete(); |
121 |
gDirectory->GetList()->Delete(); |
122 |
// |
123 |
// here windows dimension (based on the computer screen size) and position and dimension of figures |
124 |
// |
125 |
Int_t xw, yw; |
126 |
UInt_t ww, hw; |
127 |
gVirtualX->GetWindowSize(gClient->GetRoot()->GetId(),xw,yw,ww,hw); |
128 |
Float_t winx = (float)ww*0.80; |
129 |
Float_t winy = (float)hw*0.80; // 95 |
130 |
Float_t winrap = winx/winy; |
131 |
// |
132 |
// book the canvas |
133 |
// |
134 |
TCanvas *figure = new TCanvas("PAMELA event viewer", "PAMELA event viewer",(int)winx,(int)winy); |
135 |
// |
136 |
// create the PAMELA detector |
137 |
// |
138 |
FEVdetector *pamela = new FEVdetector(filename,selfile,ctrlword,*figure); |
139 |
// |
140 |
// Pop up the GUI |
141 |
// |
142 |
PAMevcontrol *pamgui = 0; |
143 |
// |
144 |
pamgui = new PAMevcontrol(gClient->GetRoot(),400,800,pamela->var,pamela->level,*figure); |
145 |
popup = true; |
146 |
pamela->SetGUIPtr(*pamgui); |
147 |
if ( outDir == "" ) outDir = startingdir; |
148 |
// |
149 |
TTree *otr0 = 0; |
150 |
TTree *otr1 = 0; |
151 |
TTree *otr2 = 0; |
152 |
TTree *otr3 = 0; |
153 |
TTree *otr4 = 0; |
154 |
TTree *otr5 = 0; |
155 |
TTree *otr6 = 0; |
156 |
TTree *otr7 = 0; |
157 |
TTree *otr8 = 0; |
158 |
// |
159 |
pamela->var.fl0 = false; |
160 |
Int_t i = 0; |
161 |
Int_t isOK = 0; |
162 |
// |
163 |
restart: |
164 |
// |
165 |
// set boolean variables |
166 |
// |
167 |
pamela->var.restart = false; |
168 |
pamela->var.waitforever = false; |
169 |
pamela->var.jumprog = true; |
170 |
pamela->var.jumpen = false; |
171 |
pamela->var.goon = false; |
172 |
pamela->var.refresh = false; |
173 |
pamela->var.alrforc = false; |
174 |
// |
175 |
// check if we have an input filename |
176 |
// |
177 |
if ( filename.Data() == "" || !strcmp(filename.Data(),"help") ){ |
178 |
pamela->var.waitforever = true; |
179 |
}; |
180 |
// |
181 |
// chek if we are forcing level0 |
182 |
// |
183 |
if ( pamela->var.fl0 == true ){ |
184 |
FORCELEV = 0; |
185 |
} else { |
186 |
FORCELEV = -1; |
187 |
}; |
188 |
// |
189 |
// Define some variables |
190 |
// |
191 |
pamela->var.bw = 0; |
192 |
pamela->var.xxvc = 0.20; |
193 |
pamela->var.yxvc = 0.44; |
194 |
pamela->var.xyvc = 0.815; |
195 |
pamela->var.yyvc = 0.44; |
196 |
pamela->var.sfx = 0.81/winrap; |
197 |
pamela->var.sfy = 0.81; |
198 |
pamela->var.nds4 = pamela->var.sfx; |
199 |
pamela->var.xcat = 0.515; |
200 |
pamela->var.ycat = 0.74; |
201 |
pamela->var.tracknds4 = 1; |
202 |
figure->Range(0.,0.,1.,1.); |
203 |
gStyle->SetOptDate(0); |
204 |
gStyle->SetOptStat(0); |
205 |
gStyle->SetLabelSize(0); |
206 |
gStyle->SetNdivisions(1,"X"); |
207 |
gStyle->SetNdivisions(1,"Y"); |
208 |
// |
209 |
if ( i < 0 ){ |
210 |
i = -i; |
211 |
} else { |
212 |
i = 0; |
213 |
}; |
214 |
isOK = 0; |
215 |
// |
216 |
// from here to refresh |
217 |
// |
218 |
refresh: |
219 |
// |
220 |
// reset pointers |
221 |
// |
222 |
TFile *headerFile = 0; |
223 |
TChain *otr = 0; |
224 |
TTree *L0 = 0; |
225 |
// |
226 |
// gROOT->Reset(); |
227 |
// |
228 |
// set selection file variables |
229 |
// |
230 |
if ( pamela->var.refresh ){ |
231 |
if ( pamela->var.selex ){ |
232 |
// pamela->var.selex = true; //<<<<<<<<<<<<<<<<<<<<<<<<<<????????????????????? |
233 |
selfile = pamela->var.thefilter.Data(); |
234 |
}; |
235 |
}; |
236 |
// |
237 |
// |
238 |
// if ( pamela->var.fl0 == true ) { |
239 |
// FORCELEV = 0; |
240 |
// } else { |
241 |
// if ( pamela->var.refresh ) FORCELEV = -1; //<<<<<<<<<<<<<<<<<<<<<<<<<<????????????????????? |
242 |
// }; |
243 |
// |
244 |
// check the detectors to be shown |
245 |
// |
246 |
// if ( !pamela->var.refresh ) pamela->checkctrlword(); |
247 |
//pamela->checkctrlword(); |
248 |
// |
249 |
// open a dialog if the program is launched without input filename |
250 |
// |
251 |
if ( firsttime ){ |
252 |
firsttime = false; |
253 |
if ( filename == "" ) pamgui->DIALOG(0," Insert the filename and press load to start "); |
254 |
}; |
255 |
// |
256 |
// WAIT for an input filename |
257 |
// |
258 |
while( pamela->var.waitforever ) { |
259 |
if ( !gROOT->GetListOfCanvases()->FindObject(figure) ) { |
260 |
pamgui->Terminate(); |
261 |
}; |
262 |
gSystem->ProcessEvents(); |
263 |
gSystem->Sleep(10); |
264 |
}; |
265 |
// |
266 |
if ( pamela->var.restart ){ |
267 |
filename = pamela->var.thefilename.Data(); |
268 |
goto restart; |
269 |
}; |
270 |
// |
271 |
// check if we are forcing level0 data |
272 |
// |
273 |
if ( FORCELEV != -1 ) { |
274 |
printf("\n WARNING: FORCING LEVEL%i DATA \n\n",FORCELEV); |
275 |
if ( !pamela->var.alrforc ) { |
276 |
pamgui->DIALOG(1," Forcing LEVEL0 data "); |
277 |
pamela->var.alrforc = true; |
278 |
}; |
279 |
}; |
280 |
// |
281 |
// LOAD SELECTION FILE |
282 |
// |
283 |
if ( selfile == "" ){ |
284 |
//if ( !pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded "); |
285 |
if ( pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded "); |
286 |
pamela->var.selex = false; |
287 |
} else { |
288 |
// |
289 |
// determine where to find the headers |
290 |
// |
291 |
gROOT->Reset(); |
292 |
stringstream paminc; |
293 |
paminc.str(""); |
294 |
const char *testinc = pathtoinclude(); |
295 |
paminc << testinc; |
296 |
// |
297 |
stringstream carica; |
298 |
// |
299 |
// load the structure header |
300 |
// |
301 |
carica.str(""); |
302 |
carica << paminc.str().c_str() << "/feventvstruct.h"; |
303 |
gROOT->LoadMacro(carica.str().c_str()); |
304 |
// carica.str(""); |
305 |
// carica << paminc.str().c_str() << "/CaloNuclei.h"; |
306 |
// gROOT->LoadMacro(carica.str().c_str()); |
307 |
// |
308 |
// load the selection macro |
309 |
// |
310 |
Int_t chkload = gROOT->LoadMacro(selfile); |
311 |
// |
312 |
pamela->var.selex = false; |
313 |
// |
314 |
if ( chkload ){ |
315 |
// |
316 |
// not able to open the selection file |
317 |
// |
318 |
stringstream dialog; |
319 |
dialog.str(""); |
320 |
dialog << pamela->var.thefilter.Data(); |
321 |
dialog << " : no such file!"; |
322 |
pamgui->DIALOG(2,dialog.str().c_str()); |
323 |
printf("\n\n ERROR! cannot read the selection file you give me as input! \n"); |
324 |
pamela->var.selex = false; |
325 |
printf("\n WARNING! no selection file loaded! \n\n"); |
326 |
pamgui->DIALOG(1," No selection file loaded! "); |
327 |
selfile = ""; |
328 |
// |
329 |
// clear field in the GUI |
330 |
// |
331 |
pamgui->clearselfi(); |
332 |
} else { |
333 |
// |
334 |
// ok, selection file loaded |
335 |
// |
336 |
printf("\n\n Selection file loaded \n\n The first event will be shown anyway. \n\n"); |
337 |
// |
338 |
if ( !pamela->var.selex ) pamgui->DIALOG(0," Selection file successfully loaded "); |
339 |
// |
340 |
pamela->var.selex = true; |
341 |
}; |
342 |
}; |
343 |
// |
344 |
// LOAD FILES |
345 |
// |
346 |
// |
347 |
// if ( headerFile ) headerFile->Close(); |
348 |
// if ( otr ) otr->Delete(); |
349 |
// if ( L0 ) L0->Delete(); |
350 |
|
351 |
// |
352 |
// check if user has given as input a correct path |
353 |
// |
354 |
ifstream myfile; |
355 |
myfile.open(filename.Data()); |
356 |
if ( !myfile ){ |
357 |
if ( filename != "" ){ |
358 |
printf("ERROR: no such file, exiting...\n"); |
359 |
stringstream hfile; |
360 |
hfile.str(""); |
361 |
hfile << filename.Data(); |
362 |
hfile << " : no such file! "; |
363 |
pamgui->DIALOG(2,hfile.str().c_str()); |
364 |
}; |
365 |
pamela->var.waitforever = true; |
366 |
goto refresh; |
367 |
}; |
368 |
myfile.close(); |
369 |
// |
370 |
// ok, open file and determine if it is a YODA or DARTHVADER file |
371 |
// |
372 |
headerFile=new TFile(filename.Data()); |
373 |
if ( FORCELEV == 0 ){ |
374 |
pamela->level.file = 0; |
375 |
L0 = (TTree*)headerFile->Get("Physics"); |
376 |
if ( !L0 ){ |
377 |
printf("ERROR: no Physics tree...\n"); |
378 |
pamgui->DIALOG(2,"No Physics tree in this file"); |
379 |
pamela->var.waitforever = true; |
380 |
goto refresh; |
381 |
} |
382 |
} else { |
383 |
pamela->level.file = 2; |
384 |
otr0 = (TTree*)headerFile->Get("Trigger"); |
385 |
otr1 = (TTree*)headerFile->Get("Calorimeter"); |
386 |
otr2 = (TTree*)headerFile->Get("Tracker"); |
387 |
otr3 = (TTree*)headerFile->Get("NeutronD"); |
388 |
otr4 = (TTree*)headerFile->Get("OrbitalInfo"); |
389 |
otr5 = (TTree*)headerFile->Get("S4"); |
390 |
otr6 = (TTree*)headerFile->Get("ToF"); |
391 |
otr7 = (TTree*)headerFile->Get("Run"); |
392 |
otr8 = (TTree*)headerFile->Get("Anticounter"); |
393 |
if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 ){ |
394 |
L0 = (TTree*)headerFile->Get("Physics"); |
395 |
pamela->level.file = -1; |
396 |
} else { |
397 |
stringstream dddec; |
398 |
dddec.str(""); |
399 |
dddec << " +ALL +RUN +CAL1 -TRKh -TRK1 "; |
400 |
if ( !otr0 ){ |
401 |
dddec << " -TRG "; |
402 |
pamela->var.TRG = 0; |
403 |
otr0 = otr1; |
404 |
}; |
405 |
if ( !otr1 ){ |
406 |
dddec << " -CAL "; |
407 |
pamela->var.CALO = 0; |
408 |
if ( !otr0 ) otr0 = otr2; |
409 |
}; |
410 |
if ( !otr2 ){ |
411 |
dddec << " -TRK2 -TRK "; |
412 |
pamela->var.TRK = 0; |
413 |
if ( !otr0 ) otr0 = otr3; |
414 |
}; |
415 |
if ( !otr3 ){ |
416 |
dddec << " -ND "; |
417 |
pamela->var.ND = 0; |
418 |
if ( !otr0 ) otr0 = otr4; |
419 |
}; |
420 |
if ( !otr4 ){ |
421 |
dddec << " -ORB "; |
422 |
pamela->var.ORB = 0; |
423 |
if ( !otr0 ) otr0 = otr5; |
424 |
}; |
425 |
if ( !otr5 ){ |
426 |
dddec << " -S4 "; |
427 |
pamela->var.S4 = 0; |
428 |
if ( !otr0 ) otr0 = otr6; |
429 |
}; |
430 |
if ( !otr6 ){ |
431 |
dddec << " -TOF "; |
432 |
pamela->var.TOF = 0; |
433 |
if ( !otr0 ) otr0 = otr8; |
434 |
}; |
435 |
if ( !otr7 ){ |
436 |
dddec << " -RUN "; |
437 |
pamela->var.RUN = 0; |
438 |
}; |
439 |
if ( !otr8 ){ |
440 |
dddec << " -AC "; |
441 |
pamela->var.AC = 0; |
442 |
}; |
443 |
pamela->SetDDEC(dddec.str().c_str()); |
444 |
}; |
445 |
if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 && !L0 ){ |
446 |
pamela->level.file = -1; |
447 |
printf("ERROR: nor Physics nor Run tree...\n"); |
448 |
pamgui->DIALOG(2,"Nor Physics nor Run tree in this file"); |
449 |
pamela->var.waitforever = true; |
450 |
goto refresh; |
451 |
}; |
452 |
}; |
453 |
// |
454 |
if ( pamela->level.file != 2 ){ |
455 |
printf(" This is a YODA (level0) file \n"); |
456 |
} else { |
457 |
printf(" This is a DARTHVADER (level2) file \n"); |
458 |
}; |
459 |
// |
460 |
// Disable on the GUI the buttons that cannot be used with this file |
461 |
// |
462 |
pamgui->CheckLevel(); |
463 |
// |
464 |
// Load the file |
465 |
// |
466 |
if ( otr0 || L0 ){ |
467 |
otr = pamela->Load(*headerFile); |
468 |
if ( !otr ){ |
469 |
pamela->level.file = -1; |
470 |
printf("ERROR: problems opening file...\n"); |
471 |
pamgui->DIALOG(2,"Problems opening file"); |
472 |
pamela->var.waitforever = true; |
473 |
goto refresh; |
474 |
}; |
475 |
} else { |
476 |
pamela->level.file = -1; |
477 |
printf("ERROR: problems with TTree while opening file...\n"); |
478 |
pamgui->DIALOG(2,"Problems opening file"); |
479 |
pamela->var.waitforever = true; |
480 |
goto refresh; |
481 |
}; |
482 |
// |
483 |
printf("\n"); |
484 |
// |
485 |
// get the number of entries |
486 |
// |
487 |
// otr = pamela->GetChain(); |
488 |
if ( !otr ) printf(" AGH! \n"); |
489 |
// |
490 |
Long64_t nevents = otr->GetEntries(); |
491 |
printf(" The file contains %i physics events \n",(int)nevents); |
492 |
// |
493 |
// check we have at least one event |
494 |
// |
495 |
if (nevents<=0) { |
496 |
headerFile->Close(); |
497 |
printf("The file is empty, exiting...\n"); |
498 |
pamgui->DIALOG(0," The file contains no physics data! "); |
499 |
pamela->var.waitforever = true; |
500 |
goto refresh; |
501 |
} |
502 |
// |
503 |
// Check that given input are inside the boundary conditions |
504 |
// |
505 |
pamela->minevent = 0; |
506 |
pamela->maxevent = nevents - 1; |
507 |
// |
508 |
// Determine the boundaries |
509 |
// |
510 |
pamela->GetWindow(); |
511 |
Int_t lastevno = pamela->lastevno; |
512 |
Int_t firstevno = pamela->firstevno; |
513 |
// |
514 |
// display the first event (unless we are refreshing only the window) |
515 |
// |
516 |
if ( !pamela->var.refresh ) i = pamela->minevent; |
517 |
pamela->var.refresh = false; |
518 |
// |
519 |
pamgui->RefreshButtons(); |
520 |
// |
521 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
522 |
// MAIN LOOP STARTS HERE: |
523 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
524 |
// |
525 |
while ( 1 ){ |
526 |
// |
527 |
// update progress bar |
528 |
// |
529 |
if ( popup ) pamgui->increment((float)(i+1)*100./(float)nevents); |
530 |
// |
531 |
// clear canvas and variables |
532 |
// |
533 |
pamela->ClearVariables(); |
534 |
// |
535 |
// get entry i |
536 |
// |
537 |
pamela->GetEntry(i); |
538 |
// |
539 |
// call the filter to select events (if filter file is given) |
540 |
// |
541 |
isOK = pamela->SelectEvent(); |
542 |
// |
543 |
// if the event is selected go on |
544 |
// |
545 |
if ( isOK ) { |
546 |
// |
547 |
// reset working variables |
548 |
// |
549 |
printf("\n\n\n\n\n\n\n\n\n\n"); |
550 |
pamela->SetEntry(i); |
551 |
pamela->si = i; |
552 |
pamela->var.doflag = 1; |
553 |
pamela->var.i = i; |
554 |
pamela->var.nevents = nevents; |
555 |
pamela->var.lastevno = lastevno; |
556 |
pamela->var.firstevno = firstevno; |
557 |
// |
558 |
printf("\n"); |
559 |
// |
560 |
// disable "stop" button in the GUI |
561 |
// |
562 |
pamgui->StopSearching(); |
563 |
// |
564 |
// make the canvas editable and clear it |
565 |
// |
566 |
figure->SetEditable(kTRUE); |
567 |
figure->Clear(); |
568 |
figure->SetFillColor(10); |
569 |
figure->cd(); |
570 |
// |
571 |
// retrieve general info for the event (OBT, pkt_num, etc. etc.) |
572 |
// |
573 |
pamela->GetGeneralInfo(); |
574 |
// |
575 |
// display the event |
576 |
// |
577 |
pamela->DisplayEvent(); |
578 |
// |
579 |
// prepare the string for the figure filename |
580 |
// |
581 |
char *bw; |
582 |
if ( pamela->var.bw ){ |
583 |
bw = "_bw"; |
584 |
} else { |
585 |
bw = ""; |
586 |
}; |
587 |
TString filenm = pamela->var.thefilename; |
588 |
const string fil = gSystem->BaseName(filenm.Data()); |
589 |
Int_t posiz = fil.find(".root"); |
590 |
TString file2; |
591 |
if ( posiz == -1 ){ |
592 |
file2 = gSystem->BaseName(filename.Data()); |
593 |
} else { |
594 |
Int_t posiz2 = 0; |
595 |
stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz); |
596 |
}; |
597 |
const char *figrec = file2; |
598 |
const char *outdir = outDir; |
599 |
stringstream figsave; |
600 |
figsave.str(""); |
601 |
figsave << outdir << "/"; |
602 |
figsave << figrec; |
603 |
figsave << "_ev_"; |
604 |
figsave << (pamela->var.i+1); |
605 |
figsave << bw; |
606 |
pamela->var.svas=figsave.str().c_str(); |
607 |
|
608 |
// printf(" qua %s \n",figsave.str().c_str()); |
609 |
// |
610 |
// upgrade the figure filename in the GUI |
611 |
// |
612 |
pamgui->upgrnamfi(); |
613 |
// |
614 |
// WAIT for user input |
615 |
// |
616 |
pamela->var.jumpen = false; |
617 |
while( !pamela->var.goon && !pamela->var.refresh && !pamela->var.restart ) { |
618 |
if ( !gROOT->GetListOfCanvases()->FindObject(figure) ) { |
619 |
pamgui->Terminate(); |
620 |
}; |
621 |
gSystem->ProcessEvents(); |
622 |
gSystem->Sleep(10); |
623 |
}; |
624 |
// |
625 |
// interpret user input |
626 |
// |
627 |
pamela->var.goon = false; |
628 |
if ( pamela->var.refresh || pamela->var.restart ){ |
629 |
if ( pamela->GetL2() ) pamela->GetL2()->Reset(); |
630 |
if ( pamela->level.file != 2 ) pamela->GetChain()->Delete(); |
631 |
otr = NULL; |
632 |
if ( headerFile ) headerFile->Close("R"); |
633 |
if ( pamela->var.refresh ) goto refresh; |
634 |
if ( pamela->var.restart ){ |
635 |
filename = pamela->var.thefilename.Data(); |
636 |
goto restart; |
637 |
}; |
638 |
}; |
639 |
// |
640 |
i = pamela->var.i; |
641 |
if ( i != pamela->si ) pamela->OOBT = 1000000000; |
642 |
if ( pamela->maxevent < i ) { |
643 |
pamela->maxevent = nevents; |
644 |
printf("WARNING: you have chosen an event number out of the starting range.\n Range extended to %i\n\n",pamela->maxevent); |
645 |
}; |
646 |
// |
647 |
}; |
648 |
// |
649 |
// if the returned entry is -1 it means we must start again from the first event going forward (doflag=1) |
650 |
// |
651 |
if ( pamela->GetThisEntry() == -1 ){ |
652 |
pamela->var.doflag = 1; |
653 |
i = pamela->minevent; |
654 |
}; |
655 |
// |
656 |
// doflag = 2 means "go backward" (check for lower boundary) |
657 |
// |
658 |
if ( pamela->var.doflag == 2 && i == 0 ) { |
659 |
printf("\n WARNING: Cannot go backward! Going forward. \n"); |
660 |
pamela->var.doflag = 1; |
661 |
}; |
662 |
if ( pamela->var.doflag == 2 && i>0 ) i--; |
663 |
// |
664 |
// doflag = 1 means go forward (the check on the upper boundary is made in FEVpamevcontrol) |
665 |
// |
666 |
if ( pamela->var.doflag == 1 ) i++; |
667 |
// |
668 |
// if in selection mode, print out a event progress bar in the text window: |
669 |
// |
670 |
if ( !pamela->var.selex || i == pamela->minevent ){ |
671 |
// do nothing |
672 |
} else { |
673 |
if ( (pamela->maxevent-pamela->minevent) != 0 ){ |
674 |
if((100*(i-pamela->minevent)/(pamela->maxevent-pamela->minevent))<10.){ |
675 |
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8); |
676 |
} else { |
677 |
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8); |
678 |
}; |
679 |
}; |
680 |
}; |
681 |
|
682 |
}; |
683 |
// |
684 |
// END OF THE MAIN LOOP AND OF THE MAIN PROGRAM |
685 |
// |
686 |
printf("\n"); |
687 |
printf(" ...done! \n\n"); |
688 |
return; |
689 |
} |