//
#include <TString.h>
+#include <TAxis.h>
#include "AliLog.h"
return 0x0;
}
- Int_t *nbins = new Int_t [fSize];
- Double_t *min = new Double_t[fSize];
- Double_t *max = new Double_t[fSize];
-
// retrieve binnings for main and secondary axes
- AliRsnValue *fcnAxis = 0;
- for (Int_t i = 0; i < fSize; i++) {
+ AliRsnValue *fcnAxis;
+ TArrayD array[3];
+ for (Int_t i = 0; i < fSize; i++)
+ {
fcnAxis = (AliRsnValue*)fAxisList.At(i);
- if (!fcnAxis) {
- nbins[i] = 0;
- min[i] = 0.0;
- max[i] = 0.0;
+ if (!fcnAxis)
+ {
AliError("Empty axis");
+ array[i].Set(2);
+ array[i][0] = -1E5;
+ array[i][1] = -1E5;
continue;
}
- nbins[i] = fcnAxis->GetNBins();
- min[i] = fcnAxis->GetMin();
- max[i] = fcnAxis->GetMax();
+ else
+ {
+ array[i] = fcnAxis->GetArray();
+ }
}
// create histogram depending on the number of axes
switch (fSize)
{
case 1:
- fH1 = new TH1F(histoName, histoTitle, nbins[0], min[0], max[0]);
+ fH1 = new TH1F(histoName, histoTitle, array[0].GetSize() - 1, array[0].GetArray());
break;
case 2:
- fH1 = new TH2F(histoName, histoTitle, nbins[0], min[0], max[0], nbins[1], min[1], max[1]);
+ fH1 = new TH2F(histoName, histoTitle, array[0].GetSize() - 1, array[0].GetArray(), array[1].GetSize() - 1, array[1].GetArray());
break;
case 3:
- fH1 = new TH3F(histoName, histoTitle, nbins[0], min[0], max[0], nbins[1], min[1], max[1], nbins[2], min[2], max[2]);
+ fH1 = new TH3F(histoName, histoTitle, array[0].GetSize() - 1, array[0].GetArray(), array[1].GetSize() - 1, array[1].GetArray(), array[2].GetSize() - 1, array[2].GetArray());
break;
}
fH1->Sumw2();
AliError("No axes defined");
return 0x0;
}
-
- Int_t *nbins = new Int_t [fSize];
- Double_t *min = new Double_t[fSize];
- Double_t *max = new Double_t[fSize];
-
- // retrieve binnings for main and secondary axes
+
+ // initialize the array of number of bins for each axis
+ // taking it from the stored values, while for the bins
+ // they are set as summied and defined later
+ Double_t dummyD;
+ Int_t *nbins = new Int_t[fSize];
AliRsnValue *fcnAxis = 0;
- for (Int_t i = 0; i < fSize; i++) {
+ for (Int_t i = 0; i < fSize; i++)
+ {
fcnAxis = (AliRsnValue*)fAxisList.At(i);
- if (!fcnAxis) {
- nbins[i] = 0;
- min[i] = 0.0;
- max[i] = 0.0;
+ if (!fcnAxis)
+ {
+ nbins[i] = 1;
AliError("Empty axis");
continue;
}
- nbins[i] = fcnAxis->GetNBins();
- min[i] = fcnAxis->GetMin();
- max[i] = fcnAxis->GetMax();
- }
-
- Int_t size = fAxisList.GetEntries();
- if (!size) {
- AliError("No axes defined");
- return 0x0;
+ nbins[i] = fcnAxis->GetArray().GetSize() - 1;
}
// create histogram
- fHSparse = new THnSparseF(histoName, histoTitle, size, nbins, min, max);
+ fHSparse = new THnSparseF(histoName, histoTitle, fSize, nbins, &dummyD, &dummyD);
fHSparse->Sumw2();
- // clean heap
+ // update the various axes using the definitions given in the array of axes here
+ for (Int_t i = 0; i < fSize; i++)
+ {
+ fcnAxis = (AliRsnValue*)fAxisList.At(i);
+ if (!fcnAxis) {
+ AliError("Empty axis: doing unique bin betweeen -100000 and 100000");
+ continue;
+ }
+ fHSparse->SetBinEdges(i, fcnAxis->GetArray().GetArray());
+ }
+
delete [] nbins;
- delete [] min;
- delete [] max;
return fHSparse;
}
AliRsnValue *fcnAxis = 0;
for (i = 0; i < fSize; i++) {
fcnAxis = (AliRsnValue*)fAxisList.At(i);
- if (!fcnAxis) {
+ if (!fcnAxis)
+ {
values[i] = 0.0;
continue;
}
- if (fcnAxis->Eval(fPair, fPairDef, fEvent)) values[i] = fcnAxis->GetValue();
+ if (fcnAxis->Eval(fPair, fPairDef, fEvent)) values[i] = (Double_t)((Float_t)fcnAxis->GetValue());
}
// fill histogram
{
// check presence of output histogram
if (!fH1) {
- AliError("Required a TH1 whish is not initialized");
+ AliError("Required a TH1 which is not initialized");
+ delete [] values;
return kFALSE;
}
break;
default:
AliError(Form("Wrong size : %d", fSize));
+ delete [] values;
return kFALSE;
}
}
// check presence of output histogram
if (!fHSparse) {
AliError("Required a THnSparseF which is not initialized");
+ delete [] values;
return kFALSE;
}