]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/corrs/CompareCentralSecMaps.C
Fixed references from PWG2 -> PWGLF - very efficiently done using ETags.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / corrs / CompareCentralSecMaps.C
CommitLineData
970b1a8a 1/**
bd6f5206 2 * @defgroup pwglf_forward_scripts_corr Correction scripts
b7b0f0f8 3 *
bd6f5206 4 * @ingroup pwglf_forward_scripts
b7b0f0f8 5 */
6
7//____________________________________________________________________
970b1a8a 8/**
9 * Compare secondary maps
10 *
11 * @param fn1 File 1
12 * @param fn2 File 2
13 * @param n1 Name 1
14 * @param n2 Name 2
15 * @param load
16 *
bd6f5206 17 * @ingroup pwglf_forward_scripts_corr
970b1a8a 18 */
b7b0f0f8 19void
20CompareCentralSecMaps(const char* fn1, const char* fn2,
21 const char* n1=0, const char* n2=0,
22 bool load=true)
23{
24
25 // --- Load Utilities ----------------------------------------------
26 if (load) {
bd6f5206 27 gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
28 // gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/CompareCorrs.C");
b7b0f0f8 29 }
30
31 // --- Get Objects -------------------------------------------------
32 TObject* o1 = 0;
33 TObject* o2 = 0;
34 TFile file1(fn1);
35 TFile file2(fn2);
36
37 AliCentralMultiplicityTask task("tmp");
38
39 o1 = file1.Get(task.GetManager().GetSecMapName());
40 o2 = file2.Get(task.GetManager().GetSecMapName());
41 if (!o1 || !o2) return;
42 AliCentralCorrSecondaryMap* obj1 = static_cast<AliCentralCorrSecondaryMap*>(o1);
43 AliCentralCorrSecondaryMap* obj2 = static_cast<AliCentralCorrSecondaryMap*>(o2);
44 UShort_t nVtx = obj1->GetVertexAxis().GetNbins();
45
46 // --- Make canvas -------------------------------------------------
47 // Canvas* c = new Canvas("CentralSecMapComparison", "Ratio of central secondary maps", n1, n2);
48 // c->Open();
49
50 // --- Loop over the data ------------------------------------------
51 //for (UShort_t d = 1; d <= 3; d++) {
52 // UShort_t nR = (d == 1 ? 1 : 2);
53 // for (UShort_t q = 0; q < nR; q++) {
54 // Char_t r = (q == 0 ? 'I' : 'O');
55 // UShort_t nS = (q == 0 ? 20 : 40);
56
57 // --- Make 2D ratios ------------------------------------------
58 //c->Clear(nVtx, d, r);
59 TCanvas* c2D = new TCanvas("2Dcomparison","2Dcomparison",800,1000);
60 TCanvas* c1D = new TCanvas("1Dcomparison","1Dcomparison",800,1000);
61 c2D->Divide(2,5);
62 c1D->Divide(2,5);
63 c2D->cd();
64
65 TList hists;
66 for (UShort_t v=1; v <= nVtx; v++) {
67 // TVirtualPad* p = c->cd(v);
68 c2D->cd(v);
69 TH2* h1 = obj1->GetCorrection( v);
70 TH2* h2 = obj2->GetCorrection( v);
71 //std::cout<<h1<<" "<<h2<<std::endl;
72 /* if (!h1) {
73 Error("CompareSecMaps",
74 "Map for SPD, vtxbin %3d not found in first",
75 v);
76 continue;
77 }
78 if (!h2) {
79 Error("CompareSecMaps",
80 "Map for SPD, vtxbin %3d not found in second",
81 v);
82 continue;
83 }
84 */
85 Double_t vl = obj1->GetVertexAxis().GetBinLowEdge(v);
86 Double_t vh = obj1->GetVertexAxis().GetBinUpEdge(v);
87 TH2* ratio =
88 static_cast<TH2*>(h1->Clone(Form("tmpSPD_%3d",v)));
89 ratio->SetName(Form("SPD_vtx%03d_ratio", v));
90 ratio->SetTitle(Form("%+5.1f<v_{z}<%-+5.1f", vl, vh));
91 ratio->Divide(h2);
92 ratio->SetStats(0);
93 ratio->SetDirectory(0);
94 ratio->SetZTitle("ratio");
95
96 //if (ratio->GetMaximum()-ratio->GetMinimum() > 10)
97 // p->SetLogz();
98
99 ratio->DrawCopy("colz");
100 hists.AddAt(ratio, v-1);
101
102 }
103 // c->Print(d, r);
104
105 // --- Make 1D profiles ----------------------------------------
106 //c->Clear(nVtx, d, r);
107
108 c1D->cd();
109 for (UShort_t v=1; v <= nVtx; v++) {
110 //c->cd(v);
111 c1D->cd(v);
112 TH2* hist = static_cast<TH2*>(hists.At(v-1));
113 TH1D* prof = hist->ProjectionX();
114 prof->Clear();
115 for(Int_t i=1; i<=hist->GetNbinsX();i++) {
116
117 Float_t sum = 0;
118 Float_t error = 0;
119 Int_t n = 0;
120 for(Int_t j=1; j<=hist->GetNbinsY();j++) {
121 if(hist->GetBinContent(i,j) > 0) {
122 sum = sum+hist->GetBinContent(i,j);
123 error = error + TMath::Power(hist->GetBinError(i,j),2);
124 n++;
125 }
126
127 }
128 if(n>0) {
129 sum = sum/(Float_t)n;
130 error = TMath::Sqrt(error) / (Float_t)n;
131 prof->SetBinContent(i,sum);
132 prof->SetBinError(i,error);
133 }
134 }
135
136 // prof->Scale(0.05);
137 prof->SetStats(0);
138 prof->SetMinimum(0.8);
139 prof->SetMaximum(1.2);
140
141
142 prof->Fit("pol0","Q");
143 prof->DrawCopy();
144
145 TF1* f = prof->GetFunction("pol0");
146
147 TLatex* l = new TLatex(0.5, 0.4, Form("A = %f #pm %f",
148 f->GetParameter(0),
149 f->GetParError(0)));
150 l->SetTextAlign(22);
151 l->SetNDC();
152 l->Draw();
153 l->DrawLatex(0.5, 0.3, Form("#chi^2/NDF = %f / %d = %f",
154 f->GetChisquare(),
155 f->GetNDF(),
156 f->GetChisquare() / f->GetNDF()));
157 Double_t dist = TMath::Abs(1 - f->GetParameter(0));
158 l->DrawLatex(0.5, 0.35, Form("|1 - A| = %f %s #deltaA",
159 dist, dist <= f->GetParError(0) ?
160 "#leq" : ">"));
161
162 TLine* l1 = new TLine(-4, 1, 6, 1);
163 l1->SetLineColor(kRed);
164 l1->SetLineStyle(2);
165 l1->Draw();
166
167 }
168
169 //c->Print(d, r, "profiles");
170 c2D->Print("comparisonSPD.pdf(");
171 c1D->Print("comparisonSPD.pdf)");
172
173
174 // --- Close stuff -------------------------------------------------
175 //c->Close();
176 // file1->Close();
177 // file2->Close();
178}
179
180
181//____________________________________________________________________
182//
183// EOF
184//