]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpRowSegment.cxx
Updated denames of station 1 for the quadrants as they have been mounted in cave
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegment.cxx
index c6cd3b16f863b870dcce357d5a8e5de80760c5f0..d00c34760ec207bee37c635b705165b8dd8df019 100755 (executable)
@@ -1,16 +1,29 @@
+/**************************************************************************
+ * 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: AliMpRowSegment.cxx,v 1.10 2006/05/24 13:58:46 ivana Exp $
 // Category: sector
 //
 // Class AliMpRowSegment
 // ---------------------
 // Class describing a row segment composed of the 
 // the identic motifs.
-//
+// Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
 
-#include <TError.h>
-#include <TMath.h>
-
 #include "AliMpRowSegment.h"
 #include "AliMpRow.h"
 #include "AliMpVMotif.h"
 #include "AliMpMotifTypePadIterator.h"
 #include "AliMpMotifMap.h"
 #include "AliMpMotifPosition.h"
+#include "AliMpConstants.h"
 
+#include "AliLog.h"
+
+#include <TMath.h>
+#include <Riostream.h>
+
+/// \cond CLASSIMP
 ClassImp(AliMpRowSegment)
+/// \endcond
 
 //_____________________________________________________________________________
 AliMpRowSegment::AliMpRowSegment(AliMpRow* row, AliMpVMotif* motif, 
@@ -35,7 +56,8 @@ AliMpRowSegment::AliMpRowSegment(AliMpRow* row, AliMpVMotif* motif,
     fMotifPositionId(motifPositionId),
     fMotifPositionDId(motifPositionDId)
 {
-// 
+/// Standard constructor
   // Keep pad offset in the low indices limits
   SetLowIndicesLimit(padOffset);
 }
@@ -51,12 +73,13 @@ AliMpRowSegment::AliMpRowSegment()
     fMotifPositionId(0),
     fMotifPositionDId(0)
 {
-//
+/// Default constructor
 }
 
 //_____________________________________________________________________________
-AliMpRowSegment::~AliMpRowSegment() {
-//  
+AliMpRowSegment::~AliMpRowSegment() 
+{
+/// Destructor  
 }
 
 //
@@ -66,9 +89,8 @@ AliMpRowSegment::~AliMpRowSegment() {
 //_____________________________________________________________________________
 Double_t AliMpRowSegment::FirstMotifCenterX() const
 {
-// Returns the x coordinate of the first motif center
-// in global coordinate system.
-// ---
+/// Return the x coordinate of the first motif center
+/// in the global coordinate system.
 
   return fOffset.X();
 }  
@@ -76,9 +98,8 @@ Double_t AliMpRowSegment::FirstMotifCenterX() const
 //_____________________________________________________________________________
 Double_t AliMpRowSegment::LastMotifCenterX() const
 {
-// Returns the x coordinate of the last motif center
-// in global coordinate system.
-// ---
+/// Return the x coordinate of the last motif center
+/// in the global coordinate system.
 
   return fOffset.X() + 2.*(fNofMotifs-1)*fMotif->Dimensions().X();
 }
@@ -86,13 +107,12 @@ Double_t AliMpRowSegment::LastMotifCenterX() const
 //_____________________________________________________________________________
 Double_t AliMpRowSegment::MotifCenterX(Int_t motifPositionId) const
 {
-// Returns the x coordinate of the motif specified with
-// the given position identifier.
-// ---
+/// Return the x coordinate of the motif specified with
+/// the given position identifier.
 
   // Check if x is in the row segment range
   if (! HasMotifPosition(motifPositionId)) {
-    Error("MotifCenterX", "Outside row segment region");
+    AliErrorStream() << "Outside row segment region" << endl;
     return 0;
   }
   
@@ -105,13 +125,12 @@ Double_t AliMpRowSegment::MotifCenterX(Int_t motifPositionId) const
 //_____________________________________________________________________________
 Double_t AliMpRowSegment::MotifCenterY(Int_t motifPositionId) const
 {
-// Returns the y coordinate of the motif specified with
-// the given position identifier.
-// ---
+/// Return the y coordinate of the motif specified with
+/// the given position identifier.
 
   // Check if x is in the row segment range
   if (! HasMotifPosition(motifPositionId)) {
-    Error("MotifCenterY", "Outside row segment region");
+    AliErrorStream() << "Outside row segment region" << endl;
     return 0;
   }
   
@@ -121,8 +140,7 @@ Double_t AliMpRowSegment::MotifCenterY(Int_t motifPositionId) const
 //_____________________________________________________________________________
 Bool_t AliMpRowSegment::IsInside(const TVector2& position, Bool_t warn) const
 {
-// Checks if the position is inside some motif of this row segment.
-// ---
+/// Check if the position is inside some motif of this row segment.
 
   Double_t minY = GetRow()->Position().Y() + fOffset.Y() - fMotif->Dimensions().Y();
   Double_t maxY = GetRow()->Position().Y() + fOffset.Y() + fMotif->Dimensions().Y();
@@ -130,7 +148,8 @@ Bool_t AliMpRowSegment::IsInside(const TVector2& position, Bool_t warn) const
   if ( position.X() < LeftBorderX() || position.X() > RightBorderX() ||
        position.Y() < minY || position.Y() > maxY ) {
 
-    if (warn) Error("MotifPositionId", "Outside row segment region");
+    if (warn)
+      AliWarningStream() << "Outside row segment region" << endl;
     return false;
   }
   else
@@ -144,9 +163,8 @@ Bool_t AliMpRowSegment::IsInside(const TVector2& position, Bool_t warn) const
 //_____________________________________________________________________________
 Double_t  AliMpRowSegment::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.
 
   return FirstMotifCenterX() - fMotif->Dimensions().X();
 }
@@ -154,9 +172,8 @@ Double_t  AliMpRowSegment::LeftBorderX() const
 //_____________________________________________________________________________
 Double_t  AliMpRowSegment::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.
 
   return LastMotifCenterX() + fMotif->Dimensions().X();
 }
@@ -164,8 +181,7 @@ Double_t  AliMpRowSegment::RightBorderX() const
 //_____________________________________________________________________________
 Double_t  AliMpRowSegment::HalfSizeY() const
 {
-// Returns the size in y of this row segment.
-// ---
+/// Return the size in y of this row segment.
 
   return fMotif->Dimensions().Y() + fOffset.Y();
 }
@@ -173,8 +189,7 @@ Double_t  AliMpRowSegment::HalfSizeY() const
 //_____________________________________________________________________________
 AliMpVMotif*  AliMpRowSegment::FindMotif(const TVector2& position) const
 {
-// Returns the motif of this row; 
-// ---
+/// Return the motif of this row; 
 
   if (IsInside(position, false))
     return fMotif;
@@ -185,9 +200,8 @@ AliMpVMotif*  AliMpRowSegment::FindMotif(const TVector2& position) const
 //_____________________________________________________________________________
 Int_t AliMpRowSegment::FindMotifPositionId(const TVector2& position) const
 {
-// Returns the motif position identified for the given
-// geometric position.
-// ---
+/// Return the motif position identified for the given
+/// geometric position.
 
   if (!IsInside(position, false)) return 0;
 
@@ -202,9 +216,8 @@ Int_t AliMpRowSegment::FindMotifPositionId(const TVector2& position) const
 //_____________________________________________________________________________
 Bool_t AliMpRowSegment::HasMotifPosition(Int_t motifPositionId) const
 {
-// Returns true if the motif specified with the given position identifier
-// is in this segment.
-// ---
+/// Return true if the motif specified with the given position identifier
+/// is in this segment.
 
   Int_t minId = TMath::Min(fMotifPositionId, 
                     fMotifPositionId + (fNofMotifs-1)*fMotifPositionDId);
@@ -221,9 +234,8 @@ Bool_t AliMpRowSegment::HasMotifPosition(Int_t motifPositionId) const
 //_____________________________________________________________________________
 TVector2 AliMpRowSegment::MotifCenter(Int_t motifPositionId) const
 {
-// Returns the coordinates of the motif specified with
-// the given position identifier.
-// ---
+/// Return the coordinates of the motif specified with
+/// the given position identifier.
 
   return TVector2(MotifCenterX(motifPositionId), MotifCenterY(motifPositionId));
 }
@@ -231,8 +243,7 @@ TVector2 AliMpRowSegment::MotifCenter(Int_t motifPositionId) const
 //_____________________________________________________________________________
 TVector2 AliMpRowSegment::Position() const
 {
-// Returns the position of the row segment centre.
-// ---
+/// Return the position of the row segment centre.
 
   Double_t x = (LeftBorderX() + RightBorderX())/2.;                
   Double_t y = GetRow()->Position().Y();  
@@ -244,7 +255,7 @@ TVector2 AliMpRowSegment::Position() const
 //_____________________________________________________________________________
 TVector2 AliMpRowSegment::Dimensions() const
 {
-// Returns the halflengths of the row segment in x, y.
+/// Return the halflengths of the row segment in x, y.
 // ---
 
   Double_t x = (RightBorderX() - LeftBorderX())/2.;                
@@ -256,9 +267,8 @@ TVector2 AliMpRowSegment::Dimensions() const
 //_____________________________________________________________________________
 void   AliMpRowSegment::SetOffset(const TVector2& offset)
 {
-// Calculates offset from given offset and 
-// stored offset in pads.
-// ---
+/// Calculate offset from given offset and 
+/// stored offset in pads.
 
   AliMpMotifTypePadIterator iter(fMotif->GetMotifType());
   iter.First();
@@ -276,34 +286,52 @@ void   AliMpRowSegment::SetOffset(const TVector2& offset)
   fOffset = TVector2(offsetX, offsetY);
 }
 
+#include <Riostream.h>
 //_____________________________________________________________________________
-void AliMpRowSegment::SetGlobalIndices()
+void AliMpRowSegment::SetGlobalIndices(AliMpRow* /*rowBefore*/)
 {
-// Sets indices limits.
-// ---
+/// Set global indices limits.
 
-  AliMpMotifPosition* firstPos
-    = GetRow()->GetMotifMap()
-        ->FindMotifPosition(GetMotifPositionId(0));
-  
-  AliMpMotifPosition* lastPos
-    = GetRow()->GetMotifMap()
-        ->FindMotifPosition(GetMotifPositionId(GetNofMotifs()-1));
-         
-  // Check if the motif positions has the limits set
-  if ( !firstPos->HasValidIndices() || !lastPos->HasValidIndices())
-    Fatal("SetGlobalIndices", "Indices of motif positions have to be set first.");
+  // The low/high indices limits has to be taken as the highest/lowest from all 
+  // motif positions
+  Int_t ixl = 9999;
+  Int_t iyl = 9999;
+  Int_t ixh = AliMpConstants::StartPadIndex();
+  Int_t iyh = AliMpConstants::StartPadIndex();
+
+  for (Int_t i=0; i<GetNofMotifs(); i++) {
+     
+     AliMpMotifPosition* mPos 
+       = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i));
+       
+     // Check if the motif positions has the limits set
+     if ( !mPos->HasValidIndices() )
+       Fatal("SetGlobalIndices", 
+             "Indices of motif positions have to be set first.");
             
