]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpRowSegmentRSpecial.cxx
Generates realistic DDL sharing and buspatch number calculated from DDL (Christian)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegmentRSpecial.cxx
index 2097282370b914815ff13a3800f277db7de06f0c..00a62824eb14c59abdb2a147506027ab508bc11a 100644 (file)
@@ -1,4 +1,20 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
 // $Id$
+// $MpId: AliMpRowSegmentRSpecial.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $
 // Category: sector
 //
 // Class AliMpRowSegmentRSpecial
@@ -8,9 +24,6 @@
 // Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
 
-#include <TError.h>
-#include <Riostream.h>
-
 #include "AliMpRowSegmentRSpecial.h"
 #include "AliMpRow.h"
 #include "AliMpPadRow.h"
 #include "AliMpMotifType.h"
 #include "AliMpMotifMap.h"
 #include "AliMpMotifPosition.h"
+#include "AliMpConstants.h"
 
+#include <Riostream.h>
+
+/// \cond CLASSIMP
 ClassImp(AliMpRowSegmentRSpecial)
+/// \endcond
 
 //______________________________________________________________________________
 AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial(AliMpRow* row, Double_t offsetX)
   : AliMpVRowSegmentSpecial(row, offsetX)
 {
-// 
+/// Standard constructor 
 }
 
 //______________________________________________________________________________
 AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial() 
   : AliMpVRowSegmentSpecial()
 {
-//
+/// Default constructor 
 }
 
 //______________________________________________________________________________
 AliMpRowSegmentRSpecial::~AliMpRowSegmentRSpecial() 
 {
-//  
+/// Destructor  
 }
 
 //
