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 <i>very</i> long - sigh - the joy of drawing
12 * things nicely in ROOT
14 * @ingroup pwglf_forward_dndeta
19 #include <TGraphErrors.h>
20 #include <TGraphAsymmErrors.h>
21 #include <TMultiGraph.h>
33 #include <TLegendEntry.h>
39 /** Systematic error color */
40 #define SYSERR_COLOR kBlue-10
41 /** Systematic error style */
42 #define SYSERR_STYLE 1001
44 Double_t myFunc(Double_t* xp, Double_t* pp);
47 * Class to draw dN/deta results
49 * @ingroup pwglf_forward_tasks_dndeta
50 * @ingroup pwglf_forward_dndeta
55 * POD of data for range zooming
59 TAxis* fMasterAxis; // Master axis
60 TAxis* fSlave1Axis; // First slave axis
61 TVirtualPad* fSlave1Pad; // First slave pad
62 TAxis* fSlave2Axis; // Second slave axis
63 TVirtualPad* fSlave2Pad; // Second slave pad
65 //__________________________________________________________________
72 fShowRatios(false), // Show ratios
73 fShowLeftRight(false), // Show asymmetry
74 fShowRings(false), // Show rings too
75 fExport(false), // Export data to script
76 fCutEdges(false), // Whether to cut edges
77 fRemoveOuters(false), // Whether to remove outers
78 fShowOthers(0), // Show other data
82 fRebin(0), // Rebinning factor
83 fFwdSysErr(0.076), // Systematic error in forward range
84 fCenSysErr(0), // Systematic error in central range
85 fTitle(""), // Title on plot
86 fClusterScale(""), // Scaling of clusters to tracklets
87 // Read (or set) information
88 fTrigString(0), // Trigger string (read, or set)
89 fNormString(0), // Normalisation string (read, or set)
90 fSNNString(0), // Energy string (read, or set)
91 fSysString(0), // Collision system string (read or set)
92 fVtxAxis(0), // Vertex cuts (read or set)
93 fCentAxis(0), // Centrality axis
95 fResults(0), // Stack of results
96 fRatios(0), // Stack of ratios
97 fLeftRight(0), // Left-right asymmetry
98 fOthers(0), // Older data
99 fTriggers(0), // Number of triggers
100 fTruth(0), // Pointer to truth
101 fRangeParam(0) // Parameter object for range zoom
103 fRangeParam = new RangeParam;
104 fRangeParam->fMasterAxis = 0;
105 fRangeParam->fSlave1Axis = 0;
106 fRangeParam->fSlave1Pad = 0;
107 fRangeParam->fSlave2Axis = 0;
108 fRangeParam->fSlave2Pad = 0;
113 dNdetaDrawer(const dNdetaDrawer&) {}
115 * Assignment operator
118 * @return Reference to this object
120 dNdetaDrawer& operator=(const dNdetaDrawer&) { return *this; }
122 //__________________________________________________________________
126 virtual ~dNdetaDrawer()
128 if (fRatios && fRatios->GetHists()) fRatios->GetHists()->Delete();
129 if (fResults && fResults->GetHists()) fResults->GetHists()->Delete();
131 if (fTrigString) { delete fTrigString; fTrigString = 0; }
132 if (fSNNString) { delete fSNNString; fSNNString = 0; }
133 if (fSysString) { delete fSysString; fSysString = 0; }
134 if (fVtxAxis) { delete fVtxAxis; fVtxAxis = 0; }
135 if (fCentAxis) { delete fCentAxis; fCentAxis = 0; }
136 if (fResults) { delete fResults; fResults = 0; }
137 if (fRatios) { delete fRatios; fRatios = 0; }
138 if (fOthers) { delete fOthers; fOthers = 0; }
139 if (fTriggers) { delete fTriggers; fTriggers = 0; }
143 //==================================================================
146 * @name Set parameters
148 void SetOld(Bool_t use=true) { fOld = use; }
150 * Show other (UA5, CMS, ...) data
152 * @param x Whether to show or not
154 void SetShowOthers(UShort_t x) { fShowOthers = x; }
155 //__________________________________________________________________
157 * Whether to show ratios or not. If there's nothing to compare to,
158 * the ratio panel will be implicitly disabled
160 * @param x Whether to show or not
162 void SetShowRatios(Bool_t x) { fShowRatios = x; }
163 //__________________________________________________________________
166 * Whether to show the left/right asymmetry
168 * @param x To show or not
170 void SetShowLeftRight(Bool_t x) { fShowLeftRight = x; }
171 //__________________________________________________________________
173 * Whether to show rings
175 * @param x To show or not
177 void SetShowRings(Bool_t x) { fShowRings = x; }
178 //__________________________________________________________________
180 * Whether to export results to a script
182 * @param x Wheter to export results to a script
184 void SetExport(Bool_t x) { fExport = x; }
185 //__________________________________________________________________
187 * Set the rebinning factor
189 * @param x Rebinning factor (must be a divisor in the number of bins)
191 void SetRebin(UShort_t x) { fRebin = x; }
192 //__________________________________________________________________
194 * Wheter to cut away the edges
196 * @param x Whether or not to cut away edges
198 void SetCutEdges(Bool_t x) { fCutEdges = x; }
199 //__________________________________________________________________
201 * Set the title of the plot
205 void SetTitle(TString x) { fTitle = x; }
206 //__________________________________________________________________
208 * Set the systematic error in the forward region
210 * @param e Systematic error in the forward region
212 void SetForwardSysError(Double_t e=0) { fFwdSysErr = e; }
213 //__________________________________________________________________
215 * Set the systematic error in the forward region
217 * @param e Systematic error in the forward region
219 void SetCentralSysError(Double_t e=0) { fCenSysErr = e; }
220 void SetForceMB(Bool_t force=true) { fForceMB = force; }
221 void SetMirror(Bool_t mirror=true) { fMirror = mirror; }
222 void SetFinalMC(const TString& file) { fFinalMC = file; }
223 void SetEmpirical(const TString& file) { fEmpirical = file; }
225 //==================================================================
228 * @name Override settings from input
231 * Override setting from file
233 * @param sNN Center of mass energy per nucleon pair (GeV)
235 void SetSNN(UShort_t sNN)
237 fSNNString = new TNamed("sNN", Form("%04dGeV", sNN));
238 fSNNString->SetUniqueID(sNN);
240 //__________________________________________________________________
242 * Set the collision system
246 * @param sys collision system
248 void SetSys(UShort_t sys)
250 fSysString = new TNamed("sys", (sys == 1 ? "pp" :
254 fSysString->SetUniqueID(sys);
256 //__________________________________________________________________
258 * Set the vertex range in centimeters
260 * @param vzMin Min @f$ v_z@f$
261 * @param vzMax Max @f$ v_z@f$
263 void SetVertexRange(Double_t vzMin, Double_t vzMax)
265 fVtxAxis = new TAxis(10, vzMin, vzMax);
266 fVtxAxis->SetName("vtxAxis");
267 fVtxAxis->SetTitle(Form("v_{z}#in[%+5.1f,%+5.1f]cm", vzMin, vzMax));
269 //__________________________________________________________________
270 void SetTrigger(UShort_t trig)
272 fTrigString = new TNamed("trigString", (trig & 0x1 ? "INEL" :
273 trig & 0x2 ? "INEL>0" :
276 fTrigString->SetUniqueID(trig);
280 //==================================================================
283 * @name Main steering functions
286 * Run the code to produce the final result.
288 * @param filename File containing the data
290 void Run(const char* filename="forward_dndeta.root")
292 Double_t max = 0, rmax=0, amax=0;
294 gStyle->SetPalette(1);
296 // --- Open input file -------------------------------------------
297 TFile* file = TFile::Open(filename, "READ");
299 Error("Open", "Cannot open %s", filename);
302 Info("Open", "Drawing results from %s", file->GetName());
304 // --- Get forward list ------------------------------------------
305 TList* forward = static_cast<TList*>(file->Get("ForwardResults"));
307 Error("Open", "Couldn't find list ForwardResults");
310 // --- Get information on the run --------------------------------
311 FetchInformation(forward);
312 // --- Set the macro pathand load other data script --------------
313 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2",
314 gROOT->GetMacroPath()));
315 gROOT->LoadMacro("OtherData.C+");
317 // --- Get the central results -----------------------------------
318 TList* clusters = static_cast<TList*>(file->Get("CentralResults"));
319 if (!clusters) Warning("Open", "Couldn't find list CentralResults");
321 // --- Get the central results -----------------------------------
322 TList* mcTruth = static_cast<TList*>(file->Get("MCTruthResults"));
323 if (!mcTruth) Warning("Open", "Couldn't find list MCTruthResults");
325 // --- Make our containtes ---------------------------------------
326 fResults = new THStack("results", "Results");
327 fRatios = new THStack("ratios", "Ratios");
328 fLeftRight = new THStack("asymmetry", "Left-right asymmetry");
329 fOthers = new TMultiGraph();
331 // --- Try to open the final MC file, and find relevant lists ----
332 TList* forwardMC = 0;
333 // TList* centralMC = 0;
334 if (!fFinalMC.IsNull()) {
335 TFile* finalMC = TFile::Open(fFinalMC, "READ");
337 Warning("Run", "Failed to open file %s for final MC corrections",
341 forwardMC = static_cast<TList*>(finalMC->Get("ForwardResults"));
343 Warning("Open", "Couldn't find list ForwardResults for final MC");
345 centralMC = static_cast<TList*>(finalMC->Get("CentralResults"));
347 Warning("Open", "Couldn't find list CentralResults for final MC");
351 if (!forwardMC) fFinalMC = "";
353 // --- Try to get the emperical correction -----------------------
354 TGraphErrors* empCorr = 0;
355 if (!fEmpirical.IsNull()) {
356 TFile* empirical = TFile::Open(fEmpirical, "READ");
358 empirical = TFile::Open(Form("$ALICE_ROOT/PWGLF/FORWARD/corrections/"
359 "Empirical/%s", fEmpirical.Data()));
362 empCorr = static_cast<TGraphErrors*>(empirical->Get("fmdfull/average"));
364 Warning("Open", "couldn't get the empirical correction");
367 Warning("Run", "Failed to open file %s for empirical corrections",
370 if (!empCorr) fEmpirical = "";
372 // --- Loop over input data --------------------------------------
374 FetchResults(mcTruth, 0, 0, "MCTruth", max, rmax, amax,truths);
375 TObjArray* fwdA = FetchResults(forward, forwardMC, empCorr, "Forward",
376 max, rmax, amax,truths);
377 TObjArray* cenA = FetchResults(clusters, 0, 0, "Central",
378 max, rmax, amax,truths);
380 // --- Get trigger information -----------------------------------
381 TList* sums = static_cast<TList*>(file->Get("ForwardSums"));
384 if (fOld) all = sums;
385 else all = static_cast<TList*>(sums->FindObject("all"));
387 fTriggers = FetchResult(all, "triggers");
388 if (!fTriggers) all->ls();
391 Warning("Run", "List all not found in ForwardSums");
396 Warning("Run", "No ForwardSums directory found in %s", file->GetName());
400 // --- Check our stacks ------------------------------------------
401 if (!fResults->GetHists() ||
402 fResults->GetHists()->GetEntries() <= 0) {
403 Error("Run", "No histograms in result stack!");
406 if (!fOthers->GetListOfGraphs() ||
407 fOthers->GetListOfGraphs()->GetEntries() <= 0) {
408 Warning("Run", "No other data found - disabling that");
411 if (!fRatios->GetHists() ||
412 fRatios->GetHists()->GetEntries() <= 0) {
413 Warning("Run", "No ratio data found - disabling that");
417 if (!fLeftRight->GetHists() ||
418 fLeftRight->GetHists()->GetEntries() <= 0) {
419 Warning("Run", "No left/right data found - disabling that");
421 fShowLeftRight = false;
423 if (fFwdSysErr > 0) {
424 if (fCenSysErr <= 0) fCenSysErr = fFwdSysErr;
425 for (Int_t i = 0; i < fwdA->GetEntriesFast(); i++) {
426 TH1* fwd = static_cast<TH1*>(fwdA->At(i));
427 TH1* cen = static_cast<TH1*>(cenA->At(i));
431 TH1* tmp = Merge(cen, fwd, low, high);
432 TF1* f = FitMerged(tmp, low, high);
433 MakeSysError(tmp, cen, fwd, f);
435 Info("", "Adding systematic error histogram %s",
437 fResults->GetHists()->AddFirst(tmp, "e5");
439 if (!fMirror) continue;
441 TH1* tmp2 = Symmetrice(tmp);
442 tmp2->SetFillColor(tmp->GetFillColor());
443 tmp2->SetFillStyle(tmp->GetFillStyle());
444 tmp2->SetMarkerStyle(tmp->GetMarkerStyle());
445 tmp2->SetLineWidth(tmp->GetLineWidth());
446 fResults->GetHists()->AddFirst(tmp2, "e5");
447 fResults->Modified();
453 // --- Close the input file --------------------------------------
458 // --- Plot results ----------------------------------------------
459 Plot(max, rmax, amax);
462 //__________________________________________________________________
464 * Fetch the information on the run from the results list
466 * @param results Results list
468 void FetchInformation(const TList* results)
471 fTrigString = static_cast<TNamed*>(results->FindObject("trigger"));
473 fNormString = static_cast<TNamed*>(results->FindObject("scheme"));
475 fSNNString = static_cast<TNamed*>(results->FindObject("sNN"));
477 fSysString = static_cast<TNamed*>(results->FindObject("sys"));
479 fVtxAxis = static_cast<TAxis*>(results->FindObject("vtxAxis"));
481 fCentAxis = static_cast<TAxis*>(results->FindObject("centAxis"));
483 TNamed* options = static_cast<TAxis*>(results->FindObject("options"));
484 if (!fTrigString) fTrigString = new TNamed("trigger", "unknown");
485 if (!fNormString) fNormString = new TNamed("scheme", "unknown");
486 if (!fSNNString) fSNNString = new TNamed("sNN", "unknown");
487 if (!fSysString) fSysString = new TNamed("sys", "unknown");
489 fVtxAxis = new TAxis(1,0,0);
490 fVtxAxis->SetName("vtxAxis");
491 fVtxAxis->SetTitle("v_{z} range unspecified");
494 TString centTxt("none");
496 Int_t nCent = fCentAxis->GetNbins();
497 centTxt = Form("%d bins", nCent);
498 for (Int_t i = 0; i <= nCent; i++)
499 centTxt.Append(Form("%c%d", i == 0 ? ' ' : '-',
500 int(fCentAxis->GetXbins()->At(i))));
502 Info("FetchInformation",
504 " Trigger: %-30s (0x%x)\n"
505 " sqrt(sNN): %-30s (%dGeV)\n"
506 " System: %-30s (%d)\n"
507 " Vz range: %-30s (%f,%f)\n"
508 " Normalization: %-30s (%d)\n"
511 fTrigString->GetTitle(), fTrigString->GetUniqueID(),
512 fSNNString->GetTitle(), fSNNString->GetUniqueID(),
513 fSysString->GetTitle(), fSysString->GetUniqueID(),
514 fVtxAxis->GetTitle(), fVtxAxis->GetXmin(), fVtxAxis->GetXmax(),
515 fNormString->GetTitle(), fNormString->GetUniqueID(),
516 centTxt.Data(), (options ? options->GetTitle() : "none"));
517 if (fSysString->GetUniqueID() == 3) {
518 Info("FetchResults", "Left/Right assymmetry, mirror, and systematic "
519 "errors explicitly disabled for pPb");
520 fShowLeftRight = false;
526 //__________________________________________________________________
527 TMultiGraph* FetchOthers(UShort_t centLow, UShort_t centHigh)
529 TMultiGraph* thisOther = 0;
530 if (fShowOthers == 0) return 0;
532 UShort_t sys = (fSysString ? fSysString->GetUniqueID() : 0);
533 UShort_t trg = (fTrigString ? fTrigString->GetUniqueID() : 0);
534 UShort_t snn = (fSNNString ? fSNNString->GetUniqueID() : 0);
535 Long_t ret = gROOT->ProcessLine(Form("GetData(%d,%d,%d,%d,%d,%d);",
541 thisOther = reinterpret_cast<TMultiGraph*>(ret);
544 //__________________________________________________________________
546 * Get the results from the top-level list
549 * @param mcList List of histograms from MC
550 * @param empCorr Emperical correction if any
552 * @param max On return, maximum of data
553 * @param rmax On return, maximum of ratios
554 * @param amax On return, maximum of left-right comparisons
555 * @param truths List of MC truths to compare to.
557 * @return Array of results
560 FetchResults(const TList* list,
562 TGraphErrors* empCorr,
570 UShort_t n = HasCent() ? fCentAxis->GetNbins() : 0;
571 // Info("FetchResults","got %d centrality bins", n);
573 TH1* h = FetchOne(list, mcList, empCorr, name, "all",
574 FetchOthers(0,0), -1000, 0,
575 max, rmax, amax, fTruth);
577 TObjArray* a = new TObjArray;
578 // Info("FetchResults", "Adding %s to result stack", h->GetName());
583 TObjArray* a = new TObjArray;
585 for (UShort_t i = 0; i < n; i++) {
586 UShort_t centLow = fCentAxis->GetBinLowEdge(i+1);
587 UShort_t centHigh = fCentAxis->GetBinUpEdge(i+1);
588 TString lname = Form("cent%03d_%03d", centLow, centHigh);
589 Int_t col = GetCentralityColor(i+1);
590 TString centTxt = Form("%3d%%-%3d%% central", centLow, centHigh);
592 TH1* tt = static_cast<TH1*>(truths.At(i));
594 TH1* h = FetchOne(list, mcList, empCorr, name, lname,
595 FetchOthers(centLow,centHigh), col,
596 centTxt.Data(), max, rmax, amax, fTruth);
599 //Info("FetchResults", "old truth=%p new truth=%p (%s)", ot, tt, name);
602 // Info("FetchResults", "Adding %p to result stack", h);
607 //__________________________________________________________________
609 * Get the color for a centrality bin
611 * @param bin Centrality bin
615 Int_t GetCentralityColor(Int_t bin) const
617 if (fCentAxis->GetNbins() < 6) {
619 case 1: return kRed+2;
620 case 2: return kGreen+2;
621 case 3: return kBlue+1;
622 case 4: return kCyan+1;
623 case 5: return kMagenta+1;
624 case 6: return kYellow+2;
627 UShort_t centLow = fCentAxis->GetBinLowEdge(bin);
628 UShort_t centHigh = fCentAxis->GetBinUpEdge(bin);
629 Float_t fc = (centLow+double(centHigh-centLow)/2) / 100;
630 Int_t nCol = gStyle->GetNumberOfColors();
631 Int_t icol = TMath::Min(nCol-1,int(fc * nCol + .5));
632 Int_t col = gStyle->GetColorPalette(icol);
633 //Info("GetCentralityColor","%3d: %3d-%3d -> %3d",bin,centLow,centHigh,col);
636 //__________________________________________________________________
638 * Set attributed on a histogram
643 void SetAttributes(TH1* h, Int_t color)
646 if (color < 0) return;
647 // h->SetLineColor(color);
648 h->SetMarkerColor(color);
649 // h->SetFillColor(color);
651 //__________________________________________________________________
653 * Set attributed on a graph
658 void SetAttributes(TGraph* g, Int_t color)
661 if (color < 0) return;
662 // g->SetLineColor(color);
663 g->SetMarkerColor(color);
664 // g->SetFillColor(color);
666 //__________________________________________________________________
671 void ModifyTitle(TNamed* h, const char* /*centTxt*/)
675 TString title(h->GetTitle());
676 title.ReplaceAll("ALICE ","");
677 if (title.Contains("Central"))
678 title.ReplaceAll("Central", "SPD clusters");
679 if (title.Contains("Forward"))
680 title.ReplaceAll("Forward", "FMD");
685 // if (!centTxt || !h) return;
686 // h->SetTitle(Form("%s, %s", h->GetTitle(), centTxt));
688 //__________________________________________________________________
689 TH1* FetchOne(const TList* list,
691 TGraphErrors* empCorr,
693 const char* folderName,
703 if (fOld) folder = const_cast<TList*>(list);
704 else folder = static_cast<TList*>(list->FindObject(folderName));
706 Error("FetchResults", "Couldn't find list '%s' in %s",
707 folderName, list->GetName());
712 mcFolder = static_cast<TList*>(mcList->FindObject(folderName));
714 Warning("FetchResults",
715 "Didn't find the list '%s' in %s for final MC correction",
716 folderName, mcList->GetName());
718 TObject* normCalc = folder->FindObject("normCalc");
719 if (normCalc) Info("FetchOne", "%s:\n%s", folderName, normCalc->GetTitle());
720 TH1* h = FetchResults(folder, mcFolder, empCorr, name,
721 others, col, txt, max, rmax, amax, truth);
724 //__________________________________________________________________
726 * Fetch results for a particular centrality bin
729 * @param mcList List of MC results
730 * @param empCorr Emperical correction if any
732 * @param thisOther Other graphs
734 * @param centTxt Centrality text
735 * @param max On return, data maximum
736 * @param rmax On return, ratio maximum
737 * @param amax On return, left-right maximum
738 * @param truth MC truth to compare to or possibly update
740 * @return Histogram of results
742 TH1* FetchResults(const TList* list,
744 TGraphErrors* empCorr,
746 TMultiGraph* thisOther,
755 TH1* dndeta = FetchResult(list, Form("dndeta%s", name));
756 TH1* dndetaMC = FetchResult(list, Form("dndeta%sMC", name));
757 TH1* dndetaTruth = FetchResult(list, "dndetaTruth");
759 if (mcList && FetchResult(mcList, "finalMCCorr"))
760 Warning("FetchResults", "dNdeta already corrected for final MC");
762 CorrectFinalMC(dndeta, mcList);
764 CorrectEmpirical(dndeta, empCorr);
767 TH1* dndetaMCSym = 0;
768 SetAttributes(dndeta, color);
769 SetAttributes(dndetaMC, HasCent() ? color : color+2);
770 SetAttributes(dndetaTruth,color);
771 SetAttributes(dndetaSym, color);
772 SetAttributes(dndetaMCSym,HasCent() ? color : color+2);
773 if (dndetaMC && HasCent())
774 dndetaMC->SetMarkerStyle(dndetaMC->GetMarkerStyle()+2);
775 if (dndetaMCSym && HasCent())
776 dndetaMCSym->SetMarkerStyle(dndetaMCSym->GetMarkerStyle()+2);
777 if (dndetaTruth && HasCent()) {
778 dndetaTruth->SetMarkerStyle(34);
779 dndetaTruth->SetMarkerColor(kYellow-1);
782 dndetaTruth->SetLineColor(kBlack);
783 dndetaTruth->SetFillColor(kBlack);
784 dndetaTruth->SetFillStyle(3002);
785 // dndetaTruth->SetLineColor(kBlack);
787 ModifyTitle(dndeta, centTxt);
788 ModifyTitle(dndetaMC, centTxt);
789 ModifyTitle(dndetaTruth,centTxt);
790 ModifyTitle(dndetaSym, centTxt);
791 ModifyTitle(dndetaMCSym,centTxt);
794 max = TMath::Max(max, AddHistogram(fResults, dndetaTruth, "e5"));
795 max = TMath::Max(max, AddHistogram(fResults, dndetaMC, dndetaMCSym));
796 max = TMath::Max(max, AddHistogram(fResults, dndeta, dndetaSym));
803 THStack* rings = static_cast<THStack*>(list->FindObject("dndetaRings"));
805 TIter next(rings->GetHists());
807 while ((hist = static_cast<TH1*>(next())))
808 max = TMath::Max(max, AddHistogram(fResults, hist));
811 // Info("FetchResults", "Got %p, %p, %p from %s with name %s, max=%f",
812 // dndeta, dndetaMC, dndetaTruth, list->GetName(), name, max);
814 if (fShowLeftRight) {
815 fLeftRight->Add(Asymmetry(dndeta, amax));
816 fLeftRight->Add(Asymmetry(dndetaMC, amax));
820 TIter next(thisOther->GetListOfGraphs());
822 while ((g = static_cast<TGraph*>(next()))) {
823 fRatios->Add(Ratio(dndeta, g, rmax));
824 fRatios->Add(Ratio(dndetaSym, g, rmax));
825 SetAttributes(g, color);
826 ModifyTitle(g, centTxt);
827 if (!fOthers->GetListOfGraphs() ||
828 !fOthers->GetListOfGraphs()->FindObject(g->GetName())) {
829 max = TMath::Max(max,TMath::MaxElement(g->GetN(), g->GetY()));
833 // fOthers->Add(thisOther);
837 fRatios->Add(Ratio(dndeta, dndetaMC, rmax));
838 fRatios->Add(Ratio(dndetaSym, dndetaMCSym, rmax));
841 fRatios->Add(Ratio(dndeta, truth, rmax));
842 fRatios->Add(Ratio(dndetaSym, truth, rmax));
846 //__________________________________________________________________
847 void CorrectFinalMC(TH1* dndeta, const TList* mcList)
852 TH1* dndetaMC = FetchResult(mcList, dndeta->GetName());
853 TH1* dndetaTruth = FetchResult(mcList, "dndetaTruth");
854 if (!dndetaMC || !dndetaTruth) return;
856 TH1* corr = static_cast<TH1*>(dndetaMC->Clone("finalMCCorr"));
857 corr->Divide(dndetaTruth);
859 Info("CorrectFinalMC", "Correcting dN/deta with final MC correction");
860 dndeta->Divide(corr);
862 //__________________________________________________________________
863 void CorrectEmpirical(TH1* dndeta, const TGraphErrors* empCorr)
866 if (!empCorr) return;
868 Info("CorrectEmpirical", "Doing empirical correction of dN/deta");
869 TAxis* xAxis = dndeta->GetXaxis();
870 for (Int_t i = 1; i <= xAxis->GetNbins(); i++) {
871 Double_t x = xAxis->GetBinCenter(i);
872 Double_t y = dndeta->GetBinContent(i);
873 Double_t c = empCorr->Eval(x);
874 dndeta->SetBinContent(i, y / c);
878 //__________________________________________________________________
881 * @param max Max value
882 * @param rmax Maximum diviation from 1 of ratios
883 * @param amax Maximum diviation from 1 of asymmetries
885 void Plot(Double_t max,
889 gStyle->SetOptTitle(0);
890 gStyle->SetTitleFont(132, "xyz");
891 gStyle->SetLabelFont(132, "xyz");
894 Int_t w = 800; // h / TMath::Sqrt(2);
898 if (!fShowRatios) w *= 1.3;
900 if (!fShowLeftRight) w *= 1.3;
903 y1 = (y11 > 0.0001 ? 0.4 : 0.2);
904 y2 = (y11 > 0.0001 ? 0.2 : 0.3);
906 TCanvas* c = new TCanvas("Results", "Results", w, h);
911 PlotResults(max, y1);
914 PlotRatios(rmax, y2, y1);
917 PlotLeftRight(amax, y3, y2);
921 Int_t vMin = fVtxAxis->GetXmin();
922 Int_t vMax = fVtxAxis->GetXmax();
923 TString trg(fTrigString->GetTitle());
925 if (fTriggers) nev = fTriggers->GetBinContent(1);
926 trg = trg.Strip(TString::kBoth);
927 trg.ReplaceAll(" ", "_");
928 trg.ReplaceAll(">", "Gt");
929 trg.ReplaceAll("&", "AND");
930 trg.ReplaceAll("|", "OR");
931 TString base(Form("dndeta_%s_%s_%s_%c%02d%c%02dcm_%09dev",
932 fSysString->GetTitle(),
933 fSNNString->GetTitle(),
935 vMin < 0 ? 'm' : 'p', TMath::Abs(vMin),
936 vMax < 0 ? 'm' : 'p', TMath::Abs(vMax),
938 c->SaveAs(Form("%s.png", base.Data()));
939 c->SaveAs(Form("%s.root", base.Data()));
940 c->SaveAs(Form("%s.C", base.Data()));
941 base.ReplaceAll("dndeta", "export");
944 //__________________________________________________________________
948 * @param stack Stack to include
949 * @param mg (optional) Multi graph to include
950 * @param x1 Lower X coordinate in the range [0,1]
951 * @param y1 Lower Y coordinate in the range [0,1]
952 * @param x2 Upper X coordinate in the range [0,1]
953 * @param y2 Upper Y coordinate in the range [0,1]
954 * @param forceCol If non-zero, force this many columns
956 void BuildLegend(THStack* stack, TMultiGraph* mg,
957 Double_t x1, Double_t y1, Double_t x2, Double_t y2,
960 TLegend* l = new TLegend(x1,y1,x2,y2);
961 Int_t nCol = forceCol;
962 if (nCol <= 0) nCol = HasCent() ? 1 : 2;
963 l->SetNColumns(nCol);
969 // Loop over items in stack and get unique items, while ignoring
970 // mirrored data and systematic error bands
971 TIter next(stack->GetHists());
975 Bool_t sysErrSeen = false;
976 while ((hist = static_cast<TH1*>(next()))) {
977 TString t(hist->GetTitle());
978 TString n(hist->GetName());
980 if (t.Contains("mirrored")) continue;
981 if (n.Contains("syserror")) { sysErrSeen = true; continue; }
982 if (unique.FindObject(t.Data())) continue;
983 TObjString* s1 = new TObjString(hist->GetTitle());
984 s1->SetUniqueID(((hist->GetMarkerStyle() & 0xFFFF) << 16) |
985 ((hist->GetMarkerColor() & 0xFFFF) << 0));
987 // l->AddEntry(hist, hist->GetTitle(), "pl");
990 // If we have other stuff, scan for unique names
991 TIter nexto(mg->GetListOfGraphs());
993 while ((g = static_cast<TGraph*>(nexto()))) {
994 TString n(g->GetTitle());
995 if (n.Contains("mirrored")) continue;
996 if (unique.FindObject(n.Data())) continue;
997 TObjString* s2 = new TObjString(n);
998 s2->SetUniqueID(((g->GetMarkerStyle() & 0xFFFF) << 16) |
999 ((g->GetMarkerColor() & 0xFFFF) << 0));
1001 // l->AddEntry(hist, hist->GetTitle(), "pl");
1005 // Add legend entries for unique items only
1006 TIter nextu(&unique);
1009 while ((s = nextu())) {
1010 TLegendEntry* dd = l->AddEntry(Form("data%2d", i++),
1011 s->GetName(), "lp");
1012 Int_t style = (s->GetUniqueID() >> 16) & 0xFFFF;
1013 Int_t color = (s->GetUniqueID() >> 0) & 0xFFFF;
1014 dd->SetLineColor(kBlack);
1015 if (HasCent()) dd->SetMarkerColor(kBlack);
1016 else dd->SetMarkerColor(color);
1017 dd->SetMarkerStyle(style);
1020 // Add entry for systematic errors
1021 TLegendEntry* d0 = l->AddEntry("d0", Form("%4.1f%% Systematic error",
1022 100*fFwdSysErr), "f");
1023 d0->SetLineColor(SYSERR_COLOR);
1024 d0->SetMarkerColor(SYSERR_COLOR);
1025 d0->SetFillColor(SYSERR_COLOR);
1026 d0->SetFillStyle(SYSERR_STYLE);
1027 d0->SetMarkerStyle(0);
1028 d0->SetLineWidth(0);
1031 if (nCol == 2 && i % 2 == 1) {
1032 // To make sure the 'data' and 'mirrored' entries are on a line
1034 TLegendEntry* dd = l->AddEntry("dd", " ", "");
1036 dd->SetFillStyle(0);
1037 dd->SetFillColor(0);
1038 dd->SetLineWidth(0);
1039 dd->SetLineColor(0);
1040 dd->SetMarkerSize(0);
1043 // Add entry for 'data'
1044 TLegendEntry* d1 = l->AddEntry("d1", "Data", "lp");
1045 d1->SetLineColor(kBlack);
1046 d1->SetMarkerColor(kBlack);
1047 d1->SetMarkerStyle(20);
1049 // Add entry for 'mirrored data'
1050 TLegendEntry* d2 = l->AddEntry("d2", "Mirrored data", "lp");
1051 d2->SetLineColor(kBlack);
1052 d2->SetMarkerColor(kBlack);
1053 d2->SetMarkerStyle(24);
1058 //__________________________________________________________________
1060 * Build centrality legend
1062 * @param x1 Lower X coordinate in the range [0,1]
1063 * @param y1 Lower Y coordinate in the range [0,1]
1064 * @param x2 Upper X coordinate in the range [0,1]
1065 * @param y2 Upper Y coordinate in the range [0,1]
1067 void BuildCentLegend(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
1069 if (!HasCent()) return;
1071 TLegend* l = new TLegend(x1,y1,x2,y2);
1075 l->SetBorderSize(0);
1076 l->SetTextFont(132);
1078 Int_t n = fCentAxis->GetNbins();
1079 for (Int_t i = 1; i <= n; i++) {
1080 Double_t low = fCentAxis->GetBinLowEdge(i);
1081 Double_t upp = fCentAxis->GetBinUpEdge(i);
1082 TLegendEntry* e = l->AddEntry(Form("dummy%02d", i),
1083 Form("%3d%% - %3d%%",
1084 int(low), int(upp)), "pl");
1085 e->SetMarkerColor(GetCentralityColor(i));
1089 //__________________________________________________________________
1093 * @param max Maximum
1094 * @param yd Bottom position of pad
1096 void PlotResults(Double_t max, Double_t yd)
1098 // Make a sub-pad for the result itself
1099 TPad* p1 = new TPad("p1", "p1", 0, yd, 1.0, 1.0, 0, 0, 0);
1100 p1->SetTopMargin(0.05);
1101 p1->SetBorderSize(0);
1102 p1->SetBorderMode(0);
1103 p1->SetBottomMargin(yd > 0.001 ? 0.001 : 0.1);
1104 p1->SetRightMargin(0.03);
1105 if (fShowLeftRight || fShowRatios) p1->SetGridx();
1111 // Info("PlotResults", "Plotting results with max=%f", max);
1112 fResults->SetMaximum(1.15*max);
1113 fResults->SetMinimum(yd > 0.00001 ? -0.02*max : 0);
1115 FixAxis(fResults, (1-yd)*(yd > .001 ? 1 : .9 / 1.2),
1116 "#font[12]{#frac{1}{N} "
1117 "#frac{dN_{#font[132]{ch}}}{d#font[152]{#eta}}}");
1120 fResults->DrawClone("nostack e1");
1122 fRangeParam->fSlave1Axis = fResults->GetXaxis();
1123 fRangeParam->fSlave1Pad = p1;
1126 if (fShowOthers != 0) {
1127 TGraphAsymmErrors* o = 0;
1128 TIter nextG(fOthers->GetListOfGraphs());
1129 while ((o = static_cast<TGraphAsymmErrors*>(nextG())))
1130 o->DrawClone("same p");
1133 // Make a legend in the main result pad
1134 BuildCentLegend(.12, 1-p1->GetTopMargin()-.01-.5,
1135 .35, 1-p1->GetTopMargin()-.01-.1);
1136 Double_t x1 = (HasCent() ? .7 : .15);
1137 Double_t x2 = (HasCent() ? 1-p1->GetRightMargin()-.01: .90);
1138 Double_t y1 = (HasCent() ? .5: p1->GetBottomMargin()+.01);
1139 Double_t y2 = (HasCent() ? 1-p1->GetTopMargin()-.01-.15 : .35);
1141 BuildLegend(fResults, fOthers, x1, y1, x2, y2);
1143 // Put a title on top
1144 fTitle.ReplaceAll("@", " ");
1145 TLatex* tit = new TLatex(0.10, 0.95, fTitle.Data());
1147 tit->SetTextFont(132);
1148 tit->SetTextSize(0.05);
1151 Int_t aliceBlue = TColor::GetColor(41,73,156);
1152 // Put a nice label in the plot
1154 UShort_t snn = fSNNString->GetUniqueID();
1155 const char* sys = fSysString->GetTitle();
1156 if (snn == 2750) snn = 2760;
1157 if (snn > 1000) eS = Form("%4.2fTeV", float(snn)/1000);
1158 else eS = Form("%3dGeV", snn);
1159 TLatex* tt = new TLatex(.93, .93, Form("%s #sqrt{s%s}=%s, %s",
1161 (HasCent() ? "_{NN}" : ""),
1163 HasCent() ? "by centrality" :
1164 fTrigString->GetTitle()));
1165 tt->SetTextColor(aliceBlue);
1167 tt->SetTextFont(132);
1168 tt->SetTextAlign(33);
1171 // Put number of accepted events on the plot
1173 if (fTriggers) nev = fTriggers->GetBinContent(1);
1174 TLatex* et = new TLatex(.93, .83, Form("%d events", nev));
1175 et->SetTextColor(aliceBlue);
1177 et->SetTextFont(132);
1178 et->SetTextAlign(33);
1181 // Put number of accepted events on the plot
1183 TLatex* vt = new TLatex(.93, .88, fVtxAxis->GetTitle());
1185 vt->SetTextFont(132);
1186 vt->SetTextAlign(33);
1187 vt->SetTextColor(aliceBlue);
1190 // results->Draw("nostack e1 same");
1193 if (!fEmpirical.IsNull()) corrs.Append("Emperical");
1194 if (!fFinalMC.IsNull()) {
1195 if (!corrs.IsNull()) corrs.Append("+");
1196 corrs.Append("Final MC");
1199 if (!corrs.IsNull()) {
1200 corrs.Append(" correction");
1201 if (corrs.Index("+") != kNPOS) corrs.Append("s");
1202 TLatex* em = new TLatex(.93, .79, corrs);
1204 em->SetTextFont(132);
1205 em->SetTextAlign(33);
1206 em->SetTextColor(aliceBlue);
1210 fRangeParam->fSlave1Axis = FindXAxis(p1, fResults->GetName());
1211 fRangeParam->fSlave1Pad = p1;
1214 // Mark the plot as preliminary
1215 TLatex* pt = new TLatex(.12, .93, "Work in progress");
1217 pt->SetTextFont(22);
1218 // pt->SetTextSize();
1219 pt->SetTextColor(TColor::GetColor(234,26,46));
1220 pt->SetTextAlign(13);
1223 const char* logos[] = { "ALICE.png", "FMD.png", 0 };
1224 const char** logo = logos;
1226 if (gSystem->AccessPathName(*logo)) {
1230 TPad* pad = new TPad("logo", "logo", .12, .7, .25, .9, 0, 0, 0);
1231 pad->SetFillStyle(0);
1234 TImage* i = TImage::Create();
1235 i->ReadImage(*logo);
1241 //__________________________________________________________________
1245 * @param max Maximum diviation from 1
1246 * @param y1 Lower y coordinate of pad
1247 * @param y2 Upper y coordinate of pad
1249 void PlotRatios(Double_t max, Double_t y1, Double_t y2)
1251 if (fShowRatios == 0) return;
1253 bool isBottom = (y1 < 0.0001);
1254 Double_t yd = y2 - y1;
1255 // Make a sub-pad for the result itself
1256 TPad* p2 = new TPad("p2", "p2", 0, y1, 1.0, y2, 0, 0, 0);
1257 p2->SetTopMargin(0.001);
1258 p2->SetRightMargin(0.03);
1259 p2->SetBottomMargin(isBottom ? 1/yd * 0.07 : 0.0001);
1267 FixAxis(fRatios, yd, "Ratios", 7);
1269 fRatios->SetMaximum(1+TMath::Max(.22,1.05*max));
1270 fRatios->SetMinimum(1-TMath::Max(.32,1.05*max));
1272 fRatios->DrawClone("nostack e1");
1276 BuildLegend(fRatios, 0, .15,p2->GetBottomMargin()+.01,.9,
1277 isBottom ? .6 : .4, 2);
1279 TLegend* l2 = p2->BuildLegend(.15,p2->GetBottomMargin()+.01,.9,
1280 isBottom ? .6 : .4);
1282 l2->SetFillColor(0);
1283 l2->SetFillStyle(0);
1284 l2->SetBorderSize(0);
1285 l2->SetTextFont(132);
1287 // Make a nice band from 0.9 to 1.1
1288 TGraphErrors* band = new TGraphErrors(2);
1289 band->SetPoint(0, fResults->GetXaxis()->GetXmin(), 1);
1290 band->SetPoint(1, fResults->GetXaxis()->GetXmax(), 1);
1291 band->SetPointError(0, 0, .1);
1292 band->SetPointError(1, 0, .1);
1293 band->SetFillColor(kYellow+2);
1294 band->SetFillStyle(3002);
1295 band->SetLineStyle(2);
1296 band->SetLineWidth(1);
1297 band->Draw("3 same");
1298 band->DrawClone("X L same");
1300 // Replot the ratios on top
1301 fRatios->DrawClone("nostack e1 same");
1304 fRangeParam->fMasterAxis = FindXAxis(p2, fRatios->GetName());
1305 p2->AddExec("range", Form("RangeExec((dNdetaDrawer::RangeParam*)%p)",
1309 fRangeParam->fSlave2Axis = FindXAxis(p2, fRatios->GetName());
1310 fRangeParam->fSlave2Pad = p2;
1313 //__________________________________________________________________
1315 * Plot the asymmetries
1317 * @param max Maximum diviation from 1
1318 * @param y1 Lower y coordinate of pad
1319 * @param y2 Upper y coordinate of pad
1321 void PlotLeftRight(Double_t max, Double_t y1, Double_t y2)
1323 if (!fShowLeftRight) return;
1325 bool isBottom = (y1 < 0.0001);
1326 Double_t yd = y2 - y1;
1327 // Make a sub-pad for the result itself
1328 TPad* p3 = new TPad("p3", "p3", 0, y1, 1.0, y2, 0, 0, 0);
1329 p3->SetTopMargin(0.001);
1330 p3->SetRightMargin(0.03);
1331 p3->SetBottomMargin(isBottom ? 1/yd * 0.07 : 0.0001);
1339 FixAxis(fLeftRight, yd, "Right/Left", 4);
1341 fLeftRight->SetMaximum(1+TMath::Max(.12,1.05*max));
1342 fLeftRight->SetMinimum(1-TMath::Max(.15,1.05*max));
1344 fLeftRight->DrawClone("nostack e1");
1348 Double_t xx1 = (HasCent() ? .7 : .15);
1349 Double_t xx2 = (HasCent() ? 1-p3->GetRightMargin()-.01 : .90);
1350 Double_t yy1 = p3->GetBottomMargin()+.01;
1351 Double_t yy2 = (HasCent() ? 1-p3->GetTopMargin()-.01-.15 : .5);
1352 BuildLegend(fLeftRight, 0, xx1, yy1, xx2, yy2);
1353 // TLegend* l2 = p3->BuildLegend(.15,p3->GetBottomMargin()+.01,.9,.5);
1354 // l2->SetNColumns(2);
1355 // l2->SetFillColor(0);
1356 // l2->SetFillStyle(0);
1357 // l2->SetBorderSize(0);
1358 // l2->SetTextFont(132);
1360 // Make a nice band from 0.9 to 1.1
1361 TGraphErrors* band = new TGraphErrors(2);
1362 band->SetPoint(0, fResults->GetXaxis()->GetXmin(), 1);
1363 band->SetPoint(1, fResults->GetXaxis()->GetXmax(), 1);
1364 band->SetPointError(0, 0, .05);
1365 band->SetPointError(1, 0, .05);
1366 band->SetFillColor(kYellow+2);
1367 band->SetFillStyle(3002);
1368 band->SetLineStyle(2);
1369 band->SetLineWidth(1);
1370 band->Draw("3 same");
1371 band->DrawClone("X L same");
1373 fLeftRight->DrawClone("nostack e1 same");
1375 fRangeParam->fMasterAxis = FindXAxis(p3, fLeftRight->GetName());
1376 p3->AddExec("range", Form("RangeExec((dNdetaDrawer::RangeParam*)%p)",
1380 fRangeParam->fSlave2Axis = FindXAxis(p3, fLeftRight->GetName());
1381 fRangeParam->fSlave2Pad = p3;
1385 //==================================================================
1388 * @name Data utility functions
1391 * Get a result from the passed list
1393 * @param list List to search
1394 * @param name Object name to search for
1398 TH1* FetchResult(const TList* list, const char* name) const
1400 if (!list) return 0;
1402 TH1* ret = static_cast<TH1*>(list->FindObject(name));
1406 Warning("GetResult", "Histogram %s not found", name);
1412 //__________________________________________________________________
1414 * Add a histogram to the stack after possibly rebinning it
1416 * @param stack Stack to add to
1417 * @param hist histogram
1418 * @param option Draw options
1420 * @return Maximum of histogram
1422 Double_t AddHistogram(THStack* stack, TH1* hist, Option_t* option="") const
1424 // Check if we have input
1425 if (!hist) return 0;
1430 stack->Add(hist, option);
1431 return hist->GetMaximum();
1433 //__________________________________________________________________
1435 * Add a histogram to the stack after possibly rebinning it
1437 * @param stack Stack to add to
1438 * @param hist histogram
1439 * @param option Draw options
1440 * @param sym On return, the data symmetriced (added to stack)
1442 * @return Maximum of histogram
1444 Double_t AddHistogram(THStack* stack, TH1* hist, TH1*& sym,
1445 Option_t* option="") const
1447 // Check if we have input
1448 if (!hist) return 0;
1452 stack->Add(hist, option);
1454 // Now symmetrice the histogram
1456 sym = Symmetrice(hist);
1457 stack->Add(sym, option);
1460 return hist->GetMaximum();
1463 //__________________________________________________________________
1467 * @param h Histogram to rebin
1469 virtual void Rebin(TH1* h) const
1471 if (fRebin <= 1) return;
1473 Int_t nBins = h->GetNbinsX();
1474 if(nBins % fRebin != 0) {
1475 Warning("Rebin", "Rebin factor %d is not a devisor of current number "
1476 "of bins %d in the histogram %s", fRebin, nBins, h->GetName());
1481 TH1* tmp = static_cast<TH1*>(h->Clone("tmp"));
1483 tmp->SetDirectory(0);
1485 // The new number of bins
1486 Int_t nBinsNew = nBins / fRebin;
1487 for(Int_t i = 1;i<= nBinsNew; i++) {
1488 Double_t content = 0;
1492 for(Int_t j = 1; j<=fRebin;j++) {
1493 Int_t bin = (i-1)*fRebin + j;
1494 Double_t c = h->GetBinContent(bin);
1496 if (c <= 0) continue;
1499 if (h->GetBinContent(bin+1)<=0 ||
1500 h->GetBinContent(bin-1)) {
1501 Warning("Rebin", "removing bin %d=%f of %s (%d=%f,%d=%f)",
1502 bin, c, h->GetName(),
1503 bin+1, h->GetBinContent(bin+1),
1504 bin-1, h->GetBinContent(bin-1));
1508 Double_t e = h->GetBinError(bin);
1509 Double_t w = 1 / (e*e); // 1/c/c
1516 if(content > 0 && nbins > 1 ) {
1517 tmp->SetBinContent(i, wsum / sumw);
1518 tmp->SetBinError(i,1./TMath::Sqrt(sumw));
1522 // Finally, rebin the histogram, and set new content
1525 for(Int_t i = 1; i<= nBinsNew; i++) {
1526 h->SetBinContent(i,tmp->GetBinContent(i));
1527 h->SetBinError(i, tmp->GetBinError(i));
1532 //__________________________________________________________________
1534 * Make an extension of @a h to make it symmetric about 0
1536 * @param h Histogram to symmertrice
1538 * @return Symmetric extension of @a h
1540 TH1* Symmetrice(const TH1* h) const
1542 Int_t nBins = h->GetNbinsX();
1543 TH1* s = static_cast<TH1*>(h->Clone(Form("%s_mirror", h->GetName())));
1544 s->SetTitle(Form("%s (mirrored)", h->GetTitle()));
1546 s->SetBins(nBins, -h->GetXaxis()->GetXmax(), -h->GetXaxis()->GetXmin());
1547 s->SetMarkerColor(h->GetMarkerColor());
1548 s->SetMarkerSize(h->GetMarkerSize());
1549 s->SetMarkerStyle(h->GetMarkerStyle()+4);
1550 s->SetFillColor(h->GetFillColor());
1551 s->SetFillStyle(h->GetFillStyle());
1554 // Find the first and last bin with data
1555 Int_t first = nBins+1;
1557 for (Int_t i = 1; i <= nBins; i++) {
1558 if (h->GetBinContent(i) <= 0) continue;
1559 first = TMath::Min(first, i);
1560 last = TMath::Max(last, i);
1563 Double_t xfirst = h->GetBinCenter(first-1);
1564 Int_t f1 = h->GetXaxis()->FindBin(-xfirst);
1565 Int_t l2 = s->GetXaxis()->FindBin(xfirst);
1566 for (Int_t i = f1, j=l2; i <= last; i++,j--) {
1567 s->SetBinContent(j, h->GetBinContent(i));
1568 s->SetBinError(j, h->GetBinError(i));
1570 // Fill in overlap bin
1571 s->SetBinContent(l2+1, h->GetBinContent(first));
1572 s->SetBinError(l2+1, h->GetBinError(first));
1575 //__________________________________________________________________
1577 * Calculate the left-right asymmetry of input histogram
1579 * @param h Input histogram
1580 * @param max On return, the maximum distance from 1 of the histogram
1584 TH1* Asymmetry(TH1* h, Double_t& max)
1588 TH1* ret = static_cast<TH1*>(h->Clone(Form("%s_leftright", h->GetName())));
1589 // Int_t oBins = h->GetNbinsX();
1590 // Double_t high = h->GetXaxis()->GetXmax();
1591 // Double_t low = h->GetXaxis()->GetXmin();
1592 // Double_t dBin = (high - low) / oBins;
1593 // Int_t tBins = Int_t(2*high/dBin+.5);
1594 // ret->SetBins(tBins, -high, high);
1595 ret->SetDirectory(0);
1597 ret->SetTitle(Form("%s (+/-)", h->GetTitle()));
1598 ret->SetYTitle("Right/Left");
1599 Int_t nBins = h->GetNbinsX();
1600 for (Int_t i = 1; i <= nBins; i++) {
1601 Double_t x = h->GetBinCenter(i);
1604 Double_t c1 = h->GetBinContent(i);
1605 Double_t e1 = h->GetBinError(i);
1606 if (c1 <= 0) continue;
1608 Int_t j = h->FindBin(-x);
1609 if (j <= 0 || j > nBins) continue;
1611 Double_t c2 = h->GetBinContent(j);
1612 Double_t e2 = h->GetBinError(j);
1614 Double_t c12 = c1*c1;
1615 Double_t e = TMath::Sqrt((e2*e2*c1*c1+e1*e1*c2*c2)/(c12*c12));
1617 Int_t k = ret->FindBin(x);
1618 ret->SetBinContent(k, c2/c1);
1619 ret->SetBinError(k, e);
1621 max = TMath::Max(max, RatioMax(ret));
1625 //__________________________________________________________________
1627 * Transform a graph into a histogram
1633 TH1* Graph2Hist(const TGraphAsymmErrors* g) const
1635 Int_t nBins = g->GetN();
1636 TArrayF bins(nBins+1);
1638 for (Int_t i = 0; i < nBins; i++) {
1639 Double_t x = g->GetX()[i];
1640 Double_t exl = g->GetEXlow()[i];
1641 Double_t exh = g->GetEXhigh()[i];
1642 bins.fArray[i] = x-exl;
1643 bins.fArray[i+1] = x+exh;
1644 Double_t dxi = exh+exl;
1645 if (i == 0) dx = dxi;
1646 else if (dxi != dx) dx = 0;
1648 TString name(g->GetName());
1649 TString title(g->GetTitle());
1652 h = new TH1D(name.Data(), title.Data(), nBins, bins[0], bins[nBins]);
1655 h = new TH1D(name.Data(), title.Data(), nBins, bins.fArray);
1657 h->SetMarkerStyle(g->GetMarkerStyle());
1658 h->SetMarkerColor(g->GetMarkerColor());
1659 h->SetMarkerSize(g->GetMarkerSize());
1664 //==================================================================
1667 * @name Ratio utility functions
1670 * Get the maximum diviation from 1 in the passed ratio
1672 * @param h Ratio histogram
1674 * @return Max diviation from 1
1676 Double_t RatioMax(TH1* h) const
1678 Int_t nBins = h->GetNbinsX();
1680 for (Int_t i = 1; i <= nBins; i++) {
1681 Double_t c = h->GetBinContent(i);
1682 if (c == 0) continue;
1683 Double_t e = h->GetBinError(i);
1684 Double_t d = TMath::Abs(1-c-e);
1685 ret = TMath::Max(d, ret);
1689 //__________________________________________________________________
1691 * Make the ratio of h1 to h2
1693 * @param o1 First object (numerator)
1694 * @param o2 Second object (denominator)
1695 * @param max Maximum diviation from 1
1699 TH1* Ratio(const TObject* o1, const TObject* o2, Double_t& max) const
1701 if (!o1 || !o2) return 0;
1704 const TAttMarker* m1 = 0;
1705 const TAttMarker* m2 = 0;
1706 const TH1* h1 = dynamic_cast<const TH1*>(o1);
1709 const TH1* h2 = dynamic_cast<const TH1*>(o2);
1715 const TGraph* g2 = dynamic_cast<const TGraph*>(o2);
1723 const TGraphAsymmErrors* g1 = dynamic_cast<const TGraphAsymmErrors*>(o1);
1726 const TGraphAsymmErrors* g2 =
1727 dynamic_cast<const TGraphAsymmErrors*>(o2);
1730 r = RatioGG(g1, g2);
1735 Warning("Ratio", "Don't know how to divide a %s (%s) with a %s (%s)",
1736 o1->ClassName(), o1->GetName(), o2->ClassName(), o2->GetName());
1739 // Check that the histogram isn't empty
1740 if (r->GetEntries() <= 0) {
1745 r->SetMarkerStyle(m2->GetMarkerStyle());
1746 r->SetMarkerColor(m1->GetMarkerColor());
1747 if (TString(o2->GetName()).Contains("truth", TString::kIgnoreCase))
1748 r->SetMarkerStyle(m1->GetMarkerStyle());
1749 r->SetMarkerSize(0.9*m1->GetMarkerSize());
1750 r->SetName(Form("%s_over_%s", o1->GetName(), o2->GetName()));
1751 r->SetTitle(Form("%s / %s", o1->GetTitle(), o2->GetTitle()));
1753 max = TMath::Max(RatioMax(r), max);
1758 //__________________________________________________________________
1760 * Compute the ratio of @a h to @a g. @a g is evaluated at the bin
1763 * @param h Numerator
1768 TH1* RatioHG(const TH1* h, const TGraph* g) const
1770 if (!h || !g) return 0;
1772 TH1* ret = static_cast<TH1*>(h->Clone("tmp"));
1774 Double_t xlow = g->GetX()[0];
1775 Double_t xhigh = g->GetX()[g->GetN()-1];
1776 if (xlow > xhigh) { Double_t t = xhigh; xhigh = xlow; xlow = t; }
1778 for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
1779 Double_t c = h->GetBinContent(i);
1780 if (c <= 0) continue;
1782 Double_t x = h->GetBinCenter(i);
1783 if (x < xlow || x > xhigh) continue;
1785 Double_t f = g->Eval(x);
1786 if (f <= 0) continue;
1788 ret->SetBinContent(i, c / f);
1789 ret->SetBinError(i, h->GetBinError(i) / f);
1793 //__________________________________________________________________
1795 * Make the ratio of h1 to h2
1797 * @param h1 First histogram (numerator)
1798 * @param h2 Second histogram (denominator)
1802 TH1* RatioHH(const TH1* h1, const TH1* h2) const
1804 if (!h1 || !h2) return 0;
1805 TH1* t1 = static_cast<TH1*>(h1->Clone("tmp"));
1809 //__________________________________________________________________
1811 * Calculate the ratio of two graphs - g1 / g2
1813 * @param g1 Numerator
1814 * @param g2 Denominator
1816 * @return g1 / g2 in a histogram
1818 TH1* RatioGG(const TGraphAsymmErrors* g1,
1819 const TGraphAsymmErrors* g2) const
1821 Int_t nBins = g1->GetN();
1822 TArrayF bins(nBins+1);
1824 for (Int_t i = 0; i < nBins; i++) {
1825 Double_t x = g1->GetX()[i];
1826 Double_t exl = g1->GetEXlow()[i];
1827 Double_t exh = g1->GetEXhigh()[i];
1828 bins.fArray[i] = x-exl;
1829 bins.fArray[i+1] = x+exh;
1830 Double_t dxi = exh+exl;
1831 if (i == 0) dx = dxi;
1832 else if (dxi != dx) dx = 0;
1836 h = new TH1F("tmp", "tmp", nBins, bins[0], bins[nBins]);
1839 h = new TH1F("tmp", "tmp", nBins, bins.fArray);
1842 Double_t low = g2->GetX()[0];
1843 Double_t high = g2->GetX()[g2->GetN()-1];
1844 if (low > high) { Double_t t = low; low = high; high = t; }
1845 for (Int_t i = 0; i < nBins; i++) {
1846 Double_t x = g1->GetX()[i];
1847 if (x < low-dx || x > high+dx) continue;
1848 Double_t c1 = g1->GetY()[i];
1849 Double_t e1 = g1->GetErrorY(i);
1850 Double_t c2 = g2->Eval(x);
1852 h->SetBinContent(i+1, c1 / c2);
1853 h->SetBinError(i+1, e1 / c2);
1858 //==================================================================
1861 * @name Graphics utility functions
1864 * Find an X axis in a pad
1867 * @param name Histogram to find axis for
1869 * @return Found axis or null
1871 TAxis* FindXAxis(TVirtualPad* p, const char* name)
1873 TObject* o = p->GetListOfPrimitives()->FindObject(name);
1875 Warning("FindXAxis", "%s not found in pad", name);
1878 THStack* stack = dynamic_cast<THStack*>(o);
1880 Warning("FindXAxis", "%s is not a THStack", name);
1883 if (!stack->GetHistogram()) {
1884 Warning("FindXAxis", "%s has no histogram", name);
1887 TAxis* ret = stack->GetHistogram()->GetXaxis();
1891 //__________________________________________________________________
1893 * Fix the apperance of the axis in a stack
1895 * @param stack stack of histogram
1896 * @param yd How the canvas is cut
1897 * @param ytitle Y axis title
1898 * @param ynDiv Divisions on Y axis
1899 * @param force Whether to draw the stack first or not
1901 void FixAxis(THStack* stack, Double_t yd, const char* ytitle,
1902 Int_t ynDiv=210, Bool_t force=true)
1905 Warning("FixAxis", "No stack passed for %s!", ytitle);
1908 if (force) stack->Draw("nostack e1");
1910 TH1* h = stack->GetHistogram();
1912 Warning("FixAxis", "Stack %s has no histogram", stack->GetName());
1915 Double_t s = 1/yd/1.2;
1916 // Info("FixAxis", "for %s, s=1/%f=%f", stack->GetName(), yd, s);
1918 h->SetXTitle("#font[152]{#eta}");
1919 h->SetYTitle(ytitle);
1920 TAxis* xa = h->GetXaxis();
1921 TAxis* ya = h->GetYaxis();
1923 // Int_t npixels = 20
1924 // Float_t dy = gPad->AbsPixeltoY(0) - gPad->AbsPixeltoY(npixels);
1925 // Float_t ts = dy/(gPad->GetY2() - gPad->GetY1());
1928 // xa->SetTitle(h->GetXTitle());
1929 // xa->SetTicks("+-");
1930 xa->SetTitleSize(s*xa->GetTitleSize());
1931 xa->SetLabelSize(s*xa->GetLabelSize());
1932 xa->SetTickLength(s*xa->GetTickLength());
1933 // xa->SetTitleOffset(xa->GetTitleOffset()/s);
1935 if (stack != fResults) {
1936 TAxis* rxa = fResults->GetXaxis();
1937 xa->Set(rxa->GetNbins(), rxa->GetXmin(), rxa->GetXmax());
1941 // ya->SetTitle(h->GetYTitle());
1943 // ya->SetTicks("+-");
1944 ya->SetNdivisions(ynDiv);
1945 ya->SetTitleSize(s*ya->GetTitleSize());
1946 ya->SetTitleOffset(ya->GetTitleOffset()/s);
1947 ya->SetLabelSize(s*ya->GetLabelSize());
1950 //__________________________________________________________________
1952 * Merge two histograms into one
1954 * @param cen Central part
1955 * @param fwd Forward part
1956 * @param xlow On return, lower eta bound
1957 * @param xhigh On return, upper eta bound
1959 * @return Newly allocated histogram or null
1962 Merge(const TH1* cen, const TH1* fwd, Double_t& xlow, Double_t& xhigh)
1964 TH1* tmp = static_cast<TH1*>(fwd->Clone("tmp"));
1965 TString name(fwd->GetName());
1966 name.ReplaceAll("Forward", "Merged");
1969 // tmp->SetMarkerStyle(28);
1970 // tmp->SetMarkerColor(kBlack);
1971 tmp->SetDirectory(0);
1974 for (Int_t i = 1; i <= tmp->GetNbinsX(); i++) {
1975 Double_t cc = cen->GetBinContent(i);
1976 Double_t cf = fwd->GetBinContent(i);
1977 Double_t ec = cen->GetBinError(i);
1978 Double_t ef = fwd->GetBinError(i);
1981 if (cc < 0.001 && cf < 0.01) continue;
1982 xlow = TMath::Min(tmp->GetXaxis()->GetBinLowEdge(i),xlow);
1983 xhigh = TMath::Max(tmp->GetXaxis()->GetBinUpEdge(i),xhigh);
1989 ne = TMath::Sqrt(ec*ec + ef*ef);
1992 tmp->SetBinContent(i, nc);
1993 tmp->SetBinError(i, ne);
1997 //____________________________________________________________________
1999 * Fit @f$g(x;A_1,A_2,\sigma_1,\sigma_2)@f$ to histogram data
2001 * @param tmp Histogram
2002 * @param xlow Lower x bound
2003 * @param xhigh Upper x bound
2005 * @return Fitted function
2008 FitMerged(TH1* tmp, Double_t xlow, Double_t xhigh)
2010 TF1* tmpf = new TF1("tmpf", "gaus", xlow, xhigh);
2011 tmp->Fit(tmpf, "NQ", "");
2012 tmp->SetDirectory(0);
2014 TF1* fit = new TF1("f", myFunc, xlow, xhigh, 4);
2015 fit->SetParNames("a_{1}", "a_{2}", "#sigma_{1}", "#sigma_{2}");
2016 fit->SetParameters(tmpf->GetParameter(0),
2018 tmpf->GetParameter(2),
2019 tmpf->GetParameter(2)/4);
2020 fit->SetParLimits(3, 0, 100);
2021 fit->SetParLimits(4, 0, 100);
2022 tmp->Fit(fit,"0W","");
2027 //____________________________________________________________________
2029 * Make band of systematic errors
2031 * @param tmp Histogram
2032 * @param cen Central
2033 * @param fwd Forward
2037 MakeSysError(TH1* tmp, TH1* cen, TH1* fwd, TF1* fit)
2039 for (Int_t i = 1; i <= tmp->GetNbinsX(); i++) {
2040 Double_t tc = tmp->GetBinContent(i);
2041 if (tc < 0.01) continue;
2042 Double_t fc = fwd->GetBinContent(i);
2043 Double_t cc = cen->GetBinContent(i);
2044 Double_t sysErr = fFwdSysErr;
2045 if (cc > .01 && fc > 0.01)
2046 sysErr = (fFwdSysErr+fCenSysErr) / 2;
2048 sysErr = fCenSysErr;
2049 Double_t x = tmp->GetXaxis()->GetBinCenter(i);
2050 Double_t y = fit->Eval(x);
2051 tmp->SetBinContent(i, y);
2052 tmp->SetBinError(i,sysErr*y);
2054 TString name(tmp->GetName());
2055 name.ReplaceAll("Merged", "SysError");
2057 tmp->SetMarkerColor(SYSERR_COLOR);
2058 tmp->SetLineColor(SYSERR_COLOR);
2059 tmp->SetFillColor(SYSERR_COLOR);
2060 tmp->SetFillStyle(SYSERR_STYLE);
2061 tmp->SetMarkerStyle(0);
2062 tmp->SetLineWidth(0);
2064 void CorrectForward(TH1* h) const
2066 if (!fRemoveOuters) return;
2068 for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
2069 Double_t eta = h->GetBinCenter(i);
2070 if (TMath::Abs(eta) < 2.3) {
2071 h->SetBinContent(i, 0);
2072 h->SetBinError(i, 0);
2076 void CorrectCentral(TH1* h) const
2078 if (fClusterScale.IsNull()) return;
2079 TString t(h->GetTitle());
2080 Info("CorrectCentral", "Replacing Central with Tracklets in %s", t.Data());
2081 t.ReplaceAll("Central", "Tracklets");
2084 TF1* cf = new TF1("clusterScale", fClusterScale);
2085 for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
2086 Double_t eta = h->GetBinCenter(i);
2087 Double_t f = cf->Eval(eta);
2088 Double_t c = h->GetBinContent(i);
2090 h->SetBinContent(i, c / f);
2094 //____________________________________________________________________
2095 void Export(const char* basename)
2097 TString bname(basename);
2098 bname.ReplaceAll(" ", "_");
2099 bname.ReplaceAll("-", "_");
2100 TString fname(Form("%s.C", bname.Data()));
2102 std::ofstream outf(fname.Data());
2104 Error("Export", "Failed to open output file %s", fname.Data());
2107 outf << "// Create by dNdetaDrawer\n"
2108 << "void " << bname << "(THStack* stack, TLegend* l, Int_t m)\n"
2110 << " Int_t ma[] = { 24, 25, 26, 32,\n"
2111 << " 20, 21, 22, 33,\n"
2112 << " 34, 30, 29, 0, \n"
2114 << " Int_t mm = ((m < 20 || m > 34) ? 0 : ma[m-20]);\n\n";
2115 TList* hists = fResults->GetHists();
2118 while ((hist = static_cast<TH1*>(next()))) {
2119 TString hname = hist->GetName();
2120 hname.Append(Form("_%04x", (gRandom->Integer(0xffff) & 0xffff)));
2121 hist->SetName(hname);
2122 hist->GetListOfFunctions()->Clear();
2123 hist->SavePrimitive(outf, "nodraw");
2124 bool mirror = hname.Contains("mirror");
2125 bool syserr = hname.Contains("SysError");
2127 outf << " " << hname << "->SetMarkerStyle("
2128 << (mirror ? "mm" : "m") << ");\n";
2130 outf << " " << hname << "->SetMarkerStyle(1);\n";
2131 outf << " stack->Add(" << hname
2132 << (syserr ? ",\"e5\"" : "") << ");\n\n";
2134 UShort_t snn = fSNNString->GetUniqueID();
2135 // const char* sys = fSysString->GetTitle();
2137 if (snn == 2750) snn = 2760;
2138 if (snn < 1000) eS = Form("%3dGeV", snn);
2139 else if (snn % 1000 == 0) eS = Form("%dTeV", snn/1000);
2140 else eS = Form("%4.2fTeV", float(snn)/1000);
2141 outf << " if (l) {\n"
2142 << " TLegendEntry* e = l->AddEntry(\"\",\"" << eS << "\",\"pl\");\n"
2143 << " e->SetMarkerStyle(m);\n"
2144 << " e->SetMarkerColor(kBlack);\n"
2146 << "}\n" << std::endl;
2149 Bool_t HasCent() const { return fCentAxis && !fForceMB; }
2153 //__________________________________________________________________
2158 Bool_t fShowRatios; // Show ratios
2159 Bool_t fShowLeftRight;// Show asymmetry
2160 Bool_t fShowRings; // Show rings too
2161 Bool_t fExport; // Export results to file
2162 Bool_t fCutEdges; // Whether to cut edges
2163 Bool_t fRemoveOuters; // Whether to remove outers
2164 UShort_t fShowOthers; // Show other data
2165 Bool_t fMirror; // Whether to mirror
2166 Bool_t fForceMB; // Force min-bias
2172 UShort_t fRebin; // Rebinning factor
2173 Double_t fFwdSysErr; // Systematic error in forward range
2174 Double_t fCenSysErr; // Systematic error in central range
2175 TString fTitle; // Title on plot
2176 TString fClusterScale; // Scaling of clusters to tracklets
2177 TString fFinalMC; // Final MC correction file name
2178 TString fEmpirical; // Empirical correction file name
2182 * @name Read (or set) information
2184 TNamed* fTrigString; // Trigger string (read, or set)
2185 TNamed* fNormString; // Normalisation string (read, or set)
2186 TNamed* fSNNString; // Energy string (read, or set)
2187 TNamed* fSysString; // Collision system string (read or set)
2188 TAxis* fVtxAxis; // Vertex cuts (read or set)
2189 TAxis* fCentAxis; // Centrality axis
2193 * @name Resulting plots
2195 THStack* fResults; // Stack of results
2196 THStack* fRatios; // Stack of ratios
2197 THStack* fLeftRight; // Left-right asymmetry
2198 TMultiGraph* fOthers; // Older data
2199 TH1* fTriggers; // Number of triggers
2200 TH1* fTruth; // Pointer to truth
2202 RangeParam* fRangeParam; // Parameter object for range zoom
2206 //____________________________________________________________________
2208 * Function to calculate
2210 * g(x;A_1,A_2,\sigma_1,\sigma_2) =
2211 * A_1\left(\frac{1}{2\pi\sigma_1}e^{(x/\sigma_1)^2} -
2212 * A_2\frac{1}{2\pi\sigma_2}e^{(x/\sigma_2)^2}\right)
2215 * @param xp Pointer to x array
2216 * @param pp Pointer to parameter array
2218 * @return @f$g(x;A_1,A_2,\sigma_1,\sigma_2)@f$
2220 Double_t myFunc(Double_t* xp, Double_t* pp)
2223 Double_t a1 = pp[0];
2224 Double_t a2 = pp[1];
2225 Double_t s1 = pp[2];
2226 Double_t s2 = pp[3];
2227 return a1*(TMath::Gaus(x, 0, s1) - a2 * TMath::Gaus(x, 0, s2));
2230 //=== Stuff for auto zooming =========================================
2232 * Update canvas range
2234 * @param p Parameter
2236 void UpdateRange(dNdetaDrawer::RangeParam* p)
2239 Warning("UpdateRange", "No parameters %p", p);
2242 if (!p->fMasterAxis) {
2243 Warning("UpdateRange", "No master axis %p", p->fMasterAxis);
2246 Int_t first = p->fMasterAxis->GetFirst();
2247 Int_t last = p->fMasterAxis->GetLast();
2248 Double_t x1 = p->fMasterAxis->GetBinCenter(first);
2249 Double_t x2 = p->fMasterAxis->GetBinCenter(last);
2251 if (p->fSlave1Axis) {
2252 Int_t i1 = p->fSlave1Axis->FindBin(x1);
2253 Int_t i2 = p->fSlave1Axis->FindBin(x2);
2254 p->fSlave1Axis->SetRange(i1, i2);
2255 p->fSlave1Pad->Modified();
2256 p->fSlave1Pad->Update();
2258 if (p->fSlave2Axis) {
2259 Int_t i1 = p->fSlave2Axis->FindBin(x1);
2260 Int_t i2 = p->fSlave2Axis->FindBin(x2);
2261 p->fSlave2Axis->SetRange(i1, i2);
2262 p->fSlave2Pad->Modified();
2263 p->fSlave2Pad->Update();
2265 TCanvas* c = gPad->GetCanvas();
2269 //____________________________________________________________________
2271 * Called when user changes X range
2273 * @param p Parameter
2275 void RangeExec(dNdetaDrawer::RangeParam* p)
2282 // 11: Mouse release
2283 // dNdetaDrawer::RangeParam* p =
2284 // reinterpret_cast<dNdetaDrawer::RangeParam*>(addr);
2285 Int_t event = gPad->GetEvent();
2286 TObject *select = gPad->GetSelected();
2291 if (event != 11 || !select || select != p->fMasterAxis) return;
2295 //=== Steering functions
2296 //==============================================
2298 * Display usage information
2304 printf("Usage: DrawdNdeta(FILE,TITLE,REBIN,OTHERS,FLAGS,"
2305 "SNN,SYS,TRIG,IPZMIN,IPZMAX)\n\n"
2306 " const char* FILE File name to open (\"forward_dndeta.root\")\n"
2307 " const char* TITLE Title to put on plot (\"\")\n"
2308 " UShort_t REBIN Rebinning factor (1)\n"
2309 " UShort_t OTHERS Other data to draw - more below (0x7)\n"
2310 " UShort_t FLAGS Visualisation flags - more below (0x7)\n"
2311 " UShort_t SYS (optional) 1:pp, 2:PbPb, 3:pPb\n"
2312 " UShort_t SNN (optional) sqrt(s_NN) in GeV\n"
2313 " UShort_t TRIG (optional) 1: INEL, 2: INEL>0, 4: NSD, ...\n"
2314 " Float_t IPZMIN (optional) Least z coordinate of IP\n"
2315 " Float_t IPZMAX (optional) Largest z coordinate of IP\n\n"
2316 " OTHERS is a bit mask of\n\n"
2317 " 0x1 Show UA5 data (INEL,NSD, ppbar, 900GeV)\n"
2318 " 0x2 Show CMS data (NSD, pp)\n"
2319 " 0x4 Show published ALICE data (INEL,INEL>0,NSD, pp)\n"
2320 " 0x8 Show event genertor data\n\n"
2321 " FLAGS is a bit mask of\n\n"
2322 " 0x1 Show ratios of data to other data and possibly MC\n"
2323 " 0x2 Show left-right asymmetry\n"
2324 " 0x4 Show systematic error band\n"
2325 " 0x8 Show individual ring results (INEL only)\n"
2326 " 0x10 Cut edges when rebinning\n"
2327 " 0x20 Remove FMDxO points\n"
2328 " 0x40 Do not make our own canvas\n"
2329 " 0x80 Force use of MB\n"
2330 " 0x100 Mirror data\n"
2331 " 0x200 Apply `final MC' correction\n"
2332 " 0x400 Apply `Emperical' correction\n"
2333 " 0x800 Export results to script\n\n"
2334 "0x200 requires the file forward_dndetamc.root\n"
2335 "0x400 requires the file EmpiricalCorrection.root\n"
2336 "To specify that you want ratios, force MB, apply empirical "
2337 "correction, and export to script, set flags to\n\n"
2338 " 0x1|0x80|0x400|0x800=0xC81\n\n"
2342 //____________________________________________________________________
2344 * Draw @f$ dN/d\eta@f$
2346 * @param filename File name
2347 * @param title Title
2348 * @param rebin Rebinning factor
2349 * @param others What other data to show
2350 * @param flags Flags
2351 * @param sNN (optional) Collision energy [GeV]
2352 * @param sys (optional) Collision system (1: pp, 2: PbPb)
2353 * @param trg (optional) Trigger (1: INEL, 2: INEL>0, 4: NSD)
2354 * @param vzMin Least @f$ v_z@f$
2355 * @param vzMax Largest @f$ v_z@f$
2357 * @ingroup pwglf_forward_dndeta
2360 DrawdNdeta(const char* filename="forward_dndeta.root",
2361 const char* title="",
2363 UShort_t others=0x7,
2364 UShort_t flags=0x187,
2371 TString fname(filename);
2373 if (fname.CompareTo("help") == 0 ||
2374 fname.CompareTo("--help") == 0) {
2378 dNdetaDrawer* pd = new dNdetaDrawer;
2379 dNdetaDrawer& d = *pd;
2382 d.SetShowOthers(others);
2383 d.SetShowRatios(flags & 0x1);
2384 d.SetShowLeftRight(flags & 0x2);
2385 d.SetForwardSysError(flags & 0x4 ? 0.076 : 0);
2386 d.SetShowRings(flags & 0x8);
2387 d.SetCutEdges(flags & 0x10);
2388 d.fRemoveOuters = (flags & 0x20);
2389 d.SetExport(flags & 0x40);
2390 d.SetForceMB(flags & 0x80);
2391 d.SetMirror(flags & 0x100);
2392 d.SetFinalMC(flags & 0x200 ? "forward_dndetamc.root" : "");
2393 d.SetEmpirical(flags & 0x400 ? "EmpiricalCorrection.root" : "");
2394 d.SetExport(flags & 0x800);
2395 d.SetOld(flags & 0x1000);
2396 // d.fClusterScale = "1.06 -0.003*x +0.0119*x*x";
2397 // Do the below if your input data does not contain these settings
2398 if (sNN > 0) d.SetSNN(sNN); // Collision energy per nucleon pair (GeV)
2399 if (sys > 0) d.SetSys(sys); // Collision system (1:pp, 2:PbPB)
2400 if (trg > 0) d.SetTrigger(trg); // Collision trigger (1:INEL, 2:INEL>0, 4:NSD)
2401 if (vzMin < 999 && vzMax > -999)
2402 d.SetVertexRange(vzMin,vzMax); // Collision vertex range (cm)
2405 //____________________________________________________________________