- Timestamp:
- Oct 25, 2014, 11:32:13 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- ad015db
- Parents:
- 2ca23b5
- Location:
- display
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
display/DelphesBranchElement.cc
r2ca23b5 r3f51314 26 26 #include <iostream> 27 27 28 //TODO implement GetVectors() 29 28 30 // special case for calo towers 29 31 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) { … … 46 48 data_->DataChanged(); 47 49 } 50 } 51 template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors() { 52 std::vector<TLorentzVector> output; 53 if(TString(GetType())=="Tower") { 54 TIter itTower(branch_); 55 Tower *tower; 56 while((tower = (Tower *) itTower.Next())) { 57 TLorentzVector v; 58 v.SetPtEtaPhiM(tower->Eem+tower->Ehad,(tower->Edges[0]+tower->Edges[1])/2.,(tower->Edges[2]+tower->Edges[3])/2.,0.); 59 output.push_back(v); 60 } 61 } 62 return output; 48 63 } 49 64 … … 91 106 } 92 107 } 108 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() { 109 std::vector<TLorentzVector> output; 110 if(TString(GetType())=="Jet") { 111 TIter itJet(branch_); 112 Jet *jet; 113 // Loop over all jets 114 while((jet = (Jet *) itJet.Next())) { 115 TLorentzVector v; 116 v.SetPtEtaPhiM(jet->PT, jet->Eta, jet->Phi, jet->Mass); 117 output.push_back(v); 118 } 119 } else if(TString(GetType())=="MissingET") { 120 TIter itMet(branch_); 121 MissingET *MET; 122 // Missing Et 123 while((MET = (MissingET*) itMet.Next())) { 124 TLorentzVector v; 125 v.SetPtEtaPhiM(MET->MET,MET->Eta,MET->Phi,0.); 126 output.push_back(v); 127 } 128 } 129 return output; 130 } 93 131 94 132 // special case for track lists … … 199 237 } 200 238 } 239 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() { 240 std::vector<TLorentzVector> output; 241 TString type = GetType(); 242 TIter itTrack(branch_); 243 if(type=="Track") { // CASE 1: TRACKS 244 Track *track; 245 while((track = (Track *) itTrack.Next())) { 246 output.push_back(track->P4()); 247 } 248 } else if(type=="Electron") { // CASE 2: ELECTRONS 249 Electron *electron; 250 while((electron = (Electron *) itTrack.Next())) { 251 output.push_back(electron->P4()); 252 } 253 } else if(type=="Muon") { // CASE 3: MUONS 254 Muon *muon; 255 while((muon = (Muon *) itTrack.Next())) { 256 output.push_back(muon->P4()); 257 } 258 } else if(type=="Photon") { // CASE 4: PHOTONS 259 Photon *photon; 260 while((photon = (Photon *) itTrack.Next())) { 261 output.push_back(photon->P4()); 262 } 263 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES 264 GenParticle *particle; 265 while((particle = (GenParticle *) itTrack.Next())) { 266 if(particle->Status != 1) continue; 267 output.push_back(particle->P4()); 268 } 269 } 270 return output; 271 } -
display/DelphesBranchElement.h
r2ca23b5 r3f51314 43 43 virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; } 44 44 virtual void ReadBranch() = 0; 45 virtual std::vector<TLorentzVector> GetVectors() = 0; 45 46 46 47 protected: … … 79 80 virtual void ReadBranch() {} 80 81 82 // return the vector for all elements 83 virtual std::vector<TLorentzVector> GetVectors() { std::vector<TLorentzVector> v; return v; } 84 81 85 private: 82 86 EveContainer* data_; … … 89 93 template<> void DelphesBranchElement<DelphesCaloData>::Reset(); 90 94 template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch(); 95 template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors(); 91 96 92 97 // special case for element lists … … 94 99 template<> void DelphesBranchElement<TEveElementList>::Reset(); 95 100 template<> void DelphesBranchElement<TEveElementList>::ReadBranch(); 101 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors(); 96 102 97 103 // special case for track lists … … 100 106 template<> void DelphesBranchElement<TEveTrackList>::Reset(); 101 107 template<> void DelphesBranchElement<TEveTrackList>::ReadBranch(); 108 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors(); 102 109 103 110 #endif // CINT, CLING -
display/DelphesEventDisplay.cc
r2ca23b5 r3f51314 156 156 fStatusBar_->SetText("Ready.", 1); 157 157 load_event(); 158 plotSummary_->FillSample(treeReader_, event_id_); //TODO later, control it via a GUI button. 159 plotSummary_->FillEvent(); //TODO later move to event loop 160 plotSummary_->Draw(); 158 161 gEve->Redraw3D(kTRUE); 159 162 … … 386 389 plotSummary_ = new DelphesPlotSummary(tab); 387 390 plotSummary_->Init(elements_); 388 plotSummary_->FillSample(treeReader_); //TODO later, control it via a GUI button. 389 plotSummary_->FillEvent(); //TODO later move to event loop 390 391 //for test 392 TH1F* h; 393 TRootEmbeddedCanvas* trec; 394 TCanvas* gCanvas_; 395 396 slot = tab->NewSlot(); 397 trec = new TRootEmbeddedCanvas(); 398 gCanvas_ = trec->GetCanvas(); 399 wf = slot->MakeFrame(trec); 400 wf->SetElementName("Tracks"); 401 h = new TH1F("tracks","tracks",100,0,100); 402 gCanvas_->cd(); 403 h->Draw(); 404 405 slot = tab->NewSlot(); 406 trec = new TRootEmbeddedCanvas(); 407 gCanvas_ = trec->GetCanvas(); 408 wf = slot->MakeFrame(trec); 409 wf->SetElementName("Electrons"); 410 h = new TH1F("electrons","electrons",100,0,100); 411 gCanvas_->cd(); 412 h->Draw(); 413 414 // TODO: here we have, for each collection, Pt,Eta,Phi for all, leading, subleading 415 // for each event, we will then add a marker with the current value and/or a histo for current event. 416 // this means to create one tab with subtabs (one per collection). 417 418 } 419 391 } 392 -
display/DelphesPlotSummary.cc
r2ca23b5 r3f51314 1 1 #include "display/DelphesPlotSummary.h" 2 #include "TRootEmbeddedCanvas.h" 2 3 3 DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab* tab) {} 4 5 DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab* tab):tab_(tab) {} 4 6 5 7 DelphesPlotSummary::~DelphesPlotSummary() {} 6 8 7 void DelphesPlotSummary::Init(std::vector<DelphesBranchBase*>& elements) {} 9 void DelphesPlotSummary::Init(std::vector<DelphesBranchBase*>& elements) { 10 elements_ = &elements; 11 // loop on the elements, and create tabs 12 for(std::vector<DelphesBranchBase*>::iterator data=elements.begin();data<elements.end();++data) { 13 // the canvas 14 TEveWindowSlot* slot = tab_->NewSlot(); 15 TRootEmbeddedCanvas* trec = new TRootEmbeddedCanvas(); 16 TCanvas* canvas = trec->GetCanvas(); 17 TEveWindowFrame * wf = slot->MakeFrame(trec); 18 wf->SetElementName((*data)->GetName()); 19 canvas->Divide(3,3); 20 canvases_[(*data)->GetName()] = canvas; 21 // the histograms 22 TH1F* h; 23 std::vector<TH1F*> histograms; 24 histograms.reserve(9); 25 h = new TH1F(Form("%sPt",(*data)->GetName()),Form("%s Pt",(*data)->GetName()),100,0,-1); 26 histograms.push_back(h); 27 h = new TH1F(Form("%sEta",(*data)->GetName()),Form("%s Eta",(*data)->GetName()),100,0,-1); 28 histograms.push_back(h); 29 h = new TH1F(Form("%sPhi",(*data)->GetName()),Form("%s Phi",(*data)->GetName()),100,0,-1); 30 histograms.push_back(h); 31 h = new TH1F(Form("l%sPt",(*data)->GetName()),Form("leading %s Pt",(*data)->GetName()),100,0,-1); 32 histograms.push_back(h); 33 h = new TH1F(Form("l%sEta",(*data)->GetName()),Form("leading %s Eta",(*data)->GetName()),100,0,-1); 34 histograms.push_back(h); 35 h = new TH1F(Form("l%sPhi",(*data)->GetName()),Form("leading %s Phi",(*data)->GetName()),100,0,-1); 36 histograms.push_back(h); 37 h = new TH1F(Form("sl%sPt",(*data)->GetName()),Form("subleading %s Pt",(*data)->GetName()),100,0,-1); 38 histograms.push_back(h); 39 h = new TH1F(Form("sl%sEta",(*data)->GetName()),Form("subleading %s Eta",(*data)->GetName()),100,0,-1); 40 histograms.push_back(h); 41 h = new TH1F(Form("sl%sPhi",(*data)->GetName()),Form("subleading %s Phi",(*data)->GetName()),100,0,-1); 42 histograms.push_back(h); 43 histograms_[(*data)->GetName()] = histograms; 44 } 45 } 8 46 9 void DelphesPlotSummary::FillSample(ExRootTreeReader* treeReader) {} 47 void DelphesPlotSummary::FillSample(ExRootTreeReader* treeReader, Int_t event_id) { 48 for(Int_t i=0;i<treeReader->GetEntries();++i) { 49 treeReader->ReadEntry(i); 50 for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) { 51 std::vector<TLorentzVector> vectors = (*element)->GetVectors(); 52 std::vector<TH1F*> histograms = histograms_[(*element)->GetName()]; 53 for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) { 54 histograms[0]->Fill(it->Pt()); 55 histograms[1]->Fill(it->Eta()); 56 histograms[2]->Fill(it->Phi()); 57 if(it==vectors.begin()) { 58 histograms[3]->Fill(it->Pt()); 59 histograms[4]->Fill(it->Eta()); 60 histograms[5]->Fill(it->Phi()); 61 } 62 if(it==vectors.begin()+1) { 63 histograms[6]->Fill(it->Pt()); 64 histograms[7]->Fill(it->Eta()); 65 histograms[8]->Fill(it->Phi()); 66 } 67 } 68 } 69 } 70 treeReader->ReadEntry(event_id); 71 } 10 72 11 void DelphesPlotSummary::FillEvent() {} 73 void DelphesPlotSummary::Draw() { 74 for(std::map< TString, TCanvas* >::iterator it=canvases_.begin(); it!=canvases_.end(); ++it) { 75 TCanvas* c = it->second; 76 std::vector<TH1F*> histograms = histograms_[it->first]; 77 std::vector<TH1F*> eventProfiles = eventProfiles_[it->first]; 78 std::vector<TMarker*> eventMarkers = eventMarkers_[it->first]; 79 for(Int_t i=0;i<9;++i) { 80 c->cd(i+1); 81 histograms[i]->Draw(); 82 if(i<3) 83 eventProfiles[i]->Draw("same"); 84 else 85 eventMarkers[i-3]->Draw("same"); 86 } 87 } 88 } 89 90 void DelphesPlotSummary::FillEvent() { 91 // clear previous markers 92 for(std::map< TString, std::vector<TMarker*> >::iterator mv = eventMarkers_.begin(); mv!=eventMarkers_.end();++mv) { 93 for(std::vector<TMarker*>::iterator m = mv->second.begin(); m<mv->second.end();++m) { 94 delete *m; 95 } 96 } 97 eventMarkers_.clear(); 98 for(std::map< TString, std::vector<TH1F*> >::iterator hv = eventProfiles_.begin(); hv!=eventProfiles_.end();++hv) { 99 for(std::vector<TH1F*>::iterator h = hv->second.begin(); h<hv->second.end();++h) { 100 delete *h; 101 } 102 } 103 eventProfiles_.clear(); 104 // loop over the elements and fill markers with event data 105 TMarker *m; 106 std::vector<TMarker*> mv; 107 for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) { 108 std::vector<TLorentzVector> vectors = (*element)->GetVectors(); 109 std::vector<TH1F*> histograms = histograms_[(*element)->GetName()]; 110 TH1F* h1 = (TH1F*)histograms[0]->Clone(); h1->Reset(); h1->SetLineColor(kBlue); 111 TH1F* h2 = (TH1F*)histograms[1]->Clone(); h2->Reset(); h2->SetLineColor(kBlue); 112 TH1F* h3 = (TH1F*)histograms[2]->Clone(); h3->Reset(); h3->SetLineColor(kBlue); 113 for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) { 114 h1->Fill(it->Pt()); 115 h2->Fill(it->Eta()); 116 h3->Fill(it->Phi()); 117 if(it==vectors.begin()) { 118 m = new TMarker(it->Pt(),0,29); m->SetMarkerColor(kBlue); 119 mv.push_back(m); 120 m = new TMarker(it->Eta(),0,29); m->SetMarkerColor(kBlue); 121 mv.push_back(m); 122 m = new TMarker(it->Phi(),0,29); m->SetMarkerColor(kBlue); 123 mv.push_back(m); 124 } 125 if(it==vectors.begin()+1) { 126 m = new TMarker(it->Pt(),0,29); m->SetMarkerColor(kBlue); 127 mv.push_back(m); 128 m = new TMarker(it->Eta(),0,29); m->SetMarkerColor(kBlue); 129 mv.push_back(m); 130 m = new TMarker(it->Phi(),0,29); m->SetMarkerColor(kBlue); 131 mv.push_back(m); 132 } 133 } 134 std::vector<TH1F*> hv; 135 hv.push_back(h1); 136 hv.push_back(h2); 137 hv.push_back(h3); 138 eventProfiles_[(*element)->GetName()] = hv; 139 eventMarkers_[(*element)->GetName()] = mv; 140 } 141 } -
display/DelphesPlotSummary.h
r2ca23b5 r3f51314 17 17 virtual ~DelphesPlotSummary(); 18 18 void Init(std::vector<DelphesBranchBase*>& elements); 19 void FillSample(ExRootTreeReader* treeReader );19 void FillSample(ExRootTreeReader* treeReader, Int_t event_id); 20 20 void FillEvent(); 21 void Draw(); 21 22 22 23 private: 23 24 TEveWindowTab* tab_; 24 std::vector<TCanvas*> canvases; 25 std::map< TString, std::vector<TH1F*> > histograms; 25 std::map< TString, TCanvas* > canvases_; 26 std::map< TString, std::vector<TH1F*> > histograms_; 27 std::vector<DelphesBranchBase*>* elements_; 28 std::map< TString, std::vector<TMarker*> > eventMarkers_; 29 std::map< TString, std::vector<TH1F*> > eventProfiles_; 26 30 27 31 };
Note:
See TracChangeset
for help on using the changeset viewer.