1 |
mocchiut |
1.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 |
|
|
if ( !popup ) { |
145 |
|
|
pamgui = new PAMevcontrol(gClient->GetRoot(),400,800,pamela->var,pamela->level,*figure); |
146 |
|
|
popup = true; |
147 |
|
|
pamela->SetGUIPtr(*pamgui); |
148 |
|
|
}; |
149 |
|
|
// |
150 |
|
|
restart: |
151 |
|
|
// |
152 |
|
|
// set boolean variables |
153 |
|
|
// |
154 |
|
|
pamela->var.restart = false; |
155 |
|
|
pamela->var.waitforever = false; |
156 |
|
|
pamela->var.jumprog = true; |
157 |
|
|
pamela->var.jumpen = false; |
158 |
|
|
pamela->var.goon = false; |
159 |
|
|
pamela->var.refresh = false; |
160 |
|
|
pamela->var.fl0 = false; |
161 |
|
|
pamela->var.alrforc = false; |
162 |
|
|
// |
163 |
|
|
// check if we have an input filename |
164 |
|
|
// |
165 |
|
|
if ( filename.Data() == "" || !strcmp(filename.Data(),"help") ){ |
166 |
|
|
pamela->var.waitforever = true; |
167 |
|
|
}; |
168 |
|
|
// |
169 |
|
|
// chek if we are forcing level0 |
170 |
|
|
// |
171 |
|
|
if ( pamela->var.fl0 == true ){ |
172 |
|
|
FORCELEV = 0; |
173 |
|
|
} else { |
174 |
|
|
FORCELEV = -1; |
175 |
|
|
}; |
176 |
|
|
// |
177 |
|
|
// Define some variables |
178 |
|
|
// |
179 |
|
|
pamela->var.bw = 0; |
180 |
|
|
pamela->var.xxvc = 0.20; |
181 |
|
|
pamela->var.yxvc = 0.44; |
182 |
|
|
pamela->var.xyvc = 0.815; |
183 |
|
|
pamela->var.yyvc = 0.44; |
184 |
|
|
pamela->var.sfx = 0.81/winrap; |
185 |
|
|
pamela->var.sfy = 0.81; |
186 |
|
|
pamela->var.nds4 = pamela->var.sfx; |
187 |
|
|
pamela->var.xcat = 0.515; |
188 |
|
|
pamela->var.ycat = 0.74; |
189 |
|
|
pamela->var.tracknds4 = 1; |
190 |
|
|
figure->Range(0.,0.,1.,1.); |
191 |
|
|
gStyle->SetOptDate(0); |
192 |
|
|
gStyle->SetOptStat(0); |
193 |
|
|
gStyle->SetLabelSize(0); |
194 |
|
|
gStyle->SetNdivisions(1,"X"); |
195 |
|
|
gStyle->SetNdivisions(1,"Y"); |
196 |
|
|
// |
197 |
|
|
Int_t i = 0; |
198 |
|
|
Int_t isOK = 0; |
199 |
|
|
// |
200 |
|
|
// from here to refresh |
201 |
|
|
// |
202 |
|
|
refresh: |
203 |
|
|
// |
204 |
|
|
// set selection file variables |
205 |
|
|
// |
206 |
|
|
pamela->var.selex = true; |
207 |
|
|
selfile = pamela->var.thefilter.Data(); |
208 |
|
|
// |
209 |
|
|
if ( outDir == "" ) outDir = startingdir; |
210 |
|
|
// |
211 |
|
|
if ( pamela->var.fl0 == true ) { |
212 |
|
|
FORCELEV = 0; |
213 |
|
|
} else { |
214 |
|
|
if ( pamela->var.refresh ) FORCELEV = -1; |
215 |
|
|
}; |
216 |
|
|
// |
217 |
|
|
// check the detectors to be shown |
218 |
|
|
// |
219 |
|
|
if ( !pamela->var.refresh ) pamela->checkctrlword(); |
220 |
|
|
// |
221 |
|
|
// open a dialog if the program is launched without input filename |
222 |
|
|
// |
223 |
|
|
if ( firsttime ){ |
224 |
|
|
firsttime = false; |
225 |
|
|
if ( filename == "" ) pamgui->DIALOG(0," Insert the filename and press load to start "); |
226 |
|
|
}; |
227 |
|
|
// |
228 |
|
|
// WAIT for an input filename |
229 |
|
|
// |
230 |
|
|
while( pamela->var.waitforever ) { |
231 |
|
|
if ( !gROOT->GetListOfCanvases()->FindObject(figure) ) { |
232 |
|
|
pamgui->Terminate(); |
233 |
|
|
}; |
234 |
|
|
gSystem->ProcessEvents(); |
235 |
|
|
gSystem->Sleep(10); |
236 |
|
|
}; |
237 |
|
|
// |
238 |
|
|
if ( pamela->var.restart ){ |
239 |
|
|
filename = pamela->var.thefilename.Data(); |
240 |
|
|
goto restart; |
241 |
|
|
}; |
242 |
|
|
// |
243 |
|
|
// check if we are forcing level0 data |
244 |
|
|
// |
245 |
|
|
if ( FORCELEV != -1 ) { |
246 |
|
|
printf("\n WARNING: FORCING LEVEL%i DATA \n\n",FORCELEV); |
247 |
|
|
if ( !pamela->var.alrforc ) { |
248 |
|
|
pamgui->DIALOG(1," Forcing LEVEL0 data "); |
249 |
|
|
pamela->var.alrforc = true; |
250 |
|
|
}; |
251 |
|
|
}; |
252 |
|
|
// |
253 |
|
|
// LOAD SELECTION FILE |
254 |
|
|
// |
255 |
|
|
if ( selfile == "" ){ |
256 |
|
|
if ( !pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded "); |
257 |
|
|
pamela->var.selex = false; |
258 |
|
|
} else { |
259 |
|
|
// |
260 |
|
|
// determine where to find the headers |
261 |
|
|
// |
262 |
|
|
gROOT->Reset(); |
263 |
|
|
stringstream paminc; |
264 |
|
|
paminc.str(""); |
265 |
|
|
const char *testinc = pathtoinclude(); |
266 |
|
|
paminc << testinc; |
267 |
|
|
// |
268 |
|
|
stringstream carica; |
269 |
|
|
// |
270 |
|
|
// load the structure header |
271 |
|
|
// |
272 |
|
|
carica.str(""); |
273 |
|
|
carica << paminc.str().c_str() << "/feventvstruct.h"; |
274 |
|
|
gROOT->LoadMacro(carica.str().c_str()); |
275 |
|
|
// |
276 |
|
|
// load the selection macro |
277 |
|
|
// |
278 |
|
|
Int_t chkload = gROOT->LoadMacro(selfile); |
279 |
|
|
// |
280 |
|
|
if ( chkload ){ |
281 |
|
|
// |
282 |
|
|
// not able to open the selection file |
283 |
|
|
// |
284 |
|
|
stringstream dialog; |
285 |
|
|
dialog.str(""); |
286 |
|
|
dialog << pamela->var.thefilter.Data(); |
287 |
|
|
dialog << " : no such file!"; |
288 |
|
|
pamgui->DIALOG(2,dialog.str().c_str()); |
289 |
|
|
printf("\n\n ERROR! cannot read the selection file you give me as input! \n"); |
290 |
|
|
pamela->var.selex = false; |
291 |
|
|
printf("\n WARNING! no selection file loaded! \n\n"); |
292 |
|
|
pamgui->DIALOG(1," No selection file loaded! "); |
293 |
|
|
// |
294 |
|
|
// clear field in the GUI |
295 |
|
|
// |
296 |
|
|
pamgui->clearselfi(); |
297 |
|
|
} else { |
298 |
|
|
// |
299 |
|
|
// ok, selection file loaded |
300 |
|
|
// |
301 |
|
|
printf("\n\n Selection file loaded \n\n The first event will be shown anyway. \n\n"); |
302 |
|
|
// |
303 |
|
|
if ( !pamela->var.selex ) pamgui->DIALOG(0," Selection file successfully loaded "); |
304 |
|
|
// |
305 |
|
|
pamela->var.selex = true; |
306 |
|
|
}; |
307 |
|
|
}; |
308 |
|
|
// |
309 |
|
|
// LOAD FILES |
310 |
|
|
// |
311 |
|
|
// |
312 |
|
|
TFile *headerFile = 0; |
313 |
|
|
TTree *otr = 0; |
314 |
|
|
// |
315 |
|
|
// check if user has given as input a correct path |
316 |
|
|
// |
317 |
|
|
ifstream myfile; |
318 |
|
|
myfile.open(filename.Data()); |
319 |
|
|
if ( !myfile ){ |
320 |
|
|
printf("ERROR: no such file, exiting...\n"); |
321 |
|
|
stringstream hfile; |
322 |
|
|
hfile.str(""); |
323 |
|
|
hfile << filename.Data(); |
324 |
|
|
hfile << " : no such file! "; |
325 |
|
|
pamgui->DIALOG(2,hfile.str().c_str()); |
326 |
|
|
pamela->var.waitforever = true; |
327 |
|
|
goto refresh; |
328 |
|
|
}; |
329 |
|
|
myfile.close(); |
330 |
|
|
// |
331 |
|
|
// ok, open file and determine if it is a YODA or DARTHVADER file |
332 |
|
|
// |
333 |
|
|
headerFile=new TFile(filename.Data()); |
334 |
|
|
if ( FORCELEV == 0 ){ |
335 |
|
|
pamela->level.file = 0; |
336 |
|
|
otr = (TTree*)headerFile->Get("Physics"); |
337 |
|
|
if ( !otr ){ |
338 |
|
|
printf("ERROR: no Physics tree...\n"); |
339 |
|
|
pamgui->DIALOG(2,"No Physics tree in this file"); |
340 |
|
|
pamela->var.waitforever = true; |
341 |
|
|
goto refresh; |
342 |
|
|
} |
343 |
|
|
} else { |
344 |
|
|
pamela->level.file = 2; |
345 |
|
|
otr = (TTree*)headerFile->Get("Trigger"); |
346 |
|
|
if ( !otr ){ |
347 |
|
|
otr = (TTree*)headerFile->Get("Physics"); |
348 |
|
|
pamela->level.file = -1; |
349 |
|
|
}; |
350 |
|
|
if ( !otr ){ |
351 |
|
|
pamela->level.file = -1; |
352 |
|
|
printf("ERROR: nor Physics nor Run tree...\n"); |
353 |
|
|
pamgui->DIALOG(2,"Nor Physics nor Run tree in this file"); |
354 |
|
|
pamela->var.waitforever = true; |
355 |
|
|
goto refresh; |
356 |
|
|
}; |
357 |
|
|
}; |
358 |
|
|
// |
359 |
|
|
if ( pamela->level.file != 2 ){ |
360 |
|
|
printf(" This is a YODA (level0) file \n"); |
361 |
|
|
} else { |
362 |
|
|
printf(" This is a DARTHVADER (level2) file \n"); |
363 |
|
|
}; |
364 |
|
|
// |
365 |
|
|
// Disable on the GUI the buttons that cannot be used with this file |
366 |
|
|
// |
367 |
|
|
pamgui->CheckLevel(); |
368 |
|
|
// |
369 |
|
|
// Load the file |
370 |
|
|
// |
371 |
|
|
pamela->Load(*otr,*headerFile); |
372 |
|
|
// |
373 |
|
|
printf("\n"); |
374 |
|
|
// |
375 |
|
|
// get the number of entries |
376 |
|
|
// |
377 |
|
|
Long64_t nevents = otr->GetEntries(); |
378 |
|
|
printf(" The file contains %i physics events \n",(int)nevents); |
379 |
|
|
// |
380 |
|
|
// check we have at least one event |
381 |
|
|
// |
382 |
|
|
if (nevents<=0) { |
383 |
|
|
headerFile->Close(); |
384 |
|
|
printf("The file is empty, exiting...\n"); |
385 |
|
|
pamgui->DIALOG(0," The file contains no physics data! "); |
386 |
|
|
pamela->var.waitforever = true; |
387 |
|
|
goto refresh; |
388 |
|
|
} |
389 |
|
|
// |
390 |
|
|
// Check that given input are inside the boundary conditions |
391 |
|
|
// |
392 |
|
|
pamela->minevent = 0; |
393 |
|
|
pamela->maxevent = nevents - 1; |
394 |
|
|
// |
395 |
|
|
// Determine the boundaries |
396 |
|
|
// |
397 |
|
|
pamela->GetWindow(); |
398 |
|
|
Int_t lastevno = pamela->lastevno; |
399 |
|
|
Int_t firstevno = pamela->firstevno; |
400 |
|
|
// |
401 |
|
|
// display the first event (unless we are refreshing only the window) |
402 |
|
|
// |
403 |
|
|
if ( !pamela->var.refresh ) i = pamela->minevent; |
404 |
|
|
pamela->var.refresh = false; |
405 |
|
|
// |
406 |
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
407 |
|
|
// MAIN LOOP STARTS HERE: |
408 |
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
409 |
|
|
// |
410 |
|
|
while ( 1 ){ |
411 |
|
|
// |
412 |
|
|
// update progress bar |
413 |
|
|
// |
414 |
|
|
if ( popup ) pamgui->increment((float)(i+1)*100./(float)nevents); |
415 |
|
|
// |
416 |
|
|
// clear canvas and variables |
417 |
|
|
// |
418 |
|
|
pamela->ClearVariables(); |
419 |
|
|
// |
420 |
|
|
// get entry i |
421 |
|
|
// |
422 |
|
|
pamela->GetEntry(i); |
423 |
|
|
// |
424 |
|
|
// call the filter to select events (if filter file is given) |
425 |
|
|
// |
426 |
|
|
isOK = pamela->SelectEvent(); |
427 |
|
|
// |
428 |
|
|
// if the event is selected go on |
429 |
|
|
// |
430 |
|
|
if ( isOK ) { |
431 |
|
|
// |
432 |
|
|
// reset working variables |
433 |
|
|
// |
434 |
|
|
printf("\n\n\n\n\n\n\n\n\n\n"); |
435 |
|
|
pamela->SetEntry(i); |
436 |
|
|
pamela->si = i; |
437 |
|
|
pamela->var.doflag = 1; |
438 |
|
|
pamela->var.i = i; |
439 |
|
|
pamela->var.nevents = nevents; |
440 |
|
|
pamela->var.lastevno = lastevno; |
441 |
|
|
pamela->var.firstevno = firstevno; |
442 |
|
|
// |
443 |
|
|
printf("\n"); |
444 |
|
|
// |
445 |
|
|
// disable "stop" button in the GUI |
446 |
|
|
// |
447 |
|
|
pamgui->StopSearching(); |
448 |
|
|
// |
449 |
|
|
// make the canvas editable and clear it |
450 |
|
|
// |
451 |
|
|
figure->SetEditable(kTRUE); |
452 |
|
|
figure->Clear(); |
453 |
|
|
figure->SetFillColor(10); |
454 |
|
|
figure->cd(); |
455 |
|
|
// |
456 |
|
|
// retrieve general info for the event (OBT, pkt_num, etc. etc.) |
457 |
|
|
// |
458 |
|
|
pamela->GetGeneralInfo(); |
459 |
|
|
// |
460 |
|
|
// display the event |
461 |
|
|
// |
462 |
|
|
pamela->DisplayEvent(); |
463 |
|
|
// |
464 |
|
|
// prepare the string for the figure filename |
465 |
|
|
// |
466 |
|
|
char *bw; |
467 |
|
|
if ( pamela->var.bw ){ |
468 |
|
|
bw = "_bw"; |
469 |
|
|
} else { |
470 |
|
|
bw = ""; |
471 |
|
|
}; |
472 |
|
|
TString filenm = pamela->var.thefilename; |
473 |
|
|
const string fil = gSystem->BaseName(filenm.Data()); |
474 |
|
|
Int_t posiz = fil.find(".root"); |
475 |
|
|
TString file2; |
476 |
|
|
if ( posiz == -1 ){ |
477 |
|
|
file2 = gSystem->BaseName(filename.Data()); |
478 |
|
|
} else { |
479 |
|
|
Int_t posiz2 = 0; |
480 |
|
|
stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz); |
481 |
|
|
}; |
482 |
|
|
const char *figrec = file2; |
483 |
|
|
const char *outdir = outDir; |
484 |
|
|
stringstream figsave; |
485 |
|
|
figsave.str(""); |
486 |
|
|
figsave << outdir << "/"; |
487 |
|
|
figsave << figrec; |
488 |
|
|
figsave << "_ev_"; |
489 |
|
|
figsave << (pamela->var.i+1); |
490 |
|
|
figsave << bw; |
491 |
|
|
pamela->var.svas=figsave.str().c_str(); |
492 |
|
|
// |
493 |
|
|
// upgrade the figure filename in the GUI |
494 |
|
|
// |
495 |
|
|
pamgui->upgrnamfi(); |
496 |
|
|
// |
497 |
|
|
// WAIT for user input |
498 |
|
|
// |
499 |
|
|
pamela->var.jumpen = false; |
500 |
|
|
while( !pamela->var.goon && !pamela->var.refresh && !pamela->var.restart ) { |
501 |
|
|
if ( !gROOT->GetListOfCanvases()->FindObject(figure) ) { |
502 |
|
|
pamgui->Terminate(); |
503 |
|
|
}; |
504 |
|
|
gSystem->ProcessEvents(); |
505 |
|
|
gSystem->Sleep(10); |
506 |
|
|
}; |
507 |
|
|
// |
508 |
|
|
// interpret user input |
509 |
|
|
// |
510 |
|
|
pamela->var.goon = false; |
511 |
|
|
if ( pamela->var.refresh || pamela->var.restart ){ |
512 |
|
|
headerFile->Close(); |
513 |
|
|
if ( pamela->var.refresh ) goto refresh; |
514 |
|
|
if ( pamela->var.restart ){ |
515 |
|
|
filename = pamela->var.thefilename.Data(); |
516 |
|
|
goto restart; |
517 |
|
|
}; |
518 |
|
|
}; |
519 |
|
|
// |
520 |
|
|
i = pamela->var.i; |
521 |
|
|
if ( i != pamela->si ) pamela->OOBT = 1000000000; |
522 |
|
|
if ( pamela->maxevent < i ) { |
523 |
|
|
pamela->maxevent = nevents; |
524 |
|
|
printf("WARNING: you have chosen an event number out of the starting range.\n Range extended to %i\n\n",pamela->maxevent); |
525 |
|
|
}; |
526 |
|
|
// |
527 |
|
|
}; |
528 |
|
|
// |
529 |
|
|
// if the returned entry is -1 it means we must start again from the first event going forward (doflag=1) |
530 |
|
|
// |
531 |
|
|
if ( pamela->GetThisEntry() == -1 ){ |
532 |
|
|
pamela->var.doflag = 1; |
533 |
|
|
i = pamela->minevent; |
534 |
|
|
}; |
535 |
|
|
// |
536 |
|
|
// doflag = 2 means "go backward" (check for lower boundary) |
537 |
|
|
// |
538 |
|
|
if ( pamela->var.doflag == 2 && i == 0 ) { |
539 |
|
|
printf("\n WARNING: Cannot go backward! Going forward. \n"); |
540 |
|
|
pamela->var.doflag = 1; |
541 |
|
|
}; |
542 |
|
|
if ( pamela->var.doflag == 2 && i>0 ) i--; |
543 |
|
|
// |
544 |
|
|
// doflag = 1 means go forward (the check on the upper boundary is made in FEVpamevcontrol) |
545 |
|
|
// |
546 |
|
|
if ( pamela->var.doflag == 1 ) i++; |
547 |
|
|
// |
548 |
|
|
// if in selection mode, print out a event progress bar in the text window: |
549 |
|
|
// |
550 |
|
|
if ( !pamela->var.selex || i == pamela->minevent ){ |
551 |
|
|
// do nothing |
552 |
|
|
} else { |
553 |
|
|
if ( (pamela->maxevent-pamela->minevent) != 0 ){ |
554 |
|
|
if((100*(i-pamela->minevent)/(pamela->maxevent-pamela->minevent))<10.){ |
555 |
|
|
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); |
556 |
|
|
} else { |
557 |
|
|
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); |
558 |
|
|
}; |
559 |
|
|
}; |
560 |
|
|
}; |
561 |
|
|
|
562 |
|
|
}; |
563 |
|
|
// |
564 |
|
|
// END OF THE MAIN LOOP AND OF THE MAIN PROGRAM |
565 |
|
|
// |
566 |
|
|
printf("\n"); |
567 |
|
|
printf(" ...done! \n\n"); |
568 |
|
|
return; |
569 |
|
|
} |