- Timestamp:
- Oct 16, 2014, 2:19:17 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 30bb83a
- Parents:
- a3b2495
- Location:
- display
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
display/DelphesEventDisplay.cc
ra3b2495 rfafc433 31 31 DelphesEventDisplay::DelphesEventDisplay() 32 32 { 33 event_id = 0;33 event_id_ = 0; 34 34 tkRadius_ = 1.29; 35 35 totRadius_ = 2.0; … … 37 37 bz_ = 3.8; 38 38 chain_ = new TChain("Delphes"); 39 gTreeReader= 0;40 gDelphesDisplay= 0;39 treeReader_ = 0; 40 delphesDisplay_ = 0; 41 41 } 42 42 … … 48 48 DelphesEventDisplay::DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D) 49 49 { 50 event_id = 0;50 event_id_ = 0; 51 51 tkRadius_ = 1.29; 52 52 totRadius_ = 2.0; … … 54 54 bz_ = 3.8; 55 55 chain_ = new TChain("Delphes"); 56 gTreeReader= 0;57 gDelphesDisplay= 0;56 treeReader_ = 0; 57 delphesDisplay_ = 0; 58 58 59 59 // initialize the application … … 103 103 // Create object of class ExRootTreeReader 104 104 printf("*** Opening Delphes data file ***\n"); 105 gTreeReader= new ExRootTreeReader(chain_);105 treeReader_ = new ExRootTreeReader(chain_); 106 106 107 107 // 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) { 110 110 DelphesBranchElement<TEveTrackList>* item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(*element); 111 111 DelphesBranchElement<TEveElementList>* item_v2 = dynamic_cast<DelphesBranchElement<TEveElementList>*>(*element); … … 115 115 116 116 // viewers and scenes 117 gDelphesDisplay= new DelphesDisplay;117 delphesDisplay_ = new DelphesDisplay; 118 118 gEve->AddGlobalElement(geometry); 119 gDelphesDisplay->ImportGeomRPhi(geometry);120 gDelphesDisplay->ImportGeomRhoZ(geometry);119 delphesDisplay_->ImportGeomRPhi(geometry); 120 delphesDisplay_->ImportGeomRhoZ(geometry); 121 121 // 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) { 123 123 if(TString((*data)->GetType())=="tower") { // we could also use GetClassName()=="DelphesCaloData" 124 124 DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer(); … … 128 128 calo3d->SetEndCapPos(tkHalfLength_); 129 129 gEve->AddGlobalElement(calo3d); 130 gDelphesDisplay->ImportCaloRPhi(calo3d);131 gDelphesDisplay->ImportCaloRhoZ(calo3d);130 delphesDisplay_->ImportCaloRPhi(calo3d); 131 delphesDisplay_->ImportCaloRhoZ(calo3d); 132 132 TEveCaloLego *lego = new TEveCaloLego(container); 133 133 lego->InitMainTrans(); … … 135 135 lego->SetAutoRebin(kFALSE); 136 136 lego->Set2DMode(TEveCaloLego::kValSizeOutline); 137 gDelphesDisplay->ImportCaloLego(lego);137 delphesDisplay_->ImportCaloLego(lego); 138 138 break; 139 139 } 140 140 } 141 141 142 //make_gui(); //TODO put back!143 //load_event(); //TODO put back!142 make_gui(); 143 load_event(); 144 144 gEve->Redraw3D(kTRUE); 145 145 … … 217 217 } 218 218 //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)); 220 220 } 221 221 // second loop for tracks … … 232 232 trkProp->SetMaxR(tk_radius); 233 233 trkProp->SetMaxZ(tk_length); 234 arrays.push_back( gTreeReader->UseBranch(name));234 arrays.push_back(treeReader_->UseBranch(name)); 235 235 } 236 236 } … … 241 241 void DelphesEventDisplay::load_event() 242 242 { 243 // Load event specified in global event_id .243 // Load event specified in global event_id_. 244 244 // The contents of previous event are removed. 245 245 246 246 //TODO move this to the status bar ??? 247 printf("Loading event %d.\n", event_id );247 printf("Loading event %d.\n", event_id_); 248 248 249 249 250 250 // clear the previous event 251 251 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) { 253 253 (*data)->Reset(); 254 254 } … … 259 259 // update display 260 260 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); 265 265 //update_html_summary(); 266 266 gEve->Redraw3D(kFALSE, kTRUE); … … 271 271 272 272 // safety 273 if(event_id >= gTreeReader->GetEntries() || event_id<0 ) return;273 if(event_id_ >= treeReader_->GetEntries() || event_id_<0 ) return; 274 274 275 275 // Load selected branches with data from specified event 276 gTreeReader->ReadEntry(event_id);276 treeReader_->ReadEntry(event_id_); 277 277 278 278 // 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_. 280 280 281 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 = 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) { 285 285 TString type = (*element)->GetType(); 286 286 // branch on the element type … … 474 474 icondir = Form("%s/icons/", (const char*)gSystem->GetFromPipe("root-config --etcdir") ); 475 475 TGPictureButton* b = 0; 476 EvNavHandler *fh = new EvNavHandler(this);477 476 478 477 b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif")); 479 478 hf->AddFrame(b); 480 b->Connect("Clicked()", " EvNavHandler", fh, "Bck()");479 b->Connect("Clicked()", "DelphesEventDisplay", this, "Bck()"); 481 480 482 481 b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif")); 483 482 hf->AddFrame(b); 484 b->Connect("Clicked()", " EvNavHandler", fh, "Fwd()");483 b->Connect("Clicked()", "DelphesEventDisplay", this, "Fwd()"); 485 484 } 486 485 frmMain->AddFrame(hf); -
display/DelphesEventDisplay.h
ra3b2495 rfafc433 21 21 22 22 #include <vector> 23 #include <iostream> 23 24 #include "external/ExRootAnalysis/ExRootTreeReader.h" 24 25 #include "display/DelphesDisplay.h" … … 40 41 DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D); 41 42 ~DelphesEventDisplay(); 42 Int_t event_id;43 ExRootTreeReader *gTreeReader;44 void load_event();45 43 46 44 private: 47 45 void make_gui(); 46 void load_event(); 48 47 void delphes_read(); 49 48 void delphes_read_towers(TClonesArray* data, DelphesBranchBase* element); … … 54 53 55 54 // Configuration and global variables. 55 Int_t event_id_; 56 ExRootTreeReader *treeReader_; 56 57 Double_t tkRadius_, totRadius_, tkHalfLength_, bz_; 57 58 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_; 61 62 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 } 68 73 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 } 91 82 }; 92 83
Note:
See TracChangeset
for help on using the changeset viewer.