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