/[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.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 141  void ShowEvent(TString filename="help", Line 168  void ShowEvent(TString filename="help",
168    //    //
169    PAMevcontrol *pamgui = 0;    PAMevcontrol *pamgui = 0;
170    //    //
171    if ( !popup ) {    pamgui = new PAMevcontrol(gClient->GetRoot(),400,800,pamela->var,pamela->level,*figure);
172      pamgui = new PAMevcontrol(gClient->GetRoot(),400,800,pamela->var,pamela->level,*figure);    popup = true;
173      popup = true;    pamela->SetGUIPtr(*pamgui);
174      pamela->SetGUIPtr(*pamgui);    if ( outDir == "" ) outDir = startingdir;    
175    };    //
176      TTree *otr0 = 0;
177      TTree *otr1 = 0;
178      TTree *otr2 = 0;
179      TTree *otr3 = 0;
180      TTree *otr4 = 0;
181      TTree *otr5 = 0;
182      TTree *otr6 = 0;
183      TTree *otr7 = 0;
184      TTree *otr8 = 0;
185      //
186      pamela->var.fl0 = false;
187      Int_t i = 0;
188      Int_t isOK = 0;
189    //    //
190   restart:   restart:
191    //    //
# Line 157  void ShowEvent(TString filename="help", Line 197  void ShowEvent(TString filename="help",
197    pamela->var.jumpen = false;        pamela->var.jumpen = false;    
198    pamela->var.goon = false;    pamela->var.goon = false;
199    pamela->var.refresh = false;    pamela->var.refresh = false;
   pamela->var.fl0 = false;  
200    pamela->var.alrforc = false;    pamela->var.alrforc = false;
201    //    //
202    // check if we have an input filename    // check if we have an input filename
# Line 194  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    // set selection file variables    // reset pointers
248    //    //
249    pamela->var.selex = true;    TFile *headerFile = 0;
250    selfile = pamela->var.thefilter.Data();    TChain *otr = 0;
251      TTree *L0 = 0;
252    //    //
253    if ( outDir == "" ) outDir = startingdir;        //  gROOT->Reset();
254    //    //
255    if ( pamela->var.fl0 == true ) {    // set selection file variables
256      FORCELEV = 0;    //
257    } else {    if ( pamela->var.refresh ){
258      if ( pamela->var.refresh ) FORCELEV = -1;      if ( pamela->var.selex ){
259          //      pamela->var.selex = true;                               //<<<<<<<<<<<<<<<<<<<<<<<<<<?????????????????????
260          selfile = pamela->var.thefilter.Data();
261        };
262    };    };
263    //    //
264      //
265      //  if ( pamela->var.fl0 == true ) {
266      //    FORCELEV = 0;
267      //  } else {
268      //    if ( pamela->var.refresh ) FORCELEV = -1;           //<<<<<<<<<<<<<<<<<<<<<<<<<<?????????????????????
269      //  };
270      //
271    // check the detectors to be shown    // check the detectors to be shown
272    //    //
273    if ( !pamela->var.refresh ) pamela->checkctrlword();    //  if ( !pamela->var.refresh ) pamela->checkctrlword();
274      //pamela->checkctrlword();
275    //    //
276    // open a dialog if the program is launched without input filename    // open a dialog if the program is launched without input filename
277    //    //
# Line 253  void ShowEvent(TString filename="help", Line 308  void ShowEvent(TString filename="help",
308    // LOAD SELECTION FILE    // LOAD SELECTION FILE
309    //        //    
310    if ( selfile == ""  ){    if ( selfile == ""  ){
311      if ( !pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded ");      //if ( !pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded ");
312        if ( pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded ");
313      pamela->var.selex = false;      pamela->var.selex = false;
314    } else {    } else {
315      //      //
# Line 269  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      //      //
337      Int_t chkload = gROOT->LoadMacro(selfile);      Int_t chkload = gROOT->LoadMacro(selfile);
338      //      //
339        pamela->var.selex = false;
340        //
341      if ( chkload ){      if ( chkload ){
342        //        //
343        // not able to open the selection file        // not able to open the selection file
# Line 290  void ShowEvent(TString filename="help", Line 351  void ShowEvent(TString filename="help",
351        pamela->var.selex = false;        pamela->var.selex = false;
352        printf("\n WARNING! no selection file loaded! \n\n");        printf("\n WARNING! no selection file loaded! \n\n");
353        pamgui->DIALOG(1," No selection file loaded! ");        pamgui->DIALOG(1," No selection file loaded! ");
354          selfile = "";
355        //        //
356        // clear field in the GUI        // clear field in the GUI
357        //        //
# Line 309  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    //    //
381    ifstream myfile;    ifstream myfile;
382    myfile.open(filename.Data());    myfile.open(filename.Data());
383    if ( !myfile ){    if ( !myfile ){
384      printf("ERROR: no such file, exiting...\n");      if ( filename != "" ){
385      stringstream hfile;        printf("ERROR: no such file, exiting...\n");
386      hfile.str("");        stringstream hfile;
387      hfile << filename.Data();        hfile.str("");
388      hfile << " : no such file! ";        hfile << filename.Data();
389      pamgui->DIALOG(2,hfile.str().c_str());        hfile << " : no such file! ";
390          pamgui->DIALOG(2,hfile.str().c_str());
391        };
392      pamela->var.waitforever = true;      pamela->var.waitforever = true;
393      goto refresh;      goto refresh;
394    };    };
# Line 330  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 342  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      if ( !otr ){      otr1 = (TTree*)headerFile->Get("Calorimeter");
414        otr = (TTree*)headerFile->Get("Physics");            otr2 = (TTree*)headerFile->Get("Tracker");
415        otr3 = (TTree*)headerFile->Get("NeutronD");
416        otr4 = (TTree*)headerFile->Get("OrbitalInfo");
417        otr5 = (TTree*)headerFile->Get("S4");
418        otr6 = (TTree*)headerFile->Get("ToF");
419        otr7 = (TTree*)headerFile->Get("Run");
420        otr8 = (TTree*)headerFile->Get("Anticounter");
421        if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 ){
422          L0 = (TTree*)headerFile->Get("Physics");      
423        pamela->level.file = -1;        pamela->level.file = -1;
424        } else {
425          stringstream dddec;
426          dddec.str("");
427          dddec << " +ALL +RUN +CAL1 -TRKh -TRK1 ";
428          if ( !otr0 ){
429            dddec << " -TRG ";
430            pamela->var.TRG = 0;
431            otr0 = otr1;
432          };
433          if ( !otr1 ){
434            dddec << " -CAL ";
435            pamela->var.CALO = 0;
436            if ( !otr0 ) otr0 = otr2;
437          };
438          if ( !otr2 ){
439            dddec << " -TRK2 -TRK ";
440            pamela->var.TRK = 0;
441            if ( !otr0 ) otr0 = otr3;
442          };
443          if ( !otr3 ){
444            dddec << " -ND ";
445            pamela->var.ND = 0;
446            if ( !otr0 ) otr0 = otr4;
447          };
448          if ( !otr4 ){
449            dddec << " -ORB ";
450            pamela->var.ORB = 0;
451            if ( !otr0 ) otr0 = otr5;
452          };
453          if ( !otr5 ){
454            dddec << " -S4 ";
455            pamela->var.S4 = 0;
456            if ( !otr0 ) otr0 = otr6;
457          };
458          if ( !otr6 ){
459            dddec << " -TOF ";
460            pamela->var.TOF = 0;
461            if ( !otr0 ) otr0 = otr8;
462          };
463          if ( !otr7 ){
464            dddec << " -RUN ";
465            pamela->var.RUN = 0;
466          };
467          if ( !otr8 ){
468            dddec << " -AC ";
469            pamela->var.AC = 0;
470          };
471          pamela->SetDDEC(dddec.str().c_str());
472      };      };
473      if ( !otr ){      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 355  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 368  void ShowEvent(TString filename="help", Line 492  void ShowEvent(TString filename="help",
492    //    //
493    // Load the file    // Load the file
494    //    //
495    pamela->Load(*otr,*headerFile);    if ( otr0 || L0 ){
496        otr = pamela->Load(filename.Data());
497        if ( !otr ){
498          pamela->level.file = -1;
499          printf("ERROR: problems opening file...\n");
500          pamgui->DIALOG(2,"Problems opening file");
501          pamela->var.waitforever = true;
502          goto refresh;
503        };
504      } else {
505        pamela->level.file = -1;
506        printf("ERROR: problems with TTree while opening file...\n");
507        pamgui->DIALOG(2,"Problems opening file");
508        pamela->var.waitforever = true;
509        goto refresh;
510      };
511    //    //
512    printf("\n");    printf("\n");
513    //    //
514    // get the number of entries    // get the number of entries
515    //    //
516      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);
520    //    //
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 403  void ShowEvent(TString filename="help", Line 544  void ShowEvent(TString filename="help",
544    if ( !pamela->var.refresh ) i = pamela->minevent;    if ( !pamela->var.refresh ) i = pamela->minevent;
545    pamela->var.refresh = false;    pamela->var.refresh = false;
546    //    //
547      pamgui->RefreshButtons();
548      //
549    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
550    //  MAIN LOOP STARTS HERE:    //  MAIN LOOP STARTS HERE:
551    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# Line 489  void ShowEvent(TString filename="help", Line 632  void ShowEvent(TString filename="help",
632        figsave << (pamela->var.i+1);        figsave << (pamela->var.i+1);
633        figsave << bw;        figsave << bw;
634        pamela->var.svas=figsave.str().c_str();        pamela->var.svas=figsave.str().c_str();
635    
636          //      printf(" qua %s \n",figsave.str().c_str());
637        //        //
638        // upgrade the figure filename in the GUI        // upgrade the figure filename in the GUI
639        //        //
# Line 509  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.1  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.23