]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Corrections after survey of Coverity tests
authorpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 27 Sep 2010 17:16:03 +0000 (17:16 +0000)
committerpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 27 Sep 2010 17:16:03 +0000 (17:16 +0000)
14 files changed:
PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx
PWG2/RESONANCES/AliRsnAnalysisMonitorTask.cxx
PWG2/RESONANCES/AliRsnCut.cxx
PWG2/RESONANCES/AliRsnCutBetheBloch.cxx
PWG2/RESONANCES/AliRsnCutDaughterType.cxx
PWG2/RESONANCES/AliRsnCutESD2010.cxx
PWG2/RESONANCES/AliRsnCutPID.cxx
PWG2/RESONANCES/AliRsnDaughter.cxx
PWG2/RESONANCES/AliRsnEvent.cxx
PWG2/RESONANCES/AliRsnFunction.cxx
PWG2/RESONANCES/AliRsnPairFunctions.cxx
PWG2/RESONANCES/AliRsnValue.cxx
PWG2/RESONANCES/macros/test/ConfigTaskRsnTest.C
PWG2/RESONANCES/macros/test/runLocal.C

index 8a283081131adaba705d79930730a5fe425cca56..5801f2573b956d60f13badfcb455eee5ee8ba5a8 100644 (file)
@@ -111,7 +111,7 @@ void AliRsnAnalysisEffSE::RsnUserCreateOutputObjects()
   AliDebug(AliLog::kDebug+2,"<-");
 
   // get number of steps and axes
-  Int_t iaxis;
+  Int_t iaxis  = 0;
   Int_t nAxes  = fAxisList.GetEntries();
   Int_t nSteps = (Int_t)fStepListMC.GetEntries() + (Int_t)fStepListESD.GetEntries();
 
@@ -128,14 +128,11 @@ void AliRsnAnalysisEffSE::RsnUserCreateOutputObjects()
   fVar.Set(nAxes);
 
   // retrieve number of bins for each axis
-  Int_t   *nBins = new Int_t[nAxes];
-  TArrayD *array = new TArrayD[nAxes];
+  Int_t *nBins = new Int_t[nAxes];
   for (iaxis = 0; iaxis < nAxes; iaxis++) 
   {
     AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis);
-    fcnAxis->Print(); 
-    array[iaxis] = fcnAxis->GetArray();
-    nBins[iaxis] = array[iaxis].GetSize() - 1;
+    nBins[iaxis] = fcnAxis->GetArray().GetSize() - 1;
   }
 
   // create ouput list of containers
@@ -149,13 +146,17 @@ void AliRsnAnalysisEffSE::RsnUserCreateOutputObjects()
   fOutList->SetOwner();
 
   // create the containers
-  Int_t i, nDef = (Int_t)fPairDefList.GetEntries();
+  Int_t i = 0, nDef = (Int_t)fPairDefList.GetEntries();
   for (i = 0; i < nDef; i++) 
   {
     AliRsnPairDef *def = (AliRsnPairDef*)fPairDefList[i];
     AliCFContainer *cont = new AliCFContainer(Form("%s", def->GetPairName()), "", nSteps, nAxes, nBins);
     // set the bin limits for each axis
-    for (iaxis = 0; iaxis < nAxes; iaxis++) cont->SetBinLimits(iaxis, array[iaxis].GetArray());
+    for (iaxis = 0; iaxis < nAxes; iaxis++) 
+    {
+      AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis);
+      cont->SetBinLimits(iaxis, fcnAxis->GetArray().GetArray());
+    }
     // add the container to output list
     fContainerList->Add(cont);
   }
@@ -164,6 +165,9 @@ void AliRsnAnalysisEffSE::RsnUserCreateOutputObjects()
   fOutList->Print();
 
   PostData(2, fOutList);
+  
+  // clear heap
+  delete [] nBins;
 
   AliDebug(AliLog::kDebug+2,"->");
 }
index 6ae21fe45f4b08f54a85ade2e4752f7e502928d1..f548e83282b1a7048ad8a08c6a46c16247bf1acc 100644 (file)
@@ -156,7 +156,11 @@ void AliRsnAnalysisMonitorTask::UserExec(Option_t *)
 
   // retrieve ESD event and related stack (if available)
   AliESDEvent *esd   = dynamic_cast<AliESDEvent*>(fInputEvent);
