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