]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFGeometry.cxx
Fix for coverity
[u/mrichter/AliRoot.git] / TOF / AliTOFGeometry.cxx
index e558af41aa176949c8a42ab012614143248ae31d..729d163763de04e76b5f6381fa0781535395577d 100644 (file)
@@ -463,7 +463,7 @@ Bool_t AliTOFGeometry::IsInsideThePadPar(Int_t *det, const Float_t * const pos)
 
 }
 //_____________________________________________________________________________
-Bool_t AliTOFGeometry::IsInsideThePad(TGeoHMatrix mat, const Float_t * const pos, Float_t *dist3d) const
+Bool_t AliTOFGeometry::IsInsideThePad(TGeoHMatrix *mat, const Float_t * const pos, Float_t *dist3d) const
 {
   //
   // Returns true if space point with coor pos (x,y,z) [cm] falls inside
@@ -483,7 +483,7 @@ Bool_t AliTOFGeometry::IsInsideThePad(TGeoHMatrix mat, const Float_t * const pos
   // from ALICE global reference system
   // towards TOF pad reference system
   Double_t posl[3] = {0., 0., 0.};
-  mat.MasterToLocal(posg,posl);
+  mat->MasterToLocal(posg,posl);
 
   Float_t xr = posl[0];
   Float_t yr = posl[1];
@@ -505,7 +505,7 @@ Bool_t AliTOFGeometry::IsInsideThePad(TGeoHMatrix mat, const Float_t * const pos
     Double_t padg[3] = {0., 0., 0.};
     // from TOF pad local reference system
     // towards ALICE global reference system
-    TGeoHMatrix inverse = mat.Inverse();
+    TGeoHMatrix inverse = mat->Inverse();
     inverse.MasterToLocal(padl,padg);
 
     // returns the 3d distance
@@ -526,14 +526,17 @@ void AliTOFGeometry::GetVolumePath(const Int_t * const ind, Char_t *path ) {
   // This function returns the colume path of a given pad 
   //--------------------------------------------------------------------
   Int_t sector = ind[0];
-  Char_t  string1[100];
-  Char_t  string2[100];
-  Char_t  string3[100];
+
+  const Int_t kSize = 100;
+
+  Char_t  string1[kSize];
+  Char_t  string2[kSize];
+  Char_t  string3[kSize];
   
   Int_t icopy=-1;
   icopy=sector;
  
-  sprintf(string1,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",icopy,icopy);
+  snprintf(string1,kSize,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",icopy,icopy);
   
   Int_t iplate=ind[1];
   Int_t istrip=ind[2];
@@ -543,16 +546,16 @@ void AliTOFGeometry::GetVolumePath(const Int_t * const ind, Char_t *path ) {
   if( iplate==3) icopy=istrip+NStripC()+NStripB()+NStripA(); 
   if( iplate==4) icopy=istrip+NStripC()+2*NStripB()+NStripA(); 
   icopy++;
-  sprintf(string2,"FTOA_0/FLTA_0/FSTR_%i",icopy);
+  snprintf(string2,kSize,"FTOA_0/FLTA_0/FSTR_%i",icopy);
   if(fHoles && (sector==13 || sector==14 || sector==15)){
-    if(iplate<2)  sprintf(string2,"FTOB_0/FLTB_0/FSTR_%i",icopy);
-    if(iplate>2)  sprintf(string2,"FTOC_0/FLTC_0/FSTR_%i",icopy);
+    if(iplate<2)  snprintf(string2,kSize,"FTOB_0/FLTB_0/FSTR_%i",icopy);
+    if(iplate>2)  snprintf(string2,kSize,"FTOC_0/FLTC_0/FSTR_%i",icopy);
   }
  
   Int_t padz = ind[3]+1; 
   Int_t padx = ind[4]+1;
-  sprintf(string3,"FPCB_1/FSEN_1/FSEZ_%i/FPAD_%i",padz,padx);
-  sprintf(path,"%s/%s/%s",string1,string2,string3); 
+  snprintf(string3,kSize,"FPCB_1/FSEN_1/FSEZ_%i/FPAD_%i",padz,padx);
+  snprintf(path,2*kSize,"%s/%s/%s",string1,string2,string3); 
 
 }
 //_____________________________________________________________________________
@@ -561,12 +564,14 @@ void AliTOFGeometry::GetVolumePath(Int_t sector, Char_t *path ){
   // This function returns the colume path of a given sector 
   //--------------------------------------------------------------------
 
-  Char_t string[100];
+  const Int_t kSize = 100;
+
+  Char_t string[kSize];
 
   Int_t icopy = sector;
 
-  sprintf(string,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",icopy,icopy);
-  sprintf(path,"%s",string);
+  snprintf(string,kSize,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",icopy,icopy);
+  snprintf(path,2*kSize,"%s",string);
 
 }
 //_____________________________________________________________________________
@@ -575,13 +580,15 @@ void AliTOFGeometry::GetVolumePath(Int_t sector, Int_t plate, Int_t strip, Char_
   // This function returns the colume path of a given strip 
   //--------------------------------------------------------------------
 
-  Char_t string1[100];
-  Char_t string2[100];
-  Char_t string3[100];
+  const Int_t kSize = 100;
+
+  Char_t string1[kSize];
+  Char_t string2[kSize];
+  Char_t string3[kSize];
   
   Int_t icopy = sector;
 
-  sprintf(string1,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",icopy,icopy);
+  snprintf(string1,kSize,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",icopy,icopy);
   
   if(plate==0) icopy=strip; 
   if(plate==1) icopy=strip+NStripC(); 
@@ -589,14 +596,14 @@ void AliTOFGeometry::GetVolumePath(Int_t sector, Int_t plate, Int_t strip, Char_
   if(plate==3) icopy=strip+NStripC()+NStripB()+NStripA(); 
   if(plate==4) icopy=strip+NStripC()+2*NStripB()+NStripA(); 
   icopy++;
-  sprintf(string2,"FTOA_0/FLTA_0/FSTR_%i",icopy);
+  snprintf(string2,kSize,"FTOA_0/FLTA_0/FSTR_%i",icopy);
   if(fHoles && (sector==13 || sector==14 || sector==15)){
-    if(plate<2)  sprintf(string2,"FTOB_0/FLTB_0/FSTR_%i",icopy);
-    if(plate>2)  sprintf(string2,"FTOC_0/FLTC_0/FSTR_%i",icopy);
+    if(plate<2)  snprintf(string2,kSize,"FTOB_0/FLTB_0/FSTR_%i",icopy);
+    if(plate>2)  snprintf(string2,kSize,"FTOC_0/FLTC_0/FSTR_%i",icopy);
   }
 
-  sprintf(string3,"FPCB_1/FSEN_1");
-  sprintf(path,"%s/%s/%s",string1,string2,string3); 
+  snprintf(string3,kSize,"FPCB_1/FSEN_1");
+  snprintf(path,2*kSize,"%s/%s/%s",string1,string2,string3); 
 
 }
 //_____________________________________________________________________________
@@ -606,8 +613,8 @@ void AliTOFGeometry::GetPos(Int_t *det, Float_t *pos)
 // Returns space point coor (x,y,z) (cm)  for Detector 
 // Indices  (iSect,iPlate,iStrip,iPadX,iPadZ) 
 //
-  Char_t path[100];
-  GetVolumePath(det,path );
+  Char_t path[200];
+  GetVolumePath(det,path);
   if (!gGeoManager) {
     printf("ERROR: no TGeo\n");
   }
@@ -1112,7 +1119,7 @@ Float_t AliTOFGeometry::GetX(const Int_t * const det) const
   Translation(posLocal,step);
 
   // FSTR reference frame -> FTOA/B/C = FLTA/B/C reference frame
-  Double_t angles[6];
+  Double_t angles[6] = {0.,0.,0.,0.,0.,0.};
   if      (GetAngles(iplate,istrip) >0.) {
     angles[0] = 90.;
     angles[1] =  0.;
@@ -1224,7 +1231,7 @@ Float_t AliTOFGeometry::GetY(const Int_t * const det) const
 
   // FSTR reference frame -> FTOA/B/C = FLTA/B/C reference frame
 
-  Double_t angles[6];
+  Double_t angles[6] = {0.,0.,0.,0.,0.,0.};
   if      (GetAngles(iplate,istrip) >0.) {
     angles[0] = 90.;
     angles[1] =  0.;
@@ -1321,7 +1328,7 @@ Float_t AliTOFGeometry::GetZ(const Int_t * const det) const
   Translation(posLocal,step);
 
   // FSTR reference frame -> FTOA/B/C = FLTA/B/C reference frame
-  Double_t angles[6];
+  Double_t angles[6] = {0.,0.,0.,0.,0.,0.};
   if      (GetAngles(iplate,istrip) >0.) {
     angles[0] = 90.;
     angles[1] =  0.;
@@ -1386,7 +1393,7 @@ Float_t AliTOFGeometry::GetZ(const Int_t * const det) const
 }
 //_____________________________________________________________________________
 
-void AliTOFGeometry::DetToSectorRF(Int_t vol[5], Double_t **coord)
+void AliTOFGeometry::DetToSectorRF(Int_t vol[5], Double_t coord[4][3])
 {
   //
   // Returns the local coordinates (x, y, z) in sector reference frame
@@ -1396,7 +1403,7 @@ void AliTOFGeometry::DetToSectorRF(Int_t vol[5], Double_t **coord)
   if (!gGeoManager) printf("ERROR: no TGeo\n");
 
   // ALICE -> TOF Sector
-  Char_t path1[100]="";
+  Char_t path1[200];
   GetVolumePath(vol[0],path1);
   gGeoManager->cd(path1);
   TGeoHMatrix aliceToSector;
@@ -1406,7 +1413,7 @@ void AliTOFGeometry::DetToSectorRF(Int_t vol[5], Double_t **coord)
   //TGeoHMatrix sectorToALICE = aliceToSector.Inverse();
 
   // ALICE -> TOF Pad
-  Char_t path2[100]="";
+  Char_t path2[200];
   GetVolumePath(vol,path2);
   gGeoManager->cd(path2);
   TGeoHMatrix aliceToPad;
@@ -2129,7 +2136,7 @@ void AliTOFGeometry::PadRF2TrackingRF(Float_t *ctrackPos, Float_t *differenceT)
   l2t.MasterToLocal(padCentreL,padCentreT);
 
 
-  Char_t path[100];
+  Char_t path[200];
   // pad centre coordinates in its ref. frame
   Double_t padCentreL2[3] = {0., 0., 0.};
   // pad centre coordinates in the ALICE global ref. frame
@@ -2141,7 +2148,7 @@ void AliTOFGeometry::PadRF2TrackingRF(Float_t *ctrackPos, Float_t *differenceT)
   l2g.MasterToLocal(padCentreL2,padCentreG);
 
 
-  Char_t path2[100];
+  Char_t path2[200];
   // strip centre coordinates in its ref. frame
   Double_t stripCentreL[3] = {0., 0., 0.};
   // strip centre coordinates in the ALICE global ref. frame