1 /*************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
17 // Dielectron Correction framework draw helper //
31 ///////////////////////////////////////////////////////////////////////////
33 #include <TSeqCollection.h>
34 #include <TObjArray.h>
39 #include <TVirtualPS.h>
42 #include <TObjString.h>
51 #include <AliCFEffGrid.h>
55 #include "AliDielectronCFdraw.h"
56 #include "AliDielectron.h"
57 #include "AliDielectronVarManager.h"
59 ClassImp(AliDielectronCFdraw)
61 AliDielectronCFdraw::AliDielectronCFdraw() :
72 //________________________________________________________________
73 AliDielectronCFdraw::AliDielectronCFdraw(const char*name, const char* title) :
85 //________________________________________________________________
86 AliDielectronCFdraw::AliDielectronCFdraw(AliCFContainer *cont) :
87 TNamed(cont->GetName(), cont->GetTitle()),
89 fEffGrid(new AliCFEffGrid("eff","eff",*cont)),
93 // directly set the CF container
98 //________________________________________________________________
99 AliDielectronCFdraw::AliDielectronCFdraw(const char* filename) :
106 // get CF container(s) from file 'filename'
108 SetCFContainers(filename);
111 //________________________________________________________________
112 AliDielectronCFdraw::~AliDielectronCFdraw()
121 //________________________________________________________________
122 void AliDielectronCFdraw::SetCFContainers(const TSeqCollection *arr)
125 // Merge CF Container out of several containers
128 delete fCfContainer; fCfContainer=0x0;
129 delete fEffGrid; fEffGrid=0x0;
134 while ( (o=next()) ){
135 AliCFContainer *cf=dynamic_cast<AliCFContainer*>(o);
137 nstep+=cf->GetNStep();
139 if (nstep==0) return;
141 fCfContainer=new AliCFContainer(GetName(), GetTitle(), nstep, 1, nbins);
143 //delete unneeded steps
144 // for (Int_t istep=0; istep<nstep; ++istep) delete fCfContainer->GetGrid(istep);
146 //add step to the new container
148 for (Int_t icf=0; icf<arr->GetEntries(); ++icf){
149 AliCFContainer *cf=dynamic_cast<AliCFContainer*>(arr->At(icf));
151 for (Int_t istepCurr=0; istepCurr<cf->GetNStep(); ++istepCurr){
152 fCfContainer->SetGrid(istep, cf->GetGrid(istepCurr));
153 fCfContainer->SetStepTitle(istep,Form("%s, Pair: %s",cf->GetTitle(),cf->GetStepTitle(istepCurr)));
157 if (fEffGrid) delete fEffGrid;
158 fEffGrid=new AliCFEffGrid("eff","eff",*fCfContainer);
161 //________________________________________________________________
162 void AliDielectronCFdraw::SetCFContainers(const char* filename)
165 // get CF containers from file
169 TList *l=f.GetListOfKeys();
172 while ( (k=static_cast<TKey*>(nextKey())) ){
173 TObject *o=k->ReadObj();
174 if (o->IsA()->InheritsFrom(TSeqCollection::Class())){
175 TSeqCollection *arr=static_cast<TSeqCollection*>(o);
176 SetCFContainers(arr);
177 } else if (o->IsA()==AliCFContainer::Class()){
178 fCfContainer=static_cast<AliCFContainer*>(o);
179 if (fEffGrid) delete fEffGrid;
180 fEffGrid=new AliCFEffGrid("eff","eff",*fCfContainer);
185 //________________________________________________________________
186 void AliDielectronCFdraw::SetRangeUser(Int_t ivar, Double_t min, Double_t max, const char* slices)
189 // Set range of cut steps defined in slices
190 // Steps may be separated by one the the characteres ,;:
192 if (ivar==-1) return;
193 TObjArray *arr=TString(slices).Tokenize(",:;");
195 //Changes in root TAxis r48279
196 //it doesn't work any longer to give the same min and max in SetRangeUser
197 //the lines below fix this
199 TAxis *a = fCfContainer->GetAxis(ivar,0);
201 const Int_t bin=a->FindBin(min);
202 const Double_t binw=a->GetBinWidth(bin);
203 if (TMath::Abs(max-min)<binw*0.001){
208 if (arr->GetEntriesFast()==0){
209 // all slices in case of 0 entries
210 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
211 fCfContainer->GetGrid(istep)->SetRangeUser(ivar,min,max);
212 fCfContainer->GetAxis(ivar,istep)->SetBit(TAxis::kAxisRange,1);
216 TObjString *ostr=0x0;
217 while ( (ostr=static_cast<TObjString*>(next())) ) {
218 Int_t istep=ostr->GetString().Atoi();
219 fCfContainer->GetGrid(istep)->SetRangeUser(ivar,min,max);
220 fCfContainer->GetAxis(ivar,istep)->SetBit(TAxis::kAxisRange,1);
226 //________________________________________________________________
227 void AliDielectronCFdraw::SetRangeUser(AliDielectronVarManager::ValueTypes type, Double_t min, Double_t max, const char* slices, Bool_t leg)
230 // Set range of cut steps defined in slices
231 // Steps may be separated by one the the characteres ,;:
233 SetRangeUser(Form("%s%s",(leg?"Leg1_":""),AliDielectronVarManager::GetValueName(type)), min, max, slices);
234 if(leg) SetRangeUser(Form("%s%s","Leg2_",AliDielectronVarManager::GetValueName(type)), min, max, slices);
238 //________________________________________________________________
239 void AliDielectronCFdraw::SetRangeUser(const char* varname, Double_t min, Double_t max, const char* slices)
242 // Set range from variable name
244 Int_t ivar=fCfContainer->GetVar(varname);
246 AliFatal(Form("Variable '%s' not found",varname));
249 SetRangeUser(ivar,min,max,slices);
252 //________________________________________________________________
253 void AliDielectronCFdraw::UnsetRangeUser(const char* varname, const char* slices)
256 // Unset range from variable name
258 Int_t ivar=fCfContainer->GetVar(varname);
260 AliFatal(Form("Variable '%s' not found",varname));
263 UnsetRangeUser(ivar,slices);
266 //________________________________________________________________
267 void AliDielectronCFdraw::UnsetRangeUser(AliDielectronVarManager::ValueTypes type, const char* slices, Bool_t leg)
270 // Unset range of cut steps defined in slices
271 // Steps may be separated by one the the characteres ,;:
273 UnsetRangeUser(Form("%s%s",(leg?"Leg1_":""),AliDielectronVarManager::GetValueName(type)), slices);
274 UnsetRangeUser(Form("%s%s",(leg?"Leg2_":""),AliDielectronVarManager::GetValueName(type)), slices);
277 //________________________________________________________________
278 void AliDielectronCFdraw::UnsetRangeUser(Int_t ivar, const char* slices)
281 // Unset range of cut steps defined in slices
282 // Steps may be separated by one the the characteres ,;:
284 if (ivar==-1) return;
285 TObjArray *arr=TString(slices).Tokenize(",:;");
287 if (arr->GetEntriesFast()==0){
288 // all slices in case of 0 entries
289 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
290 fCfContainer->GetAxis(ivar,istep)->SetRange(0,0);
291 fCfContainer->GetAxis(ivar,istep)->SetBit(TAxis::kAxisRange,0);
295 TObjString *ostr=0x0;
296 while ( (ostr=static_cast<TObjString*>(next())) ) {
297 Int_t istep=ostr->GetString().Atoi();
298 fCfContainer->GetAxis(ivar,istep)->SetRange(0,0);
299 fCfContainer->GetAxis(ivar,istep)->SetBit(TAxis::kAxisRange,0);
305 //________________________________________________________________
306 void AliDielectronCFdraw::Draw(const Option_t* varnames, const char* opt, const char* slices)
309 // Draw 'variables' of 'slices'
310 // for multidimensional draw variables may be separated by a ':'
311 // slice numbers may be separated by any of ,:;
313 // variables may be called by either their name or number
316 TObjArray *arrVars=TString(varnames).Tokenize(":");
317 Int_t entries=arrVars->GetEntriesFast();
318 if (entries<1||entries>3){
319 AliError("Wrong number of variables, supported are 1 - 3 dimensions");
325 TObjString *ostr=0x0;
326 Int_t ivar[3]={-1,-1,-1};
327 for (Int_t i=entries-1; i>=0; --i){
328 ostr=static_cast<TObjString*>(next());
329 if (ostr->GetString().IsDigit()){
330 ivar[i]=ostr->GetString().Atoi();
332 ivar[i]=fCfContainer->GetVar(ostr->GetName());
336 Draw(ivar[0],ivar[1],ivar[2],opt,slices);
340 //________________________________________________________________
341 TString AliDielectronCFdraw::FindSteps(const char* search)
344 // find steps/slices containg search string
345 // search strings may be separated by any of ,:;
347 TObjArray *arr=TString(search).Tokenize(",:;");
349 TObjString *ostr=0x0;
353 // loop over all steps
354 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
355 TString steptit = fCfContainer->GetStepTitle(istep);
358 // loop over all search strings
359 while ( (ostr=static_cast<TObjString*>(next())) ) {
360 if( steptit.Contains(ostr->GetName()) ) bfnd=kTRUE;
366 // append found slices string
369 slices.Append(Form(":%d",istep));
371 slices.Append(Form("%d", istep));
377 if(!nfnd) AliWarning(" No step searched for found. returning all steps!");
380 //________________________________________________________________
381 Int_t AliDielectronCFdraw::FindStep(const char* search)
384 // find first step/slice containg search string
385 // search strings may be separated by any of ,:;
387 TObjArray *arr=TString(search).Tokenize(",:;");
389 TObjString *ostr=0x0;
391 // loop over all steps
392 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
393 TString steptit = fCfContainer->GetStepTitle(istep);
396 // loop over all search strings
397 while ( (ostr=static_cast<TObjString*>(next())) ) {
398 if( steptit.Contains(ostr->GetName()) ) bfnd=kTRUE;
404 // return found slice/step
411 AliError(" No step searched for found. returning -1!");
416 //________________________________________________________________
417 TObjArray* AliDielectronCFdraw::CollectHistosProj(const Option_t* varnames, const char* slices)
420 // Collect histos with 'variables' of 'slices'
421 // for multidimensional histograms, variables may be separated by a ':'
422 // slice numbers may be separated by any of ,:;
424 // variables may be called by either their name or number
427 TObjArray *arrVars=TString(varnames).Tokenize(":");
428 Int_t entries=arrVars->GetEntriesFast();
429 if (entries<1||entries>3){
430 AliError("Wrong number of variables, supported are 1 - 3 dimensions");
436 TObjString *ostr=0x0;
437 Int_t ivar[3]={-1,-1,-1};
438 for (Int_t i=entries-1; i>=0; --i){
439 ostr=static_cast<TObjString*>(next());
440 if (ostr->GetString().IsDigit()){
441 ivar[i]=ostr->GetString().Atoi();
443 ivar[i]=fCfContainer->GetVar(ostr->GetName());
448 return CollectHistosProj(ivar,slices);
451 //________________________________________________________________
452 void AliDielectronCFdraw::Draw(Int_t var, const char* opt, const char* slices)
455 // Draw variable var for all slices
456 // slices may be divided by and of ,;:
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
463 Int_t vars[3]={var,-1,-1};
464 TObjArray *arr=CollectHistosProj(vars,slices);
469 //________________________________________________________________
470 void AliDielectronCFdraw::Draw(Int_t var0, Int_t var1, const char* opt, const char* slices)
475 Int_t vars[3]={var0,var1,-1};
476 TObjArray *arr=CollectHistosProj(vars,slices);
481 //________________________________________________________________
482 void AliDielectronCFdraw::Draw(Int_t var0, Int_t var1, Int_t var2, const char* opt, const char* slices)
487 Int_t vars[3]={var0,var1,var2};
488 TObjArray *arr=CollectHistosProj(vars,slices);
493 //________________________________________________________________
494 TObjArray* AliDielectronCFdraw::CollectHistosProj(const Int_t vars[3], const char* slices)
497 // Collect histos with up to 3 dimension of the 'slices' separated by one of "':;'"
498 // in a TObjArray and return it
499 // if a dimension is not used it must be set to -1
501 TObjArray *arr=TString(slices).Tokenize(",:;");
502 TObjArray *arrHists=0x0;
503 if (arr->GetEntriesFast()==0){
504 // all slices in case of 0 entries
505 arrHists=new TObjArray(fCfContainer->GetNStep());
506 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
507 TH1 *hproj=Project(vars,istep);
508 if (!hproj) continue;
509 hproj->SetName(Form("proj_%02d",istep));
510 hproj->SetTitle(fCfContainer->GetStepTitle(istep));
511 arrHists->Add(hproj);
514 arrHists=new TObjArray(arr->GetEntriesFast());
516 TObjString *ostr=0x0;
517 while ( (ostr=static_cast<TObjString*>(next())) ) {
518 Int_t istep=ostr->GetString().Atoi();
519 TH1 *hproj=Project(vars,istep);
520 if (!hproj) continue;
521 hproj->SetName(Form("proj_%02d",istep));
522 hproj->SetTitle(fCfContainer->GetStepTitle(istep));
523 arrHists->Add(hproj);
531 //________________________________________________________________
532 TObjArray* AliDielectronCFdraw::CollectMinvProj(Int_t slice, ECollectType collect, TString var)
535 // Collect invariant mass spectra of step 'slice' for pair types
538 TObjArray *arr = new TObjArray();
540 for (Int_t iType = 0; iType <= AliDielectron::kEv1PMRot; iType++) {
544 case AliDielectron::kEv1PP:
545 case AliDielectron::kEv1MM:
546 if(collect==kROT || collect==kME || collect==kMEOS) continue; break;
548 case AliDielectron::kEv1PEv2P:
549 case AliDielectron::kEv1MEv2M:
550 if(collect==kROT || collect==kSE || collect==kMEOS) continue; break;
551 case AliDielectron::kEv1MEv2P:
552 case AliDielectron::kEv1PEv2M:
553 if(collect==kROT || collect==kSE) continue; break;
555 case AliDielectron::kEv1PMRot:
556 if(collect==kSE || collect==kME || collect==kMEOS) continue; break;
558 case AliDielectron::kEv2PP:
559 case AliDielectron::kEv2PM:
560 case AliDielectron::kEv2MM:
563 SetRangeUser("PairType",iType,iType,Form("%d",slice));
564 TH1 *hM=Project(var.Data(),slice);
565 hM->SetDirectory(0x0);
566 hM->SetNameTitle(Form("Minv_%d",iType),Form("M for type %d;M (GeV/c^{2})", iType));
567 arr->AddAt(hM,iType);
569 UnsetRangeUser("PairType",Form("%d",slice));
573 //________________________________________________________________
574 TH1* AliDielectronCFdraw::Project(const Int_t *vars, Int_t slice)
577 // Do an ndim projection
579 return fCfContainer->Project(slice,vars[0],vars[1],vars[2]);
582 //________________________________________________________________
583 TH1* AliDielectronCFdraw::Project(const Option_t* var, Int_t slice)
586 // translate variable names and do projection
588 TObjArray *arrVars=TString(var).Tokenize(":");
589 Int_t entries=arrVars->GetEntriesFast();
590 if (entries<1||entries>3){
591 AliError("Wrong number of variables, supported are 1 - 3 dimensions");
597 TObjString *ostr=0x0;
598 Int_t ivar[3]={-1,-1,-1};
599 for (Int_t i=entries-1; i>=0; --i){
600 ostr=static_cast<TObjString*>(next());
601 if (ostr->GetString().IsDigit()){
602 ivar[i]=ostr->GetString().Atoi();
604 ivar[i]=fCfContainer->GetVar(ostr->GetName());
607 if (ivar[0]==-1) return 0x0;
609 return fCfContainer->Project(slice,ivar[0],ivar[1],ivar[2]);
612 //________________________________________________________________
613 void AliDielectronCFdraw::DrawEfficiency(const char* varnames, const char* numerators, Int_t denominator, const char* opt)
616 // plot efficiencies for variables. Variable may be up to 3 dim, separated by a ':'
617 // you may have several numerators, sparated by one of ',:;'
620 TObjArray *arrVars=TString(varnames).Tokenize(":");
621 Int_t entries=arrVars->GetEntriesFast();
622 if (entries<1||entries>3){
623 AliError("Wrong number of variables, supported are 1 - 3 dimensions");
629 TObjString *ostr=0x0;
630 Int_t ivar[3]={-1,-1,-1};
631 for (Int_t i=entries-1; i>=0; --i){
632 ostr=static_cast<TObjString*>(next());
633 if (ostr->GetString().IsDigit()){
634 ivar[i]=ostr->GetString().Atoi();
636 ivar[i]=fCfContainer->GetVar(ostr->GetName());
642 if (optStr.Contains("2")) type=1;
644 DrawEfficiency(ivar[0],ivar[1],ivar[2],numerators, denominator,opt,type);
648 //________________________________________________________________
649 void AliDielectronCFdraw::DrawEfficiency(Int_t var, const char* numerators, Int_t denominator, const char* opt, Int_t type)
652 // Draw Efficiencies for all numerators
653 // numerators may be divided by and of ,;:
655 // if opt contains 'same' all histograms are drawn in the same pad
656 // otherwise the pad will be divided in sub pads and the histograms
657 // are drawn in each sub pad
660 Int_t vars[3]={var,-1,-1};
661 TObjArray *arr=CollectHistosEff(vars,numerators,denominator,type);
668 //________________________________________________________________
669 void AliDielectronCFdraw::DrawEfficiency(Int_t var0, Int_t var1, const char* numerators, Int_t denominator, const char* opt, Int_t type)
674 Int_t vars[3]={var0,var1,-1};
675 TObjArray *arr=CollectHistosEff(vars,numerators,denominator,type);
682 //________________________________________________________________
683 void AliDielectronCFdraw::DrawEfficiency(Int_t var0, Int_t var1, Int_t var2, const char* numerators, Int_t denominator, const char* opt, Int_t type)
688 Int_t vars[3]={var0,var1,var2};
689 TObjArray *arr=CollectHistosEff(vars,numerators,denominator,type);
696 //________________________________________________________________
697 TObjArray* AliDielectronCFdraw::CollectHistosEff(const Int_t vars[3], const char* numerators, Int_t denominator, Int_t type)
700 // Collect histos with 'dim'ension of the 'slices' separated by one of "':;'"
701 // in a TObjArray and return it
703 TObjArray *arr=TString(numerators).Tokenize(",:;");
704 TObjArray *arrHists=0x0;
707 if (arr->GetEntriesFast()==0){
708 // all slices in case of 0 entries
709 arrHists=new TObjArray(fCfContainer->GetNStep());
710 fVdata.ResizeTo(arrHists->GetSize());
711 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
712 fEffGrid->CalculateEfficiency(istep,denominator);
713 TH1 *hproj=ProjectEff(vars);
714 if (!hproj) continue;
715 Float_t eff=fEffGrid->GetAverage();
717 hproj->SetName(Form("eff_%02d/%02d",istep,denominator));
718 hproj->SetTitle(Form("%s (%.3f)",fCfContainer->GetStepTitle(istep),eff));
719 arrHists->Add(hproj);
722 arrHists=new TObjArray(arr->GetEntriesFast());
724 TObjString *ostr=0x0;
725 fVdata.ResizeTo(arrHists->GetSize());
727 while ( (ostr=static_cast<TObjString*>(next())) ) {
728 Int_t istep=ostr->GetString().Atoi();
729 fEffGrid->CalculateEfficiency(istep,denominator);
730 TH1 *hproj=ProjectEff(vars);
731 if (!hproj) continue;
732 Float_t eff=fEffGrid->GetAverage();
734 hproj->SetName(Form("eff_%02d/%02d",istep,denominator));
735 hproj->SetTitle(Form("%s (%.3f)",fCfContainer->GetStepTitle(istep),eff));
736 arrHists->Add(hproj);
743 TH1 *hDen=Project(vars,denominator);
744 Double_t entriesDen=hDen->GetEffectiveEntries();
745 if (arr->GetEntriesFast()==0){
746 // all slices in case of 0 entries
747 arrHists=new TObjArray(fCfContainer->GetNStep());
748 fVdata.ResizeTo(arrHists->GetSize());
749 for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
750 TH1 *hproj=Project(vars,istep);
751 if (!hproj) continue;
753 if (entriesDen>0) eff=hproj->GetEffectiveEntries()/entriesDen;
755 hproj->Divide(hproj,hDen,1,1,"B");
756 hproj->SetName(Form("eff_%02d/%02d",istep,denominator));
757 hproj->SetTitle(Form("%s (%.3f)",fCfContainer->GetStepTitle(istep),eff));
758 arrHists->Add(hproj);
761 arrHists=new TObjArray(arr->GetEntriesFast());
762 fVdata.ResizeTo(arrHists->GetSize());
764 TObjString *ostr=0x0;
766 while ( (ostr=static_cast<TObjString*>(next())) ) {
767 Int_t istep=ostr->GetString().Atoi();
768 TH1 *hproj=Project(vars,istep);
769 if (!hproj) continue;
771 if (entriesDen>0) eff=hproj->GetEffectiveEntries()/entriesDen;
773 hproj->Divide(hproj,hDen,1,1,"B");
774 hproj->SetName(Form("eff_%02d/%02d",istep,denominator));
775 hproj->SetTitle(Form("%s (%.3f)",fCfContainer->GetStepTitle(istep),eff));
776 arrHists->Add(hproj);
787 //________________________________________________________________
788 TH1* AliDielectronCFdraw::ProjectEff(const Int_t vars[3])
791 // Do an nim projection
793 return fEffGrid->Project(vars[0],vars[1],vars[2]);
796 //________________________________________________________________
797 void AliDielectronCFdraw::Draw(const TObjArray *arr, const char* opt)
800 // draw all objects in arr
804 Bool_t drawSame = optStr.Contains("same");
805 Bool_t drawSamePlus = optStr.Contains("same+");
806 Bool_t drawEff = optStr.Contains("eff");
807 Bool_t optLeg = optStr.Contains("leg");
808 Bool_t optScaleMax = optStr.Contains("max");
810 if (!drawSamePlus) optStr.ReplaceAll("same","");
812 optStr.ReplaceAll("+","");
813 optStr.ReplaceAll("eff","");
814 optStr.ReplaceAll("leg","");
815 optStr.ReplaceAll("max","");
817 if (!gPad) new TCanvas;
819 Int_t nPads = arr->GetEntriesFast();
820 if (nPads==0) return;
823 // arr->UncheckedAt(0)->Draw(optStr.Data());
827 TCanvas *c=gPad->GetCanvas();
828 if (!gVirtualPS&&!drawSamePlus&&!drawSame&&nPads>1) c->Clear();
830 if (!drawSame&&nPads>1){
832 Int_t nCols = (Int_t)TMath::Ceil( TMath::Sqrt(nPads) );
833 Int_t nRows = (Int_t)TMath::Ceil( (Double_t)nPads/(Double_t)nCols );
834 c->Divide(nCols,nRows);
835 for (Int_t i=0; i<nPads; ++i){
837 arr->UncheckedAt(i)->Draw(optStr.Data());
842 //find already existing legend to attach entries to it
843 TIter nextPrimitive(gPad->GetListOfPrimitives());
845 while ((o=nextPrimitive())) if (o->IsA()==TLegend::Class()) leg=(TLegend*)o;
848 if (optLeg&&!leg) leg=new TLegend(.2,.3,.99,.9);
850 if (leg) addColor=leg->GetNRows();
852 if (nPads<7) offset=24;
853 for (Int_t i=0; i<nPads; ++i){
854 if (i==1&&!drawSamePlus) optStr+="same";
855 TH1 *hist=static_cast<TH1*>(arr->UncheckedAt(i));
856 hist->SetLineColor(i+1+addColor);
857 hist->SetLineWidth(2);
858 hist->SetMarkerColor(i+1+addColor);
859 hist->SetMarkerStyle(offset+i+addColor);
860 hist->Draw(optStr.Data());
862 if (drawEff&&i==0&&!drawSamePlus) {
863 hist->GetYaxis()->SetRangeUser(0,2);
864 hist->SetYTitle("Rec. Signal / Gen. Signal");
867 if (leg) leg->AddEntry(hist,hist->GetTitle(),"lp");
870 leg->SetFillColor(10);
871 leg->SetY1(.9-leg->GetNRows()*.05);
872 leg->SetY1NDC(.9-leg->GetNRows()*.05);
874 if (!drawSamePlus) leg->Draw();
877 TIter nextPrimitive(gPad->GetListOfPrimitives());
881 while ((o=nextPrimitive())) if (o->InheritsFrom(TH1::Class())){
883 if (!hfirst) hfirst=h;
884 if (h->GetMaximum()>max) max=h->GetMaximum();
887 hfirst->SetMaximum(max);
893 //________________________________________________________________
894 Double_t AliDielectronCFdraw::GetAverageEfficiency(Int_t numerator, Int_t denominator, Double_t &effErr)
897 // Extract the mean efficiency of the numerator and denominator
900 //use variable 0 as default, since for the average it doesn't matter
901 TH1 *hDen=fCfContainer->Project(denominator,0);
902 Double_t entriesDen=hDen->GetEffectiveEntries();
903 TH1 *hproj=fCfContainer->Project(numerator,0);
904 if (!hproj) return -1.;
905 Double_t entriesNum=hproj->GetEffectiveEntries();
906 if (entriesDen<1||entriesNum<1) return -1;
909 if (entriesDen>0) eff=entriesNum/entriesDen;
910 effErr=TMath::Sqrt(1./entriesNum+1./entriesDen)*eff;