* provided "as is" without express or implied warranty. *
**************************************************************************/
+/* $Id$ */
+
///////////////////////////////////////////////////////////////////////////
// Dielectron Correction framework draw helper //
// //
if (arr->GetEntriesFast()==0){
// all slices in case of 0 entries
for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
- fCfContainer->SetRangeUser(ivar,min,max,istep);
+ fCfContainer->GetGrid(istep)->SetRangeUser(ivar,min,max);
}
} else {
TIter next(arr);
TObjString *ostr=0x0;
while ( (ostr=static_cast<TObjString*>(next())) ) {
Int_t istep=ostr->GetString().Atoi();
- fCfContainer->SetRangeUser(ivar,min,max,istep);
+ fCfContainer->GetGrid(istep)->SetRangeUser(ivar,min,max);
}
}
delete arr;
TIter next(arrVars);
TObjString *ostr=0x0;
Int_t ivar[3]={-1,-1,-1};
- for (Int_t i=0; i<entries; ++i){
+ for (Int_t i=entries-1; i>=0; --i){
ostr=static_cast<TObjString*>(next());
if (ostr->GetString().IsDigit()){
ivar[i]=ostr->GetString().Atoi();
}
}
- switch (entries){
- case 1:
- Draw(ivar[0],opt,slices);
- break;
- case 2:
- Draw(ivar[1],ivar[0],opt,slices);
- break;
- case 3:
- Draw(ivar[2],ivar[1],ivar[0],opt,slices);
- break;
- }
+ Draw(ivar[0],ivar[1],ivar[2],opt,slices);
delete arrVars;
}
// are drawn in each sub pad
//
- const Int_t ndim=1;
- Int_t vars[ndim]={var};
- TObjArray *arr=CollectHistosProj(ndim,vars,slices);
+ Int_t vars[3]={var,-1,-1};
+ TObjArray *arr=CollectHistosProj(vars,slices);
Draw(arr,opt);
delete arr;
}
//
// Draw 2D case
//
- const Int_t ndim=2;
- Int_t vars[ndim]={var0,var1};
- TObjArray *arr=CollectHistosProj(ndim,vars,slices);
+ Int_t vars[3]={var0,var1,-1};
+ TObjArray *arr=CollectHistosProj(vars,slices);
Draw(arr,opt);
delete arr;
}
//
// Draw 3D case
//
- const Int_t ndim=3;
- Int_t vars[ndim]={var0,var1,var2};
- TObjArray *arr=CollectHistosProj(ndim,vars,slices);
+ Int_t vars[3]={var0,var1,var2};
+ TObjArray *arr=CollectHistosProj(vars,slices);
Draw(arr,opt);
delete arr;
}
//________________________________________________________________
-TObjArray* AliDielectronCFdraw::CollectHistosProj(Int_t dim, Int_t *vars, const char* slices)
+TObjArray* AliDielectronCFdraw::CollectHistosProj(const Int_t vars[3], const char* slices)
{
//
- // Collect histos with 'dim'ension of the 'slices' separated by one of "':;'"
+ // Collect histos with up to 3 dimension of the 'slices' separated by one of "':;'"
// in a TObjArray and return it
+ // if a dimension is not used it must be set to -1
//
TObjArray *arr=TString(slices).Tokenize(",:;");
TObjArray *arrHists=0x0;
// all slices in case of 0 entries
arrHists=new TObjArray(fCfContainer->GetNStep());
for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
- TH1 *hproj=Project(dim,vars,istep);
+ TH1 *hproj=Project(vars,istep);
if (!hproj) continue;
hproj->SetName(Form("proj_%02d",istep));
hproj->SetTitle(fCfContainer->GetStepTitle(istep));
TObjString *ostr=0x0;
while ( (ostr=static_cast<TObjString*>(next())) ) {
Int_t istep=ostr->GetString().Atoi();
- TH1 *hproj=Project(dim,vars,istep);
+ TH1 *hproj=Project(vars,istep);
if (!hproj) continue;
hproj->SetName(Form("proj_%02d",istep));
hproj->SetTitle(fCfContainer->GetStepTitle(istep));
}
//________________________________________________________________
-TH1* AliDielectronCFdraw::Project(Int_t ndim, Int_t *vars, Int_t slice)
+TH1* AliDielectronCFdraw::Project(const Int_t *vars, Int_t slice)
{
//
- // Do an nim projection
+ // Do an ndim projection
+ //
+ return fCfContainer->Project(slice,vars[0],vars[1],vars[2]);
+}
+
+//________________________________________________________________
+TH1* AliDielectronCFdraw::Project(const Option_t* var, Int_t slice)
+{
+ //
+ // translate variable names and do projection
//
- switch (ndim){
- case 1:
- return fCfContainer->Project(vars[0],slice);
- break;
- case 2:
- return fCfContainer->Project(vars[0],vars[1],slice);
- break;
- case 3:
- return fCfContainer->Project(vars[0],vars[1],vars[2],slice);
- break;
+ TObjArray *arrVars=TString(var).Tokenize(":");
+ Int_t entries=arrVars->GetEntriesFast();
+ if (entries<1||entries>3){
+ AliError("Wrong number of variables, supported are 1 - 3 dimensions");
+ delete arrVars;
+ return 0x0;
}
- return 0x0;
+
+ TObjString *ostr=0x0;
+ Int_t ivar[3]={-1,-1,-1};
+ for (Int_t i=entries-1; i>=0; --i){
+ ostr=static_cast<TObjString*>(arrVars->At(i));
+ if (ostr->GetString().IsDigit()){
+ ivar[i]=ostr->GetString().Atoi();
+ } else {
+ ivar[i]=fCfContainer->GetVar(ostr->GetName());
+ }
+ }
+ if (ivar[0]==-1) return 0x0;
+ delete arrVars;
+ return fCfContainer->Project(slice,ivar[0],ivar[1],ivar[2]);
}
//________________________________________________________________
-void AliDielectronCFdraw::DrawEfficiency(const char* varnames, const char* nominators, Int_t denominator, const char* opt)
+void AliDielectronCFdraw::DrawEfficiency(const char* varnames, const char* numerators, Int_t denominator, const char* opt)
{
//
// plot efficiencies for variables. Variable may be up to 3 dim, separated by a ':'
- // you may have several nominators, sparated by one of ',:;'
+ // you may have several numerators, sparated by one of ',:;'
//
TObjArray *arrVars=TString(varnames).Tokenize(":");
TString optStr(opt);
if (optStr.Contains("2")) type=1;
- switch (entries){
- case 1:
- DrawEfficiency(ivar[0],nominators, denominator,opt,type);
- break;
- case 2:
- DrawEfficiency(ivar[1],ivar[0], nominators, denominator,opt,type);
- break;
- case 3:
- DrawEfficiency(ivar[2],ivar[1],ivar[0],nominators, denominator,opt,type);
- break;
- }
+ DrawEfficiency(ivar[2],ivar[1],ivar[0],numerators, denominator,opt,type);
delete arrVars;
}
//________________________________________________________________
-void AliDielectronCFdraw::DrawEfficiency(Int_t var, const char* nominators, Int_t denominator, const char* opt, Int_t type)
+void AliDielectronCFdraw::DrawEfficiency(Int_t var, const char* numerators, Int_t denominator, const char* opt, Int_t type)
{
//
- // Draw Efficiencies for all nominators
- // nominators may be divided by and of ,;:
+ // Draw Efficiencies for all numerators
+ // numerators may be divided by and of ,;:
//
// if opt contains 'same' all histograms are drawn in the same pad
// otherwise the pad will be divided in sub pads and the histograms
// are drawn in each sub pad
//
- const Int_t ndim=1;
- Int_t vars[ndim]={var};
- TObjArray *arr=CollectHistosEff(ndim,vars,nominators,denominator,type);
+ Int_t vars[3]={var,-1,-1};
+ TObjArray *arr=CollectHistosEff(vars,numerators,denominator,type);
TString drawOpt=opt;
drawOpt+="eff";
Draw(arr,drawOpt);
}
//________________________________________________________________
-void AliDielectronCFdraw::DrawEfficiency(Int_t var0, Int_t var1, const char* nominators, Int_t denominator, const char* opt, Int_t type)
+void AliDielectronCFdraw::DrawEfficiency(Int_t var0, Int_t var1, const char* numerators, Int_t denominator, const char* opt, Int_t type)
{
//
// Draw 2D case
//
- const Int_t ndim=2;
- Int_t vars[ndim]={var0,var1};
- TObjArray *arr=CollectHistosEff(ndim,vars,nominators,denominator,type);
+ Int_t vars[3]={var0,var1,-1};
+ TObjArray *arr=CollectHistosEff(vars,numerators,denominator,type);
TString drawOpt=opt;
drawOpt+="eff";
Draw(arr,drawOpt);
}
//________________________________________________________________
-void AliDielectronCFdraw::DrawEfficiency(Int_t var0, Int_t var1, Int_t var2, const char* nominators, Int_t denominator, const char* opt, Int_t type)
+void AliDielectronCFdraw::DrawEfficiency(Int_t var0, Int_t var1, Int_t var2, const char* numerators, Int_t denominator, const char* opt, Int_t type)
{
//
// Draw 3D case
//
- const Int_t ndim=3;
- Int_t vars[ndim]={var0,var1,var2};
- TObjArray *arr=CollectHistosEff(ndim,vars,nominators,denominator,type);
+ Int_t vars[3]={var0,var1,var2};
+ TObjArray *arr=CollectHistosEff(vars,numerators,denominator,type);
TString drawOpt=opt;
drawOpt+="eff";
Draw(arr,drawOpt);
}
//________________________________________________________________
-TObjArray* AliDielectronCFdraw::CollectHistosEff(Int_t dim, Int_t *vars, const char* nominators, Int_t denominator, Int_t type)
+TObjArray* AliDielectronCFdraw::CollectHistosEff(const Int_t vars[3], const char* numerators, Int_t denominator, Int_t type)
{
//
// Collect histos with 'dim'ension of the 'slices' separated by one of "':;'"
// in a TObjArray and return it
//
- TObjArray *arr=TString(nominators).Tokenize(",:;");
+ TObjArray *arr=TString(numerators).Tokenize(",:;");
TObjArray *arrHists=0x0;
if (type==0){
fVdata.ResizeTo(arrHists->GetSize());
for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
fEffGrid->CalculateEfficiency(istep,denominator);
- TH1 *hproj=ProjectEff(dim,vars);
+ TH1 *hproj=ProjectEff(vars);
if (!hproj) continue;
Float_t eff=fEffGrid->GetAverage();
fVdata(istep)=eff;
while ( (ostr=static_cast<TObjString*>(next())) ) {
Int_t istep=ostr->GetString().Atoi();
fEffGrid->CalculateEfficiency(istep,denominator);
- TH1 *hproj=ProjectEff(dim,vars);
+ TH1 *hproj=ProjectEff(vars);
if (!hproj) continue;
Float_t eff=fEffGrid->GetAverage();
fVdata(count++)=eff;
//second approach
if (type==1){
- TH1 *hDen=Project(dim,vars,denominator);
+ TH1 *hDen=Project(vars,denominator);
Double_t entriesDen=hDen->GetEffectiveEntries();
if (arr->GetEntriesFast()==0){
// all slices in case of 0 entries
arrHists=new TObjArray(fCfContainer->GetNStep());
fVdata.ResizeTo(arrHists->GetSize());
for (Int_t istep=0; istep<fCfContainer->GetNStep(); ++istep){
- TH1 *hproj=Project(dim,vars,istep);
+ TH1 *hproj=Project(vars,istep);
if (!hproj) continue;
Float_t eff=0;
if (entriesDen>0) eff=hproj->GetEffectiveEntries()/entriesDen;
Int_t count=0;
while ( (ostr=static_cast<TObjString*>(next())) ) {
Int_t istep=ostr->GetString().Atoi();
- TH1 *hproj=Project(dim,vars,istep);
+ TH1 *hproj=Project(vars,istep);
if (!hproj) continue;
Float_t eff=0;
if (entriesDen>0) eff=hproj->GetEffectiveEntries()/entriesDen;
}
//________________________________________________________________
-TH1* AliDielectronCFdraw::ProjectEff(Int_t ndim, Int_t *vars)
+TH1* AliDielectronCFdraw::ProjectEff(const Int_t vars[3])
{
//
// Do an nim projection
//
- switch (ndim){
- case 1:
- return fEffGrid->Project(vars[0]);
- break;
- case 2:
- return fEffGrid->Project(vars[0],vars[1]);
- break;
- case 3:
- return fEffGrid->Project(vars[0],vars[1],vars[2]);
- break;
- }
- return 0x0;
+ return fEffGrid->Project(vars[0],vars[1],vars[2]);
}
//________________________________________________________________
}
}
+
+//________________________________________________________________
+Double_t AliDielectronCFdraw::GetAverageEfficiency(Int_t numerator, Int_t denominator, Double_t &effErr)
+{
+ //
+ // Extract the mean efficiency of the numerator and denominator
+ //
+
+ //use variable 0 as default, since for the average it doesn't matter
+ TH1 *hDen=fCfContainer->Project(denominator,0);
+ Double_t entriesDen=hDen->GetEffectiveEntries();
+ TH1 *hproj=fCfContainer->Project(numerator,0);
+ if (!hproj) return -1.;
+ Double_t entriesNum=hproj->GetEffectiveEntries();
+ if (entriesDen<1||entriesNum<1) return -1;
+
+ Double_t eff=-1.;
+ if (entriesDen>0) eff=entriesNum/entriesDen;
+ effErr=TMath::Sqrt(1./entriesNum+1./entriesDen)*eff;
+ delete hDen;
+ delete hproj;
+ return eff;
+}