-  AliStack    *stack = (fMCEvent ? fMCEvent->Stack() : 0x0);
+  AliStack    *stack = 0x0;
+  
+  // skip NULL events
+  if (!esd) return;
+  if (fMCEvent) stack = fMCEvent->Stack();
   
   // check the event
   EventEval(esd);
index b8f92541c852b01d1b9d8be45ea6e6aa9852cb9f..4d618dca1ce25d727947a462ba8e08b3ba3cca21 100644 (file)
@@ -356,11 +356,11 @@ void AliRsnCut::Print(Option_t*) const
   Char_t target[100];
   switch (fTarget)
   {
-    case kDaughter: sprintf(target, "DAUGHTER"); break;
-    case kMother  : sprintf(target, "MOTHER"); break;
-    case kEvent   : sprintf(target, "EVENT"); break;
-    case kMixEvent: sprintf(target, "MIX EVENT"); break;
-    default       : sprintf(target, "UNDEFINED"); break;
+    case kDaughter: snprintf(target, strlen("DAUGHTER") , "DAUGHTER") ; break;
+    case kMother  : snprintf(target, strlen("MOTHER")   , "MOTHER")   ; break;
+    case kEvent   : snprintf(target, strlen("EVENT")    , "EVENT")    ; break;
+    case kMixEvent: snprintf(target, strlen("MIX EVENT"), "MIX EVENT"); break;
+    default       : snprintf(target, strlen("UNDEFINED"), "UNDEFINED"); break;
   }
 
   AliInfo("=== CUT DETAILS ====================================");
index 5f3cbf12efb18deaa22e79a623fbe70028274662..619042c7284b0b32c9028fff221e731ad06b5044 100644 (file)
@@ -116,15 +116,13 @@ Bool_t AliRsnCutBetheBloch::IsSelected(TObject *obj1, TObject* /*obj2*/)
 // Cut checker.
 //
 
-  // coherence check
-  if (!AliRsnCut::TargetOK(obj1))
+  // dynamic cast the object into AliRsnDaughter
+  AliRsnDaughter *track = dynamic_cast<AliRsnDaughter*>(obj1);
+  if (!track)
   {
-    AliError(Form("Wrong target '%s'. Skipping cut", GetName()));
+    AliError(Form("[%s]: this cut works only with AliRsnDaughter objects", GetName()));
     return kTRUE;
   }
-  
-  // dynamic cast the object into AliRsnDaughter
-  AliRsnDaughter *track = dynamic_cast<AliRsnDaughter*>(obj1);
 
   // retrieve the TPC signal
   AliESDtrack *esd = track->GetRefESDtrack();
index f73a1a49894727669c72fcb1fa152a1eeec31060..aa834d3d8278d0f0b4b297a8e69e99453c9418ef 100644 (file)
@@ -65,7 +65,7 @@ Bool_t AliRsnCutDaughterType::IsSelected(TObject *obj1, TObject* /*obj2*/)
     case kTrackTPC:
       return ((status & AliESDtrack::kTPCin)  != 0);
     case kTrackITSSA:
-      if (esdT)
+      if (esdT && track)
       {
         UChar_t itsCluMap = track->GetITSClusterMap();
         Int_t   k, nITS   = 0;
index d801e78d07fc679711b6dfbd7102e0fc4c225689..9debdaf5859de50eb17b534003c0eff03b0c6086 100644 (file)
@@ -58,6 +58,9 @@ AliRsnCutESD2010::AliRsnCutESD2010() :
 //
 // Default constructor.
 //
+
+  Int_t i = 0;
+  for (i = 0; i < 5; i++) fTPCpar[i] = 0.0;
 }
 
 //_________________________________________________________________________________________________
@@ -89,6 +92,9 @@ AliRsnCutESD2010::AliRsnCutESD2010
 //
 // Main constructor.
 //
+
+  Int_t i = 0;
+  for (i = 0; i < 5; i++) fTPCpar[i] = 0.0;
 }
 
 //_________________________________________________________________________________________________
@@ -120,6 +126,9 @@ AliRsnCutESD2010::AliRsnCutESD2010
 //
 // Main constructor.
 //
+
+  Int_t i = 0;
+  for (i = 0; i < 5; i++) fTPCpar[i] = copy.fTPCpar[i];
 }
 
 //_________________________________________________________________________________________________
index d01c6910142afcf785a9a216de3feca08497eb51..094d05e5619713869ffb0b40e4555065a2a072d5 100644 (file)
@@ -257,16 +257,14 @@ Bool_t AliRsnCutPID::IsSelected(TObject *obj1, TObject* /*obj2*/)
 //
 // Cut checker.
 //
