/[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.3 by mocchiut, Mon Feb 26 17:30:33 2007 UTC revision 1.10 by mocchiut, Tue Jul 17 14:40:13 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    //  book the canvas    //  book the canvas
160    //    //
161    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 173  void ShowEvent(TString filename="help",
173    pamela->SetGUIPtr(*pamgui);    pamela->SetGUIPtr(*pamgui);
174    if ( outDir == "" ) outDir = startingdir;        if ( outDir == "" ) outDir = startingdir;    
175    //    //
176      TTree *otr0 = 0;
177    TTree *otr1 = 0;    TTree *otr1 = 0;
178    TTree *otr2 = 0;    TTree *otr2 = 0;
179    TTree *otr3 = 0;    TTree *otr3 = 0;
# Line 156  void ShowEvent(TString filename="help", Line 184  void ShowEvent(TString filename="help",
184    TTree *otr8 = 0;    TTree *otr8 = 0;
185    //    //
186    pamela->var.fl0 = false;    pamela->var.fl0 = false;
187      Int_t i = 0;
188      Int_t isOK = 0;
189    //    //
190   restart:   restart:
191    //    //
# Line 203  void ShowEvent(TString filename="help", Line 233  void ShowEvent(TString filename="help",
233    gStyle->SetNdivisions(1,"X");    gStyle->SetNdivisions(1,"X");
234    gStyle->SetNdivisions(1,"Y");    gStyle->SetNdivisions(1,"Y");
235    //    //
236    Int_t i = 0;    if ( i < 0 ){
237    Int_t isOK = 0;      i = -i;
238      } else {
239        i = 0;
240      };
241      isOK = 0;
242    //    //
243    // from here to refresh    // from here to refresh
244    //    //
245   refresh:   refresh:
246    //    //
247      // reset pointers
248      //
249      TFile *headerFile = 0;
250      TChain *otr = 0;
251      TTree *L0 = 0;
252      //
253      //  gROOT->Reset();
254      //
255    // set selection file variables    // set selection file variables
256    //    //
257    if ( pamela->var.refresh ){    if ( pamela->var.refresh ){
# Line 283  void ShowEvent(TString filename="help", Line 325  void ShowEvent(TString filename="help",
325      //      //
326      // load the structure header      // load the structure header
327      //      //
328      carica.str("");       carica.str("");
329      carica << paminc.str().c_str() << "/feventvstruct.h";       carica << paminc.str().c_str() << "/feventvstruct.h";
330      gROOT->LoadMacro(carica.str().c_str());       gROOT->LoadMacro(carica.str().c_str());
331        //    carica.str("");
332        //    carica << paminc.str().c_str() << "/CaloNuclei.h";
333        //    gROOT->LoadMacro(carica.str().c_str());
334      //      //
335      // load the selection macro      // load the selection macro
336      //      //
# Line 326  void ShowEvent(TString filename="help", Line 371  void ShowEvent(TString filename="help",
371    //  LOAD FILES        //  LOAD FILES    
372    //    //
373    //    //
374    TFile *headerFile = 0;  //   if ( headerFile ) headerFile->Close();
375    TTree *otr = 0;  //   if ( otr ) otr->Delete();
376    //   if ( L0 ) L0->Delete();
377    
378    //    //
379    // check if user has given as input a correct path    // check if user has given as input a correct path
380    //    //
# Line 349  void ShowEvent(TString filename="help", Line 396  void ShowEvent(TString filename="help",
396    //    //
397    // 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
398    //    //
399    
400    headerFile=new TFile(filename.Data());    headerFile=new TFile(filename.Data());
401    if ( FORCELEV == 0 ){    if ( FORCELEV == 0 ){
402      pamela->level.file = 0;      pamela->level.file = 0;
403      otr = (TTree*)headerFile->Get("Physics");      L0 = (TTree*)headerFile->Get("Physics");
404      if ( !otr ){      if ( !L0 ){
405        printf("ERROR: no Physics tree...\n");        printf("ERROR: no Physics tree...\n");
406        pamgui->DIALOG(2,"No Physics tree in this file");        pamgui->DIALOG(2,"No Physics tree in this file");
407        pamela->var.waitforever = true;        pamela->var.waitforever = true;
# Line 361  void ShowEvent(TString filename="help", Line 409  void ShowEvent(TString filename="help",
409      }      }
410    } else {    } else {
411      pamela->level.file = 2;      pamela->level.file = 2;
412      otr = (TTree*)headerFile->Get("Trigger");      otr0 = (TTree*)headerFile->Get("Trigger");
413      otr1 = (TTree*)headerFile->Get("Calorimeter");      otr1 = (TTree*)headerFile->Get("Calorimeter");
414      otr2 = (TTree*)headerFile->Get("Tracker");      otr2 = (TTree*)headerFile->Get("Tracker");
415      otr3 = (TTree*)headerFile->Get("NeutronD");      otr3 = (TTree*)headerFile->Get("NeutronD");
# Line 370  void ShowEvent(TString filename="help", Line 418  void ShowEvent(TString filename="help",
418      otr6 = (TTree*)headerFile->Get("ToF");      otr6 = (TTree*)headerFile->Get("ToF");
419      otr7 = (TTree*)headerFile->Get("Run");      otr7 = (TTree*)headerFile->Get("Run");
420      otr8 = (TTree*)headerFile->Get("Anticounter");      otr8 = (TTree*)headerFile->Get("Anticounter");
421      if ( !otr && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 ){      if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 ){
422        otr = (TTree*)headerFile->Get("Physics");              L0 = (TTree*)headerFile->Get("Physics");      
423        pamela->level.file = -1;        pamela->level.file = -1;
424      } else {      } else {
425        stringstream dddec;        stringstream dddec;
426        dddec.str("");        dddec.str("");
427        dddec << " +ALL +CAL1 -TRKh -TRK1 ";        dddec << " +ALL +RUN +CAL1 -TRKh -TRK1 ";
428        if ( !otr ){        if ( !otr0 ){
429          dddec << " -TRG ";          dddec << " -TRG ";
430          pamela->var.TRG = 0;          pamela->var.TRG = 0;
431          otr = otr1;          otr0 = otr1;
432        };        };
433        if ( !otr1 ){        if ( !otr1 ){
434          dddec << " -CAL ";          dddec << " -CAL ";
435          pamela->var.CALO = 0;          pamela->var.CALO = 0;
436          if ( !otr ) otr = otr2;          if ( !otr0 ) otr0 = otr2;
437        };        };
438        if ( !otr2 ){        if ( !otr2 ){
439          dddec << " -TRK2 -TRK ";          dddec << " -TRK2 -TRK ";
440          pamela->var.TRK = 0;          pamela->var.TRK = 0;
441          if ( !otr ) otr = otr3;          if ( !otr0 ) otr0 = otr3;
442        };        };
443        if ( !otr3 ){        if ( !otr3 ){
444          dddec << " -ND ";          dddec << " -ND ";
445          pamela->var.ND = 0;          pamela->var.ND = 0;
446          if ( !otr ) otr = otr4;          if ( !otr0 ) otr0 = otr4;
447        };        };
448        if ( !otr4 ){        if ( !otr4 ){
449          dddec << " -ORB ";          dddec << " -ORB ";
450          pamela->var.ORB = 0;          pamela->var.ORB = 0;
451          if ( !otr ) otr = otr5;          if ( !otr0 ) otr0 = otr5;
452        };        };
453        if ( !otr5 ){        if ( !otr5 ){
454          dddec << " -S4 ";          dddec << " -S4 ";
455          pamela->var.S4 = 0;          pamela->var.S4 = 0;
456          if ( !otr ) otr = otr6;          if ( !otr0 ) otr0 = otr6;
457        };        };
458        if ( !otr6 ){        if ( !otr6 ){
459          dddec << " -TOF ";          dddec << " -TOF ";
460          pamela->var.TOF = 0;          pamela->var.TOF = 0;
461          if ( !otr ) otr = otr8;          if ( !otr0 ) otr0 = otr8;
462        };        };
463        if ( !otr7 ){        if ( !otr7 ){
464          dddec << " -RUN ";          dddec << " -RUN ";
# Line 422  void ShowEvent(TString filename="help", Line 470  void ShowEvent(TString filename="help",
470        };        };
471        pamela->SetDDEC(dddec.str().c_str());        pamela->SetDDEC(dddec.str().c_str());
472      };      };
473      if ( !otr && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8){      if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 && !L0 ){
474        pamela->level.file = -1;        pamela->level.file = -1;
475        printf("ERROR: nor Physics nor Run tree...\n");        printf("ERROR: nor Physics nor Run tree...\n");
476        pamgui->DIALOG(2,"Nor Physics nor Run tree in this file");        pamgui->DIALOG(2,"Nor Physics nor Run tree in this file");
# Line 430  void ShowEvent(TString filename="help", Line 478  void ShowEvent(TString filename="help",
478        goto refresh;        goto refresh;
479      };      };
480    };    };
481      headerFile->Close("R");
482    //    //
483    if ( pamela->level.file != 2 ){    if ( pamela->level.file != 2 ){
484      printf(" This is a YODA (level0) file \n");      printf(" This is a YODA (level0) file \n");
# Line 443  void ShowEvent(TString filename="help", Line 492  void ShowEvent(TString filename="help",
492    //    //
493    // Load the file    // Load the file
494    //    //
495    if ( otr ){    if ( otr0 || L0 ){
496      if ( !pamela->Load(*otr,*headerFile) ){      otr = pamela->Load(filename.Data());
497        if ( !otr ){
498        pamela->level.file = -1;        pamela->level.file = -1;
499        printf("ERROR: problems opening file...\n");        printf("ERROR: problems opening file...\n");
500        pamgui->DIALOG(2,"Problems opening file");        pamgui->DIALOG(2,"Problems opening file");
# Line 463  void ShowEvent(TString filename="help", Line 513  void ShowEvent(TString filename="help",
513    //    //
514    // get the number of entries    // get the number of entries
515    //    //
516    //  otr->Print();    if ( !otr ) printf(" AGH! \n");
517    //    //
518    Long64_t nevents = otr->GetEntries();    Long64_t nevents = otr->GetEntries();
519    printf(" The file contains %i physics events \n",(int)nevents);    printf(" The file contains %i physics events \n",(int)nevents);
# Line 471  void ShowEvent(TString filename="help", Line 521  void ShowEvent(TString filename="help",
521    // check we have at least one event    // check we have at least one event
522    //    //
523    if (nevents<=0) {    if (nevents<=0) {
524      headerFile->Close();      //    headerFile->Close();
525      printf("The file is empty, exiting...\n");      printf("The file is empty, exiting...\n");
526      pamgui->DIALOG(0," The file contains no physics data! ");      pamgui->DIALOG(0," The file contains no physics data! ");
527      pamela->var.waitforever = true;      pamela->var.waitforever = true;
# Line 604  void ShowEvent(TString filename="help", Line 654  void ShowEvent(TString filename="help",
654        //        //
655        pamela->var.goon = false;        pamela->var.goon = false;
656        if ( pamela->var.refresh || pamela->var.restart ){        if ( pamela->var.refresh || pamela->var.restart ){
657          headerFile->Close();          if ( pamela->GetL2() ) pamela->GetL2()->Reset();
658            if ( pamela->level.file != 2 ) pamela->GetChain()->Delete();
659            otr = NULL;
660            //      if ( headerFile ) headerFile->Close("R");
661          if ( pamela->var.refresh ) goto refresh;          if ( pamela->var.refresh ) goto refresh;
662          if ( pamela->var.restart ){          if ( pamela->var.restart ){
663            filename = pamela->var.thefilename.Data();            filename = pamela->var.thefilename.Data();

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.23