Changes in display/DelphesPlotSummary.cc [77e9ae1:1fa50c2] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
display/DelphesPlotSummary.cc
r77e9ae1 r1fa50c2 21 21 #include <algorithm> 22 22 23 bool vecsorter (TLorentzVector i, TLorentzVector j) { return (i.Pt() >j.Pt()); }23 bool vecsorter (TLorentzVector i,TLorentzVector j) { return (i.Pt()>j.Pt()); } 24 24 25 DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab *tab) : 26 tab_(tab) {} 25 DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab* tab):tab_(tab) {} 27 26 28 27 DelphesPlotSummary::~DelphesPlotSummary() {} … … 30 29 void DelphesPlotSummary::Progress(Int_t p) 31 30 { 32 Emit("Progress(Int_t)", 31 Emit("Progress(Int_t)",p); 33 32 } 34 33 35 void DelphesPlotSummary::Init(std::vector<DelphesBranchBase *> &elements) 36 { 34 void DelphesPlotSummary::Init(std::vector<DelphesBranchBase*>& elements) { 37 35 elements_ = &elements; 38 36 // loop on the elements, and create tabs 39 for(std::vector<DelphesBranchBase *>::iterator data = elements.begin(); data < elements.end(); ++data) 40 { 37 for(std::vector<DelphesBranchBase*>::iterator data=elements.begin();data<elements.end();++data) { 41 38 // the canvas 42 TEveWindowSlot *slot = tab_->NewSlot();43 TRootEmbeddedCanvas *trec = new TRootEmbeddedCanvas();44 TCanvas *canvas = trec->GetCanvas();45 TEveWindowFrame * wf = slot->MakeFrame(trec);39 TEveWindowSlot* slot = tab_->NewSlot(); 40 TRootEmbeddedCanvas* trec = new TRootEmbeddedCanvas(); 41 TCanvas* canvas = trec->GetCanvas(); 42 TEveWindowFrame * wf = slot->MakeFrame(trec); 46 43 wf->SetElementName((*data)->GetName()); 47 canvas->Divide(3, 44 canvas->Divide(3,3); 48 45 canvases_[(*data)->GetName()] = canvas; 49 46 // the histograms 50 TH1F *h;51 std::vector<TH1F 47 TH1F* h; 48 std::vector<TH1F*> histograms; 52 49 histograms.reserve(9); 53 h = new TH1F(Form("%sPt", (*data)->GetName()), Form("%s Pt", (*data)->GetName()), 100, 0,-1);50 h = new TH1F(Form("%sPt",(*data)->GetName()),Form("%s Pt",(*data)->GetName()),100,0,-1); 54 51 histograms.push_back(h); 55 h = new TH1F(Form("%sEta", (*data)->GetName()), Form("%s Eta", (*data)->GetName()), 100, 0,-1);52 h = new TH1F(Form("%sEta",(*data)->GetName()),Form("%s Eta",(*data)->GetName()),100,0,-1); 56 53 histograms.push_back(h); 57 h = new TH1F(Form("%sPhi", (*data)->GetName()), Form("%s Phi", (*data)->GetName()), 100, 0,-1);54 h = new TH1F(Form("%sPhi",(*data)->GetName()),Form("%s Phi",(*data)->GetName()),100,0,-1); 58 55 histograms.push_back(h); 59 h = new TH1F(Form("l%sPt", (*data)->GetName()), Form("leading %s Pt", (*data)->GetName()), 100, 0,-1);56 h = new TH1F(Form("l%sPt",(*data)->GetName()),Form("leading %s Pt",(*data)->GetName()),100,0,-1); 60 57 histograms.push_back(h); 61 h = new TH1F(Form("l%sEta", (*data)->GetName()), Form("leading %s Eta", (*data)->GetName()), 100, 0,-1);58 h = new TH1F(Form("l%sEta",(*data)->GetName()),Form("leading %s Eta",(*data)->GetName()),100,0,-1); 62 59 histograms.push_back(h); 63 h = new TH1F(Form("l%sPhi", (*data)->GetName()), Form("leading %s Phi", (*data)->GetName()), 100, 0,-1);60 h = new TH1F(Form("l%sPhi",(*data)->GetName()),Form("leading %s Phi",(*data)->GetName()),100,0,-1); 64 61 histograms.push_back(h); 65 h = new TH1F(Form("sl%sPt", (*data)->GetName()), Form("subleading %s Pt", (*data)->GetName()), 100, 0,-1);62 h = new TH1F(Form("sl%sPt",(*data)->GetName()),Form("subleading %s Pt",(*data)->GetName()),100,0,-1); 66 63 histograms.push_back(h); 67 h = new TH1F(Form("sl%sEta", (*data)->GetName()), Form("subleading %s Eta", (*data)->GetName()), 100, 0,-1);64 h = new TH1F(Form("sl%sEta",(*data)->GetName()),Form("subleading %s Eta",(*data)->GetName()),100,0,-1); 68 65 histograms.push_back(h); 69 h = new TH1F(Form("sl%sPhi", (*data)->GetName()), Form("subleading %s Phi", (*data)->GetName()), 100, 0,-1);66 h = new TH1F(Form("sl%sPhi",(*data)->GetName()),Form("subleading %s Phi",(*data)->GetName()),100,0,-1); 70 67 histograms.push_back(h); 71 68 histograms_[(*data)->GetName()] = histograms; 72 69 // the event histograms 73 TH1F *h1 = (TH1F *)histograms[0]->Clone(); 74 h1->Reset(); 75 h1->SetLineColor(kBlue); 76 TH1F *h2 = (TH1F *)histograms[1]->Clone(); 77 h2->Reset(); 78 h2->SetLineColor(kBlue); 79 TH1F *h3 = (TH1F *)histograms[2]->Clone(); 80 h3->Reset(); 81 h3->SetLineColor(kBlue); 82 std::vector<TH1F *> hv; 70 TH1F* h1 = (TH1F*)histograms[0]->Clone(); h1->Reset(); h1->SetLineColor(kBlue); 71 TH1F* h2 = (TH1F*)histograms[1]->Clone(); h2->Reset(); h2->SetLineColor(kBlue); 72 TH1F* h3 = (TH1F*)histograms[2]->Clone(); h3->Reset(); h3->SetLineColor(kBlue); 73 std::vector<TH1F*> hv; 83 74 hv.push_back(h1); 84 75 hv.push_back(h2); … … 87 78 // the event markers 88 79 TMarker *m; 89 std::vector<TMarker *> mv; 90 m = new TMarker(0, 0, 29); 91 m->SetMarkerColor(kBlue); 92 m->SetMarkerSize(3); 80 std::vector<TMarker*> mv; 81 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 93 82 mv.push_back(m); 94 m = new TMarker(0, 0, 29); 95 m->SetMarkerColor(kBlue); 96 m->SetMarkerSize(3); 83 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 97 84 mv.push_back(m); 98 m = new TMarker(0, 0, 29); 99 m->SetMarkerColor(kBlue); 100 m->SetMarkerSize(3); 85 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 101 86 mv.push_back(m); 102 m = new TMarker(0, 0, 29); 103 m->SetMarkerColor(kBlue); 104 m->SetMarkerSize(3); 87 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 105 88 mv.push_back(m); 106 m = new TMarker(0, 0, 29); 107 m->SetMarkerColor(kBlue); 108 m->SetMarkerSize(3); 89 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 109 90 mv.push_back(m); 110 m = new TMarker(0, 0, 29); 111 m->SetMarkerColor(kBlue); 112 m->SetMarkerSize(3); 91 m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3); 113 92 mv.push_back(m); 114 93 eventMarkers_[(*data)->GetName()] = mv; … … 116 95 } 117 96 118 void DelphesPlotSummary::FillSample(ExRootTreeReader *treeReader, Int_t event_id) 119 { 97 void DelphesPlotSummary::FillSample(ExRootTreeReader* treeReader, Int_t event_id) { 120 98 Int_t entries = treeReader->GetEntries(); 121 for(Int_t i = 0; i < entries; ++i) 122 { 99 for(Int_t i=0;i<entries;++i) { 123 100 treeReader->ReadEntry(i); 124 for(std::vector<DelphesBranchBase *>::iterator element = elements_->begin(); element < elements_->end(); ++element) 125 { 101 for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) { 126 102 std::vector<TLorentzVector> vectors = (*element)->GetVectors(); 127 std::sort(vectors.begin(), vectors.end(), vecsorter); 128 std::vector<TH1F *> histograms = histograms_[(*element)->GetName()]; 129 for(std::vector<TLorentzVector>::iterator it = vectors.begin(); it < vectors.end(); ++it) 130 { 103 std::sort(vectors.begin(), vectors.end(), vecsorter); 104 std::vector<TH1F*> histograms = histograms_[(*element)->GetName()]; 105 for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) { 131 106 histograms[0]->Fill(it->Pt()); 132 107 histograms[1]->Fill(it->Eta()); 133 108 histograms[2]->Fill(it->Phi()); 134 if(it == vectors.begin()) 135 { 109 if(it==vectors.begin()) { 136 110 histograms[3]->Fill(it->Pt()); 137 111 histograms[4]->Fill(it->Eta()); 138 112 histograms[5]->Fill(it->Phi()); 139 113 } 140 if(it == vectors.begin() + 1) 141 { 114 if(it==vectors.begin()+1) { 142 115 histograms[6]->Fill(it->Pt()); 143 116 histograms[7]->Fill(it->Eta()); … … 146 119 } 147 120 } 148 Progress(int(100 * i /entries));121 Progress(int(100*i/entries)); 149 122 } 150 123 treeReader->ReadEntry(event_id); … … 152 125 } 153 126 154 void DelphesPlotSummary::Draw() 155 { 156 for(std::map<TString, TCanvas *>::iterator it = canvases_.begin(); it != canvases_.end(); ++it) 157 { 158 TCanvas *c = it->second; 159 std::vector<TH1F *> histograms = histograms_[it->first]; 160 std::vector<TH1F *> eventProfiles = eventProfiles_[it->first]; 161 std::vector<TMarker *> eventMarkers = eventMarkers_[it->first]; 162 for(Int_t i = 0; i < 9; ++i) 163 { 164 c->cd(i + 1); 165 if(histograms[i]->GetEntries() == 0) continue; 127 void DelphesPlotSummary::Draw() { 128 for(std::map< TString, TCanvas* >::iterator it=canvases_.begin(); it!=canvases_.end(); ++it) { 129 TCanvas* c = it->second; 130 std::vector<TH1F*> histograms = histograms_[it->first]; 131 std::vector<TH1F*> eventProfiles = eventProfiles_[it->first]; 132 std::vector<TMarker*> eventMarkers = eventMarkers_[it->first]; 133 for(Int_t i=0;i<9;++i) { 134 c->cd(i+1); 135 if(histograms[i]->GetEntries()==0) continue; 166 136 histograms[i]->Draw(); 167 if(i < 3) 168 { 137 if(i<3) { 169 138 eventProfiles[i]->Draw("same"); 170 } 171 else 172 { 173 eventMarkers[i - 3]->Draw("same"); 139 } else { 140 eventMarkers[i-3]->Draw("same"); 174 141 } 175 142 } 176 143 c->Update(); 177 } 144 } 178 145 } 179 146 180 void DelphesPlotSummary::FillEvent() 181 { 147 void DelphesPlotSummary::FillEvent() { 182 148 // clear event histograms and markers 183 for(std::map<TString, std::vector<TH1F *> >::iterator hv = eventProfiles_.begin(); hv != eventProfiles_.end(); ++hv) 184 { 185 for(std::vector<TH1F *>::iterator h = hv->second.begin(); h < hv->second.end(); ++h) 186 { 149 for(std::map< TString, std::vector<TH1F*> >::iterator hv = eventProfiles_.begin(); hv!=eventProfiles_.end();++hv) { 150 for(std::vector<TH1F*>::iterator h = hv->second.begin(); h<hv->second.end();++h) { 187 151 (*h)->Reset(); 188 152 } 189 153 } 190 for(std::map<TString, std::vector<TMarker *> >::iterator mv = eventMarkers_.begin(); mv != eventMarkers_.end(); ++mv) 191 { 192 for(std::vector<TMarker *>::iterator m = mv->second.begin(); m < mv->second.end(); ++m) 193 { 154 for(std::map< TString, std::vector<TMarker*> >::iterator mv = eventMarkers_.begin(); mv!=eventMarkers_.end();++mv) { 155 for(std::vector<TMarker*>::iterator m = mv->second.begin(); m<mv->second.end();++m) { 194 156 (*m)->SetMarkerSize(0); 195 157 } 196 158 } 197 159 // loop over the elements and fill markers with event data 198 for(std::vector<DelphesBranchBase *>::iterator element = elements_->begin(); element < elements_->end(); ++element) 199 { 160 for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) { 200 161 std::vector<TLorentzVector> vectors = (*element)->GetVectors(); 201 std::sort(vectors.begin(), vectors.end(), vecsorter); 202 std::vector<TH1F *> hv = eventProfiles_[(*element)->GetName()]; 203 TH1F *h1 = hv[0]; 204 h1->Reset(); 205 TH1F *h2 = hv[1]; 206 h1->Reset(); 207 TH1F *h3 = hv[2]; 208 h1->Reset(); 209 std::vector<TMarker *> mv = eventMarkers_[(*element)->GetName()]; 210 for(std::vector<TLorentzVector>::iterator it = vectors.begin(); it < vectors.end(); ++it) 211 { 162 std::sort(vectors.begin(), vectors.end(), vecsorter); 163 std::vector<TH1F*> hv = eventProfiles_[(*element)->GetName()]; 164 TH1F* h1 = hv[0]; h1->Reset(); 165 TH1F* h2 = hv[1]; h1->Reset(); 166 TH1F* h3 = hv[2]; h1->Reset(); 167 std::vector<TMarker*> mv = eventMarkers_[(*element)->GetName()]; 168 for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) { 212 169 h1->Fill(it->Pt()); 213 170 h2->Fill(it->Eta()); 214 171 h3->Fill(it->Phi()); 215 if(it == vectors.begin()) 216 { 217 mv[0]->SetX(it->Pt()); 218 mv[0]->SetMarkerSize(3); 219 mv[1]->SetX(it->Eta()); 220 mv[1]->SetMarkerSize(3); 221 mv[2]->SetX(it->Phi()); 222 mv[2]->SetMarkerSize(3); 172 if(it==vectors.begin()) { 173 mv[0]->SetX(it->Pt()); mv[0]->SetMarkerSize(3); 174 mv[1]->SetX(it->Eta()); mv[1]->SetMarkerSize(3); 175 mv[2]->SetX(it->Phi()); mv[2]->SetMarkerSize(3); 223 176 } 224 if(it == vectors.begin() + 1) 225 { 226 mv[3]->SetX(it->Pt()); 227 mv[3]->SetMarkerSize(3); 228 mv[4]->SetX(it->Eta()); 229 mv[4]->SetMarkerSize(3); 230 mv[5]->SetX(it->Phi()); 231 mv[5]->SetMarkerSize(3); 177 if(it==vectors.begin()+1) { 178 mv[3]->SetX(it->Pt()); mv[3]->SetMarkerSize(3); 179 mv[4]->SetX(it->Eta()); mv[4]->SetMarkerSize(3); 180 mv[5]->SetX(it->Phi()); mv[5]->SetMarkerSize(3); 232 181 } 233 182 }
Note:
See TracChangeset
for help on using the changeset viewer.