]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpVRowSegmentSpecial.cxx
Fix floating exception bug which can appear in few specific cases.
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpVRowSegmentSpecial.cxx
index 9e95162f3aeff00fcb91d9477b0231dcb45b457e..dfbbbc5fb5ae53583ffe7c0d693d725a6cfababf 100644 (file)
 // $Id$
 // $MpId: AliMpVRowSegmentSpecial.cxx,v 1.9 2006/05/24 13:58:46 ivana Exp $
 // Category: sector
-//
+
+//-----------------------------------------------------------------------------
 // Class AliMpVRowSegmentSpecial
 // ----------------------------
 // Class describing a special row segment composed of the 
 // pad rows.
 // Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+//-----------------------------------------------------------------------------
 
 #include "AliMpVRowSegmentSpecial.h"
 #include "AliMpRow.h"
@@ -40,9 +42,7 @@
 ClassImp(AliMpVRowSegmentSpecial)
 /// \endcond
 
-#ifdef WITH_ROOT
 const Int_t  AliMpVRowSegmentSpecial::fgkMaxNofMotifPositionIds = 20;
-#endif    
 
 //______________________________________________________________________________
 AliMpVRowSegmentSpecial::AliMpVRowSegmentSpecial(AliMpRow* row, Double_t offsetX)
@@ -51,10 +51,8 @@ AliMpVRowSegmentSpecial::AliMpVRowSegmentSpecial(AliMpRow* row, Double_t offsetX
     fOffsetX(offsetX),
     fPadRows(),
     fMotifs(),
-    fMotifPositionIds()
-#ifdef WITH_ROOT
-    ,fNofMotifPositionIds(0)
-#endif    
+    fMotifPositionIds(),
+    fNofMotifPositionIds(0)
 {
 /// Standard constructor  
 }
@@ -66,16 +64,12 @@ AliMpVRowSegmentSpecial::AliMpVRowSegmentSpecial()
     fOffsetX(0.),
     fPadRows(),
     fMotifs(),
-    fMotifPositionIds()
-#ifdef WITH_ROOT
-    ,fNofMotifPositionIds(0)
-#endif    
+    fMotifPositionIds(),
+    fNofMotifPositionIds(0)
 {
 /// Default constructor  
 
-#ifdef WITH_ROOT
    fMotifPositionIds.Set(fgkMaxNofMotifPositionIds);
-#endif    
 }
 
 //______________________________________________________________________________
@@ -133,35 +127,38 @@ AliMpVRowSegmentSpecial::FindPadRowSegment(Int_t motifPositionId) const
 }
 
 //______________________________________________________________________________
-AliMpIntPair 
+MpPair_t 
 AliMpVRowSegmentSpecial::FindRelativeLowIndicesOf(Int_t motifPositionId) const 
 { 
 /// Return the lowest pad indices where the motif of the given position ID
 /// exist in this segment.
 
-  AliMpIntPair ans(0,1000);
-  AliMpIntPair ans0 = ans;
+  Int_t ans0Ix = 0;
+  Int_t ans0Iy = 1000;
+  Int_t ansIx = 0;
+  Int_t ansIy = 1000;
+  
   Int_t maxNofPadsX=0;
   
   for (Int_t i=0; i<GetNofPadRows(); i++) {
     AliMpPadRow* padRow = GetPadRow(i);
 
     Int_t nofPadsX=0;
-    for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
+    for ( Int_t j=0; j<padRow->GetNofPadRowSegments(); j++ ) {
       AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
       nofPadsX += padRowSegment->GetNofPads();
       if (padRowSegment->GetMotifPositionId() == motifPositionId) {
-         if (ans.GetFirst() < nofPadsX) ans.SetFirst(nofPadsX);
-         if (ans.GetSecond()>i) ans.SetSecond(i);
-                  // ans.First = max (nof pads of this pos ID)
-                  // ans.Second = min of pad row number
+         if ( ansIx < nofPadsX ) ansIx = nofPadsX;
+         if ( ansIy >i ) ansIy = i;
+                  // ansIx = max (nof pads of this pos ID)
+                  // ansIy = min of pad row number
       }
     }  
-    if (nofPadsX > maxNofPadsX) maxNofPadsX = nofPadsX;
+    if ( nofPadsX > maxNofPadsX ) maxNofPadsX = nofPadsX;
   }    
-  if (ans == ans0) return AliMpIntPair::Invalid();
+  if ( ansIx == ans0Ix && ansIy == ans0Iy ) return -1;
   
-  return AliMpIntPair(maxNofPadsX-ans.GetFirst(), ans.GetSecond());
+  return AliMp::Pair(maxNofPadsX-ansIx, ansIy);
 }
  
 //______________________________________________________________________________
