3 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4 * @date Wed Mar 23 14:07:10 2011
6 * @brief Script to visualise the dN/deta for pp and PbPb
8 * This script is independent of any AliROOT code - and should stay
11 * The script is <emph>very</emph> long - sigh - the joy of drawing
12 * things nicely in ROOT
14 * @ingroup pwg2_forward_dndeta
18 #include <TGraphErrors.h>
19 #include <TGraphAsymmErrors.h>
20 #include <TMultiGraph.h>
32 #include <TLegendEntry.h>
37 * Class to draw dN/deta results
39 * @ingroup pwg2_forward_tasks_dndeta
40 * @ingroup pwg2_forward_dndeta
45 * POD of data for range zooming
49 TAxis* fMasterAxis; // Master axis
50 TAxis* fSlave1Axis; // First slave axis
51 TVirtualPad* fSlave1Pad; // First slave pad
52 TAxis* fSlave2Axis; // Second slave axis
53 TVirtualPad* fSlave2Pad; // Second slave pad
55 //__________________________________________________________________
61 : fShowOthers(false), // Bool_t
62 fShowAlice(false), // Bool_t
63 fShowRatios(false), // Bool_t
64 fShowLeftRight(false), // Bool_t
65 fRebin(5), // UShort_t
66 fCutEdges(false), // Bool_t
67 fTitle(""), // TString
68 fTrigString(0), // TNamed*
69 fNormString(0), // TNamed*
70 fSNNString(0), // TNamed*
71 fSysString(0), // TNamed*
72 fVtxAxis(0), // TAxis*
73 fCentAxis(0), // TAxis*
78 fRangeParam = new RangeParam;
79 fRangeParam->fMasterAxis = 0;
80 fRangeParam->fSlave1Axis = 0;
81 fRangeParam->fSlave1Pad = 0;
82 fRangeParam->fSlave2Axis = 0;
83 fRangeParam->fSlave2Pad = 0;
85 //__________________________________________________________________
86 virtual ~dNdetaDrawer()
88 if (fRatios && fRatios->GetHists()) fRatios->GetHists()->Delete();
89 if (fResults && fResults->GetHists()) fResults->GetHists()->Delete();
91 if (fTrigString) { delete fTrigString; fTrigString = 0; }
92 if (fSNNString) { delete fSNNString; fSNNString = 0; }
93 if (fSysString) { delete fSysString; fSysString = 0; }
94 if (fVtxAxis) { delete fVtxAxis; fVtxAxis = 0; }
95 if (fCentAxis) { delete fCentAxis; fCentAxis = 0; }
96 if (fResults) { delete fResults; fResults = 0; }
97 if (fRatios) { delete fRatios; fRatios = 0; }
98 if (fOthers) { delete fOthers; fOthers = 0; }
99 if (fTriggers) { delete fTriggers; fTriggers = 0; }
103 //==================================================================
106 * @name Set parameters
109 * Show other (UA5, CMS, ...) data
111 * @param x Whether to show or not
113 void SetShowOthers(Bool_t x) { fShowOthers = x; }
114 //__________________________________________________________________
116 * Show ALICE published data
118 * @param x Wheter to show or not
120 void SetShowAlice(Bool_t x) { fShowAlice = x; }
121 //__________________________________________________________________
123 * Whether to show ratios or not. If there's nothing to compare to,
124 * the ratio panel will be implicitly disabled
126 * @param x Whether to show or not
128 void SetShowRatios(Bool_t x) { fShowRatios = x; }
129 //__________________________________________________________________
132 * Whether to show the left/right asymmetry
134 * @param x To show or not
136 void SetShowLeftRight(Bool_t x) { fShowLeftRight = x; }
137 //__________________________________________________________________
139 * Set the rebinning factor
141 * @param x Rebinning factor (must be a divisor in the number of bins)
143 void SetRebin(UShort_t x) { fRebin = x; }
144 //__________________________________________________________________
146 * Wheter to cut away the edges
148 * @param x Whether or not to cut away edges
150 void SetCutEdges(Bool_t x) { fCutEdges = x; }
151 //__________________________________________________________________
153 * Set the title of the plot
157 void SetTitle(TString x) { fTitle = x; }
159 //==================================================================
162 * @name Override settings from input
165 * Override setting from file
167 * @param sNN Center of mass energy per nucleon pair (GeV)
169 void SetSNN(UShort_t sNN)
171 fSNNString = new TNamed("sNN", Form("%04dGeV", sNN));
172 fSNNString->SetUniqueID(sNN);
174 //__________________________________________________________________
176 * Set the collision system
180 * @param sys collision system
182 void SetSys(UShort_t sys)
184 fSysString = new TNamed("sys", (sys == 1 ? "pp" :
185 sys == 2 ? "PbPb" : "unknown"));
186 fSysString->SetUniqueID(sys);
188 //__________________________________________________________________
190 * Set the vertex range in centimeters
192 * @param vzMin Min @f$ v_z@f$
193 * @param vzMax Max @f$ v_z@f$
195 void SetVertexRange(Double_t vzMin, Double_t vzMax)
197 fVtxAxis = new TAxis(10, vzMin, vzMax);
198 fVtxAxis->SetName("vtxAxis");
199 fVtxAxis->SetTitle(Form("v_{z}#in[%+5.1f,%+5.1f]cm", vzMin, vzMax));
201 //__________________________________________________________________
202 void SetTrigger(UShort_t trig)
204 fTrigString = new TNamed("trigString", (trig & 0x1 ? "INEL" :
205 trig & 0x2 ? "INEL>0" :
208 fTrigString->SetUniqueID(trig);
212 //==================================================================
215 * @name Main steering functions
218 * Run the code to produce the final result.
220 * @param filename File containing the data
222 void Run(const char* filename="forward_dndeta.root")
224 Double_t max = 0, rmax=0, amax=0;
226 gStyle->SetPalette(1);
228 // --- Open input file -------------------------------------------
229 TFile* file = TFile::Open(filename, "READ");
231 Error("Open", "Cannot open %s", filename);
234 // --- Get forward list ------------------------------------------
235 TList* forward = static_cast<TList*>(file->Get("ForwardResults"));
237 Error("Open", "Couldn't find list ForwardResults");
240 // --- Get information on the run --------------------------------
241 FetchInformation(forward);
242 // --- Set the macro pathand load other data script --------------
243 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2",
244 gROOT->GetMacroPath()));
245 gROOT->LoadMacro("OtherData.C");
247 // --- Get the central results -----------------------------------
248 TList* clusters = static_cast<TList*>(file->Get("CentralResults"));
249 if (!clusters) Warning("Open", "Couldn't find list CentralResults");
251 // --- Make our containtes ---------------------------------------
252 fResults = new THStack("results", "Results");
253 fRatios = new THStack("ratios", "Ratios");
254 fLeftRight = new THStack("asymmetry", "Left-right asymmetry");
255 fOthers = new TMultiGraph();
257 // --- Loop over input data --------------------------------------
258 FetchResults(forward, "Forward", max, rmax, amax);
259 FetchResults(clusters, "Central", max, rmax, amax);
261 // --- Get trigger information -----------------------------------
262 TList* sums = static_cast<TList*>(file->Get("ForwardSums"));
264 TList* all = static_cast<TList*>(sums->FindObject("all"));
266 fTriggers = FetchResult(all, "triggers");
267 if (!fTriggers) all->ls();
270 Warning("Run", "List all not found in ForwardSums");
275 Warning("Run", "No ForwardSums directory found in %s", file->GetName());
279 // --- Check our stacks ------------------------------------------
280 if (!fResults->GetHists() ||
281 fResults->GetHists()->GetEntries() <= 0) {
282 Error("Run", "No histograms in result stack!");
285 if (!fOthers->GetListOfGraphs() ||
286 fOthers->GetListOfGraphs()->GetEntries() <= 0) {
287 Warning("Run", "No other data found - disabling that");
290 if (!fRatios->GetHists() ||
291 fRatios->GetHists()->GetEntries() <= 0) {
292 Warning("Run", "No ratio data found - disabling that");
296 if (!fLeftRight->GetHists() ||
297 fLeftRight->GetHists()->GetEntries() <= 0) {
298 Warning("Run", "No left/right data found - disabling that");
300 fShowLeftRight = false;
303 // --- Close the input file --------------------------------------
308 // --- Plot results ----------------------------------------------
309 Plot(max, rmax, amax);
312 //__________________________________________________________________
314 * Fetch the information on the run from the results list
316 * @param results Results list
318 void FetchInformation(const TList* results)
321 fTrigString = static_cast<TNamed*>(results->FindObject("trigger"));
323 fNormString = static_cast<TNamed*>(results->FindObject("scheme"));
325 fSNNString = static_cast<TNamed*>(results->FindObject("sNN"));
327 fSysString = static_cast<TNamed*>(results->FindObject("sys"));
329 fVtxAxis = static_cast<TAxis*>(results->FindObject("vtxAxis"));
331 fCentAxis = static_cast<TAxis*>(results->FindObject("centAxis"));
333 TNamed* options = static_cast<TAxis*>(results->FindObject("options"));
334 if (!fTrigString) fTrigString = new TNamed("trigger", "unknown");
335 if (!fNormString) fNormString = new TNamed("scheme", "unknown");
336 if (!fSNNString) fSNNString = new TNamed("sNN", "unknown");
337 if (!fSysString) fSysString = new TNamed("sys", "unknown");
339 fVtxAxis = new TAxis(1,0,0);
340 fVtxAxis->SetName("vtxAxis");
341 fVtxAxis->SetTitle("v_{z} range unspecified");
344 TString centTxt("none");
346 Int_t nCent = fCentAxis->GetNbins();
347 centTxt = Form("%d bins", nCent);
348 for (Int_t i = 0; i <= nCent; i++)
349 centTxt.Append(Form("%c%d", i == 0 ? ' ' : '-',
350 int(fCentAxis->GetXbins()->At(i))));
352 Info("FetchInformation",
354 " Trigger: %-30s (%d)\n"
355 " sqrt(sNN): %-30s (%dGeV)\n"
356 " System: %-30s (%d)\n"
357 " Vz range: %-30s (%f,%f)\n"
358 " Normalization: %-30s (%d)\n"
361 fTrigString->GetTitle(), fTrigString->GetUniqueID(),
362 fSNNString->GetTitle(), fSNNString->GetUniqueID(),
363 fSysString->GetTitle(), fSysString->GetUniqueID(),
364 fVtxAxis->GetTitle(), fVtxAxis->GetXmin(), fVtxAxis->GetXmax(),
365 fNormString->GetTitle(), fNormString->GetUniqueID(),
366 centTxt.Data(), (options ? options->GetTitle() : "none"));
368 //__________________________________________________________________
369 TMultiGraph* FetchOthers(UShort_t centLow, UShort_t centHigh)
371 TMultiGraph* thisOther = 0;
372 if (!fShowOthers && !fShowAlice) return 0;
374 Bool_t onlya = (fShowOthers ? false : true);
375 UShort_t sys = (fSysString ? fSysString->GetUniqueID() : 0);
376 UShort_t trg = (fTrigString ? fTrigString->GetUniqueID() : 0);
377 UShort_t snn = (fSNNString ? fSNNString->GetUniqueID() : 0);
378 Long_t ret = gROOT->ProcessLine(Form("GetData(%d,%d,%d,%d,%d,%d);",
380 centLow,centHigh,onlya));
383 Warning("FetchResults", "No other data found for sys=%d, sNN=%d, "
384 "trigger=%d %d%%-%d%% central %s",
385 sys, snn, trg, centLow, centHigh,
386 onlya ? " (ALICE results)" : "all");
390 thisOther = reinterpret_cast<TMultiGraph*>(ret);
394 //__________________________________________________________________
396 * Get the results from the top-level list
400 * @param max On return, maximum of data
401 * @param rmax On return, maximum of ratios
402 * @param amax On return, maximum of left-right comparisons
404 void FetchResults(const TList* list,
410 UShort_t n = fCentAxis ? fCentAxis->GetNbins() : 0;
412 TList* all = static_cast<TList*>(list->FindObject("all"));
414 Error("FetchResults", "Couldn't find list 'all' in %s",
417 FetchResults(all, name, FetchOthers(0,0), -1000, 0, max, rmax, amax);
421 for (UShort_t i = 0; i < n; i++) {
422 UShort_t centLow = fCentAxis->GetBinLowEdge(i+1);
423 UShort_t centHigh = fCentAxis->GetBinUpEdge(i+1);
424 TString lname = Form("cent%03d_%03d", centLow, centHigh);
425 TList* thisCent = static_cast<TList*>(list->FindObject(lname));
426 Int_t col = GetCentralityColor(i+1);
428 TString centTxt = Form("%3d%%-%3d%% central", centLow, centHigh);
430 Error("FetchResults", "Couldn't find list '%s' in %s",
431 lname.Data(), list->GetName());
433 FetchResults(thisCent, name, FetchOthers(centLow, centHigh),
434 col, centTxt.Data(), max, rmax, amax);
437 //__________________________________________________________________
438 Int_t GetCentralityColor(Int_t bin) const
440 UShort_t centLow = fCentAxis->GetBinLowEdge(bin);
441 UShort_t centHigh = fCentAxis->GetBinUpEdge(bin);
442 Float_t fc = (centLow+double(centHigh-centLow)/2) / 100;
443 Int_t nCol = gStyle->GetNumberOfColors();
444 Int_t icol = TMath::Min(nCol-1,int(fc * nCol + .5));
445 Int_t col = gStyle->GetColorPalette(icol);
446 //Info("GetCentralityColor","%3d: %3d-%3d -> %3d",bin,centLow,centHigh,col);
449 //__________________________________________________________________
450 void SetAttributes(TH1* h, Int_t color)
453 if (color < 0) return;
454 // h->SetLineColor(color);
455 h->SetMarkerColor(color);
456 // h->SetFillColor(color);
458 //__________________________________________________________________
459 void SetAttributes(TGraph* g, Int_t color)
462 if (color < 0) return;
463 // g->SetLineColor(color);
464 g->SetMarkerColor(color);
465 // g->SetFillColor(color);
467 //__________________________________________________________________
468 void ModifyTitle(TNamed* h, const char* centTxt)
471 // if (!centTxt || !h) return;
472 // h->SetTitle(Form("%s, %s", h->GetTitle(), centTxt));
475 //__________________________________________________________________
477 * Fetch results for a particular centrality bin
481 * @param thisOther Other graphs
483 * @param centTxt Centrality text
484 * @param max On return, data maximum
485 * @param rmax On return, ratio maximum
486 * @param amax On return, left-right maximum
488 void FetchResults(const TList* list,
490 TMultiGraph* thisOther,
497 TH1* dndeta = FetchResult(list, Form("dndeta%s", name));
498 TH1* dndetaMC = FetchResult(list, Form("dndeta%sMC", name));
499 TH1* dndetaTruth = FetchResult(list, "dndetaTruth");
501 TH1* dndetaMCSym = 0;
502 TH1* tracks = FetchResult(list, "tracks");
503 if (tracks) tracks->SetTitle("ALICE Tracks");
504 SetAttributes(dndeta, color);
505 SetAttributes(dndetaMC, fCentAxis ? color : color+2);
506 SetAttributes(dndetaTruth,color);
507 SetAttributes(dndetaSym, color);
508 SetAttributes(dndetaMCSym,fCentAxis ? color : color+2);
509 SetAttributes(tracks, fCentAxis ? color : color+3);
510 if (dndetaMC && fCentAxis)
511 dndetaMC->SetMarkerStyle(dndetaMC->GetMarkerStyle()+2);
512 if (dndetaMCSym && fCentAxis)
513 dndetaMCSym->SetMarkerStyle(dndetaMCSym->GetMarkerStyle()+2);
514 if (dndetaTruth && fCentAxis)
515 dndetaTruth->SetMarkerStyle(34);
516 ModifyTitle(dndeta, centTxt);
517 ModifyTitle(dndetaMC, centTxt);
518 ModifyTitle(dndetaTruth,centTxt);
519 ModifyTitle(dndetaSym, centTxt);
520 ModifyTitle(dndetaMCSym,centTxt);
521 ModifyTitle(tracks, centTxt);
524 max = TMath::Max(max, AddHistogram(fResults, dndetaTruth, "e5 p"));
525 max = TMath::Max(max, AddHistogram(fResults, dndetaMC, dndetaMCSym));
526 max = TMath::Max(max, AddHistogram(fResults, dndeta, dndetaSym));
527 max = TMath::Max(max, AddHistogram(fResults, tracks));
529 THStack* rings = static_cast<THStack*>(list->FindObject("dndetaRings"));
531 TIter next(rings->GetHists());
533 while ((hist = static_cast<TH1*>(next())))
534 max = TMath::Max(max, AddHistogram(fResults, hist));
536 // Info("FetchResults", "Got %p, %p, %p from %s with name %s, max=%f",
537 // dndeta, dndetaMC, dndetaTruth, list->GetName(), name, max);
539 if (fShowLeftRight) {
540 fLeftRight->Add(Asymmetry(dndeta, amax));
541 fLeftRight->Add(Asymmetry(dndetaMC, amax));
542 fLeftRight->Add(Asymmetry(tracks, amax));
546 TIter next(thisOther->GetListOfGraphs());
548 while ((g = static_cast<TGraph*>(next()))) {
549 fRatios->Add(Ratio(dndeta, g, rmax));
550 fRatios->Add(Ratio(dndetaSym, g, rmax));
551 SetAttributes(g, color);
552 ModifyTitle(g, centTxt);
553 if (!fOthers->GetListOfGraphs() ||
554 !fOthers->GetListOfGraphs()->FindObject(g->GetName())) {
555 max = TMath::Max(max,TMath::MaxElement(g->GetN(), g->GetY()));
559 // fOthers->Add(thisOther);
562 if (!fRatios->GetHists() ||
563 !fRatios->GetHists()->FindObject(tracks->GetName()))
564 fRatios->Add(Ratio(dndeta, tracks, rmax));
568 fRatios->Add(Ratio(dndeta, dndetaMC, rmax));
569 fRatios->Add(Ratio(dndetaSym, dndetaMCSym, rmax));
572 fRatios->Add(Ratio(dndeta, dndetaTruth, rmax));
573 fRatios->Add(Ratio(dndetaSym, dndetaTruth, rmax));
576 //__________________________________________________________________
579 * @param max Max value
580 * @param rmax Maximum diviation from 1 of ratios
581 * @param amax Maximum diviation from 1 of asymmetries
583 void Plot(Double_t max,
587 gStyle->SetOptTitle(0);
588 gStyle->SetTitleFont(132, "xyz");
589 gStyle->SetLabelFont(132, "xyz");
592 Int_t w = 800; // h / TMath::Sqrt(2);
596 if (!fShowRatios) w *= 1.4;
598 if (!fShowLeftRight) w *= 1.4;
601 y1 = (y11 > 0.0001 ? 0.4 : 0.2);
602 y2 = (y11 > 0.0001 ? 0.2 : 0.3);
604 TCanvas* c = new TCanvas("Results", "Results", w, h);
609 PlotResults(max, y1);
612 PlotRatios(rmax, y2, y1);
615 PlotLeftRight(amax, y3, y2);
619 Int_t vMin = fVtxAxis->GetXmin();
620 Int_t vMax = fVtxAxis->GetXmax();
621 TString trg(fTrigString->GetTitle());
623 if (fTriggers) nev = fTriggers->GetBinContent(1);
624 trg = trg.Strip(TString::kBoth);
625 TString base(Form("dndeta_%s_%s_%s_%c%02d%c%02dcm_%09dev",
626 fSysString->GetTitle(),
627 fSNNString->GetTitle(),
629 vMin < 0 ? 'm' : 'p', TMath::Abs(vMin),
630 vMax < 0 ? 'm' : 'p', TMath::Abs(vMax),
632 c->SaveAs(Form("%s.png", base.Data()));
633 c->SaveAs(Form("%s.root", base.Data()));
634 c->SaveAs(Form("%s.C", base.Data()));
636 //__________________________________________________________________
640 * @param stack Stack to include
641 * @param mg (optional) Multi graph to include
642 * @param x1 Lower X coordinate in the range [0,1]
643 * @param y1 Lower Y coordinate in the range [0,1]
644 * @param x2 Upper X coordinate in the range [0,1]
645 * @param y2 Upper Y coordinate in the range [0,1]
647 void BuildLegend(THStack* stack, TMultiGraph* mg,
648 Double_t x1, Double_t y1, Double_t x2, Double_t y2)
650 TLegend* l = new TLegend(x1,y1,x2,y2);
651 l->SetNColumns(fCentAxis ? 1 : 2);
657 TIter next(stack->GetHists());
661 while ((hist = static_cast<TH1*>(next()))) {
662 TString n(hist->GetTitle());
663 if (n.Contains("mirrored")) continue;
664 if (unique.FindObject(n.Data())) continue;
665 TObjString* s = new TObjString(n);
666 s->SetUniqueID(((hist->GetMarkerStyle() & 0xFFFF) << 16) |
667 ((hist->GetMarkerColor() & 0xFFFF) << 0));
669 // l->AddEntry(hist, hist->GetTitle(), "pl");
672 TIter nexto(mg->GetListOfGraphs());
674 while ((g = static_cast<TGraph*>(nexto()))) {
675 TString n(g->GetTitle());
676 if (n.Contains("mirrored")) continue;
677 if (unique.FindObject(n.Data())) continue;
678 TObjString* s = new TObjString(n);
679 s->SetUniqueID(((g->GetMarkerStyle() & 0xFFFF) << 16) |
680 ((g->GetMarkerColor() & 0xFFFF) << 0));
682 // l->AddEntry(hist, hist->GetTitle(), "pl");
686 TIter nextu(&unique);
689 while ((s = nextu())) {
690 TLegendEntry* dd = l->AddEntry(Form("data%2d", i++),
692 Int_t style = (s->GetUniqueID() >> 16) & 0xFFFF;
693 Int_t color = (s->GetUniqueID() >> 0) & 0xFFFF;
694 dd->SetLineColor(kBlack);
695 if (fCentAxis) dd->SetMarkerColor(kBlack);
696 else dd->SetMarkerColor(color);
697 dd->SetMarkerStyle(style);
699 TLegendEntry* d1 = l->AddEntry("d1", "Data", "lp");
700 d1->SetLineColor(kBlack);
701 d1->SetMarkerColor(kBlack);
702 d1->SetMarkerStyle(20);
703 TLegendEntry* d2 = l->AddEntry("d2", "Mirrored data", "lp");
704 d2->SetLineColor(kBlack);
705 d2->SetMarkerColor(kBlack);
706 d2->SetMarkerStyle(24);
710 //__________________________________________________________________
712 * Build centrality legend
714 * @param axis Stack to include
715 * @param x1 Lower X coordinate in the range [0,1]
716 * @param y1 Lower Y coordinate in the range [0,1]
717 * @param x2 Upper X coordinate in the range [0,1]
718 * @param y2 Upper Y coordinate in the range [0,1]
720 void BuildCentLegend(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
722 if (!fCentAxis) return;
724 TLegend* l = new TLegend(x1,y1,x2,y2);
731 Int_t n = fCentAxis->GetNbins();
732 for (Int_t i = 1; i <= n; i++) {
733 Double_t low = fCentAxis->GetBinLowEdge(i);
734 Double_t upp = fCentAxis->GetBinUpEdge(i);
735 TLegendEntry* e = l->AddEntry(Form("dummy%02d", i),
736 Form("%3d%% - %3d%%",
737 int(low), int(upp)), "pl");
738 e->SetMarkerColor(GetCentralityColor(i));
742 //__________________________________________________________________
747 * @param yd Bottom position of pad
749 void PlotResults(Double_t max, Double_t yd)
751 // Make a sub-pad for the result itself
752 TPad* p1 = new TPad("p1", "p1", 0, yd, 1.0, 1.0, 0, 0, 0);
753 p1->SetTopMargin(0.05);
754 p1->SetBorderSize(0);
755 p1->SetBorderMode(0);
756 p1->SetBottomMargin(yd > 0.001 ? 0.001 : 0.1);
757 p1->SetRightMargin(0.05);
764 // Info("PlotResults", "Plotting results with max=%f", max);
765 fResults->SetMaximum(1.15*max);
766 fResults->SetMinimum(yd > 0.00001 ? -0.1 : 0);
768 FixAxis(fResults, 1/(1-yd)/1.7, "#frac{1}{N} #frac{dN_{ch}}{d#eta}");
771 fResults->DrawClone("nostack e1");
773 fRangeParam->fSlave1Axis = fResults->GetXaxis();
774 fRangeParam->fSlave1Pad = p1;
777 if (fShowOthers || fShowAlice) {
778 TGraphAsymmErrors* o = 0;
779 TIter nextG(fOthers->GetListOfGraphs());
780 while ((o = static_cast<TGraphAsymmErrors*>(nextG())))
781 o->DrawClone("same p");
784 // Make a legend in the main result pad
785 BuildCentLegend(.12, 1-p1->GetTopMargin()-.01-.5,
786 .35, 1-p1->GetTopMargin()-.01-.1);
787 Double_t x1 = (fCentAxis ? .7 : .15);
788 Double_t x2 = (fCentAxis ? 1-p1->GetRightMargin()-.01: .90);
789 Double_t y1 = (fCentAxis ? .5: p1->GetBottomMargin()+.01);
790 Double_t y2 = (fCentAxis ? 1-p1->GetTopMargin()-.01-.15 : .35);
792 BuildLegend(fResults, fOthers, x1, y1, x2, y2);
794 // Put a title on top
795 fTitle.ReplaceAll("@", " ");
796 TLatex* tit = new TLatex(0.10, 0.95, fTitle.Data());
798 tit->SetTextFont(132);
799 tit->SetTextSize(0.05);
802 // Put a nice label in the plot
804 UShort_t snn = fSNNString->GetUniqueID();
805 const char* sys = fSysString->GetTitle();
806 if (snn == 2750) snn = 2760;
807 if (snn > 1000) eS = Form("%4.2fTeV", float(snn)/1000);
808 else eS = Form("%3dGeV", snn);
809 TLatex* tt = new TLatex(.93, .93, Form("%s #sqrt{s%s}=%s, %s",
811 (fCentAxis ? "_{NN}" : ""),
813 fCentAxis ? "by centrality" :
814 fTrigString->GetTitle()));
816 tt->SetTextFont(132);
817 tt->SetTextAlign(33);
820 // Put number of accepted events on the plot
822 if (fTriggers) nev = fTriggers->GetBinContent(1);
823 TLatex* et = new TLatex(.93, .83, Form("%d events", nev));
825 et->SetTextFont(132);
826 et->SetTextAlign(33);
829 // Put number of accepted events on the plot
831 TLatex* vt = new TLatex(.93, .88, fVtxAxis->GetTitle());
833 vt->SetTextFont(132);
834 vt->SetTextAlign(33);
837 // results->Draw("nostack e1 same");
839 fRangeParam->fSlave1Axis = FindXAxis(p1, fResults->GetName());
840 fRangeParam->fSlave1Pad = p1;
843 // Mark the plot as preliminary
844 TLatex* pt = new TLatex(.12, .93, "Preliminary");
847 pt->SetTextSize(0.07);
848 pt->SetTextColor(kRed+1);
849 pt->SetTextAlign(13);
852 if (!gSystem->AccessPathName("ALICE.png")) {
853 TPad* logo = new TPad("logo", "logo", .12, .65, .25, .85, 0, 0, 0);
854 logo->SetFillStyle(0);
857 TImage* i = TImage::Create();
858 i->ReadImage("ALICE.png");
863 //__________________________________________________________________
867 * @param max Maximum diviation from 1
868 * @param y1 Lower y coordinate of pad
869 * @param y2 Upper y coordinate of pad
871 void PlotRatios(Double_t max, Double_t y1, Double_t y2)
873 if (!fShowRatios) return;
875 bool isBottom = (y1 < 0.0001);
876 Double_t yd = y2 - y1;
877 // Make a sub-pad for the result itself
878 TPad* p2 = new TPad("p2", "p2", 0, y1, 1.0, y2, 0, 0, 0);
879 p2->SetTopMargin(0.001);
880 p2->SetRightMargin(0.05);
881 p2->SetBottomMargin(isBottom ? 1/yd * 0.07 : 0.0001);
889 FixAxis(fRatios, 1/yd/1.7, "Ratios", 7);
891 fRatios->SetMaximum(1+TMath::Max(.22,1.05*max));
892 fRatios->SetMinimum(1-TMath::Max(.32,1.05*max));
894 fRatios->DrawClone("nostack e1");
898 BuildLegend(fRatios, 0, .15,p2->GetBottomMargin()+.01,.9,
901 TLegend* l2 = p2->BuildLegend(.15,p2->GetBottomMargin()+.01,.9,
906 l2->SetBorderSize(0);
907 l2->SetTextFont(132);
909 // Make a nice band from 0.9 to 1.1
910 TGraphErrors* band = new TGraphErrors(2);
911 band->SetPoint(0, fResults->GetXaxis()->GetXmin(), 1);
912 band->SetPoint(1, fResults->GetXaxis()->GetXmax(), 1);
913 band->SetPointError(0, 0, .1);
914 band->SetPointError(1, 0, .1);
915 band->SetFillColor(kYellow+2);
916 band->SetFillStyle(3002);
917 band->SetLineStyle(2);
918 band->SetLineWidth(1);
919 band->Draw("3 same");
920 band->DrawClone("X L same");
922 // Replot the ratios on top
923 fRatios->DrawClone("nostack e1 same");
926 fRangeParam->fMasterAxis = FindXAxis(p2, fRatios->GetName());
927 p2->AddExec("range", Form("RangeExec((dNdetaDrawer::RangeParam*)%p)",
931 fRangeParam->fSlave2Axis = FindXAxis(p2, fRatios->GetName());
932 fRangeParam->fSlave2Pad = p2;
935 //__________________________________________________________________
937 * Plot the asymmetries
939 * @param max Maximum diviation from 1
940 * @param y1 Lower y coordinate of pad
941 * @param y2 Upper y coordinate of pad
943 void PlotLeftRight(Double_t max, Double_t y1, Double_t y2)
945 if (!fShowLeftRight) return;
947 bool isBottom = (y1 < 0.0001);
948 Double_t yd = y2 - y1;
949 // Make a sub-pad for the result itself
950 TPad* p3 = new TPad("p3", "p3", 0, y1, 1.0, y2, 0, 0, 0);
951 p3->SetTopMargin(0.001);
952 p3->SetRightMargin(0.05);
953 p3->SetBottomMargin(isBottom ? 1/yd * 0.07 : 0.0001);
961 FixAxis(fLeftRight, 1/yd/1.7, "Right/Left", 4);
963 fLeftRight->SetMaximum(1+TMath::Max(.12,1.05*max));
964 fLeftRight->SetMinimum(1-TMath::Max(.15,1.05*max));
966 fLeftRight->DrawClone("nostack e1");
970 Double_t xx1 = (fCentAxis ? .7 : .15);
971 Double_t xx2 = (fCentAxis ? 1-p3->GetRightMargin()-.01 : .90);
972 Double_t yy1 = p3->GetBottomMargin()+.01;
973 Double_t yy2 = (fCentAxis ? 1-p3->GetTopMargin()-.01-.15 : .5);
974 BuildLegend(fLeftRight, 0, xx1, yy1, xx2, yy2);
975 // TLegend* l2 = p3->BuildLegend(.15,p3->GetBottomMargin()+.01,.9,.5);
976 // l2->SetNColumns(2);
977 // l2->SetFillColor(0);
978 // l2->SetFillStyle(0);
979 // l2->SetBorderSize(0);
980 // l2->SetTextFont(132);
982 // Make a nice band from 0.9 to 1.1
983 TGraphErrors* band = new TGraphErrors(2);
984 band->SetPoint(0, fResults->GetXaxis()->GetXmin(), 1);
985 band->SetPoint(1, fResults->GetXaxis()->GetXmax(), 1);
986 band->SetPointError(0, 0, .05);
987 band->SetPointError(1, 0, .05);
988 band->SetFillColor(kYellow+2);
989 band->SetFillStyle(3002);
990 band->SetLineStyle(2);
991 band->SetLineWidth(1);
992 band->Draw("3 same");
993 band->DrawClone("X L same");
995 fLeftRight->DrawClone("nostack e1 same");
997 fRangeParam->fMasterAxis = FindXAxis(p3, fLeftRight->GetName());
998 p3->AddExec("range", Form("RangeExec((dNdetaDrawer::RangeParam*)%p)",
1002 fRangeParam->fSlave2Axis = FindXAxis(p3, fLeftRight->GetName());
1003 fRangeParam->fSlave2Pad = p3;
1007 //==================================================================
1010 * @name Data utility functions
1013 * Get a result from the passed list
1015 * @param list List to search
1016 * @param name Object name to search for
1020 TH1* FetchResult(const TList* list, const char* name) const
1022 if (!list) return 0;
1024 TH1* ret = static_cast<TH1*>(list->FindObject(name));
1028 Warning("GetResult", "Histogram %s not found", name);
1034 //__________________________________________________________________
1036 * Add a histogram to the stack after possibly rebinning it
1038 * @param stack Stack to add to
1039 * @param hist histogram
1040 * @param option Draw options
1042 * @return Maximum of histogram
1044 Double_t AddHistogram(THStack* stack, TH1* hist, Option_t* option="") const
1046 // Check if we have input
1047 if (!hist) return 0;
1052 stack->Add(hist, option);
1053 return hist->GetMaximum();
1055 //__________________________________________________________________
1057 * Add a histogram to the stack after possibly rebinning it
1059 * @param stack Stack to add to
1060 * @param hist histogram
1061 * @param option Draw options
1062 * @param sym On return, the data symmetriced (added to stack)
1064 * @return Maximum of histogram
1066 Double_t AddHistogram(THStack* stack, TH1* hist, TH1*& sym,
1067 Option_t* option="") const
1069 // Check if we have input
1070 if (!hist) return 0;
1074 stack->Add(hist, option);
1076 // Now symmetrice the histogram
1077 sym = Symmetrice(hist);
1078 stack->Add(sym, option);
1080 return hist->GetMaximum();
1083 //__________________________________________________________________
1087 * @param h Histogram to rebin
1091 virtual void Rebin(TH1* h) const
1093 if (fRebin <= 1) return;
1095 Int_t nBins = h->GetNbinsX();
1096 if(nBins % fRebin != 0) {
1097 Warning("Rebin", "Rebin factor %d is not a devisor of current number "
1098 "of bins %d in the histogram %s", fRebin, nBins, h->GetName());
1103 TH1* tmp = static_cast<TH1*>(h->Clone("tmp"));
1105 tmp->SetDirectory(0);
1107 // The new number of bins
1108 Int_t nBinsNew = nBins / fRebin;
1109 for(Int_t i = 1;i<= nBinsNew; i++) {
1110 Double_t content = 0;
1114 for(Int_t j = 1; j<=fRebin;j++) {
1115 Int_t bin = (i-1)*fRebin + j;
1116 Double_t c = h->GetBinContent(bin);
1118 if (c <= 0) continue;
1121 if (h->GetBinContent(bin+1)<=0 ||
1122 h->GetBinContent(bin-1)) {
1123 Warning("Rebin", "removing bin %d=%f of %s (%d=%f,%d=%f)",
1124 bin, c, h->GetName(),
1125 bin+1, h->GetBinContent(bin+1),
1126 bin-1, h->GetBinContent(bin-1));
1130 Double_t e = h->GetBinError(bin);
1131 Double_t w = 1 / (e*e); // 1/c/c
1138 if(content > 0 && nbins > 1 ) {
1139 tmp->SetBinContent(i, wsum / sumw);
1140 tmp->SetBinError(i,1./TMath::Sqrt(sumw));
1144 // Finally, rebin the histogram, and set new content
1147 for(Int_t i = 1; i<= nBinsNew; i++) {
1148 h->SetBinContent(i,tmp->GetBinContent(i));
1149 h->SetBinError(i, tmp->GetBinError(i));
1154 //__________________________________________________________________
1156 * Make an extension of @a h to make it symmetric about 0
1158 * @param h Histogram to symmertrice
1160 * @return Symmetric extension of @a h
1162 TH1* Symmetrice(const TH1* h) const
1164 Int_t nBins = h->GetNbinsX();
1165 TH1* s = static_cast<TH1*>(h->Clone(Form("%s_mirror", h->GetName())));
1166 s->SetTitle(Form("%s (mirrored)", h->GetTitle()));
1168 s->SetBins(nBins, -h->GetXaxis()->GetXmax(), -h->GetXaxis()->GetXmin());
1169 s->SetMarkerColor(h->GetMarkerColor());
1170 s->SetMarkerSize(h->GetMarkerSize());
1171 s->SetMarkerStyle(h->GetMarkerStyle()+4);
1172 s->SetFillColor(h->GetFillColor());
1173 s->SetFillStyle(h->GetFillStyle());
1176 // Find the first and last bin with data
1177 Int_t first = nBins+1;
1179 for (Int_t i = 1; i <= nBins; i++) {
1180 if (h->GetBinContent(i) <= 0) continue;
1181 first = TMath::Min(first, i);
1182 last = TMath::Max(last, i);
1185 Double_t xfirst = h->GetBinCenter(first-1);
1186 Int_t f1 = h->GetXaxis()->FindBin(-xfirst);
1187 Int_t l2 = s->GetXaxis()->FindBin(xfirst);
1188 for (Int_t i = f1, j=l2; i <= last; i++,j--) {
1189 s->SetBinContent(j, h->GetBinContent(i));
1190 s->SetBinError(j, h->GetBinError(i));
1192 // Fill in overlap bin
1193 s->SetBinContent(l2+1, h->GetBinContent(first));
1194 s->SetBinError(l2+1, h->GetBinError(first));
1197 //__________________________________________________________________
1199 * Calculate the left-right asymmetry of input histogram
1201 * @param h Input histogram
1202 * @param max On return, the maximum distance from 1 of the histogram
1206 TH1* Asymmetry(TH1* h, Double_t& max)
1210 TH1* ret = static_cast<TH1*>(h->Clone(Form("%s_leftright", h->GetName())));
1211 // Int_t oBins = h->GetNbinsX();
1212 // Double_t high = h->GetXaxis()->GetXmax();
1213 // Double_t low = h->GetXaxis()->GetXmin();
1214 // Double_t dBin = (high - low) / oBins;
1215 // Int_t tBins = Int_t(2*high/dBin+.5);
1216 // ret->SetBins(tBins, -high, high);
1217 ret->SetDirectory(0);
1219 ret->SetTitle(Form("%s (+/-)", h->GetTitle()));
1220 ret->SetYTitle("Right/Left");
1221 Int_t nBins = h->GetNbinsX();
1222 for (Int_t i = 1; i <= nBins; i++) {
1223 Double_t x = h->GetBinCenter(i);
1226 Double_t c1 = h->GetBinContent(i);
1227 Double_t e1 = h->GetBinError(i);
1228 if (c1 <= 0) continue;
1230 Int_t j = h->FindBin(-x);
1231 if (j <= 0 || j > nBins) continue;
1233 Double_t c2 = h->GetBinContent(j);
1234 Double_t e2 = h->GetBinError(j);
1236 Double_t c12 = c1*c1;
1237 Double_t e = TMath::Sqrt((e2*e2*c1*c1+e1*e1*c2*c2)/(c12*c12));
1239 Int_t k = ret->FindBin(x);
1240 ret->SetBinContent(k, c2/c1);
1241 ret->SetBinError(k, e);
1243 max = TMath::Max(max, RatioMax(ret));
1247 //__________________________________________________________________
1249 * Transform a graph into a histogram
1255 TH1* Graph2Hist(const TGraphAsymmErrors* g) const
1257 Int_t nBins = g->GetN();
1258 TArrayF bins(nBins+1);
1260 for (Int_t i = 0; i < nBins; i++) {
1261 Double_t x = g->GetX()[i];
1262 Double_t exl = g->GetEXlow()[i];
1263 Double_t exh = g->GetEXhigh()[i];
1264 bins.fArray[i] = x-exl;
1265 bins.fArray[i+1] = x+exh;
1266 Double_t dxi = exh+exl;
1267 if (i == 0) dx = dxi;
1268 else if (dxi != dx) dx = 0;
1270 TString name(g->GetName());
1271 TString title(g->GetTitle());
1274 h = new TH1D(name.Data(), title.Data(), nBins, bins[0], bins[nBins]);
1277 h = new TH1D(name.Data(), title.Data(), nBins, bins.fArray);
1279 h->SetMarkerStyle(g->GetMarkerStyle());
1280 h->SetMarkerColor(g->GetMarkerColor());
1281 h->SetMarkerSize(g->GetMarkerSize());
1286 //==================================================================
1289 * @name Ratio utility functions
1292 * Get the maximum diviation from 1 in the passed ratio
1294 * @param h Ratio histogram
1296 * @return Max diviation from 1
1298 Double_t RatioMax(TH1* h) const
1300 Int_t nBins = h->GetNbinsX();
1302 for (Int_t i = 1; i <= nBins; i++) {
1303 Double_t c = h->GetBinContent(i);
1304 if (c == 0) continue;
1305 Double_t e = h->GetBinError(i);
1306 Double_t d = TMath::Abs(1-c-e);
1307 ret = TMath::Max(d, ret);
1311 //__________________________________________________________________
1313 * Make the ratio of h1 to h2
1315 * @param o1 First object (numerator)
1316 * @param o2 Second object (denominator)
1317 * @param max Maximum diviation from 1
1321 TH1* Ratio(const TObject* o1, const TObject* o2, Double_t& max) const
1323 if (!o1 || !o2) return 0;
1326 const TAttMarker* m1 = 0;
1327 const TAttMarker* m2 = 0;
1328 const TH1* h1 = dynamic_cast<const TH1*>(o1);
1331 const TH1* h2 = dynamic_cast<const TH1*>(o2);
1337 const TGraph* g2 = dynamic_cast<const TGraph*>(o2);
1345 const TGraphAsymmErrors* g1 = dynamic_cast<const TGraphAsymmErrors*>(o1);
1348 const TGraphAsymmErrors* g2 =
1349 dynamic_cast<const TGraphAsymmErrors*>(o2);
1352 r = RatioGG(g1, g2);
1357 Warning("Ratio", "Don't know how to divide a %s (%s) with a %s (%s)",
1358 o1->ClassName(), o1->GetName(), o2->ClassName(), o2->GetName());
1361 // Check that the histogram isn't empty
1362 if (r->GetEntries() <= 0) {
1367 r->SetMarkerStyle(m1->GetMarkerStyle());
1368 r->SetMarkerColor(m2->GetMarkerColor());
1369 r->SetMarkerSize(0.9*m1->GetMarkerSize());
1370 r->SetName(Form("%s_over_%s", o1->GetName(), o2->GetName()));
1371 r->SetTitle(Form("%s / %s", o1->GetTitle(), o2->GetTitle()));
1373 max = TMath::Max(RatioMax(r), max);
1378 //__________________________________________________________________
1380 * Compute the ratio of @a h to @a g. @a g is evaluated at the bin
1383 * @param h Numerator
1388 TH1* RatioHG(const TH1* h, const TGraph* g) const
1390 if (!h || !g) return 0;
1392 TH1* ret = static_cast<TH1*>(h->Clone("tmp"));
1394 Double_t xlow = g->GetX()[0];
1395 Double_t xhigh = g->GetX()[g->GetN()-1];
1396 if (xlow > xhigh) { Double_t t = xhigh; xhigh = xlow; xlow = t; }
1398 for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
1399 Double_t c = h->GetBinContent(i);
1400 if (c <= 0) continue;
1402 Double_t x = h->GetBinCenter(i);
1403 if (x < xlow || x > xhigh) continue;
1405 Double_t f = g->Eval(x);
1406 if (f <= 0) continue;
1408 ret->SetBinContent(i, c / f);
1409 ret->SetBinError(i, h->GetBinError(i) / f);
1413 //__________________________________________________________________
1415 * Make the ratio of h1 to h2
1417 * @param h1 First histogram (numerator)
1418 * @param h2 Second histogram (denominator)
1422 TH1* RatioHH(const TH1* h1, const TH1* h2) const
1424 if (!h1 || !h2) return 0;
1425 TH1* t1 = static_cast<TH1*>(h1->Clone("tmp"));
1429 //__________________________________________________________________
1431 * Calculate the ratio of two graphs - g1 / g2
1433 * @param g1 Numerator
1434 * @param g2 Denominator
1436 * @return g1 / g2 in a histogram
1438 TH1* RatioGG(const TGraphAsymmErrors* g1,
1439 const TGraphAsymmErrors* g2) const
1441 Int_t nBins = g1->GetN();
1442 TArrayF bins(nBins+1);
1444 for (Int_t i = 0; i < nBins; i++) {
1445 Double_t x = g1->GetX()[i];
1446 Double_t exl = g1->GetEXlow()[i];
1447 Double_t exh = g1->GetEXhigh()[i];
1448 bins.fArray[i] = x-exl;
1449 bins.fArray[i+1] = x+exh;
1450 Double_t dxi = exh+exl;
1451 if (i == 0) dx = dxi;
1452 else if (dxi != dx) dx = 0;
1456 h = new TH1F("tmp", "tmp", nBins, bins[0], bins[nBins]);
1459 h = new TH1F("tmp", "tmp", nBins, bins.fArray);
1462 Double_t low = g2->GetX()[0];
1463 Double_t high = g2->GetX()[g2->GetN()-1];
1464 if (low > high) { Double_t t = low; low = high; high = t; }
1465 for (Int_t i = 0; i < nBins; i++) {
1466 Double_t x = g1->GetX()[i];
1467 if (x < low-dx || x > high+dx) continue;
1468 Double_t c1 = g1->GetY()[i];
1469 Double_t e1 = g1->GetErrorY(i);
1470 Double_t c2 = g2->Eval(x);
1472 h->SetBinContent(i+1, c1 / c2);
1473 h->SetBinError(i+1, e1 / c2);
1478 //==================================================================
1481 * @name Graphics utility functions
1484 * Find an X axis in a pad
1487 * @param name Histogram to find axis for
1489 * @return Found axis or null
1491 TAxis* FindXAxis(TVirtualPad* p, const char* name)
1493 TObject* o = p->GetListOfPrimitives()->FindObject(name);
1495 Warning("FindXAxis", "%s not found in pad", name);
1498 THStack* stack = dynamic_cast<THStack*>(o);
1500 Warning("FindXAxis", "%s is not a THStack", name);
1503 if (!stack->GetHistogram()) {
1504 Warning("FindXAxis", "%s has no histogram", name);
1507 TAxis* ret = stack->GetHistogram()->GetXaxis();
1511 //__________________________________________________________________
1513 * Fix the apperance of the axis in a stack
1515 * @param stack stack of histogram
1516 * @param s Scaling factor
1517 * @param ytitle Y axis title
1518 * @param force Whether to draw the stack first or not
1519 * @param ynDiv Divisions on Y axis
1521 void FixAxis(THStack* stack, Double_t s, const char* ytitle,
1522 Int_t ynDiv=210, Bool_t force=true)
1525 Warning("FixAxis", "No stack passed for %s!", ytitle);
1528 if (force) stack->Draw("nostack e1");
1530 TH1* h = stack->GetHistogram();
1532 Warning("FixAxis", "Stack %s has no histogram", stack->GetName());
1536 h->SetXTitle("#eta");
1537 h->SetYTitle(ytitle);
1538 TAxis* xa = h->GetXaxis();
1539 TAxis* ya = h->GetYaxis();
1541 xa->SetTitle("#eta");
1542 // xa->SetTicks("+-");
1543 xa->SetTitleSize(s*xa->GetTitleSize());
1544 xa->SetLabelSize(s*xa->GetLabelSize());
1545 xa->SetTickLength(s*xa->GetTickLength());
1547 if (stack != fResults) {
1548 TAxis* rxa = fResults->GetXaxis();
1549 xa->Set(rxa->GetNbins(), rxa->GetXmin(), rxa->GetXmax());
1553 ya->SetTitle(ytitle);
1555 // ya->SetTicks("+-");
1556 ya->SetNdivisions(ynDiv);
1557 ya->SetTitleSize(s*ya->GetTitleSize());
1558 ya->SetTitleOffset(ya->GetTitleOffset()/s);
1559 ya->SetLabelSize(s*ya->GetLabelSize());
1566 //__________________________________________________________________
1567 Bool_t fShowOthers; // Show other data
1568 Bool_t fShowAlice; // Show ALICE published data
1569 Bool_t fShowRatios; // Show ratios
1570 Bool_t fShowLeftRight;// Show asymmetry
1571 UShort_t fRebin; // Rebinning factor
1572 Bool_t fCutEdges; // Whether to cut edges
1573 TString fTitle; // Title on plot
1574 TNamed* fTrigString; // Trigger string (read, or set)
1575 TNamed* fNormString; // Normalisation string (read, or set)
1576 TNamed* fSNNString; // Energy string (read, or set)
1577 TNamed* fSysString; // Collision system string (read or set)
1578 TAxis* fVtxAxis; // Vertex cuts (read or set)
1579 TAxis* fCentAxis; // Centrality axis
1580 THStack* fResults; // Stack of results
1581 THStack* fRatios; // Stack of ratios
1582 THStack* fLeftRight; // Left-right asymmetry
1583 TMultiGraph* fOthers; // Older data
1584 TH1* fTriggers; // Number of triggers
1585 RangeParam* fRangeParam; // Parameter object for range zoom
1589 //=== Stuff for auto zooming =========================================
1590 void UpdateRange(dNdetaDrawer::RangeParam* p)
1593 Warning("UpdateRange", "No parameters %p", p);
1596 if (!p->fMasterAxis) {
1597 Warning("UpdateRange", "No master axis %p", p->fMasterAxis);
1600 Int_t first = p->fMasterAxis->GetFirst();
1601 Int_t last = p->fMasterAxis->GetLast();
1602 Double_t x1 = p->fMasterAxis->GetBinCenter(first);
1603 Double_t x2 = p->fMasterAxis->GetBinCenter(last);
1605 if (p->fSlave1Axis) {
1606 Int_t i1 = p->fSlave1Axis->FindBin(x1);
1607 Int_t i2 = p->fSlave1Axis->FindBin(x2);
1608 p->fSlave1Axis->SetRange(i1, i2);
1609 p->fSlave1Pad->Modified();
1610 p->fSlave1Pad->Update();
1612 if (p->fSlave2Axis) {
1613 Int_t i1 = p->fSlave2Axis->FindBin(x1);
1614 Int_t i2 = p->fSlave2Axis->FindBin(x2);
1615 p->fSlave2Axis->SetRange(i1, i2);
1616 p->fSlave2Pad->Modified();
1617 p->fSlave2Pad->Update();
1619 TCanvas* c = gPad->GetCanvas();
1623 //____________________________________________________________________
1624 void RangeExec(dNdetaDrawer::RangeParam* p)
1631 // 11: Mouse release
1632 // dNdetaDrawer::RangeParam* p =
1633 // reinterpret_cast<dNdetaDrawer::RangeParam*>(addr);
1634 Int_t event = gPad->GetEvent();
1635 TObject *select = gPad->GetSelected();
1640 if (event != 11 || !select || select != p->fMasterAxis) return;
1644 //=== Steering function ==============================================
1646 * Draw @f$ dN/d\eta@f$
1648 * @param filename File name
1649 * @param flags Flags
1650 * @param title Title
1651 * @param rebin Rebinning factor
1652 * @param cutEdges Whether to cut edges when rebinning
1653 * @param sNN (optional) Collision energy [GeV]
1654 * @param sys (optional) Collision system (1: pp, 2: PbPb)
1655 * @param trg (optional) Trigger (1: INEL, 2: INEL>0, 4: NSD)
1656 * @param vzMin Least @f$ v_z@f$
1657 * @param vzMax Largest @f$ v_z@f$
1659 * @ingroup pwg2_forward_dndeta
1662 DrawdNdeta(const char* filename="forward_dndeta.root",
1664 const char* title="",
1666 Bool_t cutEdges=false,
1673 dNdetaDrawer* pd = new dNdetaDrawer;
1674 dNdetaDrawer& d = *pd;
1676 d.SetCutEdges(cutEdges);
1678 d.SetShowOthers(flags & 0x1);
1679 d.SetShowAlice(flags & 0x2);
1680 d.SetShowRatios(flags & 0x4);
1681 d.SetShowLeftRight(flags & 0x8);
1682 // Do the below if your input data does not contain these settings
1683 if (sNN > 0) d.SetSNN(sNN); // Collision energy per nucleon pair (GeV)
1684 if (sys > 0) d.SetSys(sys); // Collision system (1:pp, 2:PbPB)
1685 if (trg > 0) d.SetTrigger(trg); // Collision trigger (1:INEL, 2:INEL>0, 4:NSD)
1686 if (vzMin < 999 && vzMax > -999)
1687 d.SetVertexRange(vzMin,vzMax); // Collision vertex range (cm)
1690 //____________________________________________________________________