]>
Commit | Line | Data |
---|---|---|
00bc74c1 | 1 | #include <TH1.h> |
2 | #include <TMath.h> | |
3 | #include <TLegend.h> | |
4 | ||
5 | ||
6 | namespace RawProduction { | |
7 | class Output; | |
8 | } | |
9 | ||
10 | const int nFrom=4; | |
11 | const int nTo=4; | |
12 | float fromRanges[nFrom] = {0.04, 0.05, 0.07, 0.10}; | |
13 | float toRanges[nTo] = {0.20, 0.25, 0.30, 0.40}; | |
14 | RawProduction::Output* output[nFrom][nTo] = {0}; | |
15 | ||
16 | const Double_t maxyPlot = 5., minyPlot = 1.e-3; | |
17 | const Double_t minReasonableY=1.e-7; | |
18 | ||
19 | TH1* GetHist(RawProduction::Output* out, const char* trigger, const char* pid, int cent, const char* methode) | |
20 | { | |
21 | //TH1* hist[4][4] = {0}; | |
22 | char name[256]; | |
23 | sprintf(name, "%s/c%03i/%s/%s", trigger, cent, pid, methode); | |
24 | return out->GetHistogram(name); | |
25 | } | |
26 | ||
27 | void SetVariation(TH1* hist, const char* trigger, const char* pid, int cent, const char* methode) | |
28 | { | |
29 | for(int ptb=1; ptb <= hist->GetNbinsX(); ++ptb) { | |
30 | int rejected =0; | |
31 | Double_t y[nFrom][nTo] = {0}; | |
32 | for(int fidx=0; fidx<nFrom; fidx++) { | |
33 | for(int tidx=0; tidx<nTo; tidx++) { | |
34 | TH1* fthist = GetHist(output[fidx][tidx], trigger, pid, cent, methode); | |
35 | if( 0. == fthist->GetBinContent(ptb) ) | |
36 | rejected++; | |
37 | y[fidx][tidx] = fthist->GetBinContent(ptb); | |
38 | } | |
39 | } | |
40 | if( 0 == rejected ) { | |
41 | Double_t N = (nFrom*nTo); | |
42 | Double_t m = TMath::Mean(N, (Double_t*)y); | |
43 | Double_t s = TMath::RMS(N, (Double_t*)y)*TMath::Sqrt(N/(N-1)); | |
44 | Double_t s_rel = s/m; | |
45 | Double_t e_s_rel = s_rel / TMath::Sqrt(2*(N-1)); | |
46 | hist->SetBinContent(ptb, s_rel); | |
47 | hist->SetBinError(ptb, e_s_rel); | |
48 | //Printf("%f %f", s_rel, e_s_rel); | |
49 | } | |
50 | else { | |
51 | hist->SetBinContent(ptb, 0.); | |
52 | hist->SetBinError(ptb, 0.); | |
53 | } | |
54 | } | |
55 | if( hist->GetMaximum() > maxyPlot ) | |
56 | Printf("Warning, maximum of %s is %e, larger range max: %e", hist->GetName(), hist->GetMaximum(), maxyPlot); | |
57 | if( hist->GetMinimum(minReasonableY) < minyPlot) | |
58 | Printf("Warning, minimum of %s is %e, larger range min: %e", hist->GetName(), hist->GetMinimum(minReasonableY), minyPlot); | |
59 | } | |
60 | ||
61 | void DrawVar(const char* trigger, const char* pid, int cent) | |
62 | { | |
63 | gStyle->SetOptStat(0); | |
64 | TString name = Form("%s_%s_c%03i", trigger, pid, cent); | |
65 | TCanvas* canv = new TCanvas(name.Data(), name.Data()); | |
66 | ||
67 | TLegend* leg = new TLegend(0.87, 0.12, 0.99,0.32); | |
68 | ||
69 | // yr1 | |
70 | TH1* hist = (TH1*)GetHist(output[0][0], trigger, pid, cent, "yr1")->Clone(Form("%s_%s_c%03i_yr1", trigger, pid, cent)); | |
71 | hist->SetTitle(Form("Variation of peak position with fit Range, %s, %s, %s", trigger, pid, RawProduction::GetCentString(cent))); | |
72 | SetVariation(hist, trigger, pid, cent, "yr1"); | |
73 | hist->GetXaxis()->SetTitle("p_T [GeV/c]"); | |
74 | hist->GetYaxis()->SetTitle("#frac{s}{#bar #hat #mu}"); | |
75 | canv->SetLogy(); | |
76 | hist->GetYaxis()->SetRangeUser(minyPlot, maxyPlot); | |
77 | hist->SetMarkerStyle(21); | |
78 | leg->AddEntry(hist, "yr1", "lep"); | |
79 | hist->DrawCopy("E"); | |
80 | ||
81 | // yr2 | |
82 | hist = (TH1*)GetHist(output[0][0], trigger, pid, cent, "yr2")->Clone(Form("%s_%s_c%03i_yr2", trigger, pid, cent)); | |
83 | SetVariation(hist, trigger, pid, cent, "yr2"); | |
84 | hist->SetMarkerStyle(23); | |
85 | hist->SetMarkerColor(kRed); | |
86 | hist->SetLineColor(kRed); | |
87 | leg->AddEntry(hist, "yr2", "lep"); | |
88 | hist->Draw("same"); | |
89 | ||
90 | // yr1int | |
91 | hist = (TH1*)GetHist(output[0][0], trigger, pid, cent, "yr1int")->Clone(Form("%s_%s_c%03i_yr1int", trigger, pid, cent)); | |
92 | SetVariation(hist, trigger, pid, cent, "yr1int"); | |
93 | hist->SetMarkerStyle(24); | |
94 | hist->SetMarkerColor(kGreen); | |
95 | hist->SetLineColor(kGreen); | |
96 | leg->AddEntry(hist, "yr1int", "lep"); | |
97 | hist->Draw("same"); | |
98 | ||
99 | // yr2int | |
100 | hist = (TH1*)GetHist(output[0][0], trigger, pid, cent, "yr2int")->Clone(Form("%s_%s_c%03i_yr2int", trigger, pid, cent)); | |
101 | SetVariation(hist, trigger, pid, cent, "yr2int"); | |
102 | hist->SetMarkerStyle(25); | |
103 | hist->SetMarkerColor(kBlue); | |
104 | hist->SetLineColor(kBlue); | |
105 | leg->AddEntry(hist, "yr2int", "lep"); | |
106 | hist->Draw("same"); | |
107 | ||
108 | leg->Draw(); | |
109 | ||
110 | canv->SaveAs(Form("imgs/RV_c%03i_%s_%s.png", cent, trigger, pid)); | |
111 | canv->SaveAs(Form("imgs/RV_c%03i_%s_%s.pdf", cent, trigger, pid)); | |
112 | } | |
113 | ||
114 | ||
115 | void DrawRangeVar() | |
116 | { | |
117 | for(int fidx=0; fidx<nFrom; fidx++) { | |
118 | for(int tidx=0; tidx<nTo; tidx++) { | |
119 | output[fidx][tidx] = new RawProduction::Output(Form("RawProduction_%.2f_%.2f.root", fromRanges[fidx], toRanges[tidx])); | |
120 | } | |
121 | } | |
122 | ||
123 | //TStringToken triggers("kMB kCentral kSemiCentral kPHOSPb", " "); | |
124 | TStringToken triggers("kPHOSPb kCentral kSemiCentral kMB", " "); | |
125 | while(triggers.NextToken()) { | |
126 | //TStringToken pids("All Allcore Allwou Disp Disp2 Dispcore Disp2core Dispwou CPV CPVcore CPV2 CPV2core Both Bothcore Both2 Both2core", " "); | |
127 | TStringToken pids("All Allcore Disp CPV Both", " "); | |
128 | while(pids.NextToken()) { | |
129 | for(int cent = -11; cent < 0; ++cent) { | |
130 | if(triggers.EqualTo("kMB") || triggers.EqualTo("kPHOSPb")) { | |
131 | if( -1 == cent || -11 == cent || -10 == cent || -6 == cent ) | |
132 | DrawVar(triggers.Data(), pids.Data(), cent); | |
133 | } | |
134 | if(triggers.EqualTo("kCentral") ) { | |
135 | if( -1 == cent ) | |
136 | DrawVar(triggers.Data(), pids.Data(), cent); | |
137 | } | |
138 | if(triggers.EqualTo("kSemiCentral") ) { | |
139 | if( -11 == cent ) | |
140 | DrawVar(triggers.Data(), pids.Data(), cent); | |
141 | } | |
142 | } // cent | |
143 | } // pid | |
144 | } // triggers | |
145 | } | |
146 | ||
147 | ||
148 | void DrawRangeVariation() | |
149 | { | |
150 | gROOT->LoadMacro("MakeRawProduction.C+g"); | |
151 | ||
152 | DrawRangeVar(); | |
153 | } |