]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSTrackSegmentMakerv1.cxx
Coverity fix.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTrackSegmentMakerv1.cxx
index 74827e13ae3ce397f1ccf8ddd7dbed75ea72db2b..2dc7037b1bfb7e87e8de9fc8ab20a9b13e46c26c 100644 (file)
@@ -149,7 +149,7 @@ AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() :
   fNTrackSegments(0),
   fRcpv(0.f),
   fRtpc(0.f),
-  fVtx(0.f), 
+  fVtx(0.f,0.f,0.f), 
   fLinkUpArray(0),
   fEmcFirst(0),
   fEmcLast(0),
@@ -170,7 +170,7 @@ AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(AliPHOSGeometry *geom) :
   fNTrackSegments(0),
   fRcpv(0.f),
   fRtpc(0.f),
-  fVtx(0.f), 
+  fVtx(0.f,0.f,0.f), 
   fLinkUpArray(0),
   fEmcFirst(0),
   fEmcLast(0),
@@ -193,7 +193,7 @@ AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(const AliPHOSTrackSegment
   fNTrackSegments(0),
   fRcpv(0.f),
   fRtpc(0.f),
-  fVtx(0.f), 
+  fVtx(0.f,0.f,0.f), 
   fLinkUpArray(0),
   fEmcFirst(0),
   fEmcLast(0),
@@ -230,14 +230,14 @@ void  AliPHOSTrackSegmentMakerv1::FillOneModule()
   //First EMC clusters
   Int_t totalEmc = fEMCRecPoints->GetEntriesFast() ;
   for(fEmcFirst = fEmcLast; (fEmcLast < totalEmc) &&  
-       ((dynamic_cast<AliPHOSRecPoint *>(fEMCRecPoints->At(fEmcLast)))->GetPHOSMod() == fModule ); 
+       ((static_cast<AliPHOSRecPoint *>(fEMCRecPoints->At(fEmcLast)))->GetPHOSMod() == fModule ); 
       fEmcLast ++)  ;
   
   //Now CPV clusters
   Int_t totalCpv = fCPVRecPoints->GetEntriesFast() ;
 
     for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) && 
-         ((dynamic_cast<AliPHOSRecPoint *>(fCPVRecPoints->At(fCpvLast)))->GetPHOSMod() == fModule ); 
+         ((static_cast<AliPHOSRecPoint *>(fCPVRecPoints->At(fCpvLast)))->GetPHOSMod() == fModule ); 
        fCpvLast ++) ;
       
 }
@@ -256,12 +256,12 @@ void  AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * em
 //  Float_t delta = 1 ;  // Width of the rows in sorting of RecPoints (in cm)
 //                       // if you change this value, change it as well in xxxRecPoint::Compare()
 
+  trackindex = -1;
+  dx         = 999.;
+  dz         = 999.;
+
   if(!cpvClu) {
     
-    trackindex = -1;
-    dx=999.;
-    dz=999.;
-    
     if(!emcClu) {
       return;
     }
@@ -275,7 +275,7 @@ void  AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * em
     const Double_t rPHOS = globaPos.Pt() ; //Distance to center of  PHOS module
     const Double_t kYmax = 72.+10. ; //Size of the module (with some reserve) in phi direction
     const Double_t kZmax = 64.+10. ; //Size of the module (with some reserve) in z direction
-    const Double_t kAlpha0=230./180.*TMath::Pi() ; //First PHOS module angular direction
+    const Double_t kAlpha0=330./180.*TMath::Pi() ; //First PHOS module angular direction
     const Double_t kAlpha= 20./180.*TMath::Pi() ; //PHOS module angular size
     Double_t minDistance = 1.e6;
 
@@ -301,7 +301,7 @@ void  AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * em
 
       t.GetBxByBz(b) ;
       //Direction to the current PHOS module
-      Double_t phiMod=kAlpha0+kAlpha*iPHOSMod ;
+      Double_t phiMod=kAlpha0-kAlpha*iPHOSMod ;
       if(!t.Rotate(phiMod))
         continue ;
  
@@ -392,11 +392,12 @@ void  AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * em
       
   }
     
-  if(trackindex>=0)
+  if(trackindex>=0) {
     AliDebug(1,Form("\t\tBest match for (xClu,zClu,eClu)=(%.3f,%.3f,%.3f): iTrack=%d, dR=%.3f",
                    locClu.X(),locClu.Z(),emcClu->GetEnergy(),
                    trackindex,TMath::Sqrt(dx*dx+dz*dz)));        
-  return;
+    return;
+  }
   
   Float_t distance2Track = fRtpc ; 
   
