]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/FORWARD/analysis2/AliFMDCorrELossFit.cxx
Coverity fixes
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliFMDCorrELossFit.cxx
index 626912960bdf12bf867fc3ef10d5f882f88afe38..3991420b80e6e1e823fe8be84b3006fdbdf9e80e 100644 (file)
@@ -15,7 +15,7 @@
 #include <iostream>
 #include <iomanip>
 
-Double_t AliFMDCorrELossFit::ELossFit::fgMaxRelError = .2;
+Double_t AliFMDCorrELossFit::ELossFit::fgMaxRelError = .12;
 Double_t AliFMDCorrELossFit::ELossFit::fgLeastWeight = 1e-5;
 Double_t AliFMDCorrELossFit::ELossFit::fgMaxChi2nu   = 20;
 
@@ -49,7 +49,7 @@ AliFMDCorrELossFit::ELossFit::ELossFit()
 //____________________________________________________________________
 AliFMDCorrELossFit::ELossFit::ELossFit(Int_t quality, const TF1& f)
   : fN(f.GetNpar() > AliForwardUtil::ELossFitter::kN ? 
-       f.GetParameter(AliForwardUtil::ELossFitter::kN) : 
+       Int_t(f.GetParameter(AliForwardUtil::ELossFitter::kN)) : 
        1),
     fNu(f.GetNDF()),
     fChi2(f.GetChisquare()),
@@ -96,7 +96,7 @@ AliFMDCorrELossFit::ELossFit::ELossFit(Int_t     quality,UShort_t  n,
                                       Double_t  xi,     Double_t  exi,
                                       Double_t  sigma,  Double_t  esigma, 
                                       Double_t  sigman, Double_t  esigman, 
-                                      Double_t* a,      Double_t* ea)
+                                      const Double_t* a,const Double_t* ea)
   : fN(n),
     fNu(nu),
     fChi2(chi2),
@@ -512,6 +512,17 @@ AliFMDCorrELossFit::ELossFit::Draw(Option_t* option)
 //____________________________________________________________________
 #define CHECKPAR(V,E,T) ((V > 0) && (E / V < T))
 
+//____________________________________________________________________
+Double_t
+AliFMDCorrELossFit::ELossFit::GetLowerBound(Double_t f, 
+                                           Bool_t includeSigma) const
+{
+  // 
+  // Return 
+  //    Delta - f * (xi + sigma)
+  return fDelta - f * (fXi + (includeSigma ? fSigma : 0));
+}
+
 //____________________________________________________________________
 void 
 AliFMDCorrELossFit::ELossFit::CalculateQuality(Double_t maxChi2nu, 
@@ -606,7 +617,8 @@ AliFMDCorrELossFit::FindEtaBin(Double_t eta) const
   //    Bin (in @f$[1,N_{bins}]@f$) corresponding to the given
   // eta, or 0 if out of range.
   //
-  if (fEtaAxis.GetXmin() == fEtaAxis.GetXmax() || fEtaAxis.GetNbins() == 0) {
+  if (TMath::Abs(fEtaAxis.GetXmin() - fEtaAxis.GetXmax()) < 1e-6 
+      || fEtaAxis.GetNbins() == 0) {
     AliWarning("No eta axis defined");
     return -1;
   }
@@ -803,24 +815,24 @@ AliFMDCorrELossFit::FindFit(UShort_t  d, Char_t r, Int_t etabin) const
     return 0;
   }
   if (etabin <= 0 || etabin >= fEtaAxis.GetNbins()) { 
-    AliError(Form("Eta bin=%3d out of bounds [%d,%d] for FMD%d%c", 
-                 etabin, 1, fEtaAxis.GetNbins(), d, r));
+    // AliError(Form("Eta bin=%3d out of bounds [%d,%d] for FMD%d%c", 
+    //              etabin, 1, fEtaAxis.GetNbins(), d, r));
     return 0;
   }
   if (etabin > ringArray->GetEntriesFast()) { 
-    AliError(Form("Eta bin=%3d out of bounds [%d,%d] for FMD%d%c", 
-                 etabin, 1, ringArray->GetEntriesFast(), d, r));
+    // AliError(Form("Eta bin=%3d out of bounds [%d,%d] for FMD%d%c", 
+    //                      etabin, 1, ringArray->GetEntriesFast(), d, r));
     return 0;
   }
   else if (etabin >= ringArray->GetEntriesFast()) { 
-    AliWarning(Form("Eta bin=%3d out of bounds by +1 [%d,%d] for FMD%d%c, " 
-                   "trying %3d", etabin, 1, ringArray->GetEntriesFast(), d, r,
-                   etabin-1));
+    // AliWarning(Form("Eta bin=%3d out of bounds by +1 [%d,%d] for FMD%d%c, " 
+    //             "trying %3d", etabin, 1, ringArray->GetEntriesFast(), d, r,
+    //             etabin-1));
     etabin--;
   }
   else if (!ringArray->At(etabin)) { 
-    AliWarning(Form("Eta bin=%d has no fit for FMD%d%c, trying %03d", 
-                   etabin, d, r, etabin+1));
+    // AliWarning(Form("Eta bin=%d has no fit for FMD%d%c, trying %03d", 
+    //                     etabin, d, r, etabin+1));
     etabin++;
   }
   return static_cast<ELossFit*>(ringArray->At(etabin));
@@ -897,6 +909,38 @@ AliFMDCorrELossFit::GetOrMakeRingArray(UShort_t d, Char_t r)
   return static_cast<TObjArray*>(fRings.At(idx));
 }
 
+//____________________________________________________________________
+Double_t
+AliFMDCorrELossFit::GetLowerBound(UShort_t  d, Char_t r, Int_t etabin,
+                                 Double_t f, Bool_t showErrors, 
+                                 Bool_t includeSigma) const
+{
+  ELossFit* fit = GetFit(d, r, etabin);
+  if (!fit) { 
+    if (showErrors) {
+      AliWarning(Form("No fit for FMD%d%c @ etabin=%d", d, r, etabin));
+    }
+    return -1024;
+  }
+  return fit->GetLowerBound(f, includeSigma);
+}
+
+//____________________________________________________________________
+Double_t
+AliFMDCorrELossFit::GetLowerBound(UShort_t  d, Char_t r, Double_t eta,
+                                 Double_t f, Bool_t showErrors, 
+                                 Bool_t includeSigma) const
+{
+  Int_t bin = FindEtaBin(eta);
+  if (bin <= 0) { 
+    if (showErrors)
+      AliError(Form("eta=%f out of bounds for FMD%d%c", eta, d, r));
+    return -1024;
+  }
+  return GetLowerBound(d, r, bin, f, showErrors, includeSigma);
+}
+
+//____________________________________________________________________
 namespace { 
   TH1D* MakeHist(const TAxis& axis, const char* name, const char* title, 
                 Int_t color)
@@ -915,6 +959,8 @@ namespace {
   }
 }
 
+  
+
 #define IDX2RING(I) (i == 0 || i == 1 || i == 3 ? 'I' : 'O')
 #define IDX2DET(I)  (i == 0 ? 1 : (i == 1 || i == 2 ? 2 : 3))
 //____________________________________________________________________
@@ -1136,6 +1182,14 @@ AliFMDCorrELossFit::Draw(Option_t* option)
 void
 AliFMDCorrELossFit::Print(Option_t* option) const
 {
+  // 
+  // Print this object.  
+  // 
+  // Parameters:
+  //    option Options 
+  //   - R   Print recursive  
+  //
+  //
   TString opt(option);
   opt.ToUpper();
   Int_t nRings = fRings.GetEntriesFast();