/[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.2 by mocchiut, Mon Feb 26 12:51:10 2007 UTC revision 1.14 by mocchiut, Tue Nov 27 08:41:02 2007 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 146  void ShowEvent(TString filename="help", Line 182  void ShowEvent(TString filename="help",
182    pamela->SetGUIPtr(*pamgui);    pamela->SetGUIPtr(*pamgui);
183    if ( outDir == "" ) outDir = startingdir;        if ( outDir == "" ) outDir = startingdir;    
184    //    //
185      TTree *otr0 = 0;
186    TTree *otr1 = 0;    TTree *otr1 = 0;
187    TTree *otr2 = 0;    TTree *otr2 = 0;
188    TTree *otr3 = 0;    TTree *otr3 = 0;
# Line 156  void ShowEvent(TString filename="help", Line 193  void ShowEvent(TString filename="help",
193    TTree *otr8 = 0;    TTree *otr8 = 0;
194    //    //
195    pamela->var.fl0 = false;    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;    
# Line 174  void ShowEvent(TString filename="help", Line 221  void ShowEvent(TString filename="help",
221    if ( filename.Data() == "" || !strcmp(filename.Data(),"help") ){    if ( filename.Data() == "" || !strcmp(filename.Data(),"help") ){
222      pamela->var.waitforever = true;      pamela->var.waitforever = true;
223    };    };
224    //  //   //
225    // chek if we are forcing level0  //   // chek if we are forcing level0
226    //  //   //
227    if ( pamela->var.fl0 == true ){  //   if ( pamela->var.fl0 == true ){
228      FORCELEV = 0;  //     FORCELEV = 0;
229    } else {  //   } else {
230      FORCELEV = -1;  //     FORCELEV = -1;
231    };  //   };
232    //    //
233    //  Define some variables    //  Define some variables
234    //    //
# Line 203  void ShowEvent(TString filename="help", Line 250  void ShowEvent(TString filename="help",
250    gStyle->SetNdivisions(1,"X");    gStyle->SetNdivisions(1,"X");
251    gStyle->SetNdivisions(1,"Y");    gStyle->SetNdivisions(1,"Y");
252    //    //
253    Int_t i = 0;    isOK = 0;
   Int_t isOK = 0;  
254    //    //
255    // from here to refresh    // from here to refresh
256    //    //
257   refresh:   refresh:
258    //    //
259      // reset pointers
260      //
261      TFile *headerFile = 0;
262      TChain *otr = 0;
263      TTree *L0 = 0;
264      //
265      //  gROOT->Reset();
266      //
267    // set selection file variables    // set selection file variables
268    //    //
269     if ( pamela->var.refresh ){    if ( pamela->var.refresh ){
270       pamela->var.selex = true;                               //<<<<<<<<<<<<<<<<<<<<<<<<<<?????????????????????      if ( pamela->var.selex ){
271       selfile = pamela->var.thefilter.Data();        //      pamela->var.selex = true;                               //<<<<<<<<<<<<<<<<<<<<<<<<<<?????????????????????
272     };        selfile = pamela->var.thefilter.Data();
273        };
274      };
275    //    //
276    //    //
277    //  if ( pamela->var.fl0 == true ) {    if ( pamela->var.fl0 == true ) {
278    //    FORCELEV = 0;      FORCELEV = 0;
279    //  } else {    } else {
280    //    if ( pamela->var.refresh ) FORCELEV = -1;           //<<<<<<<<<<<<<<<<<<<<<<<<<<?????????????????????      if ( pamela->var.refresh ) FORCELEV = -1;           //<<<<<<<<<<<<<<<<<<<<<<<<<<?????????????????????
281    //  };    };
282    //    //
283    // check the detectors to be shown    // check the detectors to be shown
284    //    //
# Line 246  void ShowEvent(TString filename="help", Line 302  void ShowEvent(TString filename="help",
302      gSystem->Sleep(10);      gSystem->Sleep(10);
303    };    };
304    //    //
305    if ( pamela->var.restart ){  //   if ( pamela->var.restart ){
306      filename = pamela->var.thefilename.Data();  //     filename = pamela->var.thefilename.Data();
307      goto restart;  //     goto restart;
308    };  //   };
309    //    //
310    // check if we are forcing level0 data    // check if we are forcing level0 data
311    //    //
# Line 281  void ShowEvent(TString filename="help", Line 337  void ShowEvent(TString filename="help",
337      //      //
338      // load the structure header      // load the structure header
339      //      //
340      carica.str("");       carica.str("");
341      carica << paminc.str().c_str() << "/feventvstruct.h";       carica << paminc.str().c_str() << "/feventvstruct.h";
342      gROOT->LoadMacro(carica.str().c_str());       gROOT->LoadMacro(carica.str().c_str());
343        //    carica.str("");
344        //    carica << paminc.str().c_str() << "/CaloNuclei.h";
345        //    gROOT->LoadMacro(carica.str().c_str());
346      //      //
347      // load the selection macro      // load the selection macro
348      //      //
349      Int_t chkload = gROOT->LoadMacro(selfile);      Int_t chkload = gROOT->LoadMacro(selfile);
350      //      //
351        pamela->var.selex = false;
352        //
353      if ( chkload ){      if ( chkload ){
354        //        //
355        // not able to open the selection file        // not able to open the selection file
# Line 302  void ShowEvent(TString filename="help", Line 363  void ShowEvent(TString filename="help",
363        pamela->var.selex = false;        pamela->var.selex = false;
364        printf("\n WARNING! no selection file loaded! \n\n");        printf("\n WARNING! no selection file loaded! \n\n");
365        pamgui->DIALOG(1," No selection file loaded! ");        pamgui->DIALOG(1," No selection file loaded! ");
366          selfile = "";
367        //        //
368        // clear field in the GUI        // clear field in the GUI
369        //        //
# Line 321  void ShowEvent(TString filename="help", Line 383  void ShowEvent(TString filename="help",
383    //  LOAD FILES        //  LOAD FILES    
384    //    //
385    //    //
386    TFile *headerFile = 0;  //   if ( headerFile ) headerFile->Close();
387    TTree *otr = 0;  //   if ( otr ) otr->Delete();
388    //   if ( L0 ) L0->Delete();
389    
390    //    //
391    // check if user has given as input a correct path    // check if user has given as input a correct path
392    //    //
# Line 344  void ShowEvent(TString filename="help", Line 408  void ShowEvent(TString filename="help",
408    //    //
409    // 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
410    //    //
411    
412    headerFile=new TFile(filename.Data());    headerFile=new TFile(filename.Data());
413    if ( FORCELEV == 0 ){    if ( FORCELEV == 0 ){
414      pamela->level.file = 0;      pamela->level.file = 0;
415      otr = (TTree*)headerFile->Get("Physics");      L0 = (TTree*)headerFile->Get("Physics");
416      if ( !otr ){      if ( !L0 ){
417        printf("ERROR: no Physics tree...\n");        printf("ERROR: no Physics tree...\n");
418        pamgui->DIALOG(2,"No Physics tree in this file");        pamgui->DIALOG(2,"No Physics tree in this file");
419        pamela->var.waitforever = true;        pamela->var.waitforever = true;
# Line 356  void ShowEvent(TString filename="help", Line 421  void ShowEvent(TString filename="help",
421      }      }
422    } else {    } else {
423      pamela->level.file = 2;      pamela->level.file = 2;
424      otr = (TTree*)headerFile->Get("Trigger");      otr0 = (TTree*)headerFile->Get("Trigger");
425      otr1 = (TTree*)headerFile->Get("Calorimeter");      otr1 = (TTree*)headerFile->Get("Calorimeter");
426      otr2 = (TTree*)headerFile->Get("Tracker");      otr2 = (TTree*)headerFile->Get("Tracker");
427      otr3 = (TTree*)headerFile->Get("NeutronD");      otr3 = (TTree*)headerFile->Get("NeutronD");
# Line 365  void ShowEvent(TString filename="help", Line 430  void ShowEvent(TString filename="help",
430      otr6 = (TTree*)headerFile->Get("ToF");      otr6 = (TTree*)headerFile->Get("ToF");
431      otr7 = (TTree*)headerFile->Get("Run");      otr7 = (TTree*)headerFile->Get("Run");
432      otr8 = (TTree*)headerFile->Get("Anticounter");      otr8 = (TTree*)headerFile->Get("Anticounter");
433      if ( !otr && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 ){      if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 ){
434        otr = (TTree*)headerFile->Get("Physics");              L0 = (TTree*)headerFile->Get("Physics");      
435        pamela->level.file = -1;        pamela->level.file = -1;
436      } else {      } else {
437        stringstream dddec;        stringstream dddec;
438        dddec.str("");        dddec.str("");
439        dddec << " +ALL +CAL1 -TRKh -TRK1 ";        dddec << " +AUTO ";
440        if ( !otr ){        //      dddec << " +ALL +RUN +CAL1 -TRKh -TRK1 -TRK0 -CAL0";
441          dddec << " -TRG ";         if ( !otr0 ){
442          //      pamela->var.TRG = 0;          dddec << " -TRG ";
443        };          pamela->var.TRG = 0;
444        if ( !otr1 ){          otr0 = otr1;
445          dddec << " -CAL ";         };
446          pamela->var.CALO = 0;         if ( !otr1 ){
447        };          dddec << " -CAL ";
448        if ( !otr2 ){          pamela->var.CALO = 0;
449          dddec << " -TRK2 -TRK ";          if ( !otr0 ) otr0 = otr2;
450          pamela->var.TRK = 0;         };
451        };         if ( !otr2 ){
452        if ( !otr3 ){          dddec << " -TRK2 -TRK ";
453          dddec << " -ND ";          pamela->var.TRK = 0;
454          pamela->var.ND = 0;          if ( !otr0 ) otr0 = otr3;
455        };         };
456        if ( !otr4 ){         if ( !otr3 ){
457          dddec << " -ORB ";          dddec << " -ND ";
458        //        pamela->var.CALO = 0;          pamela->var.ND = 0;
459        };          if ( !otr0 ) otr0 = otr4;
460        if ( !otr5 ){         };
461          dddec << " -S4 ";         if ( !otr4 ){
462          pamela->var.S4 = 0;          dddec << " -ORB ";
463        };          pamela->var.ORB = 0;
464        if ( !otr6 ){          if ( !otr0 ) otr0 = otr5;
465          dddec << " -TOF ";         };
466          pamela->var.TOF = 0;         if ( !otr5 ){
467        };          dddec << " -S4 ";
468        if ( !otr7 ){          pamela->var.S4 = 0;
469          dddec << " -RUN ";          if ( !otr0 ) otr0 = otr6;
470          pamela->var.RUN = 0;         };
471        };         if ( !otr6 ){
472        if ( !otr8 ){          dddec << " -TOF ";
473          dddec << " -AC ";          pamela->var.TOF = 0;
474          pamela->var.AC = 0;          if ( !otr0 ) otr0 = otr8;
475        };         };
476           if ( !otr7 ){
477            dddec << " -RUN ";
478            pamela->var.RUN = 0;
479           };
480           if ( !otr8 ){
481            dddec << " -AC ";
482            pamela->var.AC = 0;
483           };
484        pamela->SetDDEC(dddec.str().c_str());        pamela->SetDDEC(dddec.str().c_str());
485      };      };
486      if ( !otr && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8){      if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 && !L0 ){
487        pamela->level.file = -1;        pamela->level.file = -1;
488        printf("ERROR: nor Physics nor Run tree...\n");        printf("ERROR: nor Physics nor Run tree...\n");
489        pamgui->DIALOG(2,"Nor Physics nor Run tree in this file");        pamgui->DIALOG(2,"Nor Physics nor Run tree in this file");
# Line 418  void ShowEvent(TString filename="help", Line 491  void ShowEvent(TString filename="help",
491        goto refresh;        goto refresh;
492      };      };
493    };    };
494      headerFile->Close("R");
495    //    //
496    if ( pamela->level.file != 2 ){    if ( pamela->level.file != 2 ){
497      printf(" This is a YODA (level0) file \n");      printf(" This is a YODA (level0) file \n");
# Line 431  void ShowEvent(TString filename="help", Line 505  void ShowEvent(TString filename="help",
505    //    //
506    // Load the file    // Load the file
507    //    //
508    if ( !pamela->Load(*otr,*headerFile) ){    if ( otr0 || L0 ){
509        otr = pamela->Load(filename.Data());
510        if ( !otr ){
511          pamela->level.file = -1;
512          printf("ERROR: problems opening file...\n");
513          pamgui->DIALOG(2,"Problems opening file");
514          pamela->var.waitforever = true;
515          goto refresh;
516        };
517      } else {
518      pamela->level.file = -1;      pamela->level.file = -1;
519      printf("ERROR: problems opening file...\n");      printf("ERROR: problems with TTree while opening file...\n");
520      pamgui->DIALOG(2,"Problems opening file");      pamgui->DIALOG(2,"Problems opening file");
521      pamela->var.waitforever = true;      pamela->var.waitforever = true;
522      goto refresh;      goto refresh;
# Line 443  void ShowEvent(TString filename="help", Line 526  void ShowEvent(TString filename="help",
526    //    //
527    // get the number of entries    // get the number of entries
528    //    //
529    otr->Print();    if ( !otr ) printf(" AGH! \n");
530      //
531    Long64_t nevents = otr->GetEntries();    Long64_t nevents = otr->GetEntries();
532    printf(" The file contains %i physics events \n",(int)nevents);    printf(" The file contains %i physics events \n",(int)nevents);
533    //    //
534    // check we have at least one event    // check we have at least one event
535    //    //
536    if (nevents<=0) {    if (nevents<=0) {
537      headerFile->Close();      //    headerFile->Close();
538      printf("The file is empty, exiting...\n");      printf("The file is empty, exiting...\n");
539      pamgui->DIALOG(0," The file contains no physics data! ");      pamgui->DIALOG(0," The file contains no physics data! ");
540      pamela->var.waitforever = true;      pamela->var.waitforever = true;
# Line 471  void ShowEvent(TString filename="help", Line 554  void ShowEvent(TString filename="help",
554    //    //
555    // display the first event (unless we are refreshing only the window)    // display the first event (unless we are refreshing only the window)
556    //    //
557    if ( !pamela->var.refresh ) i = pamela->minevent;    if ( !pamela->var.refresh && !pamela->var.restart ) i = pamela->minevent;
558      pamela->var.restart = false;
559    pamela->var.refresh = false;    pamela->var.refresh = false;
560    //    //
561      pamgui->RefreshButtons();
562      //
563    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
564    //  MAIN LOOP STARTS HERE:    //  MAIN LOOP STARTS HERE:
565    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# Line 560  void ShowEvent(TString filename="help", Line 646  void ShowEvent(TString filename="help",
646        figsave << (pamela->var.i+1);        figsave << (pamela->var.i+1);
647        figsave << bw;        figsave << bw;
648        pamela->var.svas=figsave.str().c_str();        pamela->var.svas=figsave.str().c_str();
649    
650          //      printf(" qua %s \n",figsave.str().c_str());
651        //        //
652        // upgrade the figure filename in the GUI        // upgrade the figure filename in the GUI
653        //        //
# Line 580  void ShowEvent(TString filename="help", Line 668  void ShowEvent(TString filename="help",
668        //        //
669        pamela->var.goon = false;        pamela->var.goon = false;
670        if ( pamela->var.refresh || pamela->var.restart ){        if ( pamela->var.refresh || pamela->var.restart ){
671          headerFile->Close();          if ( pamela->GetL2() ) pamela->GetL2()->Reset();
672            if ( pamela->level.file != 2 ) pamela->GetChain()->Delete();
673            otr = NULL;
674            //      if ( headerFile ) headerFile->Close("R");
675          if ( pamela->var.refresh ) goto refresh;          if ( pamela->var.refresh ) goto refresh;
676          if ( pamela->var.restart ){          if ( pamela->var.restart ){
677              i = pamela->var.i;
678            filename = pamela->var.thefilename.Data();            filename = pamela->var.thefilename.Data();
679            goto restart;            goto restart;
680          };          };

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.23