@@ -414,7 +415,7 @@ void  AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * em
   
   emcClu->GetLocalPosition(vecEmc) ;
   
-  Double_t xCPV,zCPV ; //EMC-projected coordinates of CPV cluster 
+  Double_t xCPV=0,zCPV=0 ; //EMC-projected coordinates of CPV cluster 
   TVector3 cpvGlobal; // Global position of the CPV recpoint
   fGeom->GetGlobalPHOS((AliPHOSRecPoint*)cpvClu,cpvGlobal);
   Double_t vtxCPV[3]={cpvGlobal.X(),cpvGlobal.Y(),cpvGlobal.Z()} ;
@@ -547,20 +548,23 @@ void  AliPHOSTrackSegmentMakerv1::MakePairs()
   // remove them from the list of "unassigned". 
 
   //Make arrays to mark clusters already chosen
+  Int_t index;
+
   Int_t * emcExist = 0;
-  if(fEmcLast > fEmcFirst)
+  if(fEmcLast > fEmcFirst) {
     emcExist = new Int_t[fEmcLast-fEmcFirst] ;
-  
-  Int_t index;
-  for(index = 0; index <fEmcLast-fEmcFirst; index ++)
-    emcExist[index] = 1 ;
-  
+    for(index = 0; index <fEmcLast-fEmcFirst; index ++)
+      emcExist[index] = 1 ;
+  }
+  else 
+    return;
+
   Bool_t * cpvExist = 0;
-  if(fCpvLast > fCpvFirst)
+  if(fCpvLast > fCpvFirst) {
     cpvExist = new Bool_t[fCpvLast-fCpvFirst] ;
-  for(index = 0; index <fCpvLast-fCpvFirst; index ++)
-    cpvExist[index] = kTRUE ;
-  
+    for(index = 0; index <fCpvLast-fCpvFirst; index ++)
+      cpvExist[index] = kTRUE ;
+  }
   
   // Finds the smallest links and makes pairs of CPV and EMC clusters with smallest distance 
   TIter nextUp(fLinkUpArray) ;
@@ -573,22 +577,24 @@ void  AliPHOSTrackSegmentMakerv1::MakePairs()
 
     if(emcExist[linkUp->GetEmc()-fEmcFirst] != -1){
 
-      if(cpvExist[linkUp->GetCpv()-fCpvFirst]){ //CPV still exist
+      //array cpvExist[] should be non-zero as far as linkUp exists
+      //But Coverity requires to check it
+      if(cpvExist && cpvExist[linkUp->GetCpv()-fCpvFirst]){ //CPV still exist
          Float_t dx,dz ;
          linkUp->GetXZ(dx,dz) ;
         new ((* fTrackSegments)[fNTrackSegments]) 
-          AliPHOSTrackSegment(dynamic_cast<AliPHOSEmcRecPoint *>(fEMCRecPoints->At(linkUp->GetEmc())) , 
-                              dynamic_cast<AliPHOSCpvRecPoint *>(fCPVRecPoints->At(linkUp->GetCpv())) , 
+          AliPHOSTrackSegment(static_cast<AliPHOSEmcRecPoint *>(fEMCRecPoints->At(linkUp->GetEmc())) , 
+                              static_cast<AliPHOSCpvRecPoint *>(fCPVRecPoints->At(linkUp->GetCpv())) , 
                               linkUp->GetTrack(),dx,dz) ;
         
-       (dynamic_cast<AliPHOSTrackSegment *>(fTrackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments);
+       (static_cast<AliPHOSTrackSegment *>(fTrackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments);
        fNTrackSegments++ ;
        emcExist[linkUp->GetEmc()-fEmcFirst] = -1 ; //Mark emc  that Cpv was found 
        //mark CPV recpoint as already used 
        cpvExist[linkUp->GetCpv()-fCpvFirst] = kFALSE ;
       } //if CpvUp still exist
-    } 
-  }        
+    }
+  }
 
   //look through emc recPoints left without CPV
   if(emcExist){ //if there is emc rec point
@@ -603,13 +609,14 @@ void  AliPHOSTrackSegmentMakerv1::MakePairs()
          new ((*fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment(emcclu,nullpointer) ;
         else
           new ((*fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment(emcclu,0,track,dx,dz);
-       (dynamic_cast<AliPHOSTrackSegment *>(fTrackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments);
+       (static_cast<AliPHOSTrackSegment *>(fTrackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments);
        fNTrackSegments++;    
       } 
     }
   }
   delete [] emcExist ; 
-  delete [] cpvExist ; 
+  if(cpvExist)
+    delete [] cpvExist ; 
 }
 
 //____________________________________________________________________________