]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDReconHTA.cxx
Coverity fixed
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDReconHTA.cxx
index 949dd779e083951d075708c54a02aa1a803c3c6d..804ae722231c2d66c4fb377ddcffc4a3138f16f6 100644 (file)
@@ -37,7 +37,7 @@
 Int_t AliHMPIDReconHTA::fgDB[500][150]={{75000*0}};
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 AliHMPIDReconHTA::AliHMPIDReconHTA():
-  TTask("RichRec","RichPat"),
+  TNamed("RichRec","RichPat"),
   fMipX(-999),
   fMipY(-999),
   fMipQ(-999),
@@ -91,11 +91,11 @@ void AliHMPIDReconHTA::DeleteVars()const
 //..
 //Delete variables
 //..
-  if(fXClu) delete fXClu;
-  if(fYClu) delete fYClu;
-  if(fPhiPhot) delete fPhiPhot;
-  if(fThetaPhot) delete fThetaPhot;
-  if(fClCk) delete fClCk;
+  if(fXClu) delete [] fXClu;
+  if(fYClu) delete [] fYClu;
+  if(fPhiPhot) delete [] fPhiPhot;
+  if(fThetaPhot) delete [] fThetaPhot;
+  if(fClCk) delete [] fClCk;
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Bool_t AliHMPIDReconHTA::CkovHiddenTrk(AliESDtrack *pTrk,TClonesArray *pCluLst,Int_t index, Double_t nmean)
@@ -222,12 +222,14 @@ Bool_t AliHMPIDReconHTA::FindShape(Double_t &thTrkRec,Double_t &phiTrkRec,Double
 //              thetaCRec - estimate of ThetaCerenkov
 //              status    - TRUE if a good solution is found, FALSE if not
 
-  Double_t *phiphot = new Double_t[fNClu];  
-  Double_t *dist    = new Double_t[fNClu];  
-  Int_t    *indphi  = new    Int_t[fNClu];  
+  Double_t phiphot[1000];  
+  Double_t    dist[1000];  
+  Int_t     indphi[1000];  
 
   Bool_t status;
     
+  if(fNClu>1000) return kFALSE;  // too many clusters....
+  
 // Sort in phi angle...
   for(Int_t i=0;i<fNClu;i++) {
     if(!fClCk[i]) {
@@ -253,9 +255,10 @@ Bool_t AliHMPIDReconHTA::FindShape(Double_t &thTrkRec,Double_t &phiTrkRec,Double
     dMean2+=dist[indphi[i]]*dist[indphi[i]];
     np++;
   }
-  
-  dMean  /=(Double_t)np;
-  dMean2 /=(Double_t)np;
+  if(np>0){    
+   dMean  /=(Double_t)np;
+   dMean2 /=(Double_t)np;}
   Double_t rms = TMath::Sqrt(dMean2 - dMean*dMean);
   
   for(Int_t i=0;i<fNClu;i++) {
@@ -281,10 +284,6 @@ Bool_t AliHMPIDReconHTA::FindShape(Double_t &thTrkRec,Double_t &phiTrkRec,Double
     npeff++;
   }
   
-  delete [] phiphot;
-  delete [] dist;
-  delete [] indphi;
-
   if(npeff<3) {
     AliDebug(1,Form("FindShape failed: no enough photons = %i...",npeff));
     delete [] phiphotP;
@@ -705,6 +704,10 @@ Int_t AliHMPIDReconHTA::r2(Double_t *coef, Double_t &x1, Double_t &x2)
     x1=x2=-b/(2*a);
     return 1;
   }
+  if(a==0) {
+    x1 = -c/b;
+    return 1;
+  }
   // delta>0
   x1 = (-b+TMath::Sqrt(delta))/(2*a);
   x2 = (-b-TMath::Sqrt(delta))/(2*a);
@@ -753,8 +756,10 @@ Double_t AliHMPIDReconHTA::FindSimmPhi()
   
   //_____calc. met min quadr using effective distance _________________________________________________
   
-  coeff2ord = xy-xrotsumm*yrotsumm/np;    
-  coeff1ord = yrotsumm*yrotsumm/np - xrotsumm*xrotsumm/np - yy + xx;
+  if(np>0){ 
+    coeff2ord = xy-xrotsumm*yrotsumm/np;    
+    coeff1ord = yrotsumm*yrotsumm/np - xrotsumm*xrotsumm/np - yy + xx;
+  }
   coeff0ord = -coeff2ord;
   
   AliDebug(1,Form(" a = %f b = %f c = %f",coeff2ord,coeff1ord,coeff0ord));
@@ -765,8 +770,9 @@ Double_t AliHMPIDReconHTA::FindSimmPhi()
   
   r2(coeff,m1,m2);
   
-  n1=(yrotsumm-m1*xrotsumm)/np;                         
-  n2=(yrotsumm-m2*xrotsumm)/np;
+  if(np>0){ 
+    n1=(yrotsumm-m1*xrotsumm)/np;                         
+    n2=(yrotsumm-m2*xrotsumm)/np;}
   // 2 solutions.................
   
   // negative angles solved...
@@ -857,6 +863,7 @@ Bool_t AliHMPIDReconHTA::UniformDistrib()
    Double_t chi2 = 0;
    for(Int_t i=0;i<nPhiBins;i++) {
      Double_t theo = (Double_t)npeff/(Double_t)nPhiBins;
+     if(theo==0) continue;
      chi2+= (iPhiBin[i] - theo)*(iPhiBin[i] - theo)/theo;
    }