In AliMUONAlignment: Coverity fixes
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 25 Jan 2012 15:03:06 +0000 (15:03 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 25 Jan 2012 15:03:06 +0000 (15:03 +0000)
(Javier)

MUON/AliMUONAlignment.cxx

index 7f99b62..8c25728 100644 (file)
@@ -496,14 +496,19 @@ void AliMUONAlignment::AddConstraints(const Bool_t *lChOnOff, const Bool_t *lVar
       }
     }
   }
-  lMeanY /= lNDetElem;
-  lSigmaY /= lNDetElem;
-  lSigmaY = TMath::Sqrt(lSigmaY-lMeanY*lMeanY);
-  lMeanZ /= lNDetElem;
-  lSigmaZ /= lNDetElem;
-  lSigmaZ = TMath::Sqrt(lSigmaZ-lMeanZ*lMeanZ);
-  AliInfo(Form("Used %i DetElem, MeanZ= %f , SigmaZ= %f", lNDetElem,lMeanZ,lSigmaZ));
-
+  if (lNDetElem) {
+    lMeanY /= lNDetElem;
+    lSigmaY /= lNDetElem;
+    lSigmaY = TMath::Sqrt(lSigmaY-lMeanY*lMeanY);
+    lMeanZ /= lNDetElem;
+    lSigmaZ /= lNDetElem;
+    lSigmaZ = TMath::Sqrt(lSigmaZ-lMeanZ*lMeanZ);
+     AliInfo(Form("Used %i DetElem, MeanZ= %f , SigmaZ= %f", lNDetElem,lMeanZ,lSigmaZ));
+  } else {
+    AliError("No detection elements to constrain!!!");
+    return;    
+  }
+               
   for (Int_t i = 0; i < fgNDetElem; i++){
     Int_t iCh=0;
     for (iCh=1; iCh<=fgNCh; iCh++){