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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mocchiut, Fri Jul 14 14:18:06 2006 UTC revision 1.16 by mocchiut, Mon Jun 22 09:30:02 2009 UTC
# Line 129  void ShowEvent(TString filename="help", Line 129  void ShowEvent(TString filename="help",
129    Float_t winy = (float)hw*0.80; // 95    Float_t winy = (float)hw*0.80; // 95
130    Float_t winrap = winx/winy;    Float_t winrap = winx/winy;
131    //    //
132      //
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      // 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    //  book the canvas    //  book the canvas
169    //    //
170    TCanvas *figure = new TCanvas("PAMELA event viewer", "PAMELA event viewer",(int)winx,(int)winy);    TCanvas *figure = new TCanvas("PAMELA event viewer", "PAMELA event viewer",(int)winx,(int)winy);
# Line 141  void ShowEvent(TString filename="help", Line 177  void ShowEvent(TString filename="help",
177    //    //
178    PAMevcontrol *pamgui = 0;    PAMevcontrol *pamgui = 0;
179    //    //
180    if ( !popup ) {    pamgui = new PAMevcontrol(gClient->GetRoot(),400,800,pamela->var,pamela->level,*figure);
181      pamgui = new PAMevcontrol(gClient->GetRoot(),400,800,pamela->var,pamela->level,*figure);    popup = true;
182      popup = true;    pamela->SetGUIPtr(*pamgui);
183      pamela->SetGUIPtr(*pamgui);    if ( outDir == "" ) outDir = startingdir;    
184    };    //
185      TTree *otr0 = 0;
186      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      pamela->var.restart = false;
197      Int_t i = 0;
198      Int_t isOK = 0;
199    //    //
200   restart:   restart:
201    //    //
202      if ( !pamela->var.restart ){
203        if ( i < 0 ){
204          i = -i;
205        } else {
206          i = 0;
207        };
208      };
209      //
210    // set boolean variables    // set boolean variables
211    //    //
   pamela->var.restart = false;  
212    pamela->var.waitforever = false;    pamela->var.waitforever = false;
213    pamela->var.jumprog = true;    pamela->var.jumprog = true;
214    pamela->var.jumpen = false;        pamela->var.jumpen = false;    
215    pamela->var.goon = false;    pamela->var.goon = false;
216    pamela->var.refresh = false;    pamela->var.refresh = false;
   pamela->var.fl0 = false;  
217    pamela->var.alrforc = false;    pamela->var.alrforc = false;
218    //    //
219    // check if we have an input filename    // check if we have an input filename
220    //    //
221    if ( filename.Data() == "" || !strcmp(filename.Data(),"help") ){    //  if ( filename.Data() == "" || !strcmp(filename.Data(),"help") ){
222      if ( !strcmp(gSystem->BaseName(filename),"") || filename.Contains("help") ){
223      pamela->var.waitforever = true;      pamela->var.waitforever = true;
224    };    };
225    //  //   //
226    // chek if we are forcing level0  //   // chek if we are forcing level0
227    //  //   //
228    if ( pamela->var.fl0 == true ){  //   if ( pamela->var.fl0 == true ){
229      FORCELEV = 0;  //     FORCELEV = 0;
230    } else {  //   } else {
231      FORCELEV = -1;  //     FORCELEV = -1;
232    };  //   };
233    //    //
234    //  Define some variables    //  Define some variables
235    //    //
# Line 194  void ShowEvent(TString filename="help", Line 251  void ShowEvent(TString filename="help",
251    gStyle->SetNdivisions(1,"X");    gStyle->SetNdivisions(1,"X");
252    gStyle->SetNdivisions(1,"Y");    gStyle->SetNdivisions(1,"Y");
253    //    //
254    Int_t i = 0;    isOK = 0;
   Int_t isOK = 0;  
255    //    //
256    // from here to refresh    // from here to refresh
257    //    //
258   refresh:   refresh:
259    //    //
260      // reset pointers
261      //
262      TFile *headerFile = 0;
263      TChain *otr = 0;
264      TTree *L0 = 0;
265      //
266      //  gROOT->Reset();
267      //
268    // set selection file variables    // set selection file variables
269    //    //
270    pamela->var.selex = true;    if ( pamela->var.refresh ){
271    selfile = pamela->var.thefilter.Data();      if ( pamela->var.selex ){
272          //      pamela->var.selex = true;                               //<<<<<<<<<<<<<<<<<<<<<<<<<<?????????????????????
273          selfile = pamela->var.thefilter.Data();
274        };
275      };
276    //    //
   if ( outDir == "" ) outDir = startingdir;      
