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 **************************************************************************/
17 // Dielectron helper functions wrapped in a namespace
21 // Jens Wiechula <Jens.Wiechula@cern.ch>
29 #include <TObjString.h>
30 #include <TObjArray.h>
33 #include "AliDielectronHelper.h"
35 //_____________________________________________________________________________
36 TVectorD* AliDielectronHelper::MakeLogBinning(Int_t nbinsX, Double_t xmin, Double_t xmax)
39 // Make logarithmic binning
40 // the user has to delete the array afterwards!!!
44 if (xmin<1e-20 || xmax<1e-20){
45 Error("AliDielectronHelper::MakeLogBinning","For Log binning xmin and xmax must be > 1e-20. Using linear binning instead!");
46 return AliDielectronHelper::MakeLinBinning(nbinsX, xmin, xmax);
53 TVectorD *binLim=new TVectorD(nbinsX+1);
56 Double_t expMax=TMath::Log(last/first);
57 for (Int_t i=0; i<nbinsX+1; ++i){
58 (*binLim)[i]=first*TMath::Exp(expMax/nbinsX*(Double_t)i);
63 //_____________________________________________________________________________
64 TVectorD* AliDielectronHelper::MakeLinBinning(Int_t nbinsX, Double_t xmin, Double_t xmax)
67 // Make linear binning
68 // the user has to delete the array afterwards!!!
75 TVectorD *binLim=new TVectorD(nbinsX+1);
78 Double_t binWidth=(last-first)/nbinsX;
79 for (Int_t i=0; i<nbinsX+1; ++i){
80 (*binLim)[i]=first+binWidth*(Double_t)i;
85 //_____________________________________________________________________________
86 TVectorD* AliDielectronHelper::MakeArbitraryBinning(const char* bins)
89 // Make arbitrary binning, bins separated by a ','
93 Error("AliDielectronHelper::MakeArbitraryBinning","Bin Limit string is empty, cannot add the variable");
97 TObjArray *arr=limits.Tokenize(",");
98 Int_t nLimits=arr->GetEntries();
100 Error("AliDielectronHelper::MakeArbitraryBinning","Need at leas 2 bin limits, cannot add the variable");
105 TVectorD *binLimits=new TVectorD(nLimits);
106 for (Int_t iLim=0; iLim<nLimits; ++iLim){
107 (*binLimits)[iLim]=(static_cast<TObjString*>(arr->At(iLim)))->GetString().Atof();