From 079fd6690356a815c312ffc5ec831352ba174c40 Mon Sep 17 00:00:00 2001 From: cholm Date: Wed, 17 Jul 2013 09:12:38 +0000 Subject: [PATCH] Add possibility to override title on plots. Especially useful when drawing more than one plot in the pad, and we want the title to not be that of the first plot drawn, but something that's meaningful for all plots drawn. --- .../analysis2/scripts/SummaryAODDrawer.C | 51 ++++++++++++------- .../FORWARD/analysis2/scripts/SummaryDrawer.C | 50 +++++++++++++----- 2 files changed, 69 insertions(+), 32 deletions(-) diff --git a/PWGLF/FORWARD/analysis2/scripts/SummaryAODDrawer.C b/PWGLF/FORWARD/analysis2/scripts/SummaryAODDrawer.C index fcb662fc787..9c49bc0b570 100644 --- a/PWGLF/FORWARD/analysis2/scripts/SummaryAODDrawer.C +++ b/PWGLF/FORWARD/analysis2/scripts/SummaryAODDrawer.C @@ -221,9 +221,11 @@ protected: if (!sc) { ptr++; continue; } fBody->Divide(2,3); - DrawInPad(fBody, 1, GetH1(sc, "esdEloss"), "", 0x2); + DrawInPad(fBody, 1, GetH1(sc, "esdEloss"), "", 0x2, + "#Delta/#Delta_{mip} reconstructed and merged"); DrawInPad(fBody, 1, GetH1(sc, "anaEloss"), "same", 0x12); - DrawInPad(fBody, 2, GetH1(sc, "singleEloss"), "", 0x2); + DrawInPad(fBody, 2, GetH1(sc, "singleEloss"), "", 0x2, + "#Delta/#Delta_{mip} for single, double, and tripple hits"); DrawInPad(fBody, 2, GetH1(sc, "doubleEloss"), "same", 0x2); DrawInPad(fBody, 2, GetH1(sc, "tripleEloss"), "same", 0x12); DrawInPad(fBody, 3, GetH2(sc, "singlePerStrip"), "colz", 0x4); @@ -237,7 +239,8 @@ protected: nB->GetYaxis()->SetRangeUser(0,8); } DrawInPad(fBody, 5, nB, "colz", 0x4); - DrawInPad(fBody, 5, GetH2(sc, "neighborsAfter"), "p same", 0x4); + DrawInPad(fBody, 5, GetH2(sc, "neighborsAfter"), "p same", 0x4, + "Correlation of neighbors before and after merging"); DrawInPad(fBody, 6, GetH2(sc, "beforeAfter"), "colz", 0x4); PrintCanvas(Form("Sharing filter - %s", *ptr)); @@ -344,7 +347,8 @@ protected: DrawInPad(fBody, 1, GetH2(sc, "elossVsPoisson"), "colz", 0x4); DrawInPad(fBody, 2, GetH1(sc, "diffElossPoisson"), "HIST E", 0x2); DrawInPad(fBody, 3, GetH1(sc, "occupancy"), "", 0x2); - DrawInPad(fBody, 4, GetH1(sc, "eloss"), "", 0x2); + DrawInPad(fBody, 4, GetH1(sc, "eloss"), "", 0x2, + "#Delta/#Delta_{mip} before and after cuts"); DrawInPad(fBody, 4, GetH1(sc, "elossUsed"), "same", 0x12); TH1* phiB = GetH1(sc, "phiBefore"); TH1* phiA = GetH1(sc, "phiAfter"); @@ -521,9 +525,12 @@ protected: fBody->cd(1); - DrawInPad(fBody, 1, GetH2(c, "coverage"), "col", 0); - DrawInPad(fBody, 2, GetH2(c, "nClusterVsnTracklet"), "colz", 0x03); - DrawInPad(fBody, 3, GetH2(c, "clusterPerTracklet"), "colz", 0x0); + DrawInPad(fBody, 1, GetH2(c, "coverage"), "col", 0, + "#eta coverage per v_{z}"); + DrawInPad(fBody, 2, GetH2(c, "nClusterVsnTracklet"), "colz", 0x03, + "Correlation of # of tracklets and clusters"); + DrawInPad(fBody, 3, GetH2(c, "clusterPerTracklet"), "colz", 0x0, + "# clusters per tracklet vs #eta"); fBody->cd(1)->Modified(); fBody->cd(2)->Modified(); @@ -643,6 +650,8 @@ protected: p->Modified(); p->Update(); p->cd(); + + gStyle->SetOptTitle(1); } //____________________________________________________________________ @@ -849,24 +858,28 @@ protected: } pring++; } - DrawInPad(fBody, 1, GetStack(c, "all"), "nostack", mcRings ? 0 : 0x10); - DrawInPad(fBody, 2, dndeta_phi); + DrawInPad(fBody, 1, GetStack(c, "all"), "nostack", mcRings ? 0 : 0x10, + "Individual ring results"); + DrawInPad(fBody, 1, mcRings, "nostack same", 0x10); + DrawInPad(fBody, 2, dndeta_phi, + "1/#it{N}_{ev} d#it{N}_{ch}/d#it{#eta}"); DrawInPad(fBody, 2, dndeta_eta, "Same", 0x10); - DrawInPad(fBody, 3, allEta, "nostack hist", 0x10); + DrawInPad(fBody, 3, allEta, "nostack hist", 0x10, + "#phi acceptance and #eta coverage per ring"); DrawInPad(fBody, 3, allPhi, "nostack hist same", 0x0); - DrawInPad(fBody, 4, GetH1(fResults, "norm")); + DrawInPad(fBody, 4, GetH1(fResults, "norm"), "", 0x0, + "Total #phi acceptance and #eta coverage"); DrawInPad(fBody, 4, GetH1(fResults, "phi"), "same", 0x10); // DrawInPad(fBody, 4, GetH1(fSums, "d2Ndetadphi"), "colz"); - DrawInPad(fBody, 1, mcRings, "nostack same", 0x10); - fBody->cd(1); - TLatex* l = new TLatex(.5, .2, "Ring results"); - l->SetNDC(); - l->SetTextAlign(21); - l->Draw(); + // fBody->cd(1); + // TLatex* l = new TLatex(.5, .2, "Ring results"); + // l->SetNDC(); + // l->SetTextAlign(21); + // l->Draw(); - fBody->cd(2); - l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta"); + // fBody->cd(2); + // l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta"); // fBody->cd(3); // l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta (#vta norm.)"); diff --git a/PWGLF/FORWARD/analysis2/scripts/SummaryDrawer.C b/PWGLF/FORWARD/analysis2/scripts/SummaryDrawer.C index 2a89ab6594a..bb9f74ce378 100644 --- a/PWGLF/FORWARD/analysis2/scripts/SummaryDrawer.C +++ b/PWGLF/FORWARD/analysis2/scripts/SummaryDrawer.C @@ -631,15 +631,36 @@ protected: Int_t padNo, TObject* h, Option_t* opts="", - UShort_t flags=0x0) + UShort_t flags=0x0, + const char* title="") { TVirtualPad* p = c->GetPad(padNo); if (!p) { Warning("DrawInPad", "Pad # %d not found in %s", padNo, c->GetName()); return; } - DrawInPad(p, h, opts, flags); + DrawInPad(p, h, opts, flags, title); } + virtual void DrawObjClone(TObject* o, Option_t* options, const char* title) + { + if (o->IsA()->InheritsFrom(TH1::Class())) + DrawObjClone(static_cast(o), options, title); + else if (o->IsA()->InheritsFrom(THStack::Class())) + DrawObjClone(static_cast(o), options, title); + else + o->Draw(options); + } + virtual void DrawObjClone(THStack* o, Option_t* options, const char* title) + { + // THStack* tmp = static_cast(o->Clone()); + o->Draw(options); + if (title && title[0] != '\0') o->GetHistogram()->SetTitle(title); + } + virtual void DrawObjClone(TH1* o, Option_t* options, const char* title) + { + TH1* tmp = o->DrawCopy(options); + if (title && title[0] != '\0') tmp->SetTitle(title); + } //__________________________________________________________________ /** * Draw an object in pad @@ -652,7 +673,8 @@ protected: void DrawInPad(TVirtualPad* p, TObject* h, Option_t* opts="", - UShort_t flags=0x0) + UShort_t flags=0x0, + const char* title="") { if (!p) { Warning("DrawInPad", "No pad specified"); @@ -681,7 +703,7 @@ protected: hh->SetMarkerSize(2); o.Append("30"); } - h->Draw(o); + DrawObjClone(h, o, title); if (flags& kLegend) { TLegend* l = p->BuildLegend(0.33, .67, .66, .99-p->GetTopMargin()); @@ -957,18 +979,19 @@ protected: * @param opts Options * @param flags Flags */ - void DrawInRingPad(UShort_t d, - Char_t r, - TObject* h, - Option_t* opts="", - UShort_t flags=0x0) + void DrawInRingPad(UShort_t d, + Char_t r, + TObject* h, + Option_t* opts="", + UShort_t flags=0x0, + const char* title="") { TVirtualPad* p = RingPad(d, r); if (!p) { Warning("DrawInRingPad", "No pad found for FMD%d%c", d, r); return; } - DrawInPad(p, h, opts, flags); + DrawInPad(p, h, opts, flags, title); } @@ -1009,9 +1032,9 @@ protected: if (GetParameter(c, "sNN", sNN)) { TString tsNN = TString::Format("%dGeV", sNN); if (sNN >= 10000) - tsNN = TString::Format("%5.2f", float(sNN)/1000); + tsNN = TString::Format("%5.2fTeV", float(sNN)/1000); else if (sNN >= 1000) - tsNN = TString::Format("%4.2f", float(sNN)/1000); + tsNN = TString::Format("%4.2fTeV", float(sNN)/1000); DrawParameter(y, "#sqrt{s_{NN}}", tsNN); } @@ -1073,7 +1096,8 @@ protected: // vertex->Rebin(2); vertex->SetFillColor(kMagenta+2); } - DrawInPad(fBody, 1, nEventsTr, "", 0x2); + DrawInPad(fBody, 1, nEventsTr, "", 0x2, + "Events w/trigger, trigger+vertex, accepted"); if (vertex) DrawInPad(fBody, 1, vertex, "same"); DrawInPad(fBody, 1, nEventsTrVtx, "same"); DrawInPad(fBody, 1, nEventsAcc, "same", 0x10); -- 2.43.0