]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpMotifSpecial.cxx
Changing __sparc to __sun to compile on solarisCC5
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotifSpecial.cxx
index 216c3c0514e9c834a4eb24cee570ec3a0de81234..3d90d9fbcf02d9e12aa44197b0cbe5e5e82014d7 100755 (executable)
@@ -1,13 +1,31 @@
+/**************************************************************************
+ * 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: AliMpMotifSpecial.cxx,v 1.8 2005/08/26 15:43:36 ivana Exp $
 // Category: motif
 //
 // Class AliMpMotifSpecial
 // -----------------------
 // Class that defines a motif with its unique ID
 // and the motif type.
-//
+// Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
 
+#include <TString.h>
+
 #include "AliMpMotifSpecial.h"
 #include "AliMpMotifType.h"
 #include "AliMpIntPair.h"
 ClassImp(AliMpMotifSpecial)
 
 
-// private methods
-//______________________________________________________________________________
-Int_t AliMpMotifSpecial::VectorIndex(const AliMpIntPair& indices) const
-{
-// transform indices to linear vector index
-  return indices.GetFirst()*GetMotifType()->GetNofPadsY() + indices.GetSecond();
-}
-
-
-
-//public methods
 //______________________________________________________________________________
 AliMpMotifSpecial::AliMpMotifSpecial():
   AliMpVMotif(),
   fPadDimensionsVector(),
   fPadDimensionsVector2()
 {
-  //default dummy constructor
+  /// Default constructor
 }
 
 
@@ -45,18 +52,58 @@ AliMpMotifSpecial::AliMpMotifSpecial(const TString &id,
     fPadDimensionsVector2()
   
 {
-  // Normal constructor.
+  /// Standard constructor.
 
+#ifdef WITH_STL
   fPadDimensionsVector.resize(motifType->GetNofPadsX()*motifType->GetNofPadsY());
+#endif  
+
+#ifdef WITH_ROOT
+  fPadDimensionsVector.Expand(motifType->GetNofPadsX()*motifType->GetNofPadsY());
+#endif  
+}
+
+//______________________________________________________________________________
+AliMpMotifSpecial::~AliMpMotifSpecial()
+{
+  /// Destructor
+
+#ifdef WITH_ROOT
+  fPadDimensionsVector.Delete();
+#endif  
+}
+
+
+//
+// private methods
+//
+
+//______________________________________________________________________________
+Int_t AliMpMotifSpecial::VectorIndex(const AliMpIntPair& indices) const
+{
+/// Transform indices to linear vector index
+
+  return indices.GetFirst()*GetMotifType()->GetNofPadsY() + indices.GetSecond();
 }
 
+
+//
+// public methods
+//
+
 //______________________________________________________________________________
 TVector2 
 AliMpMotifSpecial::GetPadDimensions(const AliMpIntPair& localIndices) const
 {
-// returns the dimensions of pad located at the given indices
+/// Return the dimensions of pad located at the given indices
+
   if (GetMotifType()->HasPad(localIndices))
+#ifdef WITH_STL
     return fPadDimensionsVector[VectorIndex(localIndices)];
+#endif  
+#ifdef WITH_ROOT
+    return  *((TVector2*)fPadDimensionsVector[VectorIndex(localIndices)]);
+#endif  
   else {
     Warning("GetPadDimensions","Indices outside limits");
     return TVector2(0.,0.);
@@ -66,28 +113,40 @@ AliMpMotifSpecial::GetPadDimensions(const AliMpIntPair& localIndices) const
 //______________________________________________________________________________
 Int_t AliMpMotifSpecial::GetNofPadDimensions() const
 {
-// returns number of different pad dimensions in this motif
+/// Return number of different pad dimensions in this motif
 
+#ifdef WITH_STL
   return fPadDimensionsVector2.size();
+#endif  
+
+#ifdef WITH_ROOT
+  return fPadDimensionsVector2.GetEntriesFast();
+#endif  
 }  
 
 //______________________________________________________________________________
 TVector2 AliMpMotifSpecial::GetPadDimensions(Int_t i) const
 {
-// returns the i-th different pad dimensions 
+/// Returns the i-th different pad dimensions 
 
   if (i<0 || i>GetNofPadDimensions()) {
     Fatal("GetPadDimensions(i)", "Index outside limits.");
     return TVector2();
   }  
 
+#ifdef WITH_STL
   return fPadDimensionsVector2[i];
+#endif  
+
+#ifdef WITH_ROOT
+  return *((TVector2*) fPadDimensionsVector2[i]);
+#endif  
 }  
 
 //______________________________________________________________________________
 TVector2 AliMpMotifSpecial::Dimensions() const
 {
-  // gives the dimension of the motif
+  /// Give the dimension of the motif
 
 
   Int_t i,j;
@@ -110,7 +169,7 @@ TVector2 AliMpMotifSpecial::Dimensions() const
     if (tabSizeX[j]>sizeX) sizeX = tabSizeX[j];
   }
 
-  delete tabSizeX;
+  delete [] tabSizeX;
   
   return TVector2(sizeX,sizeY);
 }
@@ -119,8 +178,8 @@ TVector2 AliMpMotifSpecial::Dimensions() const
 TVector2 
 AliMpMotifSpecial::PadPositionLocal(const AliMpIntPair& localIndices) const 
 {
-  // gives the local position of the pad number (ix,iy)
-  // (0,0 is the center of the motif)
+  /// Give the local position of the pad number (ix,iy)
+  /// (0,0 is the center of the motif)
 
   TVector2 dim = GetPadDimensions(localIndices);
   
@@ -140,13 +199,13 @@ AliMpMotifSpecial::PadPositionLocal(const AliMpIntPair& localIndices) const
 //______________________________________________________________________________
 AliMpIntPair AliMpMotifSpecial::PadIndicesLocal(const TVector2& localPos) const
 {
-  // return the pad indices from a given local position
-  // or AliMpIntPair::Invalid() if this position doesn't correspond to any valid
-  // connection
-
-  // *SOLEIL* : This code suppose that
-  // 1) all cells have the same size along the Y direction
-  // 2) the column 0 is entierly filled
+  /// Return the pad indices from a given local position
+  /// or AliMpIntPair::Invalid() if this position doesn't correspond to any valid
+  /// connection
+  ///
+  /// *SOLEIL* : This code suppose that
+  /// - 1) all cells have the same size along the Y direction
+  /// - 2) the column 0 is entierly filled
     
 
   // First : find the j index
@@ -194,8 +253,8 @@ AliMpIntPair AliMpMotifSpecial::PadIndicesLocal(const TVector2& localPos) const
 void AliMpMotifSpecial::SetPadDimensions(const AliMpIntPair& localIndices,
                                          const TVector2& dimensions)
 {
-  // set the dimensions of the pad located at <localIndices> to the given
-  // <dimensions>
+  /// Set the dimensions of the pad located at <localIndices> to the given
+  /// <dimensions>
   
   if ( !GetMotifType()->HasPad(localIndices)){
     Warning("SetPadDimensions","Pad indices outside limits");
@@ -203,6 +262,7 @@ void AliMpMotifSpecial::SetPadDimensions(const AliMpIntPair& localIndices,
   }  
 
   // fill the dimensions map vector
+#ifdef WITH_STL
   fPadDimensionsVector[VectorIndex(localIndices)]=dimensions;
   
   // fill the vector of different pad dimensions
@@ -214,4 +274,21 @@ void AliMpMotifSpecial::SetPadDimensions(const AliMpIntPair& localIndices,
   }    
   
   if (!isPresent) fPadDimensionsVector2.push_back(dimensions);
+#endif  
+
+#ifdef WITH_ROOT
+  TVector2* dimensionsObj = new TVector2(dimensions);
+  fPadDimensionsVector[VectorIndex(localIndices)]= dimensionsObj;
+
+  // fill the vector of different pad dimensions
+  // only if these dimensions are not yet present
+  Bool_t isPresent = false;
+  for (Int_t i=0; i<GetNofPadDimensions(); i++) {
+    if (AliMpConstants::IsEqual(*((TVector2*) fPadDimensionsVector2[i]), dimensions)) 
+      isPresent = true;    
+  }    
+  
+  if (!isPresent) fPadDimensionsVector2.Add(dimensionsObj);
+#endif  
+  
 }