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