]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpRow.cxx
Updates from David Rohr to add checks for fakes and clones and several bugfixes
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRow.cxx
index 3a2ce1e0a825eff77be98a4dbc07ce0b8aa985ce..f010c5a5bd20fd1bb5a59de3ed88edb4d8659635 100755 (executable)
@@ -40,6 +40,7 @@
 #include <TMath.h>
 #include <Riostream.h>
 
+using std::endl;
 /// \cond CLASSIMP
 ClassImp(AliMpRow)
 /// \endcond
@@ -71,14 +72,7 @@ AliMpRow::~AliMpRow()
 {
 /// Destructor 
 
-#ifdef WITH_STL
-  for (Int_t i=0; i<GetNofRowSegments(); i++)
-    delete fSegments[i]; 
-#endif
-
-#ifdef WITH_ROOT
   fSegments.Delete();
-#endif
 }
 
 //
@@ -94,7 +88,7 @@ AliMpVRowSegment*  AliMpRow::FindRowSegment(Int_t ix) const
     AliMpVRowSegment* segment = GetRowSegment(i);
 
     if (!dynamic_cast<AliMpVRowSegmentSpecial*>(segment) &&
-         segment->GetHighIndicesLimit().GetFirst() >= ix)
+         segment->GetHighLimitIx() >= ix)
         
      return segment;    
   }   
@@ -120,7 +114,7 @@ AliMpRow::FindMotifPosition(AliMpVRowSegment* segment, Int_t ix) const
        return 0;
      }  
      
-     if (motifPosition->GetHighIndicesLimit().GetFirst()>=ix) 
+     if (motifPosition->GetHighLimitIx()>=ix) 
        return motifPosition;
   }
   
@@ -138,8 +132,7 @@ void AliMpRow::SetHighIndicesLimits(Int_t iy)
   for (Int_t j=0; j<GetNofRowSegments(); j++) {
      AliMpVRowSegment* rowSegment = GetRowSegment(j);       
      rowSegment
-       ->SetHighIndicesLimit(
-           AliMpIntPair(rowSegment->GetHighIndicesLimit().GetFirst(),iy));
+       ->SetHighIndicesLimit(rowSegment->GetHighLimitIx(),iy);
 
     for (Int_t k=0; k<rowSegment->GetNofMotifs(); k++) {
 
@@ -148,8 +141,7 @@ void AliMpRow::SetHighIndicesLimits(Int_t iy)
        = GetMotifMap()->FindMotifPosition(motifPositionId);
 
       motifPosition
-       ->SetHighIndicesLimit(
-            AliMpIntPair(motifPosition->GetHighIndicesLimit().GetFirst(), iy));
+       ->SetHighIndicesLimit(motifPosition->GetHighLimitIx(), iy);
      
     }
   }  
@@ -173,13 +165,7 @@ void AliMpRow::AddRowSegment(AliMpVRowSegment* rowSegment)
 {
 /// Add row segment at the end.
 
-#ifdef WITH_STL
-  fSegments.push_back(rowSegment);
-#endif
-
-#ifdef WITH_ROOT
   fSegments.Add(rowSegment);
-#endif
 }  
   
 //_____________________________________________________________________________
@@ -187,13 +173,7 @@ void AliMpRow::AddRowSegmentInFront(AliMpVRowSegment* rowSegment)
 {
 /// Insert row segment in the first vector position.
 
-#ifdef WITH_STL
-  fSegments.insert(fSegments.begin(), rowSegment);
-#endif
-
-#ifdef WITH_ROOT
   fSegments.AddFirst(rowSegment);
-#endif
 }  
   
 //_____________________________________________________________________________
