Fork me on GitHub

Ignore:
Timestamp:
Oct 16, 2014, 10:11:54 PM (10 years ago)
Author:
Christophe Delaere <christophe.delaere@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
369744d
Parents:
fafc433
Message:

Some small cleaning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • display/DelphesEventDisplay.cc

    rfafc433 r30bb83a  
    6666   tkHalfLength_ = det3D.getTrackerHalfLength();
    6767   bz_ = det3D.getBField();
    68 
    69    //TODO specific to some classical detector... could use better the det3D
    7068   TGeoVolume* top = det3D.getDetector(false);
    7169   geom->SetTopVolume(top);
    7270   TEveElementList *geometry = new TEveElementList("Geometry");
    73    TEveGeoTopNode* trk = new TEveGeoTopNode(gGeoManager, top->FindNode("tracker_1"));
    74    trk->SetVisLevel(6);
    75    geometry->AddElement(trk);
    76    TEveGeoTopNode* calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_barrel_1"));
    77    calo->SetVisLevel(3);
    78    geometry->AddElement(calo);
    79    calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_endcap_1"));
    80    calo->SetVisLevel(3);
    81    calo->UseNodeTrans();
    82    geometry->AddElement(calo);
    83    calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_endcap_2"));
    84    calo->SetVisLevel(3);
    85    calo->UseNodeTrans();
    86    geometry->AddElement(calo);
    87    TEveGeoTopNode* muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_barrel_1"));
    88    muon->SetVisLevel(4);
    89    geometry->AddElement(muon);
    90    muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_endcap_1"));
    91    muon->SetVisLevel(4);
    92    muon->UseNodeTrans();
    93    geometry->AddElement(muon);
    94    muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_endcap_2"));
    95    muon->SetVisLevel(4);
    96    muon->UseNodeTrans();
    97    geometry->AddElement(muon);
    98    //gGeoManager->DefaultColors();
     71   TObjArray* nodes = top->GetNodes();
     72   TIter itNodes(nodes);
     73   TGeoNode* nodeobj;
     74   TEveGeoTopNode* node;
     75   while((nodeobj = (TGeoNode*)itNodes.Next())) {
     76     node = new TEveGeoTopNode(gGeoManager,nodeobj);
     77     node->UseNodeTrans();
     78     geometry->AddElement(node);
     79   }
    9980
    10081   // Create chain of root trees
     
    145126
    146127}
     128
    147129// function that parses the config to extract the branches of interest and prepare containers
    148130void DelphesEventDisplay::readConfig(const char *configFile, Delphes3DGeometry& det3D, std::vector<DelphesBranchBase*>& elements, std::vector<TClonesArray*>& arrays) {
     
    216198       continue;
    217199     }
    218 //TODO one possible simplification could be to add the array to the element class.
    219200     arrays.push_back(treeReader_->UseBranch(name));
    220201   }
     
    237218}
    238219
    239 
    240 //______________________________________________________________________________
    241220void DelphesEventDisplay::load_event()
    242221{
     
    244223   // The contents of previous event are removed.
    245224
     225   // safety
     226   if(event_id_ >= treeReader_->GetEntries() || event_id_<0 ) return;
     227
    246228   //TODO move this to the status bar ???
    247229   printf("Loading event %d.\n", event_id_);
    248 
    249230
    250231   // clear the previous event
     
    254235   }
    255236
    256    // read the new event
    257    delphes_read();
     237   // Load selected branches with data from specified event
     238   treeReader_->ReadEntry(event_id_);
     239
     240   // loop over selected branches, and apply the proper recipe to fill the collections.
     241   // this is basically to loop on arrays_ to fill elements_.
     242   std::vector<TClonesArray*>::iterator data = arrays_.begin();
     243   std::vector<DelphesBranchBase*>::iterator element = elements_.begin();
     244   for(; data<arrays_.end() && element<elements_.end(); ++data, ++element) {
     245     TString type = (*element)->GetType();
     246     // branch on the element type
     247     if(type=="tower") delphes_read_towers(*data,*element);
     248     else if(type=="track" || type=="photon" || type=="electron" || type=="muon" || type=="genparticle") delphes_read_tracks(*data,*element);
     249     else if(type=="jet") delphes_read_jets(*data,*element);
     250     else if(type=="vector") delphes_read_vectors(*data,*element);
     251   }
    258252
    259253   // update display
     
    264258   delphesDisplay_->ImportEventRhoZ(top);
    265259   //update_html_summary();
     260
    266261   gEve->Redraw3D(kFALSE, kTRUE);
    267 }
    268 
    269 void DelphesEventDisplay::delphes_read()
    270 {
    271 
    272   // safety
    273   if(event_id_ >= treeReader_->GetEntries() || event_id_<0 ) return;
    274 
    275   // Load selected branches with data from specified event
    276   treeReader_->ReadEntry(event_id_);
    277 
    278   // loop over selected branches, and apply the proper recipe to fill the collections.
    279   // this is basically to loop on arrays_ to fill elements_.
    280 
    281 //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 = arrays_.begin();
    283   std::vector<DelphesBranchBase*>::iterator element = elements_.begin();
    284   for(; data<arrays_.end() && element<elements_.end(); ++data, ++element) {
    285     TString type = (*element)->GetType();
    286     // branch on the element type
    287     if(type=="tower") delphes_read_towers(*data,*element);
    288     else if(type=="track" || type=="photon" || type=="electron" || type=="muon" || type=="genparticle") delphes_read_tracks(*data,*element);
    289     else if(type=="jet") delphes_read_jets(*data,*element);
    290     else if(type=="vector") delphes_read_vectors(*data,*element);
    291   }
    292262}
    293263
Note: See TracChangeset for help on using the changeset viewer.