-  SetLowIndicesLimit(firstPos->GetLowIndicesLimit());
-  SetHighIndicesLimit(lastPos->GetHighIndicesLimit());
+     if ( mPos->GetLowIndicesLimit().GetFirst() < ixl ) 
+       ixl = mPos->GetLowIndicesLimit().GetFirst();
+       
+     if ( mPos->GetLowIndicesLimit().GetSecond() < iyl ) 
+       iyl = mPos->GetLowIndicesLimit().GetSecond();
+
+     if ( mPos->GetHighIndicesLimit().GetFirst() > ixh ) 
+       ixh = mPos->GetHighIndicesLimit().GetFirst();
+       
+     if ( mPos->GetHighIndicesLimit().GetSecond() > iyh ) 
+       iyh = mPos->GetHighIndicesLimit().GetSecond();
+  }     
+
+  SetLowIndicesLimit(AliMpIntPair(ixl, iyl));
+  SetHighIndicesLimit(AliMpIntPair(ixh, iyh));
 }  
 
 //_____________________________________________________________________________
-Int_t AliMpRowSegment::SetIndicesToMotifPosition(Int_t i, AliMpIntPair indices)
+Int_t AliMpRowSegment::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.
 
   // Get motif position
   AliMpMotifPosition* motifPosition
