]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnFunction.cxx
bugfix
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnFunction.cxx
index bcd944a77bcea227334a3a5baf99118441f77778..3a2a322c8f02e5c38094a3506cab0903c85df402 100644 (file)
@@ -26,8 +26,8 @@
 #include "AliRsnDaughter.h"
 #include "AliRsnEvent.h"
 #include "AliRsnPairDef.h"
-#include "AliRsnPairParticle.h"
-#include "AliRsnFunctionAxis.h"
+#include "AliRsnMother.h"
+#include "AliRsnValue.h"
 
 #include "AliRsnFunction.h"
 
@@ -35,10 +35,9 @@ ClassImp(AliRsnFunction)
 
 //________________________________________________________________________________________
 AliRsnFunction::AliRsnFunction(Bool_t useTH1) :
-    TNamed(),
+    TObject(),
     fPairDef(0x0),
-    fAxisList("AliRsnFunctionAxis", 0),
-    fTrack(0x0),
+    fAxisList("AliRsnValue", 0),
     fPair(0x0),
     fEvent(0x0),
     fUseTH1(useTH1),
@@ -53,10 +52,9 @@ AliRsnFunction::AliRsnFunction(Bool_t useTH1) :
 
 //________________________________________________________________________________________
 AliRsnFunction::AliRsnFunction(const AliRsnFunction &copy) :
-    TNamed(copy),
+    TObject(copy),
     fPairDef(copy.fPairDef),
     fAxisList(copy.fAxisList),
-    fTrack(copy.fTrack),
     fPair(copy.fPair),
     fEvent(copy.fEvent),
     fUseTH1(copy.fUseTH1),
@@ -76,11 +74,10 @@ const AliRsnFunction& AliRsnFunction::operator=(const AliRsnFunction& copy)
 // Assignment operator.
 //
 
-  SetName(copy.GetName());
-  SetTitle(copy.GetTitle());
+  //SetName(copy.GetName());
+  //SetTitle(copy.GetTitle());
 
   fPairDef = copy.fPairDef;
-  fTrack = copy.fTrack;
   fPair = copy.fPair;
   fEvent = copy.fEvent;
   fUseTH1 = copy.fUseTH1;
@@ -106,9 +103,9 @@ const char* AliRsnFunction::GetName() const
   TString name("");
 
   TObjArrayIter next(&fAxisList);
-  AliRsnFunctionAxis *axis = 0;
+  AliRsnValue *axis = 0;
 
-  while ((axis = (AliRsnFunctionAxis*)next())) {
+  while ((axis = (AliRsnValue*)next())) {
     if (name.Length() > 1) name += '_';
     name += axis->GetName();
   }
@@ -117,15 +114,18 @@ const char* AliRsnFunction::GetName() const
 }
 
 //________________________________________________________________________________________
-void AliRsnFunction::AddAxis(AliRsnFunctionAxis *const axis)
+void AliRsnFunction::AddAxis(AliRsnValue *const axis)
 {
+  AliDebug(AliLog::kDebug+2,"<-");
   Int_t size = fAxisList.GetEntries();
-  if (size >= 3 && fUseTH1)
+  new(fAxisList[size]) AliRsnValue(*axis);
+  AliDebug(AliLog::kDebug+2,"->");
+  
+  if (fAxisList.GetEntries() > 3)
   {
     AliWarning("A TH1-type output cannot add more than 3 axes: switching to THnSparse -- THIS COULD CAUSE VERY LARGE FILES!!!");
     fUseTH1 = kFALSE;
   }
-  new(fAxisList[size]) AliRsnFunctionAxis(*axis);
 }
 
 //________________________________________________________________________________________