277    //    //
278    if ( pamela->var.fl0 == true ) {    if ( pamela->var.fl0 == true ) {
279      FORCELEV = 0;      FORCELEV = 0;
280    } else {    } else {
281      if ( pamela->var.refresh ) FORCELEV = -1;      if ( pamela->var.refresh ) FORCELEV = -1;           //<<<<<<<<<<<<<<<<<<<<<<<<<<?????????????????????
282    };    };
283    //    //
284    // check the detectors to be shown    // check the detectors to be shown
285    //    //
286    if ( !pamela->var.refresh ) pamela->checkctrlword();    //  if ( !pamela->var.refresh ) pamela->checkctrlword();
287      //pamela->checkctrlword();
288    //    //
289    // open a dialog if the program is launched without input filename    // open a dialog if the program is launched without input filename
290    //    //
291    if ( firsttime ){    if ( firsttime ){
292      firsttime = false;      firsttime = false;
293      if ( filename == "" ) pamgui->DIALOG(0," Insert the filename and press load to start ");      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    };    };
297    //    //
298    // WAIT for an input filename    // WAIT for an input filename
# Line 231  void ShowEvent(TString filename="help", Line 301  void ShowEvent(TString filename="help",
301      if ( !gROOT->GetListOfCanvases()->FindObject(figure)  ) {      if ( !gROOT->GetListOfCanvases()->FindObject(figure)  ) {
302        pamgui->Terminate();        pamgui->Terminate();
303      };      };
304        pamgui->Refresh();
305      gSystem->ProcessEvents();      gSystem->ProcessEvents();
306      gSystem->Sleep(10);      gSystem->Sleep(10);
307    };    };
308    //    //
309    if ( pamela->var.restart ){  //   if ( pamela->var.restart ){
310      filename = pamela->var.thefilename.Data();  //     filename = pamela->var.thefilename.Data();
311      goto restart;  //     goto restart;
312    };  //   };
313    //    //
314    // check if we are forcing level0 data    // check if we are forcing level0 data
315    //    //
# Line 252  void ShowEvent(TString filename="help", Line 323  void ShowEvent(TString filename="help",
323    //    //
324    // LOAD SELECTION FILE    // LOAD SELECTION FILE
325    //        //    
326    if ( selfile == ""  ){    if (  !strcmp(gSystem->BaseName(selfile),"") ){ //selfile == ""  ){
327      if ( !pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded ");      //if ( !pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded ");
328        if ( pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded ");
329      pamela->var.selex = false;      pamela->var.selex = false;
330    } else {    } else {
331      //      //
# Line 269  void ShowEvent(TString filename="help", Line 341  void ShowEvent(TString filename="help",
341      //      //
342      // load the structure header      // load the structure header
343      //      //
344      carica.str("");       carica.str("");
345      carica << paminc.str().c_str() << "/feventvstruct.h";       carica << paminc.str().c_str() << "/feventvstruct.h";
346      gROOT->LoadMacro(carica.str().c_str());       gROOT->LoadMacro(carica.str().c_str());
347        //    carica.str("");
348        //    carica << paminc.str().c_str() << "/CaloNuclei.h";
349        //    gROOT->LoadMacro(carica.str().c_str());
350      //      //
351      // load the selection macro      // load the selection macro
352      //      //
353      Int_t chkload = gROOT->LoadMacro(selfile);      Int_t chkload = gROOT->LoadMacro(selfile);
354      //      //
355        pamela->var.selex = false;
356        //
357      if ( chkload ){      if ( chkload ){
358        //        //
359        // not able to open the selection file        // not able to open the selection file
# Line 290  void ShowEvent(TString filename="help", Line 367  void ShowEvent(TString filename="help",
367        pamela->var.selex = false;        pamela->var.selex = false;
368        printf("\n WARNING! no selection file loaded! \n\n");        printf("\n WARNING! no selection file loaded! \n\n");
369        pamgui->DIALOG(1," No selection file loaded! ");        pamgui->DIALOG(1," No selection file loaded! ");
370          selfile = "";
371        //        //
372        // clear field in the GUI        // clear field in the GUI
373        //        //
# Line 309  void ShowEvent(TString filename="help", Line 387  void ShowEvent(TString filename="help",
387    //  LOAD FILES        //  LOAD FILES    
388    //    //
389    //    //
390    TFile *headerFile = 0;    //   if ( headerFile ) headerFile->Close();
391    TTree *otr = 0;    //   if ( otr ) otr->Delete();
392      //   if ( L0 ) L0->Delete();
393    
394    //    //
395    // check if user has given as input a correct path    // check if user has given as input a correct path
396    //    //
397    ifstream myfile;    ifstream myfile;
398    myfile.open(filename.Data());    myfile.open(filename.Data());
399    if ( !myfile ){    if ( !myfile ){
400      printf("ERROR: no such file, exiting...\n");      if ( filename != "" ){
401      stringstream hfile;        printf("ERROR: no such file, exiting...\n");
402      hfile.str("");        stringstream hfile;
403      hfile << filename.Data();        hfile.str("");
404      hfile << " : no such file! ";        hfile << filename.Data();
405      pamgui->DIALOG(2,hfile.str().c_str());        hfile << " : no such file! ";
406          pamgui->DIALOG(2,hfile.str().c_str());
407        };
408      pamela->var.waitforever = true;      pamela->var.waitforever = true;
409      goto refresh;      goto refresh;
410    };    };
# Line 330  void ShowEvent(TString filename="help", Line 412  void ShowEvent(TString filename="help",
412    //    //
413    // ok, open file and determine if it is a YODA or DARTHVADER file    // ok, open file and determine if it is a YODA or DARTHVADER file
414    //    //
415    
416    headerFile=new TFile(filename.Data());    headerFile=new TFile(filename.Data());
417    if ( FORCELEV == 0 ){    if ( FORCELEV == 0 ){
418      pamela->level.file = 0;      pamela->level.file = 0;
419      otr = (TTree*)headerFile->Get("Physics");      L0 = (TTree*)headerFile->Get("Physics");
420      if ( !otr ){      if ( !L0 ){
421        printf("ERROR: no Physics tree...\n");        printf("ERROR: no Physics tree...\n");
422        pamgui->DIALOG(2,"No Physics tree in this file");        pamgui->DIALOG(2,"No Physics tree in this file");
423        pamela->var.waitforever = true;        pamela->var.waitforever = true;
# Line 342  void ShowEvent(TString filename="help", Line 425  void ShowEvent(TString filename="help",
425      }      }
426    } else {    } else {
427      pamela->level.file = 2;      pamela->level.file = 2;
428      otr = (TTree*)headerFile->Get("Trigger");      otr0 = (TTree*)headerFile->Get("Trigger");
429      if ( !otr ){      otr1 = (TTree*)headerFile->Get("Calorimeter");
430        otr = (TTree*)headerFile->Get("Physics");            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        if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 ){
438          L0 = (TTree*)headerFile->Get("Physics");      
439        pamela->level.file = -1;        pamela->level.file = -1;
440        } else {
441          stringstream dddec;
442          dddec.str("");
443          dddec << " +AUTO ";
444          //      dddec << " +ALL +RUN +CAL1 -TRKh -TRK1 -TRK0 -CAL0";
445           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          pamela->SetDDEC(dddec.str().c_str());
489      };      };
490      if ( !otr ){      if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 && !L0 ){
491        pamela->level.file = -1;        pamela->level.file = -1;
492        printf("ERROR: nor Physics nor Run tree...\n");        printf("ERROR: nor Physics nor Run tree...\n");
493        pamgui->DIALOG(2,"Nor Physics nor Run tree in this file");        pamgui->DIALOG(2,"Nor Physics nor Run tree in this file");
# Line 355  void ShowEvent(TString filename="help", Line 495  void ShowEvent(TString filename="help",
495        goto refresh;        goto refresh;
496      };      };
497    };    };
498      headerFile->Close("R");
499    //    //
500    if ( pamela->level.file != 2 ){    if ( pamela->level.file != 2 ){
501      printf(" This is a YODA (level0) file \n");      printf(" This is a YODA (level0) file \n");
# Line 368  void ShowEvent(TString filename="help", Line 509  void ShowEvent(TString filename="help",
509    //    //
510    // Load the file    // Load the file
511    //    //
512    pamela->Load(*otr,*headerFile);    if ( otr0 || L0 ){
513        otr = pamela->Load(filename.Data());
514        if ( !otr ){
515          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        pamela->level.file = -1;
523        printf("ERROR: problems with TTree while opening file...\n");
524        pamgui->DIALOG(2,"Problems opening file");
525        pamela->var.waitforever = true;
526        goto refresh;
527      };
528    //    //
529    printf("\n");    printf("\n");
530    //    //
531    // get the number of entries    // get the number of entries
532    //    //
533      if ( !otr ) printf(" AGH! \n");
534      //
535    Long64_t nevents = otr->GetEntries();    Long64_t nevents = otr->GetEntries();
536    printf(" The file contains %i physics events \n",(int)nevents);    printf(" The file contains %i physics events \n",(int)nevents);
537    //    //
538    // check we have at least one event    // check we have at least one event
539    //    //
540    if (nevents<=0) {    if (nevents<=0) {
541      headerFile->Close();      //    headerFile->Close();
542      printf("The file is empty, exiting...\n");      printf("The file is empty, exiting...\n");
543      pamgui->DIALOG(0," The file contains no physics data! ");      pamgui->DIALOG(0," The file contains no physics data! ");
544      pamela->var.waitforever = true;      pamela->var.waitforever = true;
# Line 400  void ShowEvent(TString filename="help", Line 558  void ShowEvent(TString filename="help",
558    //    //
559    // display the first event (unless we are refreshing only the window)    // display the first event (unless we are refreshing only the window)
560    //    //
561    if ( !pamela->var.refresh ) i = pamela->minevent;    if ( !pamela->var.refresh && !pamela->var.restart ) i = pamela->minevent;
562      pamela->var.restart = false;
563    pamela->var.refresh = false;    pamela->var.refresh = false;
564    //    //
565      pamgui->RefreshButtons();
566      //
567    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
568    //  MAIN LOOP STARTS HERE:    //  MAIN LOOP STARTS HERE:
569    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# Line 489  void ShowEvent(TString filename="help", Line 650  void ShowEvent(TString filename="help",
650        figsave << (pamela->var.i+1);        figsave << (pamela->var.i+1);
651        figsave << bw;        figsave << bw;
652        pamela->var.svas=figsave.str().c_str();        pamela->var.svas=figsave.str().c_str();
653    
654          //      printf(" qua %s \n",figsave.str().c_str());
655        //        //
656        // upgrade the figure filename in the GUI        // upgrade the figure filename in the GUI
657        //        //
# Line 509  void ShowEvent(TString filename="help", Line 672  void ShowEvent(TString filename="help",
672        //        //
673        pamela->var.goon = false;        pamela->var.goon = false;
674        if ( pamela->var.refresh || pamela->var.restart ){        if ( pamela->var.refresh || pamela->var.restart ){
675          headerFile->Close();          //      printf(" qua \n");
676            if ( pamela->GetL2() ) pamela->GetL2()->Clear();
677            if ( pamela->GetL2() ) pamela->GetL2()->Reset();
678            if ( pamela->GetL2() ) pamela->GetL2()->Delete();
679            pamela->Reset();
680            if ( pamela->level.file != 2 ) pamela->GetChain()->Delete();
681            otr = NULL;
682            //      if ( headerFile ) headerFile->Close("R");
683            //      if ( pamela->var.refresh ){
684            //        pamela->var.refresh = false;
685            //        pamela->var.restart = true;
686            //      };
687          if ( pamela->var.refresh ) goto refresh;          if ( pamela->var.refresh ) goto refresh;
688          if ( pamela->var.restart ){          if ( pamela->var.restart ){
689              //      if ( pamela->GetL2() ) pamela->GetL2()->Reset();
690              //      pamela->Reset();
691              //      if ( pamela->level.file != 2 ) pamela->GetChain()->Delete();
692              //      otr = NULL;
693              i = pamela->var.i;
694            filename = pamela->var.thefilename.Data();            filename = pamela->var.thefilename.Data();
695            goto restart;            goto restart;
696          };          };
697        };        };
698        //        //
699          //      printf(" que %i \n",i);
700          //      if ( i < 0 ) i = 0; // boh
701        i = pamela->var.i;        i = pamela->var.i;
702        if ( i != pamela->si ) pamela->OOBT = 1000000000;        if ( i != pamela->si ) pamela->OOBT = 1000000000;
703        if ( pamela->maxevent < i ) {        if ( pamela->maxevent < i ) {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.23