]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGLF/RESONANCES/AliRsnListOutput.cxx
Fix for coverity 24399, 24400, 24401
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnListOutput.cxx
index 516914b7650d6f4dbad5e30c721d105b82ea6923..29f2b5dfe08b92cf25f128746d45db46a14e56e1 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "AliRsnListOutput.h"
 
-
 ClassImp(AliRsnListOutput)
 
 //________________________________________________________________________________________
@@ -46,6 +45,7 @@ AliRsnListOutput::AliRsnListOutput(const char *name, AliRsnListOutput::EOut type
    fNValues(0),
    fList(0x0),
    fIndex(-1),
+   fCheckHistRange(kTRUE),
    fArray(0)
 {
 //
@@ -65,6 +65,7 @@ AliRsnListOutput::AliRsnListOutput(const AliRsnListOutput &copy) :
    fNValues(copy.fNValues),
    fList(copy.fList),
    fIndex(copy.fIndex),
+   fCheckHistRange(copy.fCheckHistRange),
    fArray(0)
 {
 //
@@ -94,6 +95,7 @@ AliRsnListOutput &AliRsnListOutput::operator=(const AliRsnListOutput &copy)
    fNValues = copy.fNValues;
    fList = copy.fList;
    fIndex = copy.fIndex;
+   fCheckHistRange = copy.fCheckHistRange;
    fArray = copy.fArray;
 
    Reset();
@@ -164,8 +166,17 @@ Bool_t AliRsnListOutput::Init(const char *prefix, TList *list)
    // resize the output array
    fArray.Set(fNValues);
 
+
+   Bool_t isPair=kFALSE;
+
    // create the name
-   TString name(Form("%s_%s", prefix, GetName()));
+   TString name(GetName());
+   if (!name.CompareTo("pair")) isPair = kTRUE;
+   if (isPair) name = "";
+   else name.Prepend(".");
+   name.Prepend(prefix);
+
+//    TString name(Form("%s.%s", prefix, GetName()));
    AliRsnValue *val = 0x0;
    for (i = 0; i < fNValues; i++) {
       val = GetValue(i);
@@ -173,8 +184,10 @@ Bool_t AliRsnListOutput::Init(const char *prefix, TList *list)
          AliError(Form("Slot %d in value list is NULL", i));
          return kFALSE;
       }
-      name += '_';
-      name += val->GetName();
+      if (!isPair) {
+         name += '_';
+         name += val->GetName();
+      }
    }
 
    // allowed objects
@@ -184,15 +197,15 @@ Bool_t AliRsnListOutput::Init(const char *prefix, TList *list)
    // and, if successful, insert into the list
    switch (fType) {
       case kHistoDefault:
-         name.Append("_hist");
+//          name.Append("_hist");
          object = CreateHistogram(name.Data());
          break;
       case kHistoSparse:
-         name.Append("_hsparse");
+//          name.Append("_hsparse");
          object = CreateHistogramSparse(name.Data());
          break;
       case kCFContainer:
-         name.Append("_cf");
+//          name.Append("_cf");
          object = CreateCFContainer(name.Data());
          break;
       default:
@@ -276,7 +289,10 @@ THnSparseF *AliRsnListOutput::CreateHistogramSparse(const char *name)
    hist->Sumw2();
 
    // update the various axes using the definitions given in the array of axes here
+   AliRsnValue *val = 0x0;
    for (i = 0; i < fNValues; i++) {
+      val = GetValue(i);
+      if (val) hist->GetAxis(i)->SetName(val->GetName());
       hist->GetAxis(i)->Set(nbins[i], array[i].GetArray());
    }
 
@@ -375,6 +391,11 @@ Bool_t AliRsnListOutput::Fill(TObject *target, Int_t step)
       return kTRUE;
    } else if (obj->InheritsFrom(THnSparse::Class())) {
       THnSparseF *h = (THnSparseF *)obj;
+      if (fCheckHistRange) {
+         for (Int_t iAxis = 0; iAxis<h->GetNdimensions(); iAxis++) {
+            if (fArray.At(iAxis)>h->GetAxis(iAxis)->GetXmax() || fArray.At(iAxis)<h->GetAxis(iAxis)->GetXmin()) return kFALSE;
+         }
+      }
       h->Fill(fArray.GetArray());
       return kTRUE;
    } else if (obj->InheritsFrom(AliCFContainer::Class())) {
@@ -441,6 +462,11 @@ Bool_t AliRsnListOutput::Fill(AliRsnEvent *ev, AliRsnDaughter *d)
       return kTRUE;
    } else if (obj->InheritsFrom(THnSparse::Class())) {
       THnSparseF *h = (THnSparseF *)obj;
+      if (fCheckHistRange) {
+         for (Int_t iAxis = 0; iAxis<h->GetNdimensions(); iAxis++) {
+            if (values[iAxis]>h->GetAxis(iAxis)->GetXmax() || values[iAxis]<h->GetAxis(iAxis)->GetXmin()) return kFALSE;
+         }
+      }
       h->Fill(values);
       return kTRUE;
    } else {