]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpVRowSegmentSpecial.cxx
In Print(): added an option to print area borders
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpVRowSegmentSpecial.cxx
index 5f52683bfba101eb86c2fa28a9924036cfdb5b99..52943ee8fd4db94a5f6262339e43381e9060b58b 100644 (file)
@@ -1,15 +1,30 @@
+/**************************************************************************
+ * 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: 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 <TError.h>
-#include <Riostream.h>
+//-----------------------------------------------------------------------------
 
 #include "AliMpVRowSegmentSpecial.h"
 #include "AliMpRow.h"
 #include "AliMpMotifPosition.h"
 #include "AliMpConstants.h"
 
+#include <Riostream.h>
+
+/// \cond CLASSIMP
 ClassImp(AliMpVRowSegmentSpecial)
+/// \endcond
+
+#ifdef WITH_ROOT
+const Int_t  AliMpVRowSegmentSpecial::fgkMaxNofMotifPositionIds = 20;
+#endif    
 
 //______________________________________________________________________________
 AliMpVRowSegmentSpecial::AliMpVRowSegmentSpecial(AliMpRow* row, Double_t offsetX)
@@ -31,8 +54,11 @@ AliMpVRowSegmentSpecial::AliMpVRowSegmentSpecial(AliMpRow* row, Double_t offsetX
     fPadRows(),
     fMotifs(),
     fMotifPositionIds()
+#ifdef WITH_ROOT
+    ,fNofMotifPositionIds(0)
+#endif    
 {
-// 
+/// Standard constructor  
 }
 
 //______________________________________________________________________________
@@ -43,14 +69,22 @@ AliMpVRowSegmentSpecial::AliMpVRowSegmentSpecial()
     fPadRows(),
     fMotifs(),
     fMotifPositionIds()
+#ifdef WITH_ROOT
+    ,fNofMotifPositionIds(0)
+#endif    
 {
-//
+/// Default constructor  
+
+#ifdef WITH_ROOT
+   fMotifPositionIds.Set(fgkMaxNofMotifPositionIds);
+#endif    
 }
 
 //______________________________________________________________________________
 AliMpVRowSegmentSpecial::~AliMpVRowSegmentSpecial() 
 {
-//  
+/// Destructor
+  
   for (Int_t i=0; i<GetNofPadRows(); i++)
     delete fPadRows[i];
 }
@@ -62,8 +96,7 @@ AliMpVRowSegmentSpecial::~AliMpVRowSegmentSpecial()
 //______________________________________________________________________________
 AliMpPadRow*  AliMpVRowSegmentSpecial::FindPadRow(Double_t y) const
 {
-// Finds the pad row in the given y coordinate.
-// ---
+/// Find the pad row in the given y coordinate.
 
   Double_t lowBorder =  fRow->LowBorderY();
   Double_t highBorder = fRow->LowBorderY();
@@ -86,8 +119,7 @@ AliMpPadRow*  AliMpVRowSegmentSpecial::FindPadRow(Double_t y) const
 AliMpVPadRowSegment*  
 AliMpVRowSegmentSpecial::FindPadRowSegment(Int_t motifPositionId) const
 {
-// Find the most down pad row segment with this motifPositionId.
-// ---
+/// Find the most down pad row segment with this motifPositionId.
 
   for (Int_t i=0; i<GetNofPadRows(); i++) {
     AliMpPadRow* padRow = GetPadRow(i);    
@@ -106,9 +138,8 @@ AliMpVRowSegmentSpecial::FindPadRowSegment(Int_t motifPositionId) const
 AliMpIntPair 
 AliMpVRowSegmentSpecial::FindRelativeLowIndicesOf(Int_t motifPositionId) const 
 { 
-// Returns the lowest pad indices where the motif of the given position ID
-// exists in this segment.
-// ---
+/// Return the lowest pad indices where the motif of the given position ID
+/// exist in this segment.
 
   AliMpIntPair ans(0,1000);
   AliMpIntPair ans0 = ans;
@@ -138,8 +169,7 @@ AliMpVRowSegmentSpecial::FindRelativeLowIndicesOf(Int_t motifPositionId) const
 //______________________________________________________________________________
 Int_t  AliMpVRowSegmentSpecial::MaxNofPadsInRow() const 
 { 
-// Returns the maximum number of pads in this row segment along the X direction
-// ---
+/// Return the maximum number of pads in this row segment along the X direction
 
   Int_t maxNofPads = 0;    
 
@@ -156,12 +186,18 @@ Int_t  AliMpVRowSegmentSpecial::MaxNofPadsInRow() const
 //______________________________________________________________________________
 Bool_t AliMpVRowSegmentSpecial::HasMotif(const AliMpVMotif* motif) const
 {
-// Returns true if the specified motif is already in fMotifs vector,
-// returns false otherwise.
-// ---
+/// 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;         
 }
@@ -169,19 +205,29 @@ Bool_t AliMpVRowSegmentSpecial::HasMotif(const AliMpVMotif* motif) const
 //______________________________________________________________________________
 Int_t AliMpVRowSegmentSpecial::GetNofPadRows() const
 {
-// Returns number of pad rows.
-// ---
+/// Return number of pad rows.
 
+#ifdef WITH_STL
   return fPadRows.size();
+#endif
+
+#ifdef WITH_ROOT
+  return fPadRows.GetEntriesFast();
+#endif
 }  
 
 //______________________________________________________________________________
 AliMpPadRow* AliMpVRowSegmentSpecial::GetPadRow(Int_t i) const
 {
-// Returns number of pad rows.
-// ---
+/// Return number of pad rows.
 
+#ifdef WITH_STL
   return fPadRows[i];
+#endif
+
+#ifdef WITH_ROOT
+  return (AliMpPadRow*)fPadRows[i];
+#endif
 }  
 
 //
@@ -191,20 +237,25 @@ AliMpPadRow* AliMpVRowSegmentSpecial::GetPadRow(Int_t i) const
 //______________________________________________________________________________
 void  AliMpVRowSegmentSpecial::AddPadRow(AliMpPadRow* padRow)
 {
-// Adds a pad row.
-// ---
+/// Add a pad row.
 
   padRow->SetOffsetX(fOffsetX);
   padRow->SetID(GetNofPadRows());
+
+#ifdef WITH_STL
   fPadRows.push_back(padRow);
+#endif
+
+#ifdef WITH_ROOT
+  fPadRows.Add(padRow);
+#endif
 }  
 
 //______________________________________________________________________________
 void AliMpVRowSegmentSpecial::UpdateMotifVector()
 {
-// Add motifs associated with the pad row segments in the specified
-// pad row in the fMotifs vector.
-// ---
+/// Add motifs associated with the pad row segments in the specified
+/// pad row in the fMotifs vector.
 
   for (Int_t i=0; i<GetNofPadRows(); i++) {
     AliMpPadRow* padRow = GetPadRow(i);
@@ -213,9 +264,22 @@ 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
+       if (fNofMotifPositionIds<fgkMaxNofMotifPositionIds)
+         fMotifPositionIds.Set(fMotifPositionIds.GetSize()+
+                               fgkMaxNofMotifPositionIds);      
+        fMotifPositionIds.AddAt(
+          padRow->GetPadRowSegment(j)->GetMotifPositionId(),
+         fNofMotifPositionIds++);
+#endif
       }
     }  
   }
@@ -224,8 +288,7 @@ void AliMpVRowSegmentSpecial::UpdateMotifVector()
 //______________________________________________________________________________
 Double_t  AliMpVRowSegmentSpecial::HalfSizeY() const
 {
-// Returns the size in y of this row segment.
-// ---
+/// Return the size in y of this row segment.
 
   Double_t halfSizeY = 0.;
   for (Int_t i=0; i<GetNofPadRows(); i++) {
@@ -238,8 +301,7 @@ Double_t  AliMpVRowSegmentSpecial::HalfSizeY() const
 //______________________________________________________________________________
 AliMpVMotif*  AliMpVRowSegmentSpecial::FindMotif(const TVector2& position) const
 {
-// Returns the motif of this row; 
-// ---
+/// Return the motif of this row; 
 
   AliMpPadRow* padRow 
     = FindPadRow(position.Y());
@@ -257,9 +319,8 @@ AliMpVMotif*  AliMpVRowSegmentSpecial::FindMotif(const TVector2& position) const
 //______________________________________________________________________________
 Int_t AliMpVRowSegmentSpecial::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.
 
   AliMpPadRow* padRow 
     = FindPadRow(position.Y());
@@ -277,9 +338,8 @@ Int_t AliMpVRowSegmentSpecial::FindMotifPositionId(const TVector2& position) con
 //______________________________________________________________________________
 Bool_t AliMpVRowSegmentSpecial::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.
 
   if (FindPadRowSegment(motifPositionId))
     return true;
@@ -290,9 +350,8 @@ Bool_t AliMpVRowSegmentSpecial::HasMotifPosition(Int_t motifPositionId) const
 //______________________________________________________________________________
 TVector2 AliMpVRowSegmentSpecial::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.
 
   // Try to get the motif position from the motif map first
   AliMpMotifPosition* motifPosition
@@ -306,8 +365,7 @@ TVector2 AliMpVRowSegmentSpecial::MotifCenter(Int_t motifPositionId) const
 //______________________________________________________________________________
 TVector2 AliMpVRowSegmentSpecial::Dimensions() const
 {
-// Returns the halflengths in x, y of the row segment rectangular envelope.
-// ---
+/// Return the halflengths in x, y of the row segment rectangular envelope.
 
   Double_t x = 0.;                 
   Double_t y = 0.;  
@@ -327,44 +385,10 @@ TVector2 AliMpVRowSegmentSpecial::Dimensions() const
   return TVector2(x, y);   
 }
 
-//______________________________________________________________________________
-void AliMpVRowSegmentSpecial::SetGlobalIndices()
-{
-// Sets indices limits.
-// ---
-
-  AliMpMotifPosition* firstPos = 0;
-  AliMpMotifPosition* lastPos = 0;
-       
-  for (Int_t i=0;i<GetNofMotifs();i++) {
-    AliMpMotifPosition* mPos
-      = GetRow()->GetMotifMap()
-        ->FindMotifPosition(GetMotifPositionId(i));
-       
-    if (!firstPos || 
-        mPos->GetLowIndicesLimit().GetFirst()
-       < firstPos->GetLowIndicesLimit().GetFirst())
-       firstPos = mPos;
-       
-    if (!lastPos || 
-        mPos->GetHighIndicesLimit().GetFirst()
-       >lastPos->GetHighIndicesLimit().GetFirst())
-       lastPos = mPos;
-  }
-
-  // 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.");
-
-  SetLowIndicesLimit(firstPos->GetLowIndicesLimit());
-  SetHighIndicesLimit(lastPos->GetHighIndicesLimit());
-}  
-
 //______________________________________________________________________________
 AliMpRow*  AliMpVRowSegmentSpecial::GetRow() const
 {
-// Returns the row.which this row segment belongs to.
-// ---
+/// Return the row.which this row segment belongs to.
 
   return fRow;
 }  
@@ -372,26 +396,33 @@ AliMpRow*  AliMpVRowSegmentSpecial::GetRow() const
 //______________________________________________________________________________
 Int_t  AliMpVRowSegmentSpecial::GetNofMotifs() const 
 { 
-// Returns the number of different motifs present in this row segment.
-// ---
+/// 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
 }  
 
 //______________________________________________________________________________
 AliMpVMotif* AliMpVRowSegmentSpecial::GetMotif(Int_t i) const  
 {
-// Returns the i-th motif present in this row segment.
-// ---
+/// 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
 }
 
 //______________________________________________________________________________
 Int_t  AliMpVRowSegmentSpecial::GetMotifPositionId(Int_t i) const 
 { 
-// Returns the i-th motif position Id present in this row segment.
-// ---
+/// Return the i-th motif position Id present in this row segment.
 
    return fMotifPositionIds[i]; 
 }