+/**************************************************************************
+ * 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.12 2006/05/24 13:58:41 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"
#include "AliMpConstants.h"
-ClassImp(AliMpMotifSpecial)
-
+#include "AliLog.h"
-// private methods
-//______________________________________________________________________________
-Int_t AliMpMotifSpecial::VectorIndex(const AliMpIntPair& indices) const
-{
-// transform indices to linear vector index
- return indices.GetFirst()*GetMotifType()->GetNofPadsY() + indices.GetSecond();
-}
+#include <TString.h>
+/// \cond CLASSIMP
+ClassImp(AliMpMotifSpecial)
+/// \endcond
-//public methods
//______________________________________________________________________________
AliMpMotifSpecial::AliMpMotifSpecial():
AliMpVMotif(),
+ fDimensions(),
fPadDimensionsVector(),
fPadDimensionsVector2()
{
- //default dummy constructor
+ /// Default constructor
}
AliMpMotifSpecial::AliMpMotifSpecial(const TString &id,
AliMpMotifType *motifType)
: AliMpVMotif(id,motifType),
+ fDimensions(),
+#ifdef WITH_STL
fPadDimensionsVector(),
+#endif
+#ifdef WITH_ROOT
+ fPadDimensionsVector(true),
+#endif
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
+ /// 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
+//
+
+#include <Riostream.h>
//______________________________________________________________________________
TVector2
AliMpMotifSpecial::GetPadDimensions(const AliMpIntPair& localIndices) const
{
-// returns the dimensions of pad located at the given indices
- if (GetMotifType()->HasPad(localIndices))
+/// 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
+ if (!fPadDimensionsVector.GetValue(localIndices)) {
+ Warning("GetPadDimensions","Indices outside limits");
+ return TVector2(0.,0.);
+ }
+ else
+ return *((TVector2*)fPadDimensionsVector.GetValue(localIndices));
+#endif
+ }
else {
Warning("GetPadDimensions","Indices outside limits");
return TVector2(0.,0.);
//______________________________________________________________________________
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();
//______________________________________________________________________________
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.");
+ AliFatal("Index outside limits.");
return TVector2();
}
}
//______________________________________________________________________________
-TVector2 AliMpMotifSpecial::Dimensions() const
+void AliMpMotifSpecial::CalculateDimensions()
{
- // gives the dimension of the motif
-
+ /// Calculate motif dimensions and keep them in fDimensions data
Int_t i,j;
Double_t sizeY=0.;
if (tabSizeX[j]>sizeX) sizeX = tabSizeX[j];
}
- delete tabSizeX;
+ delete [] tabSizeX;
- return TVector2(sizeX,sizeY);
+ fDimensions = TVector2(sizeX,sizeY);
+}
+
+//______________________________________________________________________________
+TVector2 AliMpMotifSpecial::Dimensions() const
+{
+ /// Give the dimension of the motif
+
+ return fDimensions;
}
//______________________________________________________________________________
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);
//______________________________________________________________________________
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
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 \a localIndices to the given
+ /// \a dimensions
if ( !GetMotifType()->HasPad(localIndices)){
Warning("SetPadDimensions","Pad indices outside limits");
#ifdef WITH_ROOT
TVector2* dimensionsObj = new TVector2(dimensions);
- fPadDimensionsVector[VectorIndex(localIndices)]= dimensionsObj;
+ fPadDimensionsVector.Add(localIndices, dimensionsObj);
// fill the vector of different pad dimensions
// only if these dimensions are not yet present