@@ -138,7 +138,7 @@ TH1* AliRsnFunction::CreateHistogram(const char *histoName, const char *histoTit
 // even if the bins are equal, since they are defined in this class.
 // Eventually present histoDef's in other slots of array (1, 2) are ignored.
 //
-// This version produces a THnSparseD.
+// This version produces a THnSparseF.
 //
 
   fSize = fAxisList.GetEntries();
@@ -157,9 +157,9 @@ TH1* AliRsnFunction::CreateHistogram(const char *histoName, const char *histoTit
   Double_t *max   = new Double_t[fSize];
 
   // retrieve binnings for main and secondary axes
-  AliRsnFunctionAxis *fcnAxis = 0;
+  AliRsnValue *fcnAxis = 0;
   for (Int_t i = 0; i < fSize; i++) {
-    fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(i);
+    fcnAxis = (AliRsnValue*)fAxisList.At(i);
     if (!fcnAxis) {
       nbins[i] = 0;
       min[i]   = 0.0;
@@ -176,13 +176,13 @@ TH1* AliRsnFunction::CreateHistogram(const char *histoName, const char *histoTit
   switch (fSize)
   {
     case 1:
-      fH1 = new TH1D(histoName, histoTitle, nbins[0], min[0], max[0]);
+      fH1 = new TH1F(histoName, histoTitle, nbins[0], min[0], max[0]);
       break;
     case 2:
-      fH1 = new TH2D(histoName, histoTitle, nbins[0], min[0], max[0], nbins[1], min[1], max[1]);
+      fH1 = new TH2F(histoName, histoTitle, nbins[0], min[0], max[0], nbins[1], min[1], max[1]);
       break;
     case 3:
-      fH1 = new TH3D(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, nbins[0], min[0], max[0], nbins[1], min[1], max[1], nbins[2], min[2], max[2]);
       break;
   }
   fH1->Sumw2();
@@ -191,7 +191,7 @@ TH1* AliRsnFunction::CreateHistogram(const char *histoName, const char *histoTit
 }
 
 //________________________________________________________________________________________
-THnSparseD* AliRsnFunction::CreateHistogramSparse(const char *histoName, const char *histoTitle)
+THnSparseF* AliRsnFunction::CreateHistogramSparse(const char *histoName, const char *histoTitle)
 {
 //
 // Creates and returns the histogram defined using
@@ -200,7 +200,7 @@ THnSparseD* AliRsnFunction::CreateHistogramSparse(const char *histoName, const c
 // even if the bins are equal, since they are defined in this class.
 // Eventually present histoDef's in other slots of array (1, 2) are ignored.
 //
-// This version produces a THnSparseD.
+// This version produces a THnSparseF.
 //
 
   fSize = fAxisList.GetEntries();
@@ -214,9 +214,9 @@ THnSparseD* AliRsnFunction::CreateHistogramSparse(const char *histoName, const c
   Double_t *max   = new Double_t[fSize];
 
   // retrieve binnings for main and secondary axes
-  AliRsnFunctionAxis *fcnAxis = 0;
+  AliRsnValue *fcnAxis = 0;
   for (Int_t i = 0; i < fSize; i++) {
-    fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(i);
+    fcnAxis = (AliRsnValue*)fAxisList.At(i);
     if (!fcnAxis) {
       nbins[i] = 0;
       min[i]   = 0.0;
@@ -236,7 +236,7 @@ THnSparseD* AliRsnFunction::CreateHistogramSparse(const char *histoName, const c
   }
 
   // create histogram
-  fHSparse = new THnSparseD(histoName, histoTitle, size, nbins, min, max);
+  fHSparse = new THnSparseF(histoName, histoTitle, size, nbins, min, max);
   fHSparse->Sumw2();
   
   // clean heap
@@ -260,26 +260,14 @@ Bool_t AliRsnFunction::Fill()
   Int_t  i;
   Double_t *values = new Double_t[fSize];
 
-  AliRsnFunctionAxis *fcnAxis = 0;
+  AliRsnValue *fcnAxis = 0;
   for (i = 0; i < fSize; i++) {
-    fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(i);
+    fcnAxis = (AliRsnValue*)fAxisList.At(i);
     if (!fcnAxis) {
       values[i] = 0.0;
       continue;
     }
-    switch (fcnAxis->GetAxisObject()) {
-    case AliRsnFunctionAxis::kParticle:
-      values[i] = fcnAxis->Eval(fTrack);
-      break;
-    case AliRsnFunctionAxis::kPair:
-      values[i] = fcnAxis->Eval(fPair, fPairDef);
-      break;
-    case AliRsnFunctionAxis::kEvent:
-      values[i] = fcnAxis->Eval(fEvent);
-      break;
-    default:
-      values[i] = 0.0;
-    }
+    if (fcnAxis->Eval(fPair, fPairDef, fEvent)) values[i] = fcnAxis->GetValue();
   }
   
   // fill histogram
@@ -296,19 +284,19 @@ Bool_t AliRsnFunction::Fill()
     {
       case 1:
         {
-          TH1D *h1 = (TH1D*)fH1;
+          TH1F *h1 = (TH1F*)fH1;
           h1->Fill(values[0]);
         }
         break;
       case 2:
         {
-          TH2D *h2 = (TH2D*)fH1;
+          TH2F *h2 = (TH2F*)fH1;
           h2->Fill(values[0], values[1]);
         }
         break;
       case 3:
         {
-          TH3D *h3 = (TH3D*)fH1;
+          TH3F *h3 = (TH3F*)fH1;
           h3->Fill(values[0], values[1], values[2]);
         }
         break;
@@ -321,7 +309,7 @@ Bool_t AliRsnFunction::Fill()
   {
     // check presence of output histogram
     if (!fHSparse) {
-      AliError("Required a THnSparseD whish is not initialized");
+      AliError("Required a THnSparseF which is not initialized");
       return kFALSE;
     }