-
-  // coherence check
-  if (!AliRsnCut::TargetOK(obj1))
-  {
-    AliError(Form("Wrong target '%s'. Skipping cut", GetName()));
-    return kTRUE;
-  }
   
   // convert the object into the unique correct type
   AliRsnDaughter *daughter = dynamic_cast<AliRsnDaughter*>(obj1);
+  if (!daughter)
+  {
+    AliError(Form("[%s]: this cut works only with AliRsnDaughter objects", GetName()));
+    return kTRUE;
+  }
   
   // depending on the PID type, recalls the appropriate method:
   // in case of perfect PID, checks only if the PID type is 
index ca966938ff3be5d6002b5b72da51d6d5d521850f..10cee1488004f0e118f177985d647e230fa2c612 100644 (file)
@@ -128,14 +128,14 @@ void AliRsnDaughter::Print(Option_t * const /*option*/) const
 //
   
   Char_t type[50], source[50];
-  if (IsTrack()) sprintf(type, "track");
-  else if (IsV0()) sprintf(type, "V0");
-  else sprintf(type, "none");
+  if (IsTrack()) snprintf(type, 5, "track");
+  else if (IsV0()) snprintf(type, 2, "V0");
+  else snprintf(type, 4, "none");
   
-  if (IsESD()) sprintf(source, "ESD");
-  else if (IsAOD()) sprintf(source, "AOD");
-  else if (fRefMC != 0x0) sprintf(source, "MC only");
-  else sprintf(source, "none");
+  if (IsESD()) snprintf(source, 3, "ESD");
+  else if (IsAOD()) snprintf(source, 3, "AOD");
+  else if (fRefMC != 0x0) snprintf(source, 7, "MC only");
+  else snprintf(source, 4, "none");
   
   AliInfo("===== ALIRSNDAUGHTER INFORMATION ==============================================");
   AliInfo(Form(".......Index                  : %d", GetID()));
index 540829a00f97db290c2547c3fba1525224241036..a14936918f8515f4402aa167ab3e5af3d42dbfd0 100644 (file)
@@ -95,7 +95,6 @@ Bool_t AliRsnEvent::SetDaughter(AliRsnDaughter &out, Int_t i, AliRsnDaughter::ER
       return kFALSE;
     }
     AliVTrack *track = (AliVTrack*)fRef->GetTrack(i);
-    label = TMath::Abs(track->GetLabel());
     if (!track)
     {
       out.SetBad();
@@ -103,6 +102,7 @@ Bool_t AliRsnEvent::SetDaughter(AliRsnDaughter &out, Int_t i, AliRsnDaughter::ER
     }
     else
     {
+      label = TMath::Abs(track->GetLabel());
       out.SetRef(track);
       out.SetLabel(label);
       if (fRefMC)
@@ -396,4 +396,4 @@ Bool_t AliRsnEvent::GetAngleDistr
   angleRMS = TMath::Sqrt(angle2Mean - angleMean * angleMean);
 
   return kTRUE;
-}
\ No newline at end of file
+}
index a476ed518a28e82769f5b5ebbd7831e8d60e353c..a1c97aaa0236499d15843b362c89fa5bdfba1675 100644 (file)
@@ -262,7 +262,8 @@ Bool_t AliRsnFunction::Fill()
   AliRsnValue *fcnAxis = 0;
   for (i = 0; i < fSize; i++) {
     fcnAxis = (AliRsnValue*)fAxisList.At(i);
-    if (!fcnAxis) {
+    if (!fcnAxis) 
+    {
       values[i] = 0.0;
       continue;
     }
@@ -274,7 +275,8 @@ Bool_t AliRsnFunction::Fill()
   {
     // 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;
     }
     
@@ -301,6 +303,7 @@ Bool_t AliRsnFunction::Fill()
         break;
       default:
         AliError(Form("Wrong size : %d", fSize));
+        delete [] values;
         return kFALSE;
     }
   }
index 1bbe267d4e6ba217015b0e26eb1c33da76daa8ae..9b2944f45edd1b74ace93b67fc18c0074d86c4d9 100644 (file)
@@ -118,15 +118,18 @@ void AliRsnPairFunctions::Init(const char *prefix, TList *list)
   AliDebug(AliLog::kDebug+2,"<-");
 
   Int_t  i;
