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