Fix Coverity 10982
authorakisiel <akisiel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 3 Feb 2011 12:53:07 +0000 (12:53 +0000)
committerakisiel <akisiel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 3 Feb 2011 12:53:07 +0000 (12:53 +0000)
PWG2/FEMTOSCOPY/AliFemto/AliFemtoAnalysisAzimuthal.cxx

index 726316c..82a24e1 100644 (file)
@@ -406,16 +406,21 @@ TVector2 AliFemtoAnalysisAzimuthal::GetQVector(AliFemtoParticleCollection* parti
   TVector2 mQ;
   float mQx=0, mQy=0;
 
-      AliFemtoParticle* flowparticle;
-      AliFemtoParticleIterator pIter;
-      AliFemtoParticleIterator startLoop = particlecollection->begin();
-      AliFemtoParticleIterator endLoop   = particlecollection->end();
-      for (pIter=startLoop;pIter!=endLoop;pIter++){
-       flowparticle = *pIter;
-       mQx += (cos(2*flowparticle->FourMomentum().Phi()))*(flowparticle->Track()->Pt());
-       mQy += (sin(2*flowparticle->FourMomentum().Phi()))*(flowparticle->Track()->Pt());
-      }
+  if (!particlecollection) {
+    mQ.Set(0.0, 0.0);
+    return mQ;
+  }
 
+  AliFemtoParticle* flowparticle;
+  AliFemtoParticleIterator pIter;
+  AliFemtoParticleIterator startLoop = particlecollection->begin();
+  AliFemtoParticleIterator endLoop   = particlecollection->end();
+  for (pIter=startLoop;pIter!=endLoop;pIter++){
+    flowparticle = *pIter;
+    mQx += (cos(2*flowparticle->FourMomentum().Phi()))*(flowparticle->Track()->Pt());
+    mQy += (sin(2*flowparticle->FourMomentum().Phi()))*(flowparticle->Track()->Pt());
+  }
+  
   mQ.Set(mQx,mQy);
   return mQ;
 }