@@ -187,15 +184,8 @@ Bool_t AliMpVRowSegmentSpecial::HasMotif(const AliMpVMotif* motif) const
 /// Return true if the specified motif is already in fMotifs vector,
 /// returns false otherwise.
 
-#ifdef WITH_STL
-  for (UInt_t i=0; i<fMotifs.size(); i++)
-    if (fMotifs[i] == motif) return true;
-#endif
-
-#ifdef WITH_ROOT
   for (Int_t i=0; i<fMotifs.GetEntriesFast(); i++)
     if (fMotifs[i] == (const TObject*)motif) return true;
-#endif
 
   return false;         
 }
@@ -205,13 +195,7 @@ Int_t AliMpVRowSegmentSpecial::GetNofPadRows() const
 {
 /// Return number of pad rows.
 
-#ifdef WITH_STL
-  return fPadRows.size();
-#endif
-
-#ifdef WITH_ROOT
   return fPadRows.GetEntriesFast();
-#endif
 }  
 
 //______________________________________________________________________________
@@ -219,13 +203,7 @@ AliMpPadRow* AliMpVRowSegmentSpecial::GetPadRow(Int_t i) const
 {
 /// Return number of pad rows.
 
-#ifdef WITH_STL
-  return fPadRows[i];
-#endif
-
-#ifdef WITH_ROOT
   return (AliMpPadRow*)fPadRows[i];
-#endif
 }  
 
 //
@@ -240,13 +218,7 @@ void  AliMpVRowSegmentSpecial::AddPadRow(AliMpPadRow* padRow)
   padRow->SetOffsetX(fOffsetX);
   padRow->SetID(GetNofPadRows());
 
-#ifdef WITH_STL
-  fPadRows.push_back(padRow);
-#endif
-
-#ifdef WITH_ROOT
   fPadRows.Add(padRow);
-#endif
 }  
 
 //______________________________________________________________________________
@@ -262,12 +234,6 @@ void AliMpVRowSegmentSpecial::UpdateMotifVector()
       AliMpVMotif* motif = padRow->GetPadRowSegment(j)->GetMotif();            
 
       if (!HasMotif(motif)) {
-#ifdef WITH_STL
-        fMotifs.push_back(motif);       
-        fMotifPositionIds.push_back(
-          padRow->GetPadRowSegment(j)->GetMotifPositionId());
-#endif
-#ifdef WITH_ROOT
         fMotifs.Add(motif);
        
        // resize array if needed
@@ -277,7 +243,6 @@ void AliMpVRowSegmentSpecial::UpdateMotifVector()
         fMotifPositionIds.AddAt(
           padRow->GetPadRowSegment(j)->GetMotifPositionId(),
          fNofMotifPositionIds++);
-#endif
       }
     }  
   }
@@ -297,38 +262,34 @@ Double_t  AliMpVRowSegmentSpecial::HalfSizeY() const
 }
 
 //______________________________________________________________________________
-AliMpVMotif*  AliMpVRowSegmentSpecial::FindMotif(const TVector2& position) const
+AliMpVMotif*  AliMpVRowSegmentSpecial::FindMotif(Double_t x, Double_t y) const
 {
 /// Return the motif of this row; 
 
-  AliMpPadRow* padRow 
-    = FindPadRow(position.Y());
+  AliMpPadRow* padRow = FindPadRow(y);
   
-  if (!padRow) return 0;
+  if ( ! padRow ) return 0;
 
-  AliMpVPadRowSegment* padRowSegment 
-    = padRow->FindPadRowSegment(position.X());
+  AliMpVPadRowSegment* padRowSegment = padRow->FindPadRowSegment(x);
     
-  if (!padRowSegment) return 0;
+  if (! padRowSegment ) return 0;
 
   return padRowSegment->GetMotif();
 }  
 
 //______________________________________________________________________________
