]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGGA/EMCALTasks/AliEmcalParticle.cxx
coverty
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / AliEmcalParticle.cxx
index ad6a6519a0aea46254b2f98a30fc531e659eb766..12e27035ab4377da98e226d21e35df56c13fece3 100644 (file)
@@ -37,8 +37,10 @@ AliEmcalParticle::AliEmcalParticle(TObject *particle, Int_t id, Double_t vx, Dou
 {
   // Constructor.
 
-  if (!particle)
+  if (!particle) {
     AliWarning("Null pointer passed as particle.");
+    return;
+  }
 
   fTrack = dynamic_cast<AliVTrack*>(particle);
   if (fTrack) {
@@ -47,15 +49,20 @@ AliEmcalParticle::AliEmcalParticle(TObject *particle, Int_t id, Double_t vx, Dou
     fPt = fTrack->Pt();
   } else {
     fCluster = dynamic_cast<AliVCluster*>(particle);
-    Double_t vtx[3]; vtx[0]=vx;vtx[1]=vy;vtx[2]=vz;
-    TLorentzVector vect;
-    fCluster->GetMomentum(vect, vtx);
-    fEta = vect.Eta();
-    fPhi = vect.Phi();
-    fPt  = vect.Pt();
+    if (fCluster) {
+      Double_t vtx[3]; vtx[0]=vx;vtx[1]=vy;vtx[2]=vz;
+      TLorentzVector vect;
+      fCluster->GetMomentum(vect, vtx);
+      fEta = vect.Eta();
+      fPhi = vect.Phi();
+      fPt  = vect.Pt();
+    }
   }
-  if (!fTrack && !fCluster)
+
+  if (!fTrack && !fCluster) {
     AliWarning("Particle type not recognized (not AliVTrack nor AliVCluster).");
+    return;
+  }
 
   ResetMatchedObjects();
 }