AliPhysics  b5b0183 (b5b0183)
CompareSecMaps.C
Go to the documentation of this file.
1 //____________________________________________________________________
13 void
14 CompareSecMaps(const char* fn1, const char* fn2,
15  const char* n1=0, const char* n2=0,
16  bool load=true)
17 {
18 
19  // --- Load Utilities ----------------------------------------------
20  if (load) {
21  gROOT->Macro("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
22  gROOT->LoadMacro("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/corrs/CompareCorrs.C");
23  }
24 
25  // --- Get Objects -------------------------------------------------
26  TObject* o1 = 0;
27  TObject* o2 = 0;
28  GetObjects("AliFMDCorrSecondaryMap", fn1, fn2, o1, o2);
29  if (!o1 || !o2) return;
30  AliFMDCorrSecondaryMap* obj1 = static_cast<AliFMDCorrSecondaryMap*>(o1);
31  AliFMDCorrSecondaryMap* obj2 = static_cast<AliFMDCorrSecondaryMap*>(o2);
32  UShort_t nVtx = obj1->GetVertexAxis().GetNbins();
33 
34  // --- Make canvas -------------------------------------------------
35  Canvas* c = new Canvas("secMapComparison", "Ratio of secondary maps", n1, n2);
36  c->Open();
37 
38  TObjArray* allVtx = new TObjArray(nVtx);
39  // --- Loop over the data ------------------------------------------
40  for (UShort_t d = 1; d <= 3; d++) {
41  UShort_t nR = (d == 1 ? 1 : 2);
42  for (UShort_t q = 0; q < nR; q++) {
43  Char_t r = (q == 0 ? 'I' : 'O');
44  UShort_t nS = (q == 0 ? 20 : 40);
45  Color_t col = ((d == 1 ? kRed : (d == 2 ? kGreen : kBlue))
46  + ((r == 'I' || r == 'i') ? -3 : -9));
47 
48  // --- Make 2D ratios ------------------------------------------
49  c->Clear(nVtx, d, r, true);
50  TList hists;
51  for (UShort_t v=1; v <= nVtx; v++) {
52  TVirtualPad* p = c->cd(v);
53  p->SetGridx();
54  p->SetGridy();
55  // p->SetRightMargin(0.01);
56  // p->SetTopMargin(0.01);
57 
58  TH2* h1 = obj1->GetCorrection(d, r, v);
59  TH2* h2 = obj2->GetCorrection(d, r, v);
60 
61  if (!h1) {
62  Error("CompareSecMaps",
63  "Map for FMD%d%c, vtxbin %3d not found in first",
64  d, r, v);
65  continue;
66  }
67  if (!h2) {
68  Error("CompareSecMaps",
69  "Map for FMD%d%c, vtxbin %3d not found in second",
70  d, r, v);
71  continue;
72  }
73 
74  Double_t vl = obj1->GetVertexAxis().GetBinLowEdge(v);
75  Double_t vh = obj1->GetVertexAxis().GetBinUpEdge(v);
76  TH2* ratio =
77  static_cast<TH2*>(h1->Clone(Form("tmpFMD%d%c_%3d",d,r,v)));
78  ratio->SetName(Form("FMD%d%c_vtx%03d_ratio", d, r, v));
79  ratio->SetTitle(Form("%+5.1f<v_{z}<%-+5.1f", vl, vh));
80  ratio->Divide(h2);
81  ratio->SetStats(0);
82  ratio->SetDirectory(0);
83  ratio->SetZTitle("ratio");
84  ratio->GetXaxis()->SetTitleSize(0.01/p->GetHNDC());
85  ratio->GetXaxis()->SetLabelSize(0.01/p->GetHNDC());
86  ratio->GetYaxis()->SetTitleSize(0.01/p->GetHNDC());
87  ratio->GetYaxis()->SetLabelSize(0.01/p->GetHNDC());
88 
89  if (ratio->GetMaximum()-ratio->GetMinimum() > 10)
90  p->SetLogz();
91 
92  ratio->Draw("colz");
93  hists.AddAt(ratio, v-1);
94  }
95  c->Print(d, r);
96 
97  // --- Make 1D profiles ----------------------------------------
98  c->Clear(nVtx, d, r, true);
99  for (UShort_t v=1; v <= nVtx; v++) {
100  TVirtualPad* p = c->cd(v);
101  p->SetGridx();
102  p->SetGridy();
103 
104 
105  TH2* hist = static_cast<TH2*>(hists.At(v-1));
106  TH1* prof = hist->ProjectionX();
107  prof->SetDirectory(0);
108  prof->Scale(1. / nS);
109  // TProfile* prof = hist->ProfileX();
110  prof->SetStats(0);
111  prof->SetMinimum(0.8);
112  prof->SetMaximum(1.2);
113  prof->SetLineColor(col);
114  prof->SetMarkerColor(col);
115  prof->SetMarkerStyle(20);
116  prof->GetXaxis()->SetTitleSize(0.01/p->GetHNDC());
117  prof->GetXaxis()->SetLabelSize(0.01/p->GetHNDC());
118  prof->GetYaxis()->SetTitleSize(0.01/p->GetHNDC());
119  prof->GetYaxis()->SetLabelSize(0.01/p->GetHNDC());
120 
121  THStack* stack = static_cast<THStack*>(allVtx->At(v-1));
122  if (!stack) {
123  stack = new THStack(prof->GetName(), prof->GetTitle());
124  stack->SetMinimum(prof->GetMinimum());
125  stack->SetMaximum(prof->GetMaximum());
126  allVtx->AddAt(stack, v-1);
127  }
128  stack->Add(static_cast<TH1*>(prof->Clone()));
129 
130  prof->Draw();
131  prof->Fit("pol0","Q");
132 
133  TF1* f = prof->GetFunction("pol0");
134  if (!f) continue;
135 
136  f->SetLineColor(kBlack);
137  Double_t chi2nu = (f->GetNDF() != 0 ?
138  f->GetChisquare() / f->GetNDF() : 0);
139  Double_t dist = TMath::Abs(1 - f->GetParameter(0));
140 
141  Double_t ly = .8;
142  TLatex* l = new TLatex(0.5, ly,
143  Form("A = %f #pm %f",
144  f->GetParameter(0), f->GetParError(0)));
145  l->SetTextAlign(22);
146  l->SetNDC();
147  l->Draw();
148  ly -= 1.1*l->GetTextSize();
149  l->DrawLatex(0.5, ly, Form("|1 - A| = %f %s #deltaA",
150  dist, dist <= f->GetParError(0) ?
151  "#leq" : ">"));
152  ly -= 1.1*l->GetTextSize();
153  l->DrawLatex(0.5, ly, Form("#chi^2/NDF = %f / %d = %f",
154  f->GetChisquare(), f->GetNDF(), chi2nu));
155 
156  TLine* l1 = new TLine(prof->GetXaxis()->GetXmin(), 1,
157  prof->GetXaxis()->GetXmax(), 1);
158  l1->SetLineColor(kGray+2);
159  l1->SetLineStyle(2);
160  l1->Draw();
161 
162  }
163 
164  c->Print(d, r, "profiles");
165  }
166  }
167  c->Clear(nVtx, 0, '*', true);
168  for (UShort_t v=1; v <= nVtx; v++) {
169  TVirtualPad* p = c->cd(v);
170  p->SetGridx();
171  p->SetGridy();
172  THStack* stack = static_cast<THStack*>(allVtx->At(v-1));
173  if (!stack) continue;
174  stack->Draw("nostack");
175  TH1* h = stack->GetHistogram();
176  if (!h) continue;
177  TLine* l1 = new TLine(h->GetXaxis()->GetXmin(), 1,
178  h->GetXaxis()->GetXmax(), 1);
179  l1->SetLineColor(kGray+2);
180  l1->SetLineStyle(2);
181  l1->Draw();
182  }
183  c->Print(0,'*',"summary");
184 
185 
186  // --- Close stuff -------------------------------------------------
187  c->Close();
188  // file1->Close();
189  // file2->Close();
190 }
191 
192 
193 //____________________________________________________________________
194 //
195 // EOF
196 //
double Double_t
Definition: External.C:58
TH2D * GetCorrection(UShort_t d, Char_t r, Double_t v) const
char Char_t
Definition: External.C:18
TCanvas * c
Definition: TestFitELoss.C:172
const TAxis & GetVertexAxis() const
void Print(UShort_t d, Char_t r, const char *extra="")
Definition: CompareCorrs.C:131
AliStack * stack
void Close()
Definition: CompareCorrs.C:141
TPad * Clear(UShort_t nPad, UShort_t d, Char_t r, Bool_t flush=false)
Definition: CompareCorrs.C:84
TVirtualPad * cd(Int_t i)
Definition: CompareCorrs.C:117
void CompareSecMaps(const char *fn1, const char *fn2, const char *n1=0, const char *n2=0, bool load=true)
void Open()
Definition: CompareCorrs.C:63
Definition: External.C:220
unsigned short UShort_t
Definition: External.C:28
void GetObjects(const char *what, const char *fn1, const char *fn2, TObject *&o1, TObject *&o2)
Definition: CompareCorrs.C:174
Definition: External.C:196