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

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

  ViewVC Help
Powered by ViewVC 1.1.23