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