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