Fork me on GitHub

Changeset fafc433 in git


Ignore:
Timestamp:
Oct 16, 2014, 2:19:17 PM (10 years ago)
Author:
Christophe Delaere <christophe.delaere@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
30bb83a
Parents:
a3b2495
Message:

Working basic GUI

The functionality of Fwd and Bck buttons has been restored.
This brings us back to a fully working prototype ready for new features.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • display/DelphesEventDisplay.cc

    ra3b2495 rfafc433  
    3131DelphesEventDisplay::DelphesEventDisplay()
    3232{
    33    event_id = 0;
     33   event_id_ = 0;
    3434   tkRadius_ = 1.29;
    3535   totRadius_ = 2.0;
     
    3737   bz_ = 3.8;
    3838   chain_ = new TChain("Delphes");
    39    gTreeReader = 0;
    40    gDelphesDisplay = 0;
     39   treeReader_ = 0;
     40   delphesDisplay_ = 0;
    4141}
    4242
     
    4848DelphesEventDisplay::DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D)
    4949{
    50    event_id = 0;
     50   event_id_ = 0;
    5151   tkRadius_ = 1.29;
    5252   totRadius_ = 2.0;
     
    5454   bz_ = 3.8;
    5555   chain_ = new TChain("Delphes");
    56    gTreeReader = 0;
    57    gDelphesDisplay = 0;
     56   treeReader_ = 0;
     57   delphesDisplay_ = 0;
    5858
    5959   // initialize the application
     
    103103   // Create object of class ExRootTreeReader
    104104   printf("*** Opening Delphes data file ***\n");
    105    gTreeReader = new ExRootTreeReader(chain_);
     105   treeReader_ = new ExRootTreeReader(chain_);
    106106
    107107   // prepare data collections
    108    readConfig(configFile, det3D, gElements, gArrays);
    109    for(std::vector<DelphesBranchBase*>::iterator element = gElements.begin(); element<gElements.end(); ++element) {
     108   readConfig(configFile, det3D, elements_, arrays_);
     109   for(std::vector<DelphesBranchBase*>::iterator element = elements_.begin(); element<elements_.end(); ++element) {
    110110     DelphesBranchElement<TEveTrackList>*   item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(*element);
    111111     DelphesBranchElement<TEveElementList>* item_v2 = dynamic_cast<DelphesBranchElement<TEveElementList>*>(*element);
     
    115115
    116116   // viewers and scenes
    117    gDelphesDisplay = new DelphesDisplay;
     117   delphesDisplay_ = new DelphesDisplay;
    118118   gEve->AddGlobalElement(geometry);
    119    gDelphesDisplay->ImportGeomRPhi(geometry);
    120    gDelphesDisplay->ImportGeomRhoZ(geometry);
     119   delphesDisplay_->ImportGeomRPhi(geometry);
     120   delphesDisplay_->ImportGeomRhoZ(geometry);
    121121   // find the first calo data and use that to initialize the calo display
    122    for(std::vector<DelphesBranchBase*>::iterator data=gElements.begin();data<gElements.end();++data) {
     122   for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) {
    123123     if(TString((*data)->GetType())=="tower") { // we could also use GetClassName()=="DelphesCaloData"
    124124       DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer();
     
    128128       calo3d->SetEndCapPos(tkHalfLength_);
    129129       gEve->AddGlobalElement(calo3d);
    130        gDelphesDisplay->ImportCaloRPhi(calo3d);
    131        gDelphesDisplay->ImportCaloRhoZ(calo3d);
     130       delphesDisplay_->ImportCaloRPhi(calo3d);
     131       delphesDisplay_->ImportCaloRhoZ(calo3d);
    132132       TEveCaloLego *lego = new TEveCaloLego(container);
    133133       lego->InitMainTrans();
     
    135135       lego->SetAutoRebin(kFALSE);
    136136       lego->Set2DMode(TEveCaloLego::kValSizeOutline);
    137        gDelphesDisplay->ImportCaloLego(lego);
     137       delphesDisplay_->ImportCaloLego(lego);
    138138       break;
    139139     }
    140140   }
    141141
    142    //make_gui(); //TODO put back!
    143    //load_event(); //TODO put back!
     142   make_gui();
     143   load_event();
    144144   gEve->Redraw3D(kTRUE);   
    145145
     
    217217     }
    218218//TODO one possible simplification could be to add the array to the element class.
    219      arrays.push_back(gTreeReader->UseBranch(name));
     219     arrays.push_back(treeReader_->UseBranch(name));
    220220   }
    221221   // second loop for tracks
     
    232232       trkProp->SetMaxR(tk_radius);
    233233       trkProp->SetMaxZ(tk_length);
    234        arrays.push_back(gTreeReader->UseBranch(name));
     234       arrays.push_back(treeReader_->UseBranch(name));
    235235     }
    236236   }
     
    241241void DelphesEventDisplay::load_event()
    242242{
    243    // Load event specified in global event_id.
     243   // Load event specified in global event_id_.
    244244   // The contents of previous event are removed.
    245245
    246246   //TODO move this to the status bar ???
    247    printf("Loading event %d.\n", event_id);
     247   printf("Loading event %d.\n", event_id_);
    248248
    249249
    250250   // clear the previous event
    251251   gEve->GetViewers()->DeleteAnnotations();
    252    for(std::vector<DelphesBranchBase*>::iterator data=gElements.begin();data<gElements.end();++data) {
     252   for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) {
    253253     (*data)->Reset();
    254254   }
     
    259259   // update display
    260260   TEveElement* top = (TEveElement*)gEve->GetCurrentEvent();
    261    gDelphesDisplay->DestroyEventRPhi();
    262    gDelphesDisplay->ImportEventRPhi(top);
    263    gDelphesDisplay->DestroyEventRhoZ();
    264    gDelphesDisplay->ImportEventRhoZ(top);
     261   delphesDisplay_->DestroyEventRPhi();
     262   delphesDisplay_->ImportEventRPhi(top);
     263   delphesDisplay_->DestroyEventRhoZ();
     264   delphesDisplay_->ImportEventRhoZ(top);
    265265   //update_html_summary();
    266266   gEve->Redraw3D(kFALSE, kTRUE);
     
    271271
    272272  // safety
    273   if(event_id >= gTreeReader->GetEntries() || event_id<0 ) return;
     273  if(event_id_ >= treeReader_->GetEntries() || event_id_<0 ) return;
    274274
    275275  // Load selected branches with data from specified event
    276   gTreeReader->ReadEntry(event_id);
     276  treeReader_->ReadEntry(event_id_);
    277277
    278278  // loop over selected branches, and apply the proper recipe to fill the collections.
    279   // this is basically to loop on gArrays to fill gElements.
     279  // this is basically to loop on arrays_ to fill elements_.
    280280
    281281//TODO: one option would be to have templated methods in the element classes. We could simply call "element.fill()"
    282   std::vector<TClonesArray*>::iterator data = gArrays.begin();
    283   std::vector<DelphesBranchBase*>::iterator element = gElements.begin();
    284   for(; data<gArrays.end() && element<gElements.end(); ++data, ++element) {
     282  std::vector<TClonesArray*>::iterator data = arrays_.begin();
     283  std::vector<DelphesBranchBase*>::iterator element = elements_.begin();
     284  for(; data<arrays_.end() && element<elements_.end(); ++data, ++element) {
    285285    TString type = (*element)->GetType();
    286286    // branch on the element type
     
    474474        icondir = Form("%s/icons/", (const char*)gSystem->GetFromPipe("root-config --etcdir") );
    475475      TGPictureButton* b = 0;
    476       EvNavHandler    *fh = new EvNavHandler(this);
    477476
    478477      b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif"));
    479478      hf->AddFrame(b);
    480       b->Connect("Clicked()", "EvNavHandler", fh, "Bck()");
     479      b->Connect("Clicked()", "DelphesEventDisplay", this, "Bck()");
    481480
    482481      b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif"));
    483482      hf->AddFrame(b);
    484       b->Connect("Clicked()", "EvNavHandler", fh, "Fwd()");
     483      b->Connect("Clicked()", "DelphesEventDisplay", this, "Fwd()");
    485484   }
    486485   frmMain->AddFrame(hf);
  • display/DelphesEventDisplay.h

    ra3b2495 rfafc433  
    2121
    2222#include <vector>
     23#include <iostream>
    2324#include "external/ExRootAnalysis/ExRootTreeReader.h"
    2425#include "display/DelphesDisplay.h"
     
    4041    DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D);
    4142    ~DelphesEventDisplay();
    42     Int_t event_id;
    43     ExRootTreeReader *gTreeReader;
    44     void load_event();
    4543
    4644  private:
    4745    void make_gui();
     46    void load_event();
    4847    void delphes_read();
    4948    void delphes_read_towers(TClonesArray* data, DelphesBranchBase* element);
     
    5453
    5554    // Configuration and global variables.
     55    Int_t event_id_;
     56    ExRootTreeReader *treeReader_;
    5657    Double_t tkRadius_, totRadius_, tkHalfLength_, bz_;
    5758    TChain* chain_;
    58     std::vector<DelphesBranchBase*> gElements;
    59     std::vector<TClonesArray*> gArrays;
    60     DelphesDisplay *gDelphesDisplay;
     59    std::vector<DelphesBranchBase*> elements_;
     60    std::vector<TClonesArray*> arrays_;
     61    DelphesDisplay *delphesDisplay_;
    6162
    62     // EvNavHandler class is needed to connect GUI signals.
    63     class EvNavHandler
    64     {     
    65       public:
    66      
    67          EvNavHandler(DelphesEventDisplay* display):display_(display) {}
     63    // gui controls
     64  public:
     65     void Fwd() { 
     66        if (event_id_ < treeReader_->GetEntries() - 1) {
     67           ++event_id_;
     68           load_event();
     69        } else {
     70           printf("Already at last event.\n");
     71        }
     72     }
    6873
    69          ~EvNavHandler() {}
    70 
    71          void Fwd() { 
    72             if (display_->event_id < display_->gTreeReader->GetEntries() - 1) {
    73                ++(display_->event_id);
    74                display_->load_event();
    75             } else {
    76                printf("Already at last event.\n");
    77             }
    78          }
    79 
    80          void Bck() {
    81             if (display_->event_id > 0) {
    82                --(display_->event_id);
    83                display_->load_event();
    84             } else {
    85                printf("Already at first event.\n");
    86             }
    87          }
    88        private:
    89          DelphesEventDisplay* display_;
    90     };
     74     void Bck() {
     75        if (event_id_ > 0) {
     76           --event_id_;
     77           load_event();
     78        } else {
     79           printf("Already at first event.\n");
     80        }
     81     }
    9182};
    9283
  • examples/evdisplay.C

    ra3b2495 rfafc433  
    88   // load the libraries
    99   gSystem->Load("libGeom");
    10    //gSystem->Load("../libDelphes");
    1110   gSystem->Load("../libDelphesDisplay");
    1211
     
    1615
    1716   // create the application items
    18    DelphesEventDisplay display("delphes_card_CMS.tcl", "../delphes_output.root", det3D); //TODO root file as input cfg
     17   DelphesEventDisplay* display = new DelphesEventDisplay("delphes_card_CMS.tcl", "../delphes_output.root", det3D);
     18
    1919/*
    20    make_gui();
    21    load_event();
    22    gEve->Redraw3D(kTRUE); // Reset camera after the first event has been shown.
    23 
    2420   // EClipType not exported to CINT (see TGLUtil.h):
    2521   // 0 - no clip, 1 - clip plane, 2 - clip box
Note: See TracChangeset for help on using the changeset viewer.