/[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.20 - (hide annotations) (download)
Fri Apr 23 10:33:12 2010 UTC (14 years, 10 months ago) by mocchiut
Branch: MAIN
CVS Tags: v10REDr01, v10RED, HEAD
Changes since 1.19: +13 -0 lines
9red special feature

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

  ViewVC Help
Powered by ViewVC 1.1.23