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