]>
Commit | Line | Data |
---|---|---|
6551594b | 1 | /************************************************************************* |
2 | * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /////////////////////////////////////////////////////////////////////////// | |
17 | // Dielectron Correction framework draw helper // | |
18 | // // | |
19 | /* | |
20 | ||
21 | ||
22 | ||
23 | ||
24 | ||
25 | ||
26 | ||
27 | ||
28 | ||
29 | */ | |
30 | // // | |
31 | /////////////////////////////////////////////////////////////////////////// | |
32 | ||
33 | #include <TSeqCollection.h> | |
34 | #include <TObjArray.h> | |
35 | #include <TKey.h> | |
36 | #include <TList.h> | |
a655b716 | 37 | #include <TClass.h> |
6551594b | 38 | #include <TObject.h> |
39 | #include <TFile.h> | |
40 | #include <TString.h> | |
41 | #include <TObjString.h> | |
42 | #include <TMath.h> | |
43 | #include <TH1.h> | |
44 | #include <TH2.h> | |
45 | #include <TH3.h> | |
46 | #include <TPad.h> | |
47 | #include <TCanvas.h> | |
a655b716 | 48 | #include <TLegend.h> |
49 | #include <AliCFEffGrid.h> | |
6551594b | 50 | |
51 | #include <AliLog.h> | |
52 | ||
53 | #include "AliDielectronCFdraw.h" | |
54 | ||
55 | ClassImp(AliDielectronCFdraw) | |
56 | ||
57 | AliDielectronCFdraw::AliDielectronCFdraw() : | |
58 | TNamed(), | |
a655b716 | 59 | fCfContainer(0x0), |
60 | fEffGrid(0x0) | |
6551594b | 61 | { |
62 | // | |
63 | // Ctor | |
64 | // | |
65 | } | |
66 | ||
67 | //________________________________________________________________ | |
68 | AliDielectronCFdraw::AliDielectronCFdraw(const char*name, const char* title) : | |
69 | TNamed(name,title), | |
a655b716 | 70 | fCfContainer(0x0), |
71 | fEffGrid(0x0) | |
6551594b | 72 | { |
73 | // | |
74 | // Named Ctor | |
75 | // | |
76 | ||
77 | } | |
78 | ||
a655b716 | 79 | //________________________________________________________________ |
80 | AliDielectronCFdraw::AliDielectronCFdraw(AliCFContainer *cont) : | |
81 | TNamed(cont->GetName(), cont->GetTitle()), | |
82 | fCfContainer(cont), | |
83 | fEffGrid(new AliCFEffGrid("eff","eff",*cont)) | |
84 | { | |
85 | // | |
86 | // directly set the CF container | |
87 | // | |
88 | ||
89 | } | |
90 | ||
91 | //________________________________________________________________ | |
92 | AliDielectronCFdraw::AliDielectronCFdraw(const char* filename) : | |
93 | TNamed(), | |
94 | fCfContainer(0x0), | |
95 | fEffGrid(0x0) | |
96 | { | |
97 | // | |
98 | // get CF container(s) from file 'filename' | |
99 | // | |
100 | SetCFContainers(filename); | |
101 | } | |
102 | ||
6551594b | 103 | //________________________________________________________________ |
104 | void AliDielectronCFdraw::SetCFContainers(const TSeqCollection *arr) | |
105 | { | |
106 | // | |
107 | // Merge CF Container out of several containers | |
108 | // | |
109 | ||
110 | TIter next(arr); | |
111 | TObject *o=0x0; | |
112 | ||
113 | Int_t nstep=0; | |
114 | while ( (o=next()) ){ | |
115 | AliCFContainer *cf=dynamic_cast<AliCFContainer*>(o); | |
116 | if (!o) continue; | |
117 | nstep+=cf->GetNStep(); | |
118 | } | |
119 | Int_t nbins[1]={1}; | |
120 | fCfContainer=new AliCFContainer(GetName(), GetTitle(), nstep, 1, nbins); | |
121 | ||
122 | //delete unneeded steps | |
123 | for (Int_t istep=0; istep<nstep; ++istep) delete fCfContainer->GetGrid(istep); | |
124 | ||
125 | //add step to the new container | |
126 | Int_t istep=0; | |
127 | for (Int_t icf=0; icf<arr->GetEntries(); ++icf){ | |
128 | AliCFContainer *cf=dynamic_cast<AliCFContainer*>(arr->At(icf)); | |
129 | if (!cf) continue; | |
130 | for (Int_t istepCurr=0; istepCurr<cf->GetNStep(); ++istepCurr){ | |
131 | fCfContainer->SetGrid(istep, cf->GetGrid(istepCurr)); | |
66b2c564 | 132 | fCfContainer->SetStepTitle(istep,Form("%s, Pair: %s",cf->GetTitle(),cf->GetStepTitle(istepCurr))); |
6551594b | 133 | ++istep; |
134 | } | |
135 | } | |
a655b716 | 136 | if (fEffGrid) delete fEffGrid; |
137 | fEffGrid=new AliCFEffGrid("eff","eff",*fCfContainer); | |
6551594b | 138 | } |
139 | ||
140 | //________________________________________________________________ | |
141 | void AliDielectronCFdraw::SetCFContainers(const char* filename) | |
142 | { | |
143 | // | |
144 | // get CF containers from file | |
145 | // | |
146 | ||
147 | TFile f(filename); | |
148 | TList *l=f.GetListOfKeys(); | |
149 | Int_t entries=l->GetEntries(); | |
150 | if (entries==0) return; | |
151 | ||
152 | TKey *k=(TKey*)l->At(0); | |
a655b716 | 153 | if (!k) return; |
154 | TObject *o=k->ReadObj(); | |
155 | if (o->IsA()->InheritsFrom(TSeqCollection::Class())){ | |
156 | TSeqCollection *arr=static_cast<TSeqCollection*>(o); | |
157 | SetCFContainers(arr); | |
158 | } else if (o->IsA()==AliCFContainer::Class()){ | |
159 | fCfContainer=static_cast<AliCFContainer*>(o); | |
160 | if (fEffGrid) delete fEffGrid; | |
161 | fEffGrid=new AliCFEffGrid("eff","eff",*fCfContainer); | |
162 | } | |
6551594b | 163 | } |
164 | ||
165 | //________________________________________________________________ | |
166 | void AliDielectronCFdraw::SetRangeUser(Int_t ivar, Double_t min, Double_t max, const char* slices) | |
167 | { | |
168 | // | |
169 | // Set range of cut steps defined in slices | |
170 | // Steps may be separated by one the the characteres ,;: | |
171 | // | |
172 | TObjArray *arr=TString(slices).Tokenize(",:;"); | |
173 | ||
174 | if (arr->GetEntriesFast()==0){ | |
175 | // all slices in case of 0 entries | |
176 | for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){ | |
177 | fCfContainer->SetRangeUser(ivar,min,max,istep); | |
178 | } | |
179 | } else { | |
180 | TIter next(arr); | |
181 | TObjString *ostr=0x0; | |
182 | while ( (ostr=static_cast<TObjString*>(next())) ) { | |
183 | Int_t istep=ostr->GetString().Atoi(); | |
184 | fCfContainer->SetRangeUser(ivar,min,max,istep); | |
185 | } | |
186 | } | |
187 | delete arr; | |
188 | } | |
189 | ||
190 | //________________________________________________________________ | |
191 | void AliDielectronCFdraw::UnsetRangeUser(Int_t ivar, const char* slices) | |
192 | { | |
193 | // | |
194 | // Unset range of cut steps defined in slices | |
195 | // Steps may be separated by one the the characteres ,;: | |
196 | // | |
197 | TObjArray *arr=TString(slices).Tokenize(",:;"); | |
198 | ||
199 | if (arr->GetEntriesFast()==0){ | |
200 | // all slices in case of 0 entries | |
201 | for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){ | |
202 | fCfContainer->SetRangeUser(ivar,fCfContainer->GetAxis(ivar,istep)->GetXmin(), | |
203 | fCfContainer->GetAxis(ivar,istep)->GetXmax(),istep); | |
204 | } | |
205 | } else { | |
206 | TIter next(arr); | |
207 | TObjString *ostr=0x0; | |
208 | while ( (ostr=static_cast<TObjString*>(next())) ) { | |
209 | Int_t istep=ostr->GetString().Atoi(); | |
210 | fCfContainer->SetRangeUser(ivar,fCfContainer->GetAxis(ivar,istep)->GetXmin(), | |
211 | fCfContainer->GetAxis(ivar,istep)->GetXmax(),istep); | |
212 | } | |
213 | } | |
214 | delete arr; | |
215 | } | |
216 | ||
217 | //________________________________________________________________ | |
218 | void AliDielectronCFdraw::Draw(const Option_t* varnames, const char* slices, const char* opt) | |
219 | { | |
220 | // | |
221 | // Draw 'variables' of 'slices' | |
222 | // for multidimensional draw variables may be separated by a ':' | |
223 | // slice numbers may be separated by any of ,:; | |
224 | // | |
225 | // variables may be called by either their name or number | |
226 | // | |
227 | ||
228 | TObjArray *arrVars=TString(varnames).Tokenize(":"); | |
229 | Int_t entries=arrVars->GetEntriesFast(); | |
230 | if (entries<1||entries>3){ | |
231 | AliError("Wrong number of variables, supported are 1 - 3 dimensions"); | |
232 | delete arrVars; | |
233 | return; | |
234 | } | |
235 | ||
236 | TIter next(arrVars); | |
237 | TObjString *ostr=0x0; | |
238 | Int_t ivar[3]={-1,-1,-1}; | |
239 | for (Int_t i=0; i<entries; ++i){ | |
240 | ostr=static_cast<TObjString*>(next()); | |
241 | if (ostr->GetString().IsDigit()){ | |
242 | ivar[i]=ostr->GetString().Atoi(); | |
243 | } else { | |
244 | ivar[i]=fCfContainer->GetVar(ostr->GetName()); | |
245 | } | |
246 | } | |
247 | ||
248 | switch (entries){ | |
249 | case 1: | |
250 | Draw(ivar[0],slices,opt); | |
251 | break; | |
252 | case 2: | |
a655b716 | 253 | Draw(ivar[1],ivar[0],slices,opt); |
6551594b | 254 | break; |
255 | case 3: | |
a655b716 | 256 | Draw(ivar[2],ivar[1],ivar[0],slices,opt); |
6551594b | 257 | break; |
258 | } | |
259 | delete arrVars; | |
260 | } | |
261 | ||
262 | //________________________________________________________________ | |
263 | void AliDielectronCFdraw::Draw(Int_t var, const char* opt, const char* slices) | |
264 | { | |
265 | // | |
266 | // Draw variable var for all slices | |
267 | // slices may be divided by and of ,;: | |
268 | // | |
269 | // if opt contains 'same' all histograms are drawn in the same pad | |
270 | // otherwise the pad will be divided in sub pads and the histograms | |
271 | // are drawn in each sub pad | |
272 | // | |
273 | ||
274 | const Int_t ndim=1; | |
275 | Int_t vars[ndim]={var}; | |
a655b716 | 276 | TObjArray *arr=CollectHistosProj(ndim,vars,slices); |
6551594b | 277 | Draw(arr,opt); |
278 | delete arr; | |
279 | } | |
280 | ||
281 | //________________________________________________________________ | |
282 | void AliDielectronCFdraw::Draw(Int_t var0, Int_t var1, const char* opt, const char* slices) | |
283 | { | |
284 | // | |
285 | // Draw 2D case | |
286 | // | |
287 | const Int_t ndim=2; | |
288 | Int_t vars[ndim]={var0,var1}; | |
a655b716 | 289 | TObjArray *arr=CollectHistosProj(ndim,vars,slices); |
6551594b | 290 | Draw(arr,opt); |
291 | delete arr; | |
292 | } | |
293 | ||
294 | //________________________________________________________________ | |
295 | void AliDielectronCFdraw::Draw(Int_t var0, Int_t var1, Int_t var2, const char* opt, const char* slices) | |
296 | { | |
297 | // | |
298 | // Draw 3D case | |
299 | // | |
300 | const Int_t ndim=3; | |
301 | Int_t vars[ndim]={var0,var1,var2}; | |
a655b716 | 302 | TObjArray *arr=CollectHistosProj(ndim,vars,slices); |
6551594b | 303 | Draw(arr,opt); |
304 | delete arr; | |
305 | } | |
306 | ||
307 | //________________________________________________________________ | |
a655b716 | 308 | TObjArray* AliDielectronCFdraw::CollectHistosProj(Int_t dim, Int_t *vars, const char* slices) |
6551594b | 309 | { |
310 | // | |
a655b716 | 311 | // Collect histos with 'dim'ension of the 'slices' separated by one of "':;'" |
312 | // in a TObjArray and return it | |
6551594b | 313 | // |
a655b716 | 314 | TObjArray *arr=TString(slices).Tokenize(",:;"); |
315 | TObjArray *arrHists=0x0; | |
316 | if (arr->GetEntriesFast()==0){ | |
317 | // all slices in case of 0 entries | |
318 | arrHists=new TObjArray(fCfContainer->GetNStep()); | |
319 | for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){ | |
320 | TH1 *hproj=Project(dim,vars,istep); | |
66b2c564 | 321 | hproj->SetName(Form("proj_%02d",istep)); |
322 | hproj->SetTitle(fCfContainer->GetStepTitle(istep)); | |
a655b716 | 323 | arrHists->Add(hproj); |
324 | } | |
325 | } else { | |
326 | arrHists=new TObjArray(arr->GetEntriesFast()); | |
327 | TIter next(arr); | |
328 | TObjString *ostr=0x0; | |
329 | while ( (ostr=static_cast<TObjString*>(next())) ) { | |
330 | Int_t istep=ostr->GetString().Atoi(); | |
331 | TH1 *hproj=Project(dim,vars,istep); | |
66b2c564 | 332 | hproj->SetName(Form("proj_%02d",istep)); |
333 | hproj->SetTitle(fCfContainer->GetStepTitle(istep)); | |
a655b716 | 334 | arrHists->Add(hproj); |
335 | } | |
336 | } | |
337 | delete arr; | |
338 | ||
339 | return arrHists; | |
340 | } | |
341 | ||
342 | //________________________________________________________________ | |
343 | TH1* AliDielectronCFdraw::Project(Int_t ndim, Int_t *vars, Int_t slice) | |
344 | { | |
345 | // | |
346 | // Do an nim projection | |
347 | // | |
348 | switch (ndim){ | |
349 | case 1: | |
350 | return fCfContainer->Project(vars[0],slice); | |
351 | break; | |
352 | case 2: | |
353 | return fCfContainer->Project(vars[0],vars[1],slice); | |
354 | break; | |
355 | case 3: | |
356 | return fCfContainer->Project(vars[0],vars[1],vars[2],slice); | |
357 | break; | |
358 | } | |
359 | return 0x0; | |
360 | } | |
361 | ||
362 | //________________________________________________________________ | |
363 | void AliDielectronCFdraw::DrawEfficiency(const char* varnames, const char* nominators, Int_t denominator, const char* opt) | |
364 | { | |
365 | // | |
366 | // plot efficiencies for variables. Variable may be up to 3 dim, separated by a ':' | |
367 | // you may have several nominators, sparated by one of ',:;' | |
368 | // | |
369 | ||
370 | TObjArray *arrVars=TString(varnames).Tokenize(":"); | |
371 | Int_t entries=arrVars->GetEntriesFast(); | |
372 | if (entries<1||entries>3){ | |
373 | AliError("Wrong number of variables, supported are 1 - 3 dimensions"); | |
374 | delete arrVars; | |
375 | return; | |
376 | } | |
377 | ||
378 | TIter next(arrVars); | |
379 | TObjString *ostr=0x0; | |
380 | Int_t ivar[3]={-1,-1,-1}; | |
381 | for (Int_t i=0; i<entries; ++i){ | |
382 | ostr=static_cast<TObjString*>(next()); | |
383 | if (ostr->GetString().IsDigit()){ | |
384 | ivar[i]=ostr->GetString().Atoi(); | |
385 | } else { | |
386 | ivar[i]=fCfContainer->GetVar(ostr->GetName()); | |
6551594b | 387 | } |
388 | } | |
66b2c564 | 389 | |
390 | Int_t type=0; | |
391 | TString optStr(opt); | |
392 | if (optStr.Contains("2")) type=1; | |
a655b716 | 393 | |
394 | switch (entries){ | |
395 | case 1: | |
66b2c564 | 396 | DrawEfficiency(ivar[0],nominators, denominator,opt,type); |
a655b716 | 397 | break; |
398 | case 2: | |
66b2c564 | 399 | DrawEfficiency(ivar[1],ivar[0], nominators, denominator,opt,type); |
a655b716 | 400 | break; |
401 | case 3: | |
66b2c564 | 402 | DrawEfficiency(ivar[2],ivar[1],ivar[0],nominators, denominator,opt,type); |
a655b716 | 403 | break; |
404 | } | |
405 | delete arrVars; | |
406 | } | |
407 | ||
408 | //________________________________________________________________ | |
66b2c564 | 409 | void AliDielectronCFdraw::DrawEfficiency(Int_t var, const char* nominators, Int_t denominator, const char* opt, Int_t type) |
a655b716 | 410 | { |
411 | // | |
412 | // Draw Efficiencies for all nominators | |
413 | // nominators may be divided by and of ,;: | |
414 | // | |
415 | // if opt contains 'same' all histograms are drawn in the same pad | |
416 | // otherwise the pad will be divided in sub pads and the histograms | |
417 | // are drawn in each sub pad | |
418 | // | |
419 | ||
420 | const Int_t ndim=1; | |
421 | Int_t vars[ndim]={var}; | |
66b2c564 | 422 | TObjArray *arr=CollectHistosEff(ndim,vars,nominators,denominator,type); |
a655b716 | 423 | Draw(arr,opt); |
424 | delete arr; | |
425 | } | |
426 | ||
427 | //________________________________________________________________ | |
66b2c564 | 428 | void AliDielectronCFdraw::DrawEfficiency(Int_t var0, Int_t var1, const char* nominators, Int_t denominator, const char* opt, Int_t type) |
a655b716 | 429 | { |
430 | // | |
431 | // Draw 2D case | |
432 | // | |
433 | const Int_t ndim=2; | |
434 | Int_t vars[ndim]={var0,var1}; | |
66b2c564 | 435 | TObjArray *arr=CollectHistosEff(ndim,vars,nominators,denominator,type); |
a655b716 | 436 | Draw(arr,opt); |
437 | delete arr; | |
438 | } | |
439 | ||
440 | //________________________________________________________________ | |
66b2c564 | 441 | void AliDielectronCFdraw::DrawEfficiency(Int_t var0, Int_t var1, Int_t var2, const char* nominators, Int_t denominator, const char* opt, Int_t type) |
a655b716 | 442 | { |
443 | // | |
444 | // Draw 3D case | |
445 | // | |
446 | const Int_t ndim=3; | |
447 | Int_t vars[ndim]={var0,var1,var2}; | |
66b2c564 | 448 | TObjArray *arr=CollectHistosEff(ndim,vars,nominators,denominator,type); |
a655b716 | 449 | Draw(arr,opt); |
450 | delete arr; | |
6551594b | 451 | } |
452 | ||
453 | //________________________________________________________________ | |
66b2c564 | 454 | TObjArray* AliDielectronCFdraw::CollectHistosEff(Int_t dim, Int_t *vars, const char* nominators, Int_t denominator, Int_t type) |
6551594b | 455 | { |
456 | // | |
457 | // Collect histos with 'dim'ension of the 'slices' separated by one of "':;'" | |
458 | // in a TObjArray and return it | |
459 | // | |
a655b716 | 460 | TObjArray *arr=TString(nominators).Tokenize(",:;"); |
6551594b | 461 | TObjArray *arrHists=0x0; |
66b2c564 | 462 | |
463 | if (type==0){ | |
464 | if (arr->GetEntriesFast()==0){ | |
6551594b | 465 | // all slices in case of 0 entries |
66b2c564 | 466 | arrHists=new TObjArray(fCfContainer->GetNStep()); |
467 | for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){ | |
468 | fEffGrid->CalculateEfficiency(istep,denominator); | |
469 | TH1 *hproj=ProjectEff(dim,vars); | |
470 | Float_t eff=fEffGrid->GetAverage(); | |
471 | hproj->SetName(Form("eff_%02d/%02d",istep,denominator)); | |
472 | hproj->SetTitle(Form("%s (%f)",fCfContainer->GetStepTitle(istep),eff)); | |
473 | arrHists->Add(hproj); | |
474 | } | |
475 | } else { | |
476 | arrHists=new TObjArray(arr->GetEntriesFast()); | |
477 | TIter next(arr); | |
478 | TObjString *ostr=0x0; | |
479 | while ( (ostr=static_cast<TObjString*>(next())) ) { | |
480 | Int_t istep=ostr->GetString().Atoi(); | |
481 | fEffGrid->CalculateEfficiency(istep,denominator); | |
482 | TH1 *hproj=ProjectEff(dim,vars); | |
483 | Float_t eff=fEffGrid->GetAverage(); | |
484 | hproj->SetName(Form("eff_%02d/%02d",istep,denominator)); | |
485 | hproj->SetTitle(Form("%s (%f)",fCfContainer->GetStepTitle(istep),eff)); | |
486 | arrHists->Add(hproj); | |
487 | } | |
6551594b | 488 | } |
66b2c564 | 489 | } |
490 | ||
491 | //second approach | |
492 | if (type==1){ | |
493 | TH1 *hDen=Project(dim,vars,denominator); | |
494 | Double_t entriesDen=hDen->GetEffectiveEntries(); | |
495 | if (arr->GetEntriesFast()==0){ | |
496 | // all slices in case of 0 entries | |
497 | arrHists=new TObjArray(fCfContainer->GetNStep()); | |
498 | for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){ | |
499 | TH1 *hproj=Project(dim,vars,istep); | |
500 | Float_t eff=0; | |
501 | if (entriesDen>0) eff=hproj->GetEffectiveEntries()/entriesDen; | |
502 | hproj->Divide(hDen); | |
503 | hproj->SetName(Form("eff_%02d/%02d",istep,denominator)); | |
504 | hproj->SetTitle(Form("%s (%f)",fCfContainer->GetStepTitle(istep),eff)); | |
505 | arrHists->Add(hproj); | |
506 | } | |
507 | } else { | |
508 | arrHists=new TObjArray(arr->GetEntriesFast()); | |
509 | TIter next(arr); | |
510 | TObjString *ostr=0x0; | |
511 | while ( (ostr=static_cast<TObjString*>(next())) ) { | |
512 | Int_t istep=ostr->GetString().Atoi(); | |
513 | TH1 *hproj=Project(dim,vars,istep); | |
514 | Float_t eff=0; | |
515 | if (entriesDen>0) eff=hproj->GetEffectiveEntries()/entriesDen; | |
516 | hproj->Divide(hDen); | |
517 | hproj->SetName(Form("eff_%02d/%02d",istep,denominator)); | |
518 | hproj->SetTitle(Form("%s (%f)",fCfContainer->GetStepTitle(istep),eff)); | |
519 | arrHists->Add(hproj); | |
520 | } | |
6551594b | 521 | } |
66b2c564 | 522 | delete hDen; |
6551594b | 523 | } |
a655b716 | 524 | |
66b2c564 | 525 | |
526 | delete arr; | |
6551594b | 527 | return arrHists; |
528 | } | |
529 | ||
530 | //________________________________________________________________ | |
a655b716 | 531 | TH1* AliDielectronCFdraw::ProjectEff(Int_t ndim, Int_t *vars) |
6551594b | 532 | { |
533 | // | |
534 | // Do an nim projection | |
535 | // | |
536 | switch (ndim){ | |
537 | case 1: | |
a655b716 | 538 | return fEffGrid->Project(vars[0]); |
6551594b | 539 | break; |
540 | case 2: | |
a655b716 | 541 | return fEffGrid->Project(vars[0],vars[1]); |
6551594b | 542 | break; |
543 | case 3: | |
a655b716 | 544 | return fEffGrid->Project(vars[0],vars[1],vars[2]); |
6551594b | 545 | break; |
546 | } | |
547 | return 0x0; | |
548 | } | |
549 | ||
a655b716 | 550 | //________________________________________________________________ |
551 | void AliDielectronCFdraw::Draw(const TObjArray *arr, const char* opt) | |
552 | { | |
553 | // | |
554 | // draw all objects in arr | |
555 | // | |
556 | TString optStr(opt); | |
557 | optStr.ToLower(); | |
558 | Bool_t drawSame=optStr.Contains("same"); | |
559 | Bool_t optLeg=optStr.Contains("leg"); | |
560 | optStr.ReplaceAll("same",""); | |
561 | ||
562 | if (!gPad) new TCanvas; | |
563 | ||
564 | Int_t nPads = arr->GetEntriesFast(); | |
565 | if (nPads==0) return; | |
566 | ||
567 | if (nPads==1){ | |
568 | arr->UncheckedAt(0)->Draw(optStr.Data()); | |
569 | return; | |
570 | } | |
571 | ||
572 | TCanvas *c=gPad->GetCanvas(); | |
573 | c->Clear(); | |
574 | ||
575 | ||
576 | if (!drawSame){ | |
577 | //optimised division | |
578 | Int_t nCols = (Int_t)TMath::Ceil( TMath::Sqrt(nPads) ); | |
579 | Int_t nRows = (Int_t)TMath::Ceil( (Double_t)nPads/(Double_t)nCols ); | |
580 | c->Divide(nCols,nRows); | |
581 | for (Int_t i=0; i<nPads; ++i){ | |
582 | c->cd(i+1); | |
583 | arr->UncheckedAt(i)->Draw(optStr.Data()); | |
584 | } | |
585 | } else { | |
586 | TLegend *leg=0; | |
587 | if (optLeg) leg=new TLegend(.8,.3,.99,.9); | |
66b2c564 | 588 | Int_t offset=20; |
589 | if (nPads<7) offset=24; | |
a655b716 | 590 | for (Int_t i=0; i<nPads; ++i){ |
591 | if (i==1) optStr+="same"; | |
592 | TH1 *hist=static_cast<TH1*>(arr->UncheckedAt(i)); | |
593 | hist->SetLineColor(i+1); | |
66b2c564 | 594 | hist->SetLineWidth(2); |
a655b716 | 595 | hist->SetMarkerColor(i+1); |
66b2c564 | 596 | hist->SetMarkerStyle(offset+i); |
a655b716 | 597 | hist->Draw(optStr.Data()); |
66b2c564 | 598 | if (leg) leg->AddEntry(hist,hist->GetTitle(),"lp"); |
a655b716 | 599 | } |
600 | if (leg){ | |
601 | leg->SetFillColor(10); | |
602 | leg->SetY1(.9-nPads*.05); | |
66b2c564 | 603 | leg->SetMargin(.1); |
a655b716 | 604 | leg->Draw(); |
605 | } | |
606 | } | |
607 | ||
608 | } |