[2ca23b5] | 1 | #include "display/DelphesPlotSummary.h"
|
---|
[3f51314] | 2 | #include "TRootEmbeddedCanvas.h"
|
---|
[ad015db] | 3 | #include <algorithm>
|
---|
[2ca23b5] | 4 |
|
---|
[ad015db] | 5 | bool vecsorter (TLorentzVector i,TLorentzVector j) { return (i.Pt()>j.Pt()); }
|
---|
[3f51314] | 6 |
|
---|
| 7 | DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab* tab):tab_(tab) {}
|
---|
[2ca23b5] | 8 |
|
---|
| 9 | DelphesPlotSummary::~DelphesPlotSummary() {}
|
---|
| 10 |
|
---|
[53b78e8] | 11 | void DelphesPlotSummary::Progress(Int_t p)
|
---|
| 12 | {
|
---|
| 13 | Emit("Progress(Int_t)",p);
|
---|
| 14 | }
|
---|
| 15 |
|
---|
[3f51314] | 16 | void DelphesPlotSummary::Init(std::vector<DelphesBranchBase*>& elements) {
|
---|
| 17 | elements_ = &elements;
|
---|
| 18 | // loop on the elements, and create tabs
|
---|
| 19 | for(std::vector<DelphesBranchBase*>::iterator data=elements.begin();data<elements.end();++data) {
|
---|
| 20 | // the canvas
|
---|
| 21 | TEveWindowSlot* slot = tab_->NewSlot();
|
---|
| 22 | TRootEmbeddedCanvas* trec = new TRootEmbeddedCanvas();
|
---|
| 23 | TCanvas* canvas = trec->GetCanvas();
|
---|
| 24 | TEveWindowFrame * wf = slot->MakeFrame(trec);
|
---|
| 25 | wf->SetElementName((*data)->GetName());
|
---|
| 26 | canvas->Divide(3,3);
|
---|
| 27 | canvases_[(*data)->GetName()] = canvas;
|
---|
| 28 | // the histograms
|
---|
| 29 | TH1F* h;
|
---|
| 30 | std::vector<TH1F*> histograms;
|
---|
| 31 | histograms.reserve(9);
|
---|
| 32 | h = new TH1F(Form("%sPt",(*data)->GetName()),Form("%s Pt",(*data)->GetName()),100,0,-1);
|
---|
| 33 | histograms.push_back(h);
|
---|
| 34 | h = new TH1F(Form("%sEta",(*data)->GetName()),Form("%s Eta",(*data)->GetName()),100,0,-1);
|
---|
| 35 | histograms.push_back(h);
|
---|
| 36 | h = new TH1F(Form("%sPhi",(*data)->GetName()),Form("%s Phi",(*data)->GetName()),100,0,-1);
|
---|
| 37 | histograms.push_back(h);
|
---|
| 38 | h = new TH1F(Form("l%sPt",(*data)->GetName()),Form("leading %s Pt",(*data)->GetName()),100,0,-1);
|
---|
| 39 | histograms.push_back(h);
|
---|
| 40 | h = new TH1F(Form("l%sEta",(*data)->GetName()),Form("leading %s Eta",(*data)->GetName()),100,0,-1);
|
---|
| 41 | histograms.push_back(h);
|
---|
| 42 | h = new TH1F(Form("l%sPhi",(*data)->GetName()),Form("leading %s Phi",(*data)->GetName()),100,0,-1);
|
---|
| 43 | histograms.push_back(h);
|
---|
| 44 | h = new TH1F(Form("sl%sPt",(*data)->GetName()),Form("subleading %s Pt",(*data)->GetName()),100,0,-1);
|
---|
| 45 | histograms.push_back(h);
|
---|
| 46 | h = new TH1F(Form("sl%sEta",(*data)->GetName()),Form("subleading %s Eta",(*data)->GetName()),100,0,-1);
|
---|
| 47 | histograms.push_back(h);
|
---|
| 48 | h = new TH1F(Form("sl%sPhi",(*data)->GetName()),Form("subleading %s Phi",(*data)->GetName()),100,0,-1);
|
---|
| 49 | histograms.push_back(h);
|
---|
| 50 | histograms_[(*data)->GetName()] = histograms;
|
---|
[c3c9ac5] | 51 | // the event histograms
|
---|
| 52 | TH1F* h1 = (TH1F*)histograms[0]->Clone(); h1->Reset(); h1->SetLineColor(kBlue);
|
---|
| 53 | TH1F* h2 = (TH1F*)histograms[1]->Clone(); h2->Reset(); h2->SetLineColor(kBlue);
|
---|
| 54 | TH1F* h3 = (TH1F*)histograms[2]->Clone(); h3->Reset(); h3->SetLineColor(kBlue);
|
---|
| 55 | std::vector<TH1F*> hv;
|
---|
| 56 | hv.push_back(h1);
|
---|
| 57 | hv.push_back(h2);
|
---|
| 58 | hv.push_back(h3);
|
---|
| 59 | eventProfiles_[(*data)->GetName()] = hv;
|
---|
| 60 | // the event markers
|
---|
| 61 | TMarker *m;
|
---|
| 62 | std::vector<TMarker*> mv;
|
---|
| 63 | m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
|
---|
| 64 | mv.push_back(m);
|
---|
| 65 | m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
|
---|
| 66 | mv.push_back(m);
|
---|
| 67 | m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
|
---|
| 68 | mv.push_back(m);
|
---|
| 69 | m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
|
---|
| 70 | mv.push_back(m);
|
---|
| 71 | m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
|
---|
| 72 | mv.push_back(m);
|
---|
| 73 | m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
|
---|
| 74 | mv.push_back(m);
|
---|
| 75 | eventMarkers_[(*data)->GetName()] = mv;
|
---|
[3f51314] | 76 | }
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | void DelphesPlotSummary::FillSample(ExRootTreeReader* treeReader, Int_t event_id) {
|
---|
[53b78e8] | 80 | Int_t entries = treeReader->GetEntries();
|
---|
| 81 | for(Int_t i=0;i<entries;++i) {
|
---|
[3f51314] | 82 | treeReader->ReadEntry(i);
|
---|
| 83 | for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) {
|
---|
| 84 | std::vector<TLorentzVector> vectors = (*element)->GetVectors();
|
---|
[ad015db] | 85 | std::sort(vectors.begin(), vectors.end(), vecsorter);
|
---|
[3f51314] | 86 | std::vector<TH1F*> histograms = histograms_[(*element)->GetName()];
|
---|
| 87 | for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) {
|
---|
| 88 | histograms[0]->Fill(it->Pt());
|
---|
| 89 | histograms[1]->Fill(it->Eta());
|
---|
| 90 | histograms[2]->Fill(it->Phi());
|
---|
| 91 | if(it==vectors.begin()) {
|
---|
| 92 | histograms[3]->Fill(it->Pt());
|
---|
| 93 | histograms[4]->Fill(it->Eta());
|
---|
| 94 | histograms[5]->Fill(it->Phi());
|
---|
| 95 | }
|
---|
| 96 | if(it==vectors.begin()+1) {
|
---|
| 97 | histograms[6]->Fill(it->Pt());
|
---|
| 98 | histograms[7]->Fill(it->Eta());
|
---|
| 99 | histograms[8]->Fill(it->Phi());
|
---|
| 100 | }
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
[53b78e8] | 103 | Progress(int(100*i/entries));
|
---|
[3f51314] | 104 | }
|
---|
| 105 | treeReader->ReadEntry(event_id);
|
---|
[53b78e8] | 106 | Progress(100);
|
---|
[3f51314] | 107 | }
|
---|
[2ca23b5] | 108 |
|
---|
[3f51314] | 109 | void DelphesPlotSummary::Draw() {
|
---|
| 110 | for(std::map< TString, TCanvas* >::iterator it=canvases_.begin(); it!=canvases_.end(); ++it) {
|
---|
| 111 | TCanvas* c = it->second;
|
---|
| 112 | std::vector<TH1F*> histograms = histograms_[it->first];
|
---|
| 113 | std::vector<TH1F*> eventProfiles = eventProfiles_[it->first];
|
---|
| 114 | std::vector<TMarker*> eventMarkers = eventMarkers_[it->first];
|
---|
| 115 | for(Int_t i=0;i<9;++i) {
|
---|
| 116 | c->cd(i+1);
|
---|
[2695ae1] | 117 | if(histograms[i]->GetEntries()==0) continue;
|
---|
[3f51314] | 118 | histograms[i]->Draw();
|
---|
[ad015db] | 119 | if(i<3) {
|
---|
[3f51314] | 120 | eventProfiles[i]->Draw("same");
|
---|
[ad015db] | 121 | } else {
|
---|
[c3c9ac5] | 122 | eventMarkers[i-3]->Draw("same");
|
---|
[ad015db] | 123 | }
|
---|
[3f51314] | 124 | }
|
---|
[ad015db] | 125 | c->Update();
|
---|
[3f51314] | 126 | }
|
---|
| 127 | }
|
---|
[2ca23b5] | 128 |
|
---|
[c3c9ac5] | 129 | void DelphesPlotSummary::FillEvent() {
|
---|
| 130 | // clear event histograms and markers
|
---|
[3f51314] | 131 | for(std::map< TString, std::vector<TH1F*> >::iterator hv = eventProfiles_.begin(); hv!=eventProfiles_.end();++hv) {
|
---|
| 132 | for(std::vector<TH1F*>::iterator h = hv->second.begin(); h<hv->second.end();++h) {
|
---|
[c3c9ac5] | 133 | (*h)->Reset();
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 | for(std::map< TString, std::vector<TMarker*> >::iterator mv = eventMarkers_.begin(); mv!=eventMarkers_.end();++mv) {
|
---|
| 137 | for(std::vector<TMarker*>::iterator m = mv->second.begin(); m<mv->second.end();++m) {
|
---|
| 138 | (*m)->SetMarkerSize(0);
|
---|
[3f51314] | 139 | }
|
---|
| 140 | }
|
---|
| 141 | // loop over the elements and fill markers with event data
|
---|
| 142 | for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) {
|
---|
| 143 | std::vector<TLorentzVector> vectors = (*element)->GetVectors();
|
---|
[ad015db] | 144 | std::sort(vectors.begin(), vectors.end(), vecsorter);
|
---|
[c3c9ac5] | 145 | std::vector<TH1F*> hv = eventProfiles_[(*element)->GetName()];
|
---|
| 146 | TH1F* h1 = hv[0]; h1->Reset();
|
---|
| 147 | TH1F* h2 = hv[1]; h1->Reset();
|
---|
| 148 | TH1F* h3 = hv[2]; h1->Reset();
|
---|
| 149 | std::vector<TMarker*> mv = eventMarkers_[(*element)->GetName()];
|
---|
[3f51314] | 150 | for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) {
|
---|
| 151 | h1->Fill(it->Pt());
|
---|
| 152 | h2->Fill(it->Eta());
|
---|
| 153 | h3->Fill(it->Phi());
|
---|
| 154 | if(it==vectors.begin()) {
|
---|
[c3c9ac5] | 155 | mv[0]->SetX(it->Pt()); mv[0]->SetMarkerSize(3);
|
---|
| 156 | mv[1]->SetX(it->Eta()); mv[1]->SetMarkerSize(3);
|
---|
| 157 | mv[2]->SetX(it->Phi()); mv[2]->SetMarkerSize(3);
|
---|
[3f51314] | 158 | }
|
---|
| 159 | if(it==vectors.begin()+1) {
|
---|
[c3c9ac5] | 160 | mv[3]->SetX(it->Pt()); mv[3]->SetMarkerSize(3);
|
---|
| 161 | mv[4]->SetX(it->Eta()); mv[4]->SetMarkerSize(3);
|
---|
| 162 | mv[5]->SetX(it->Phi()); mv[5]->SetMarkerSize(3);
|
---|
[3f51314] | 163 | }
|
---|
| 164 | }
|
---|
| 165 | }
|
---|
| 166 | }
|
---|