-Int_t AliMpVRowSegmentSpecial::FindMotifPositionId(const TVector2& position) const
+Int_t AliMpVRowSegmentSpecial::FindMotifPositionId(Double_t x, Double_t y) const
 {
 /// Return the motif position identified for the given
 /// geometric position.
 
-  AliMpPadRow* padRow 
-    = FindPadRow(position.Y());
+  AliMpPadRow* padRow = FindPadRow(y);
   
-  if (!padRow) return 0;
+  if ( ! padRow ) return 0;
 
-  AliMpVPadRowSegment* padRowSegment 
-    = padRow->FindPadRowSegment(position.X());
+  AliMpVPadRowSegment* padRowSegment = padRow->FindPadRowSegment(x);
     
-  if (!padRowSegment) return 0;
+  if ( ! padRowSegment ) return 0;
 
   return padRowSegment->GetMotifPositionId();
 }
@@ -346,7 +307,8 @@ Bool_t AliMpVRowSegmentSpecial::HasMotifPosition(Int_t motifPositionId) const
 }
 
 //______________________________________________________________________________
-TVector2 AliMpVRowSegmentSpecial::MotifCenter(Int_t motifPositionId) const
+void AliMpVRowSegmentSpecial::MotifCenter(Int_t motifPositionId,
+                                          Double_t& x, Double_t& y) const
 {
 /// Return the coordinates of the motif specified with
 /// the given position identifier.
@@ -354,25 +316,25 @@ TVector2 AliMpVRowSegmentSpecial::MotifCenter(Int_t motifPositionId) const
   // Try to get the motif position from the motif map first
   AliMpMotifPosition* motifPosition
     = GetRow()->GetMotifMap()->FindMotifPosition(motifPositionId);
-  if (motifPosition) return motifPosition->Position();
-
-  // Use slow method otherwise
-  return MotifCenterSlow(motifPositionId);
+    
+  if (motifPosition) { 
+    x = motifPosition->GetPositionX(), 
+    y = motifPosition->GetPositionY();
+  }
+  else {  
+    MotifCenterSlow(motifPositionId, x, y);
+  }
 }
 
 //______________________________________________________________________________
-TVector2 AliMpVRowSegmentSpecial::Dimensions() const
+Double_t AliMpVRowSegmentSpecial::GetDimensionX() const
 {
 /// Return the halflengths in x, y of the row segment rectangular envelope.
 
   Double_t x = 0.;                 
-  Double_t y = 0.;  
   for (Int_t i=0; i<GetNofPadRows(); i++) {    
     AliMpPadRow* padRow = GetPadRow(i); 
     
-    // Add all pad rows y halfsizes   
-    y += padRow->HalfSizeY();
-
     // Find the biggest pad rows x halfsize
     Double_t xx 
       = (padRow->GetPadRowSegment(0)->RightBorderX() -
@@ -380,7 +342,23 @@ TVector2 AliMpVRowSegmentSpecial::Dimensions() const
     if (xx > x) x = xx;                   
   }                  
     
-  return TVector2(x, y);   
+  return x;   
+}
+
+//______________________________________________________________________________
+Double_t AliMpVRowSegmentSpecial::GetDimensionY() const
+{
+/// Return the halflengths in x, y of the row segment rectangular envelope.
+
+  Double_t y = 0.;  
+  for (Int_t i=0; i<GetNofPadRows(); i++) {    
+    AliMpPadRow* padRow = GetPadRow(i); 
+    
+    // Add all pad rows y halfsizes   
+    y += padRow->HalfSizeY();
+  }                  
+    
+  return y;   
 }
 
 //______________________________________________________________________________
@@ -396,12 +374,7 @@ Int_t  AliMpVRowSegmentSpecial::GetNofMotifs() const
 { 
 /// Return the number of different motifs present in this row segment.
 
-#ifdef WITH_STL
-  return fMotifs.size();
-#endif
-#ifdef WITH_ROOT
   return fMotifs.GetEntriesFast();
-#endif
 }  
 
 //______________________________________________________________________________
@@ -409,12 +382,7 @@ AliMpVMotif* AliMpVRowSegmentSpecial::GetMotif(Int_t i) const
 {
 /// Return the i-th motif present in this row segment.
 
-#ifdef WITH_STL
-   return fMotifs[i]; 
-#endif
-#ifdef WITH_ROOT
    return (AliMpVMotif*)fMotifs[i]; 
-#endif
 }
 
 //______________________________________________________________________________