@@ -50,8 +68,7 @@ AliMpRowSegmentRSpecial::~AliMpRowSegmentRSpecial()
 AliMpVPadRowSegment*  
 AliMpRowSegmentRSpecial::FindMostLeftPadRowSegment(Int_t motifPositionId) const
 {
-// Find the most left pad row segment with this motifPositionId.
-// ---
+/// Find the most left pad row segment with this motifPositionId.
 
   AliMpVPadRowSegment* found = 0;
 
@@ -74,7 +91,7 @@ AliMpRowSegmentRSpecial::FindMostLeftPadRowSegment(Int_t motifPositionId) const
 //______________________________________________________________________________
 void AliMpRowSegmentRSpecial::SetGlobalIndicesLow()
 {
-// ...
+/// Set global low indices
    
   // Last normal row segment in the row
   // (preceding this special row segment)
@@ -96,11 +113,10 @@ void AliMpRowSegmentRSpecial::SetGlobalIndicesLow()
 //______________________________________________________________________________
 TVector2 AliMpRowSegmentRSpecial::MotifCenterSlow(Int_t motifPositionId) const
 {
-// Returns the coordinates of the motif specified with
-// the given position identifier.
-// !! Applicable only for motifs that have their most down pad in
-// this row segment.
-// ---
+/// Return the coordinates of the motif specified with
+/// the given position identifier.                                           \n
+/// !! Applicable only for motifs that have their most down pad in
+/// this row segment.
 
   // Find the first (left, down) pad row segment with this motifPositionId.
   AliMpVPadRowSegment* downPadRowSegment 
@@ -110,13 +126,13 @@ TVector2 AliMpRowSegmentRSpecial::MotifCenterSlow(Int_t motifPositionId) const
   
   // Check if the motifPositionId is present 
   if (!downPadRowSegment || !leftPadRowSegment) {
-    Error("MotifCenter", "Outside row segment region");
+    AliErrorStream() << "Outside row segment region" << endl;
     return 0;
   }
 
   // Check if both pad row segments have the same motif 
   if (downPadRowSegment->GetMotif() != leftPadRowSegment->GetMotif()) {
-    Fatal("MotifCenter", "Outside row segment region");
+    AliFatal("Outside row segment region");
     return 0;
   }
 
@@ -141,9 +157,8 @@ TVector2 AliMpRowSegmentRSpecial::MotifCenterSlow(Int_t motifPositionId) const
 //______________________________________________________________________________
 Double_t  AliMpRowSegmentRSpecial::LeftBorderX() const
 {
-// Returns the x coordinate of the left row segment border
-// in global coordinate system.
-// ---
+/// Return the x coordinate of the left row segment border
+/// in the global coordinate system.
 
   // The right edge of the last normal segment
   Double_t sameBorder = GetOffsetX();
@@ -157,7 +172,7 @@ Double_t  AliMpRowSegmentRSpecial::LeftBorderX() const
   }  
 
   if (TMath::Abs(sameBorder - leftBorder) > 1.e-04)  {
-    Error("LeftBorderX", "WrongBorder");
+    AliErrorStream() << "WrongBorder" << endl;;
     return sameBorder;
   }  
   
@@ -168,9 +183,8 @@ Double_t  AliMpRowSegmentRSpecial::LeftBorderX() const
 //______________________________________________________________________________
 Double_t  AliMpRowSegmentRSpecial::RightBorderX() const
 {
-// Returns the x coordinate of the right row segment border
-// in global coordinate system.
-// ---
+/// Return the x coordinate of the right row segment border
+/// in the global coordinate system.
 
   Double_t rightBorder = -DBL_MAX;
   for (Int_t i=0; i<GetNofPadRows(); i++) {
@@ -188,10 +202,9 @@ Double_t  AliMpRowSegmentRSpecial::RightBorderX() const
 //______________________________________________________________________________
 TVector2 AliMpRowSegmentRSpecial::Position() const
 {
-// Returns the position of the row segment centre.
-// The centre is defined as the centre of the rectangular
-// row segment envelope.
-// ---
+/// Return the position of the row segment centre.
+/// The centre is defined as the centre of the rectangular
+/// row segment envelope.
 
   // The right edge of the last normal segment
   Double_t x = GetOffsetX()  + Dimensions().X();
@@ -204,12 +217,11 @@ TVector2 AliMpRowSegmentRSpecial::Position() const
 Int_t AliMpRowSegmentRSpecial::SetIndicesToMotifPosition(Int_t i, 
                                          const AliMpIntPair& indices)
 {
-// Sets global indices to i-th motif position and returns next index in x.
-// ---
+/// Set global indices to i-th motif position and returns next index in x.
 
   // Update low indices limit for this row segment
   SetGlobalIndicesLow();
-  
+
   // Check for consistence
   if (GetLowIndicesLimit().GetFirst() != indices.GetFirst()) 
     Fatal("SetIndicesToMotifPosition", "Inconsistent indices");
@@ -217,34 +229,84 @@ Int_t AliMpRowSegmentRSpecial::SetIndicesToMotifPosition(Int_t i,
   // Get motif position
   AliMpMotifPosition* motifPosition
     = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
+    
+  // Set limits only once
+  if ( motifPosition->GetHighIndicesLimit().IsValid() ) 
+    return indices.GetFirst();; 
 
   // Low limit
-  AliMpIntPair low = GetLowIndicesLimit();
-         
-  if (! motifPosition->GetHighIndicesLimit().IsValid()) {   
-     motifPosition->SetLowIndicesLimit(low);
-  } 
-  else {
-    if (motifPosition->GetLowIndicesLimit().GetFirst() > low.GetFirst())
-      motifPosition->SetLowIndicesLimit(
-                        AliMpIntPair(low.GetFirst(),
-                                 motifPosition->GetLowIndicesLimit().GetSecond()));
-
-    if (motifPosition->GetLowIndicesLimit().GetSecond() > low.GetSecond())
-       motifPosition->SetLowIndicesLimit(
-                         AliMpIntPair(motifPosition->GetLowIndicesLimit().GetFirst(),
-                                  low.GetSecond()));
-  }
+  //
+  Int_t ixl = GetLowIndicesLimit().GetFirst();
+  Int_t iyl = GetLowIndicesLimit().GetSecond();
+
+  // Find the most down pad row segment with this motifPositionId.
+  AliMpVPadRowSegment* padRowSegment = FindPadRowSegment(GetMotifPositionId(i));
+  Int_t padRowID = padRowSegment->GetPadRow()->GetID();
+  iyl += padRowID; 
+
+  // Add pads offset of this motif position in the row segment
+  for (Int_t im=0; im<i; im++) {
+    AliMpVPadRowSegment* rs = GetPadRow(padRowID)->GetPadRowSegment(im);
+    if ( rs->GetMotifPositionId() == GetMotifPositionId(i) ) break; 
+    ixl += rs->GetNofPads();
+  }  
+  motifPosition->SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
 
-  // High limit             
+  // High limit        
+  //     
   AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();  
   AliMpIntPair high 
     = motifPosition->GetLowIndicesLimit()
       + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);            
   motifPosition->SetHighIndicesLimit(high);
-  
+
   // No increment index needed (this is always the last element)
   return indices.GetFirst();
 }
 
+//______________________________________________________________________________
+void AliMpRowSegmentRSpecial::SetGlobalIndices(AliMpRow* rowBefore)
+{
+/// Set indices limits.
+/// The limits are defined as the limits of the smallest rectangle which
+/// includes all pads of this special row segment.
+
+  // Get first motif position
+  AliMpMotifPosition* firstMotifPosition
+    = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(0));
+    
+  // Low ix
+  Int_t ixl = firstMotifPosition->GetLowIndicesLimit().GetFirst();
+              // We have to take the motif position limit
+             // as it can overlap over more rows and the indices
+             // of the right border of the precedent normal segment
+             // differ from one row to another  
+
+  // High ix
+  Int_t ixh = ixl + MaxNofPadsInRow() - 1;
+
+  // Low iy
+  Int_t iyl = AliMpConstants::StartPadIndex();
+  if (rowBefore) {
+    //if (constPadSizeDirection == kY) {
+      iyl = rowBefore->GetHighIndicesLimit().GetSecond()+1;
+    //} 
+    /*
+    else {
+      AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);  
+      AliMpMotifPosition* motPos =  rowBefore->FindMotifPosition(seg, ixl);
+      if (!motPos) 
+        Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
+      iyl = motPos->GetHighIndicesLimit().GetSecond()+1;
+    }
+    */
+  }  
+
+  // High iy
+  Int_t iyh = iyl + GetNofPadRows() - 1;
+  
+  SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
+  SetHighIndicesLimit(AliMpIntPair(ixh, iyh));
+}  
+