-  Char_t hName[255];
+  TString hName("");
   AliRsnFunction *fcn = 0;
   for (i = 0; i < fFunctions.GetEntries(); i++)
   {
     fcn = (AliRsnFunction*)fFunctions.At(i);
-    sprintf(hName, "%s_%s_%s", prefix, GetName(), fcn->GetName());
-
-    if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName, ""));
-    else list->Add(fcn->CreateHistogramSparse(hName, ""));
+    hName += prefix;
+    hName += '_';
+    hName += GetName();
+    hName += '_';
+    hName += fcn->GetName();
+    if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), ""));
+    else list->Add(fcn->CreateHistogramSparse(hName.Data(), ""));
   }
 
   AliDebug(AliLog::kDebug+2,"->");
index df9493159b39de88067d67975089587aeb9b4c9a..143bdefb48ff27f4e0bfa909d8f2bd2fcb3445b3 100644 (file)
@@ -224,14 +224,23 @@ Bool_t AliRsnValue::Eval(AliRsnMother * const mother, AliRsnPairDef * const pair
          while(fValue >= TMath::Pi()) fValue -= 2*TMath::Pi();
          while(fValue < -0.5*TMath::Pi()) fValue += 2*TMath::Pi();
          //Printf("%g", fValue);
-
       }
       break;
     case kEventMult:
-      if (!event) fValue = 0.0;
-      fValue = (Double_t)event->GetMultiplicity();
+      if (!event) 
+      {
+        fValue = 0.0;
+        return kFALSE;
+      }
+      else fValue = (Double_t)event->GetMultiplicity();
       break;
     case kLeadingPt:
+      if (!event) 
+      {
+        fValue = 0.0;
+        return kFALSE;
+      }
+      else
       {
          int leadingID = event->SelectLeadingParticle(0);
          if(leadingID >= 0) {
@@ -272,6 +281,31 @@ Bool_t AliRsnValue::Eval(AliRsnDaughter * const daughter, AliRsnEvent * const ev
 
   switch (fType)
   {
+    case kEventMult:
+      if (!event) 
+      {
+        fValue = 0.0;
+        return kFALSE;
+      }
+      else fValue = (Double_t)event->GetMultiplicity();
+      break;
+    case kLeadingPt:
+      if (!event) 
+      {
+        fValue = 0.0;
+        return kFALSE;
+      }
+      else
+      {
+         int leadingID = event->SelectLeadingParticle(0);
+         if(leadingID >= 0) {
+                 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
+                 AliVParticle *ref = leadingPart.GetRef();
+                 fValue = ref->Pt();
+         }
+         else fValue = 0;
+      }
+      break;
     default:
       AliWarning("Invalid value type");
       return kFALSE;
index e46dcab510e45b778bb9c2cbbd70a80e7b6448e9..488c0af769e25275ae7b643388f2723c9b7e7214 100644 (file)
@@ -85,7 +85,7 @@ Bool_t RsnConfigTask(AliRsnAnalysisSE* &task, const char *dataLabel)
   cuts2010->GetCutsTPC()->SetDCAToVertex2D(kFALSE); // each DCA is checked separately
   cuts2010->GetCutsTPC()->SetRequireSigmaToVertex(kFALSE);
   // ----> set standard quality cuts for ITS standalone tracks
-  cuts2010->GetCutsITS()->SetRequireITSStandAlone(kTRUE, kTRUE);
+  cuts2010->GetCutsITS()->SetRequireITSStandAlone(kTRUE);
   cuts2010->GetCutsITS()->SetRequireITSRefit(kTRUE);
   cuts2010->GetCutsITS()->SetMinNClustersITS(4);
   cuts2010->GetCutsITS()->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
index 70c4d678c91e40f14f23cfcd3abc0fdf70db240c..fec5c40a9ede8df95810b567cbbce993fd905239 100644 (file)
@@ -28,7 +28,7 @@ void runLocal
 (
   Int_t       nReadFiles  = 0,
   Int_t       nSkipFiles  = 0,
-  const char *addTaskName = "AddAnalysisTaskRsnTest.C:AddAnalysisTaskRsnEff.C",
+  const char *addTaskName = "AddAnalysisTaskRsnTest.C",
   const char *inputSource = "/home/pulvir/analysis/resonances/LHC2010-7TeV-phi/alien+plugin/sim.txt",
   const char *dataLabel   = "7TeV_pass2_sim_ESD",
   const char *outName     = "rsn-test"