@@ -329,8 +357,7 @@ Int_t AliMpRowSegment::SetIndicesToMotifPosition(Int_t i, AliMpIntPair indices)
 //_____________________________________________________________________________
 AliMpRow*  AliMpRowSegment::GetRow() const
 {
-// Returns the row.which this row segment belongs to.
-// ---
+/// Return the row.which this row segment belongs to.
 
   return fRow;
 }  
@@ -338,8 +365,7 @@ AliMpRow*  AliMpRowSegment::GetRow() const
 //_____________________________________________________________________________
 Int_t  AliMpRowSegment::GetNofMotifs() const
 {
-// Returns number of motifs in this this row segment.
-// ---
+/// Return number of motifs in this this row segment.
 
   return fNofMotifs;
 }  
@@ -347,17 +373,15 @@ Int_t  AliMpRowSegment::GetNofMotifs() const
 //_____________________________________________________________________________
 Int_t  AliMpRowSegment::GetMotifPositionId(Int_t i) const
 {
-// Returns number of motifs in this this row segment.
-// ---
+/// Return number of motifs in this this row segment.
 
   return fMotifPositionId + i*fMotifPositionDId;
 }  
 
 //_____________________________________________________________________________
-AliMpVMotif*  AliMpRowSegment::GetMotif(Int_t i) const
+AliMpVMotif*  AliMpRowSegment::GetMotif(Int_t /*i*/) const
 {
-// Returns the motif of this row segment.
-// ---
+/// Return the motif of this row segment.
 
   return fMotif;
 }