@@ -204,12 +184,7 @@ AliMpVRowSegment* AliMpRow::FindRowSegment(Double_t x) const
 
   for (Int_t i=0; i<GetNofRowSegments(); i++) {
 
-#ifdef WITH_STL
-    AliMpVRowSegment* rs = fSegments[i];
-#endif
-#ifdef WITH_ROOT
     AliMpVRowSegment* rs = (AliMpVRowSegment*)fSegments.At(i);
-#endif
 
     if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
       return rs;
@@ -264,14 +239,17 @@ void AliMpRow::SetMotifPositions()
         // Get values 
        Int_t motifPositionId = rowSegment->GetMotifPositionId(k);
        AliMpVMotif* motif = rowSegment->GetMotif(k);
-       TVector2 position = rowSegment->MotifCenter(motifPositionId);
+        
+        Double_t posx, posy;
+       rowSegment->MotifCenter(motifPositionId, posx, posy);
        
         AliMpMotifPosition* motifPosition 
-         = new AliMpMotifPosition(motifPositionId, motif, position);
+         = new AliMpMotifPosition(motifPositionId, motif, posx, posy);
+
         // set the initial value to of HighIndicesLimit() Invalid()
         // (this is used for calculation of indices in case of
         // special row segments)
-        motifPosition->SetHighIndicesLimit(AliMpIntPair::Invalid());
+        motifPosition->SetHighIndicesLimit(0, 0, false);
 
         //Bool_t warn = (rowSegment->GetNofMotifs()==1); 
         Bool_t warn = true;
@@ -299,29 +277,31 @@ void AliMpRow::SetGlobalIndices(AliMp::Direction constPadSizeDirection,
   for (Int_t j=0; j<GetNofRowSegments(); j++) {
      AliMpVRowSegment* rowSegment = GetRowSegment(j);
      
-     ix += rowSegment->GetLowIndicesLimit().GetFirst();
+     ix += rowSegment->GetLowLimitIx();
 
      for (Int_t k=0; k<rowSegment->GetNofMotifs(); k++) {
      
        // Find the y index value of the low edge
        if (rowBefore) {
          if (constPadSizeDirection == AliMp::kY) {
-           iy = rowBefore->GetHighIndicesLimit().GetSecond()+1;
+           iy = rowBefore->GetHighLimitIy()+1;
          } 
         else {
            AliMpVRowSegment* seg = rowBefore->FindRowSegment(ix);      
           AliMpMotifPosition* motPos =  FindMotifPosition(seg, ix);
           if (!dynamic_cast<AliMpRowSegmentRSpecial*>(rowSegment)) {
-             if (!motPos) 
+             if (!motPos) {
               Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
+               return;
+             }  
           
-             iy = motPos->GetHighIndicesLimit().GetSecond()+1;
+             iy = motPos->GetHighLimitIy()+1;
           }  
          }
        } 
 
        // Set (ix, iy) to k-th motif position and update ix
-       ix = rowSegment->SetIndicesToMotifPosition(k, AliMpIntPair(ix, iy));
+       ix = rowSegment->SetIndicesToMotifPosition(k, AliMp::Pair(ix, iy));
     }
     rowSegment->SetGlobalIndices(rowBefore);    
   }
@@ -337,51 +317,59 @@ void AliMpRow::SetGlobalIndices(AliMp::Direction constPadSizeDirection,
     
     AliMpVRowSegment* rowSegment = GetRowSegment(i);
     
-    if ( rowSegment->GetLowIndicesLimit().GetFirst() < ixl ) 
-       ixl = rowSegment->GetLowIndicesLimit().GetFirst();
+    if ( rowSegment->GetLowLimitIx() < ixl ) 
+       ixl = rowSegment->GetLowLimitIx();
        
-    if ( rowSegment->GetLowIndicesLimit().GetSecond() < iyl ) 
-       iyl = rowSegment->GetLowIndicesLimit().GetSecond();
+    if ( rowSegment->GetLowLimitIy() < iyl ) 
+       iyl = rowSegment->GetLowLimitIy();
 
-    if ( rowSegment->GetHighIndicesLimit().GetFirst() > ixh ) 
-       ixh = rowSegment->GetHighIndicesLimit().GetFirst();
+    if ( rowSegment->GetHighLimitIx() > ixh ) 
+       ixh = rowSegment->GetHighLimitIx();
        
-    if ( rowSegment->GetHighIndicesLimit().GetSecond() > iyh ) 
-       iyh = rowSegment->GetHighIndicesLimit().GetSecond();
+    if ( rowSegment->GetHighLimitIy() > iyh ) 
+       iyh = rowSegment->GetHighLimitIy();
   }     
 
-  SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
-  SetHighIndicesLimit(AliMpIntPair(ixh, iyh));
+  SetLowIndicesLimit(ixl, iyl);
+  SetHighIndicesLimit(ixh, iyh);
 }
 
 //_____________________________________________________________________________
-TVector2  AliMpRow::Position() const
+Double_t  AliMpRow::GetPositionX() const
 {
 /// Return the position of the row centre.
 
-  Double_t x = (GetRowSegment(0)->LeftBorderX() +
-                GetRowSegment(GetNofRowSegments()-1)->RightBorderX())/2.;
-                   
-  Double_t y = fOffsetY;  
-    
-  return TVector2(x, y);   
+  return ( GetRowSegment(0)->LeftBorderX() +
+           GetRowSegment(GetNofRowSegments()-1)->RightBorderX() )/2.;
+}
+
+//_____________________________________________________________________________
+Double_t  AliMpRow::GetPositionY() const
+{
+/// Return the position of the row centre.
+
+  return fOffsetY;  
 }
 
 //_____________________________________________________________________________
-TVector2  AliMpRow::Dimensions() const
+Double_t  AliMpRow::GetDimensionX() const
 {
 /// Return the maximum halflengths of the row in x, y.
 
-  Double_t x = (GetRowSegment(GetNofRowSegments()-1)->RightBorderX() -
-                GetRowSegment(0)->LeftBorderX())/2.;
-                  
-  Double_t y = GetRowSegment(0)->HalfSizeY();  
-    
-  return TVector2(x, y);   
+  return ( GetRowSegment(GetNofRowSegments()-1)->RightBorderX() -
+           GetRowSegment(0)->LeftBorderX() )/2.;
+}
+
+//_____________________________________________________________________________
+Double_t  AliMpRow::GetDimensionY() const
+{
+/// Return the maximum halflengths of the row in x, y.
+
+  return GetRowSegment(0)->HalfSizeY();  
 }
 
 //_____________________________________________________________________________
-void AliMpRow::SetRowSegmentOffsets(const TVector2& offset)
+void AliMpRow::SetRowSegmentOffsets(Double_t offsetx)
 {
 /// Set the row segments offsets in X .
 
@@ -396,9 +384,9 @@ void AliMpRow::SetRowSegmentOffsets(const TVector2& offset)
      if (previous) 
       offsetX = previous->RightBorderX();
     else
-      offsetX = offset.X();  
+      offsetX = offsetx;  
   
-    rowSegment->SetOffset(TVector2(offsetX, 0.));
+    rowSegment->SetOffset(offsetX, 0.);
     previous = rowSegment;  
   }
 }
@@ -438,13 +426,7 @@ Int_t AliMpRow::GetNofRowSegments() const
 {
 /// Return number of row segments.
 
-#ifdef WITH_STL
-  return fSegments.size();
-#endif
-
-#ifdef WITH_ROOT
   return fSegments.GetSize();
-#endif
 }  
 
 //_____________________________________________________________________________
@@ -457,12 +439,6 @@ AliMpVRowSegment* AliMpRow::GetRowSegment(Int_t i) const
     return 0;
   }
   
-#ifdef WITH_STL
-  return fSegments[i];  
-#endif
-
-#ifdef WITH_ROOT
   return (AliMpVRowSegment*)fSegments.At(i);  
-#endif
 }