/[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.13 by mocchiut, Mon Nov 26 08:29:55 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      pamela->var.restart = false;
188      Int_t i = 0;
189      Int_t isOK = 0;
190    //    //
191   restart:   restart:
192    //    //
193      if ( !pamela->var.restart ){
194        if ( i < 0 ){
195          i = -i;
196        } else {
197          i = 0;
198        };
199      };
200      //
201    // set boolean variables    // set boolean variables
202    //    //
   pamela->var.restart = false;  
203    pamela->var.waitforever = false;    pamela->var.waitforever = false;
204    pamela->var.jumprog = true;    pamela->var.jumprog = true;
205    pamela->var.jumpen = false;        pamela->var.jumpen = false;    
206    pamela->var.goon = false;    pamela->var.goon = false;
207    pamela->var.refresh = false;    pamela->var.refresh = false;
   pamela->var.fl0 = false;  
208    pamela->var.alrforc = false;    pamela->var.alrforc = false;
209    //    //
210    // check if we have an input filename    // check if we have an input filename
# Line 165  void ShowEvent(TString filename="help", Line 212  void ShowEvent(TString filename="help",
212    if ( filename.Data() == "" || !strcmp(filename.Data(),"help") ){    if ( filename.Data() == "" || !strcmp(filename.Data(),"help") ){
213      pamela->var.waitforever = true;      pamela->var.waitforever = true;
214    };    };
215    //  //   //
216    // chek if we are forcing level0  //   // chek if we are forcing level0
217    //  //   //
218    if ( pamela->var.fl0 == true ){  //   if ( pamela->var.fl0 == true ){
219      FORCELEV = 0;  //     FORCELEV = 0;
220    } else {  //   } else {
221      FORCELEV = -1;  //     FORCELEV = -1;
222    };  //   };
223    //    //
224    //  Define some variables    //  Define some variables
225    //    //
# Line 194  void ShowEvent(TString filename="help", Line 241  void ShowEvent(TString filename="help",
241    gStyle->SetNdivisions(1,"X");    gStyle->SetNdivisions(1,"X");
242    gStyle->SetNdivisions(1,"Y");    gStyle->SetNdivisions(1,"Y");
243    //    //
244    Int_t i = 0;    isOK = 0;
   Int_t isOK = 0;  
245    //    //
246    // from here to refresh    // from here to refresh
247    //    //
248   refresh:   refresh:
249    //    //
250      // reset pointers
251      //
252      TFile *headerFile = 0;
253      TChain *otr = 0;
254      TTree *L0 = 0;
255      //
256      //  gROOT->Reset();
257      //
258    // set selection file variables    // set selection file variables
259    //    //
260    pamela->var.selex = true;    if ( pamela->var.refresh ){
261    selfile = pamela->var.thefilter.Data();      if ( pamela->var.selex ){
262          //      pamela->var.selex = true;                               //<<<<<<<<<<<<<<<<<<<<<<<<<<?????????????????????
263          selfile = pamela->var.thefilter.Data();
264        };
265      };
266    //    //
   if ( outDir == "" ) outDir = startingdir;      
267    //    //
268    if ( pamela->var.fl0 == true ) {    if ( pamela->var.fl0 == true ) {
269      FORCELEV = 0;      FORCELEV = 0;
270    } else {    } else {
271      if ( pamela->var.refresh ) FORCELEV = -1;      if ( pamela->var.refresh ) FORCELEV = -1;           //<<<<<<<<<<<<<<<<<<<<<<<<<<?????????????????????
272    };    };
273    //    //
274    // check the detectors to be shown    // check the detectors to be shown
275    //    //
276    if ( !pamela->var.refresh ) pamela->checkctrlword();    //  if ( !pamela->var.refresh ) pamela->checkctrlword();
277      //pamela->checkctrlword();
278    //    //
279    // open a dialog if the program is launched without input filename    // open a dialog if the program is launched without input filename
280    //    //
# Line 235  void ShowEvent(TString filename="help", Line 293  void ShowEvent(TString filename="help",
293      gSystem->Sleep(10);      gSystem->Sleep(10);
294    };    };
295    //    //
296    if ( pamela->var.restart ){  //   if ( pamela->var.restart ){
297      filename = pamela->var.thefilename.Data();  //     filename = pamela->var.thefilename.Data();
298      goto restart;  //     goto restart;
299    };  //   };
300    //    //
301    // check if we are forcing level0 data    // check if we are forcing level0 data
302    //    //
# Line 253  void ShowEvent(TString filename="help", Line 311  void ShowEvent(TString filename="help",
311    // LOAD SELECTION FILE    // LOAD SELECTION FILE
312    //        //    
313    if ( selfile == ""  ){    if ( selfile == ""  ){
314      if ( !pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded ");      //if ( !pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded ");
315        if ( pamela->var.selex ) pamgui->DIALOG(0," Selection file unloaded ");
316      pamela->var.selex = false;      pamela->var.selex = false;
317    } else {    } else {
318      //      //
# Line 269  void ShowEvent(TString filename="help", Line 328  void ShowEvent(TString filename="help",
328      //      //
329      // load the structure header      // load the structure header
330      //      //
331      carica.str("");       carica.str("");
332      carica << paminc.str().c_str() << "/feventvstruct.h";       carica << paminc.str().c_str() << "/feventvstruct.h";
333      gROOT->LoadMacro(carica.str().c_str());       gROOT->LoadMacro(carica.str().c_str());
334        //    carica.str("");
335        //    carica << paminc.str().c_str() << "/CaloNuclei.h";
336        //    gROOT->LoadMacro(carica.str().c_str());
337      //      //
338      // load the selection macro      // load the selection macro
339      //      //
340      Int_t chkload = gROOT->LoadMacro(selfile);      Int_t chkload = gROOT->LoadMacro(selfile);
341      //      //
342        pamela->var.selex = false;
343        //
344      if ( chkload ){      if ( chkload ){
345        //        //
346        // not able to open the selection file        // not able to open the selection file
# Line 290  void ShowEvent(TString filename="help", Line 354  void ShowEvent(TString filename="help",
354        pamela->var.selex = false;        pamela->var.selex = false;
355        printf("\n WARNING! no selection file loaded! \n\n");        printf("\n WARNING! no selection file loaded! \n\n");
356        pamgui->DIALOG(1," No selection file loaded! ");        pamgui->DIALOG(1," No selection file loaded! ");
357          selfile = "";
358        //        //
359        // clear field in the GUI        // clear field in the GUI
360        //        //
# Line 309  void ShowEvent(TString filename="help", Line 374  void ShowEvent(TString filename="help",
374    //  LOAD FILES        //  LOAD FILES    
375    //    //
376    //    //
377    TFile *headerFile = 0;  //   if ( headerFile ) headerFile->Close();
378    TTree *otr = 0;  //   if ( otr ) otr->Delete();
379    //   if ( L0 ) L0->Delete();
380    
381    //    //
382    // check if user has given as input a correct path    // check if user has given as input a correct path
383    //    //
384    ifstream myfile;    ifstream myfile;
385    myfile.open(filename.Data());    myfile.open(filename.Data());
386    if ( !myfile ){    if ( !myfile ){
387      printf("ERROR: no such file, exiting...\n");      if ( filename != "" ){
388      stringstream hfile;        printf("ERROR: no such file, exiting...\n");
389      hfile.str("");        stringstream hfile;
390      hfile << filename.Data();        hfile.str("");
391      hfile << " : no such file! ";        hfile << filename.Data();
392      pamgui->DIALOG(2,hfile.str().c_str());        hfile << " : no such file! ";
393          pamgui->DIALOG(2,hfile.str().c_str());
394        };
395      pamela->var.waitforever = true;      pamela->var.waitforever = true;
396      goto refresh;      goto refresh;
397    };    };
# Line 330  void ShowEvent(TString filename="help", Line 399  void ShowEvent(TString filename="help",
399    //    //
400    // 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
401    //    //
402    
403    headerFile=new TFile(filename.Data());    headerFile=new TFile(filename.Data());
404    if ( FORCELEV == 0 ){    if ( FORCELEV == 0 ){
405      pamela->level.file = 0;      pamela->level.file = 0;
406      otr = (TTree*)headerFile->Get("Physics");      L0 = (TTree*)headerFile->Get("Physics");
407      if ( !otr ){      if ( !L0 ){
408        printf("ERROR: no Physics tree...\n");        printf("ERROR: no Physics tree...\n");
409        pamgui->DIALOG(2,"No Physics tree in this file");        pamgui->DIALOG(2,"No Physics tree in this file");
410        pamela->var.waitforever = true;        pamela->var.waitforever = true;
# Line 342  void ShowEvent(TString filename="help", Line 412  void ShowEvent(TString filename="help",
412      }      }
413    } else {    } else {
414      pamela->level.file = 2;      pamela->level.file = 2;
415      otr = (TTree*)headerFile->Get("Trigger");      otr0 = (TTree*)headerFile->Get("Trigger");
416      if ( !otr ){      otr1 = (TTree*)headerFile->Get("Calorimeter");
417        otr = (TTree*)headerFile->Get("Physics");            otr2 = (TTree*)headerFile->Get("Tracker");
418        otr3 = (TTree*)headerFile->Get("NeutronD");
419        otr4 = (TTree*)headerFile->Get("OrbitalInfo");
420        otr5 = (TTree*)headerFile->Get("S4");
421        otr6 = (TTree*)headerFile->Get("ToF");
422        otr7 = (TTree*)headerFile->Get("Run");
423        otr8 = (TTree*)headerFile->Get("Anticounter");
424        if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 ){
425          L0 = (TTree*)headerFile->Get("Physics");      
426        pamela->level.file = -1;        pamela->level.file = -1;
427        } else {
428          stringstream dddec;
429          dddec.str("");
430          dddec << " +AUTO ";
431          //      dddec << " +ALL +RUN +CAL1 -TRKh -TRK1 -TRK0 -CAL0";
432           if ( !otr0 ){
433            dddec << " -TRG ";
434            pamela->var.TRG = 0;
435            otr0 = otr1;
436           };
437           if ( !otr1 ){
438            dddec << " -CAL ";
439            pamela->var.CALO = 0;
440            if ( !otr0 ) otr0 = otr2;
441           };
442           if ( !otr2 ){
443            dddec << " -TRK2 -TRK ";
444            pamela->var.TRK = 0;
445            if ( !otr0 ) otr0 = otr3;
446           };
447           if ( !otr3 ){
448            dddec << " -ND ";
449            pamela->var.ND = 0;
450            if ( !otr0 ) otr0 = otr4;
451           };
452           if ( !otr4 ){
453            dddec << " -ORB ";
454            pamela->var.ORB = 0;
455            if ( !otr0 ) otr0 = otr5;
456           };
457           if ( !otr5 ){
458            dddec << " -S4 ";
459            pamela->var.S4 = 0;
460            if ( !otr0 ) otr0 = otr6;
461           };
462           if ( !otr6 ){
463            dddec << " -TOF ";
464            pamela->var.TOF = 0;
465            if ( !otr0 ) otr0 = otr8;
466           };
467           if ( !otr7 ){
468            dddec << " -RUN ";
469            pamela->var.RUN = 0;
470           };
471           if ( !otr8 ){
472            dddec << " -AC ";
473            pamela->var.AC = 0;
474           };
475          pamela->SetDDEC(dddec.str().c_str());
476      };      };
477      if ( !otr ){      if ( !otr0 && !otr1 && !otr2 && !otr3 && !otr4 && !otr5 && !otr6 && !otr7 && !otr8 && !L0 ){
478        pamela->level.file = -1;        pamela->level.file = -1;
479        printf("ERROR: nor Physics nor Run tree...\n");        printf("ERROR: nor Physics nor Run tree...\n");
480        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 482  void ShowEvent(TString filename="help",
482        goto refresh;        goto refresh;
483      };      };
484    };    };
485      headerFile->Close("R");
486    //    //
487    if ( pamela->level.file != 2 ){    if ( pamela->level.file != 2 ){
488      printf(" This is a YODA (level0) file \n");      printf(" This is a YODA (level0) file \n");
# Line 368  void ShowEvent(TString filename="help", Line 496  void ShowEvent(TString filename="help",
496    //    //
497    // Load the file    // Load the file
498    //    //
499    pamela->Load(*otr,*headerFile);    if ( otr0 || L0 ){
500        otr = pamela->Load(filename.Data());
501        if ( !otr ){
502          pamela->level.file = -1;
503          printf("ERROR: problems opening file...\n");
504          pamgui->DIALOG(2,"Problems opening file");
505          pamela->var.waitforever = true;
506          goto refresh;
507        };
508      } else {
509        pamela->level.file = -1;
510        printf("ERROR: problems with TTree while opening file...\n");
511        pamgui->DIALOG(2,"Problems opening file");
512        pamela->var.waitforever = true;
513        goto refresh;
514      };
515    //    //
516    printf("\n");    printf("\n");
517    //    //
518    // get the number of entries    // get the number of entries
519    //    //
520      if ( !otr ) printf(" AGH! \n");
521      //
522    Long64_t nevents = otr->GetEntries();    Long64_t nevents = otr->GetEntries();
523    printf(" The file contains %i physics events \n",(int)nevents);    printf(" The file contains %i physics events \n",(int)nevents);
524    //    //
525    // check we have at least one event    // check we have at least one event
526    //    //
527    if (nevents<=0) {    if (nevents<=0) {
528      headerFile->Close();      //    headerFile->Close();
529      printf("The file is empty, exiting...\n");      printf("The file is empty, exiting...\n");
530      pamgui->DIALOG(0," The file contains no physics data! ");      pamgui->DIALOG(0," The file contains no physics data! ");
531      pamela->var.waitforever = true;      pamela->var.waitforever = true;
# Line 400  void ShowEvent(TString filename="help", Line 545  void ShowEvent(TString filename="help",
545    //    //
546    // display the first event (unless we are refreshing only the window)    // display the first event (unless we are refreshing only the window)
547    //    //
548    if ( !pamela->var.refresh ) i = pamela->minevent;    if ( !pamela->var.refresh && !pamela->var.restart ) i = pamela->minevent;
549      pamela->var.restart = false;
550    pamela->var.refresh = false;    pamela->var.refresh = false;
551    //    //
552      pamgui->RefreshButtons();
553      //
554    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
555    //  MAIN LOOP STARTS HERE:    //  MAIN LOOP STARTS HERE:
556    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# Line 489  void ShowEvent(TString filename="help", Line 637  void ShowEvent(TString filename="help",
637        figsave << (pamela->var.i+1);        figsave << (pamela->var.i+1);
638        figsave << bw;        figsave << bw;
639        pamela->var.svas=figsave.str().c_str();        pamela->var.svas=figsave.str().c_str();
640    
641          //      printf(" qua %s \n",figsave.str().c_str());
642        //        //
643        // upgrade the figure filename in the GUI        // upgrade the figure filename in the GUI
644        //        //
# Line 509  void ShowEvent(TString filename="help", Line 659  void ShowEvent(TString filename="help",
659        //        //
660        pamela->var.goon = false;        pamela->var.goon = false;
661        if ( pamela->var.refresh || pamela->var.restart ){        if ( pamela->var.refresh || pamela->var.restart ){
662          headerFile->Close();          if ( pamela->GetL2() ) pamela->GetL2()->Reset();
663            if ( pamela->level.file != 2 ) pamela->GetChain()->Delete();
664            otr = NULL;
665            //      if ( headerFile ) headerFile->Close("R");
666          if ( pamela->var.refresh ) goto refresh;          if ( pamela->var.refresh ) goto refresh;
667          if ( pamela->var.restart ){          if ( pamela->var.restart ){
668              i = pamela->var.i;
669            filename = pamela->var.thefilename.Data();            filename = pamela->var.thefilename.Data();
670            goto restart;            goto restart;
671          };          };

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

  ViewVC Help
Powered by ViewVC 1.1.23