]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/dielectron/AliDielectronCFdraw.cxx
Add AliEMCALRecoUtils pointer to remove bad or exotic clusters for cluster histograms...
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronCFdraw.cxx
CommitLineData
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>
572b0139 39#include <TVirtualPS.h>
6551594b 40#include <TFile.h>
41#include <TString.h>
42#include <TObjString.h>
572b0139 43#include <TVectorD.h>
6551594b 44#include <TMath.h>
45#include <TH1.h>
46#include <TH2.h>
47#include <TH3.h>
48#include <TPad.h>
49#include <TCanvas.h>
a655b716 50#include <TLegend.h>
51#include <AliCFEffGrid.h>
6551594b 52
53#include <AliLog.h>
54
55#include "AliDielectronCFdraw.h"
56
57ClassImp(AliDielectronCFdraw)
58
59AliDielectronCFdraw::AliDielectronCFdraw() :
60 TNamed(),
a655b716 61 fCfContainer(0x0),
572b0139 62 fEffGrid(0x0),
63 fVdata(0)
6551594b 64{
65 //
66 // Ctor
67 //
68}
69
70//________________________________________________________________
71AliDielectronCFdraw::AliDielectronCFdraw(const char*name, const char* title) :
72 TNamed(name,title),
a655b716 73 fCfContainer(0x0),
572b0139 74 fEffGrid(0x0),
75 fVdata(0)
6551594b 76{
77 //
78 // Named Ctor
79 //
80
81}
82
a655b716 83//________________________________________________________________
84AliDielectronCFdraw::AliDielectronCFdraw(AliCFContainer *cont) :
85 TNamed(cont->GetName(), cont->GetTitle()),
86 fCfContainer(cont),
572b0139 87 fEffGrid(new AliCFEffGrid("eff","eff",*cont)),
88 fVdata(0)
a655b716 89{
90 //
91 // directly set the CF container
92 //
93
94}
95
96//________________________________________________________________
97AliDielectronCFdraw::AliDielectronCFdraw(const char* filename) :
98 TNamed(),
99 fCfContainer(0x0),
572b0139 100 fEffGrid(0x0),
101 fVdata(0)
a655b716 102{
103 //
104 // get CF container(s) from file 'filename'
105 //
106 SetCFContainers(filename);
107}
108
6551594b 109//________________________________________________________________
110void AliDielectronCFdraw::SetCFContainers(const TSeqCollection *arr)
111{
112 //
113 // Merge CF Container out of several containers
114 //
115
116 TIter next(arr);
117 TObject *o=0x0;
118
119 Int_t nstep=0;
120 while ( (o=next()) ){
121 AliCFContainer *cf=dynamic_cast<AliCFContainer*>(o);
61d106d3 122 if (!cf) continue;
6551594b 123 nstep+=cf->GetNStep();
124 }
61d106d3 125 if (nstep==0) return;
6551594b 126 Int_t nbins[1]={1};
127 fCfContainer=new AliCFContainer(GetName(), GetTitle(), nstep, 1, nbins);
128
129 //delete unneeded steps
572b0139 130// for (Int_t istep=0; istep<nstep; ++istep) delete fCfContainer->GetGrid(istep);
6551594b 131
132 //add step to the new container
133 Int_t istep=0;
134 for (Int_t icf=0; icf<arr->GetEntries(); ++icf){
135 AliCFContainer *cf=dynamic_cast<AliCFContainer*>(arr->At(icf));
136 if (!cf) continue;
137 for (Int_t istepCurr=0; istepCurr<cf->GetNStep(); ++istepCurr){
138 fCfContainer->SetGrid(istep, cf->GetGrid(istepCurr));
66b2c564 139 fCfContainer->SetStepTitle(istep,Form("%s, Pair: %s",cf->GetTitle(),cf->GetStepTitle(istepCurr)));
6551594b 140 ++istep;
141 }
142 }
a655b716 143 if (fEffGrid) delete fEffGrid;
144 fEffGrid=new AliCFEffGrid("eff","eff",*fCfContainer);
6551594b 145}
146
147//________________________________________________________________
148void AliDielectronCFdraw::SetCFContainers(const char* filename)
149{
150 //
151 // get CF containers from file
152 //
153
154 TFile f(filename);
155 TList *l=f.GetListOfKeys();
61d106d3 156 TIter nextKey(l);
157 TKey *k=0x0;
158 while ( (k=static_cast<TKey*>(nextKey())) ){
159 TObject *o=k->ReadObj();
160 if (o->IsA()->InheritsFrom(TSeqCollection::Class())){
161 TSeqCollection *arr=static_cast<TSeqCollection*>(o);
162 SetCFContainers(arr);
163 } else if (o->IsA()==AliCFContainer::Class()){
164 fCfContainer=static_cast<AliCFContainer*>(o);
165 if (fEffGrid) delete fEffGrid;
166 fEffGrid=new AliCFEffGrid("eff","eff",*fCfContainer);
167 }
a655b716 168 }
6551594b 169}
170
171//________________________________________________________________
172void AliDielectronCFdraw::SetRangeUser(Int_t ivar, Double_t min, Double_t max, const char* slices)
173{
174 //
175 // Set range of cut steps defined in slices
176 // Steps may be separated by one the the characteres ,;:
177 //
ba15fdfb 178 if (ivar==-1) return;
6551594b 179 TObjArray *arr=TString(slices).Tokenize(",:;");
180
181 if (arr->GetEntriesFast()==0){
182 // all slices in case of 0 entries
183 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
ffbede40 184 fCfContainer->GetGrid(istep)->SetRangeUser(ivar,min,max);
ba15fdfb 185 fCfContainer->GetAxis(ivar,istep)->SetBit(TAxis::kAxisRange,1);
6551594b 186 }
187 } else {
188 TIter next(arr);
189 TObjString *ostr=0x0;
190 while ( (ostr=static_cast<TObjString*>(next())) ) {
191 Int_t istep=ostr->GetString().Atoi();
ffbede40 192 fCfContainer->GetGrid(istep)->SetRangeUser(ivar,min,max);
ba15fdfb 193 fCfContainer->GetAxis(ivar,istep)->SetBit(TAxis::kAxisRange,1);
6551594b 194 }
195 }
196 delete arr;
197}
198
199//________________________________________________________________
200void AliDielectronCFdraw::UnsetRangeUser(Int_t ivar, const char* slices)
201{
202 //
203 // Unset range of cut steps defined in slices
204 // Steps may be separated by one the the characteres ,;:
205 //
ba15fdfb 206 if (ivar==-1) return;
6551594b 207 TObjArray *arr=TString(slices).Tokenize(",:;");
208
209 if (arr->GetEntriesFast()==0){
210 // all slices in case of 0 entries
211 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
572b0139 212 fCfContainer->GetAxis(ivar,istep)->SetRange(0,0);
5cc8c825 213 fCfContainer->GetAxis(ivar,istep)->SetBit(TAxis::kAxisRange,0);
6551594b 214 }
215 } else {
216 TIter next(arr);
217 TObjString *ostr=0x0;
218 while ( (ostr=static_cast<TObjString*>(next())) ) {
219 Int_t istep=ostr->GetString().Atoi();
572b0139 220 fCfContainer->GetAxis(ivar,istep)->SetRange(0,0);
5cc8c825 221 fCfContainer->GetAxis(ivar,istep)->SetBit(TAxis::kAxisRange,0);
6551594b 222 }
223 }
224 delete arr;
225}
226
227//________________________________________________________________
572b0139 228void AliDielectronCFdraw::Draw(const Option_t* varnames, const char* opt, const char* slices)
6551594b 229{
230 //
231 // Draw 'variables' of 'slices'
232 // for multidimensional draw variables may be separated by a ':'
233 // slice numbers may be separated by any of ,:;
234 //
235 // variables may be called by either their name or number
236 //
237
238 TObjArray *arrVars=TString(varnames).Tokenize(":");
239 Int_t entries=arrVars->GetEntriesFast();
240 if (entries<1||entries>3){
241 AliError("Wrong number of variables, supported are 1 - 3 dimensions");
242 delete arrVars;
243 return;
244 }
245
246 TIter next(arrVars);
247 TObjString *ostr=0x0;
248 Int_t ivar[3]={-1,-1,-1};
ffbede40 249 for (Int_t i=entries-1; i>=0; --i){
6551594b 250 ostr=static_cast<TObjString*>(next());
251 if (ostr->GetString().IsDigit()){
252 ivar[i]=ostr->GetString().Atoi();
253 } else {
254 ivar[i]=fCfContainer->GetVar(ostr->GetName());
255 }
256 }
257
ffbede40 258 Draw(ivar[0],ivar[1],ivar[2],opt,slices);
6551594b 259 delete arrVars;
260}
261
ba15fdfb 262//________________________________________________________________
263TObjArray* AliDielectronCFdraw::CollectHistosProj(const Option_t* varnames, const char* slices)
264{
265 //
266 // Collect histos with 'variables' of 'slices'
267 // for multidimensional histograms, variables may be separated by a ':'
268 // slice numbers may be separated by any of ,:;
269 //
270 // variables may be called by either their name or number
271 //
272
273 TObjArray *arrVars=TString(varnames).Tokenize(":");
274 Int_t entries=arrVars->GetEntriesFast();
275 if (entries<1||entries>3){
276 AliError("Wrong number of variables, supported are 1 - 3 dimensions");
277 delete arrVars;
278 return 0x0;
279 }
280
281 TIter next(arrVars);
282 TObjString *ostr=0x0;
283 Int_t ivar[3]={-1,-1,-1};
284 for (Int_t i=entries-1; i>=0; --i){
285 ostr=static_cast<TObjString*>(next());
286 if (ostr->GetString().IsDigit()){
287 ivar[i]=ostr->GetString().Atoi();
288 } else {
289 ivar[i]=fCfContainer->GetVar(ostr->GetName());
290 }
291 }
292 delete arrVars;
293
294 return CollectHistosProj(ivar,slices);
295}
296
6551594b 297//________________________________________________________________
298void AliDielectronCFdraw::Draw(Int_t var, const char* opt, const char* slices)
299{
300 //
301 // Draw variable var for all slices
302 // slices may be divided by and of ,;:
303 //
304 // if opt contains 'same' all histograms are drawn in the same pad
305 // otherwise the pad will be divided in sub pads and the histograms
306 // are drawn in each sub pad
307 //
308
ffbede40 309 Int_t vars[3]={var,-1,-1};
310 TObjArray *arr=CollectHistosProj(vars,slices);
6551594b 311 Draw(arr,opt);
312 delete arr;
313}
314
315//________________________________________________________________
316void AliDielectronCFdraw::Draw(Int_t var0, Int_t var1, const char* opt, const char* slices)
317{
318 //
319 // Draw 2D case
320 //
ffbede40 321 Int_t vars[3]={var0,var1,-1};
322 TObjArray *arr=CollectHistosProj(vars,slices);
6551594b 323 Draw(arr,opt);
324 delete arr;
325}
326
327//________________________________________________________________
328void AliDielectronCFdraw::Draw(Int_t var0, Int_t var1, Int_t var2, const char* opt, const char* slices)
329{
330 //
331 // Draw 3D case
332 //
ffbede40 333 Int_t vars[3]={var0,var1,var2};
334 TObjArray *arr=CollectHistosProj(vars,slices);
6551594b 335 Draw(arr,opt);
336 delete arr;
337}
338
339//________________________________________________________________
ffbede40 340TObjArray* AliDielectronCFdraw::CollectHistosProj(const Int_t vars[3], const char* slices)
6551594b 341{
342 //
ffbede40 343 // Collect histos with up to 3 dimension of the 'slices' separated by one of "':;'"
a655b716 344 // in a TObjArray and return it
ffbede40 345 // if a dimension is not used it must be set to -1
6551594b 346 //
a655b716 347 TObjArray *arr=TString(slices).Tokenize(",:;");
348 TObjArray *arrHists=0x0;
349 if (arr->GetEntriesFast()==0){
350 // all slices in case of 0 entries
351 arrHists=new TObjArray(fCfContainer->GetNStep());
352 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
ffbede40 353 TH1 *hproj=Project(vars,istep);
572b0139 354 if (!hproj) continue;
66b2c564 355 hproj->SetName(Form("proj_%02d",istep));
356 hproj->SetTitle(fCfContainer->GetStepTitle(istep));
a655b716 357 arrHists->Add(hproj);
358 }
359 } else {
360 arrHists=new TObjArray(arr->GetEntriesFast());
361 TIter next(arr);
362 TObjString *ostr=0x0;
363 while ( (ostr=static_cast<TObjString*>(next())) ) {
364 Int_t istep=ostr->GetString().Atoi();
ffbede40 365 TH1 *hproj=Project(vars,istep);
572b0139 366 if (!hproj) continue;
66b2c564 367 hproj->SetName(Form("proj_%02d",istep));
368 hproj->SetTitle(fCfContainer->GetStepTitle(istep));
a655b716 369 arrHists->Add(hproj);
370 }
371 }
372 delete arr;
373
374 return arrHists;
375}
376
377//________________________________________________________________
ffbede40 378TH1* AliDielectronCFdraw::Project(const Int_t *vars, Int_t slice)
a655b716 379{
380 //
2a14a7b1 381 // Do an ndim projection
a655b716 382 //
ffbede40 383 return fCfContainer->Project(slice,vars[0],vars[1],vars[2]);
a655b716 384}
385
2a14a7b1 386//________________________________________________________________
387TH1* AliDielectronCFdraw::Project(const Option_t* var, Int_t slice)
388{
389 //
390 // translate variable names and do projection
391 //
392 TObjArray *arrVars=TString(var).Tokenize(":");
393 Int_t entries=arrVars->GetEntriesFast();
394 if (entries<1||entries>3){
395 AliError("Wrong number of variables, supported are 1 - 3 dimensions");
396 delete arrVars;
397 return 0x0;
398 }
399
2a14a7b1 400 TObjString *ostr=0x0;
401 Int_t ivar[3]={-1,-1,-1};
ffbede40 402 for (Int_t i=entries-1; i>=0; --i){
403 ostr=static_cast<TObjString*>(arrVars->At(i));
2a14a7b1 404 if (ostr->GetString().IsDigit()){
405 ivar[i]=ostr->GetString().Atoi();
406 } else {
407 ivar[i]=fCfContainer->GetVar(ostr->GetName());
408 }
409 }
ffbede40 410 if (ivar[0]==-1) return 0x0;
2a14a7b1 411 delete arrVars;
ffbede40 412 return fCfContainer->Project(slice,ivar[0],ivar[1],ivar[2]);
2a14a7b1 413}
414
a655b716 415//________________________________________________________________
554e40f8 416void AliDielectronCFdraw::DrawEfficiency(const char* varnames, const char* numerators, Int_t denominator, const char* opt)
a655b716 417{
418 //
419 // plot efficiencies for variables. Variable may be up to 3 dim, separated by a ':'
554e40f8 420 // you may have several numerators, sparated by one of ',:;'
a655b716 421 //
422
423 TObjArray *arrVars=TString(varnames).Tokenize(":");
424 Int_t entries=arrVars->GetEntriesFast();
425 if (entries<1||entries>3){
426 AliError("Wrong number of variables, supported are 1 - 3 dimensions");
427 delete arrVars;
428 return;
429 }
430
431 TIter next(arrVars);
432 TObjString *ostr=0x0;
433 Int_t ivar[3]={-1,-1,-1};
434 for (Int_t i=0; i<entries; ++i){
435 ostr=static_cast<TObjString*>(next());
436 if (ostr->GetString().IsDigit()){
437 ivar[i]=ostr->GetString().Atoi();
438 } else {
439 ivar[i]=fCfContainer->GetVar(ostr->GetName());
6551594b 440 }
441 }
66b2c564 442
443 Int_t type=0;
444 TString optStr(opt);
445 if (optStr.Contains("2")) type=1;
a655b716 446
ffbede40 447 DrawEfficiency(ivar[2],ivar[1],ivar[0],numerators, denominator,opt,type);
a655b716 448 delete arrVars;
449}
450
451//________________________________________________________________
554e40f8 452void AliDielectronCFdraw::DrawEfficiency(Int_t var, const char* numerators, Int_t denominator, const char* opt, Int_t type)
a655b716 453{
454 //
554e40f8 455 // Draw Efficiencies for all numerators
456 // numerators may be divided by and of ,;:
a655b716 457 //
458 // if opt contains 'same' all histograms are drawn in the same pad
459 // otherwise the pad will be divided in sub pads and the histograms
460 // are drawn in each sub pad
461 //
462
ffbede40 463 Int_t vars[3]={var,-1,-1};
464 TObjArray *arr=CollectHistosEff(vars,numerators,denominator,type);
572b0139 465 TString drawOpt=opt;
466 drawOpt+="eff";
467 Draw(arr,drawOpt);
a655b716 468 delete arr;
469}
470
471//________________________________________________________________
554e40f8 472void AliDielectronCFdraw::DrawEfficiency(Int_t var0, Int_t var1, const char* numerators, Int_t denominator, const char* opt, Int_t type)
a655b716 473{
474 //
475 // Draw 2D case
476 //
ffbede40 477 Int_t vars[3]={var0,var1,-1};
478 TObjArray *arr=CollectHistosEff(vars,numerators,denominator,type);
572b0139 479 TString drawOpt=opt;
480 drawOpt+="eff";
481 Draw(arr,drawOpt);
a655b716 482 delete arr;
483}
484
485//________________________________________________________________
554e40f8 486void AliDielectronCFdraw::DrawEfficiency(Int_t var0, Int_t var1, Int_t var2, const char* numerators, Int_t denominator, const char* opt, Int_t type)
a655b716 487{
488 //
489 // Draw 3D case
490 //
ffbede40 491 Int_t vars[3]={var0,var1,var2};
492 TObjArray *arr=CollectHistosEff(vars,numerators,denominator,type);
572b0139 493 TString drawOpt=opt;
494 drawOpt+="eff";
495 Draw(arr,drawOpt);
a655b716 496 delete arr;
6551594b 497}
498
499//________________________________________________________________
ffbede40 500TObjArray* AliDielectronCFdraw::CollectHistosEff(const Int_t vars[3], const char* numerators, Int_t denominator, Int_t type)
6551594b 501{
502 //
503 // Collect histos with 'dim'ension of the 'slices' separated by one of "':;'"
504 // in a TObjArray and return it
505 //
554e40f8 506 TObjArray *arr=TString(numerators).Tokenize(",:;");
6551594b 507 TObjArray *arrHists=0x0;
66b2c564 508
509 if (type==0){
510 if (arr->GetEntriesFast()==0){
6551594b 511 // all slices in case of 0 entries
66b2c564 512 arrHists=new TObjArray(fCfContainer->GetNStep());
572b0139 513 fVdata.ResizeTo(arrHists->GetSize());
66b2c564 514 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
515 fEffGrid->CalculateEfficiency(istep,denominator);
ffbede40 516 TH1 *hproj=ProjectEff(vars);
572b0139 517 if (!hproj) continue;
66b2c564 518 Float_t eff=fEffGrid->GetAverage();
572b0139 519 fVdata(istep)=eff;
66b2c564 520 hproj->SetName(Form("eff_%02d/%02d",istep,denominator));
572b0139 521 hproj->SetTitle(Form("%s (%.3f)",fCfContainer->GetStepTitle(istep),eff));
66b2c564 522 arrHists->Add(hproj);
523 }
524 } else {
525 arrHists=new TObjArray(arr->GetEntriesFast());
526 TIter next(arr);
527 TObjString *ostr=0x0;
572b0139 528 fVdata.ResizeTo(arrHists->GetSize());
529 Int_t count=0;
66b2c564 530 while ( (ostr=static_cast<TObjString*>(next())) ) {
531 Int_t istep=ostr->GetString().Atoi();
532 fEffGrid->CalculateEfficiency(istep,denominator);
ffbede40 533 TH1 *hproj=ProjectEff(vars);
572b0139 534 if (!hproj) continue;
66b2c564 535 Float_t eff=fEffGrid->GetAverage();
572b0139 536 fVdata(count++)=eff;
66b2c564 537 hproj->SetName(Form("eff_%02d/%02d",istep,denominator));
572b0139 538 hproj->SetTitle(Form("%s (%.3f)",fCfContainer->GetStepTitle(istep),eff));
66b2c564 539 arrHists->Add(hproj);
540 }
6551594b 541 }
66b2c564 542 }
543
544 //second approach
545 if (type==1){
ffbede40 546 TH1 *hDen=Project(vars,denominator);
66b2c564 547 Double_t entriesDen=hDen->GetEffectiveEntries();
548 if (arr->GetEntriesFast()==0){
549 // all slices in case of 0 entries
550 arrHists=new TObjArray(fCfContainer->GetNStep());
572b0139 551 fVdata.ResizeTo(arrHists->GetSize());
66b2c564 552 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
ffbede40 553 TH1 *hproj=Project(vars,istep);
572b0139 554 if (!hproj) continue;
66b2c564 555 Float_t eff=0;
556 if (entriesDen>0) eff=hproj->GetEffectiveEntries()/entriesDen;
572b0139 557 fVdata(istep)=eff;
48609e3d 558 hproj->Divide(hproj,hDen,1,1,"B");
66b2c564 559 hproj->SetName(Form("eff_%02d/%02d",istep,denominator));
572b0139 560 hproj->SetTitle(Form("%s (%.3f)",fCfContainer->GetStepTitle(istep),eff));
66b2c564 561 arrHists->Add(hproj);
562 }
563 } else {
564 arrHists=new TObjArray(arr->GetEntriesFast());
572b0139 565 fVdata.ResizeTo(arrHists->GetSize());
66b2c564 566 TIter next(arr);
567 TObjString *ostr=0x0;
572b0139 568 Int_t count=0;
66b2c564 569 while ( (ostr=static_cast<TObjString*>(next())) ) {
570 Int_t istep=ostr->GetString().Atoi();
ffbede40 571 TH1 *hproj=Project(vars,istep);
572b0139 572 if (!hproj) continue;
66b2c564 573 Float_t eff=0;
574 if (entriesDen>0) eff=hproj->GetEffectiveEntries()/entriesDen;
572b0139 575 fVdata(count++)=eff;
48609e3d 576 hproj->Divide(hproj,hDen,1,1,"B");
66b2c564 577 hproj->SetName(Form("eff_%02d/%02d",istep,denominator));
572b0139 578 hproj->SetTitle(Form("%s (%.3f)",fCfContainer->GetStepTitle(istep),eff));
66b2c564 579 arrHists->Add(hproj);
580 }
6551594b 581 }
66b2c564 582 delete hDen;
6551594b 583 }
a655b716 584
66b2c564 585
586 delete arr;
6551594b 587 return arrHists;
588}
589
590//________________________________________________________________
ffbede40 591TH1* AliDielectronCFdraw::ProjectEff(const Int_t vars[3])
6551594b 592{
593 //
594 // Do an nim projection
595 //
ffbede40 596 return fEffGrid->Project(vars[0],vars[1],vars[2]);
6551594b 597}
598
a655b716 599//________________________________________________________________
600void AliDielectronCFdraw::Draw(const TObjArray *arr, const char* opt)
601{
602 //
603 // draw all objects in arr
604 //
605 TString optStr(opt);
606 optStr.ToLower();
572b0139 607 Bool_t drawSame = optStr.Contains("same");
608 Bool_t drawSamePlus = optStr.Contains("same+");
609 Bool_t drawEff = optStr.Contains("eff");
610 Bool_t optLeg = optStr.Contains("leg");
611 Bool_t optScaleMax = optStr.Contains("max");
612
613 if (!drawSamePlus) optStr.ReplaceAll("same","");
614
615 optStr.ReplaceAll("+","");
616 optStr.ReplaceAll("eff","");
617 optStr.ReplaceAll("leg","");
618 optStr.ReplaceAll("max","");
a655b716 619
620 if (!gPad) new TCanvas;
621
622 Int_t nPads = arr->GetEntriesFast();
623 if (nPads==0) return;
624
572b0139 625// if (nPads==1){
626// arr->UncheckedAt(0)->Draw(optStr.Data());
627// return;
628// }
a655b716 629
630 TCanvas *c=gPad->GetCanvas();
8df8e382 631 if (!gVirtualPS&&!drawSamePlus&&!drawSame&&nPads>1) c->Clear();
a655b716 632
8df8e382 633 if (!drawSame&&nPads>1){
a655b716 634 //optimised division
635 Int_t nCols = (Int_t)TMath::Ceil( TMath::Sqrt(nPads) );
636 Int_t nRows = (Int_t)TMath::Ceil( (Double_t)nPads/(Double_t)nCols );
637 c->Divide(nCols,nRows);
638 for (Int_t i=0; i<nPads; ++i){
639 c->cd(i+1);
640 arr->UncheckedAt(i)->Draw(optStr.Data());
641 }
642 } else {
643 TLegend *leg=0;
572b0139 644 if (drawSamePlus){
645 //find already existing legend to attach entries to it
646 TIter nextPrimitive(gPad->GetListOfPrimitives());
647 TObject *o=0x0;
648 while ((o=nextPrimitive())) if (o->IsA()==TLegend::Class()) leg=(TLegend*)o;
649 }
650
651 if (optLeg&&!leg) leg=new TLegend(.2,.3,.99,.9);
652 Int_t addColor=0;
653 if (leg) addColor=leg->GetNRows();
66b2c564 654 Int_t offset=20;
655 if (nPads<7) offset=24;
a655b716 656 for (Int_t i=0; i<nPads; ++i){
572b0139 657 if (i==1&&!drawSamePlus) optStr+="same";
a655b716 658 TH1 *hist=static_cast<TH1*>(arr->UncheckedAt(i));
572b0139 659 hist->SetLineColor(i+1+addColor);
66b2c564 660 hist->SetLineWidth(2);
572b0139 661 hist->SetMarkerColor(i+1+addColor);
662 hist->SetMarkerStyle(offset+i+addColor);
a655b716 663 hist->Draw(optStr.Data());
572b0139 664
665 if (drawEff&&i==0&&!drawSamePlus) {
666 hist->GetYaxis()->SetRangeUser(0,2);
667 hist->SetYTitle("Rec. Signal / Gen. Signal");
668 }
669
66b2c564 670 if (leg) leg->AddEntry(hist,hist->GetTitle(),"lp");
a655b716 671 }
672 if (leg){
673 leg->SetFillColor(10);
572b0139 674 leg->SetY1(.9-leg->GetNRows()*.05);
675 leg->SetY1NDC(.9-leg->GetNRows()*.05);
66b2c564 676 leg->SetMargin(.1);
572b0139 677 if (!drawSamePlus) leg->Draw();
678 }
679 if (optScaleMax){
680 TIter nextPrimitive(gPad->GetListOfPrimitives());
681 TObject *o=0x0;
682 TH1 *hfirst=0x0;
683 Float_t max=0;
684 while ((o=nextPrimitive())) if (o->InheritsFrom(TH1::Class())){
685 TH1 *h=(TH1*)o;
686 if (!hfirst) hfirst=h;
687 if (h->GetMaximum()>max) max=h->GetMaximum();
688 }
689 max*=1.1;
690 hfirst->SetMaximum(max);
a655b716 691 }
692 }
693
694}
554e40f8 695
696//________________________________________________________________
697Double_t AliDielectronCFdraw::GetAverageEfficiency(Int_t numerator, Int_t denominator, Double_t &effErr)
698{
699 //
700 // Extract the mean efficiency of the numerator and denominator
701 //
702
703 //use variable 0 as default, since for the average it doesn't matter
ffbede40 704 TH1 *hDen=fCfContainer->Project(denominator,0);
554e40f8 705 Double_t entriesDen=hDen->GetEffectiveEntries();
ffbede40 706 TH1 *hproj=fCfContainer->Project(numerator,0);
554e40f8 707 if (!hproj) return -1.;
708 Double_t entriesNum=hproj->GetEffectiveEntries();
709 if (entriesDen<1||entriesNum<1) return -1;
710
711 Double_t eff=-1.;
712 if (entriesDen>0) eff=entriesNum/entriesDen;
713 effErr=TMath::Sqrt(1./entriesNum+1./entriesDen)*eff;
714 delete hDen;
715 delete hproj;
716 return eff;
717}