/[PAMELA software]/eventviewer/flight/src/FEventViewerCore.cpp
ViewVC logotype

Annotation of /eventviewer/flight/src/FEventViewerCore.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (hide annotations) (download)
Mon Jun 22 09:30:02 2009 UTC (15 years, 8 months ago) by mocchiut
Branch: MAIN
Changes since 1.15: +7 -3 lines
Possible bug in TRK cluster visualization fixed, new transient windows appearance

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

  ViewVC Help
Powered by ViewVC 1.1.23