+/**************************************************************************
+ * 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: AliMpSector.cxx,v 1.14 2006/05/24 13:58:46 ivana Exp $
// Category: sector
//
// Class AliMpSector
// Included in AliRoot: 2003/05/02
// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
-#include <TError.h>
-#include <Riostream.h>
-
#include "AliMpSector.h"
#include "AliMpSectorPadIterator.h"
#include "AliMpZone.h"
#include "AliMpIntPair.h"
#include "AliMpConstants.h"
+#include "AliLog.h"
+
+#include <Riostream.h>
+
+/// \cond CLASSIMP
ClassImp(AliMpSector)
+/// \endcond
//_____________________________________________________________________________
AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows,
- AliMpDirection direction, const TVector2& offset)
- : TObject(),
+ AliMp::Direction direction, const TVector2& offset)
+ : TNamed("Sector", ""),
fID(id),
fOffset(offset),
fZones(),
fRows(),
+ fMotifMap(0),
fDirection(direction),
- fMinPadDimensions(TVector2(1.e6, 1.e6))
+ fMinPadDimensions(TVector2(1.e6, 1.e6)),
+ fMaxPadDimensions(),
+ fMaxPadIndices(AliMpIntPair::Invalid()),
+ fNofPads(0)
{
-//
- fMotifMap = new AliMpMotifMap();
+/// Standard constructor
+
+ AliDebugStream(1) << "this = " << this << endl;
+
+ fMotifMap = new AliMpMotifMap(true);
+ //fMotifMap = new AliMpMotifMap();
#ifdef WITH_STL
for (Int_t izone = 0; izone<nofZones; izone++)
#endif
}
-//_____________________________________________________________________________
-AliMpSector::AliMpSector(const AliMpSector& right)
- : TObject(right) {
-//
- Fatal("AliMpSector", "Copy constructor not provided.");
-}
-
//_____________________________________________________________________________
AliMpSector::AliMpSector()
- : TObject(),
+ : TNamed(),
fID(""),
fOffset(TVector2(0., 0.)),
fZones(),
fRows(),
fMotifMap(0),
- fDirection(kX),
- fMinPadDimensions(TVector2(0., 0.))
+ fDirection(AliMp::kX),
+ fMinPadDimensions(TVector2(0., 0.)),
+ fMaxPadDimensions(),
+ fMaxPadIndices(AliMpIntPair::Invalid()),
+ fNofPads(0)
{
-//
+/// Default constructor
+
+ AliDebugStream(1) << "this = " << this << endl;
}
//_____________________________________________________________________________
-AliMpSector::~AliMpSector() {
-//
+AliMpSector::~AliMpSector()
+{
+/// Destructor
+
+ AliDebugStream(1) << "this = " << this << endl;
+
// deletes
for (Int_t izone = 0; izone<GetNofZones(); izone++)
delete fZones[izone];
delete fMotifMap;
}
-//
-// operators
-//
-
-//_____________________________________________________________________________
-AliMpSector& AliMpSector::operator=(const AliMpSector& right)
-{
- // check assignement to self
- if (this == &right) return *this;
-
- Fatal("operator =", "Assignement operator not provided.");
-
- return *this;
-}
-
//
// private methods
//
//_____________________________________________________________________________
AliMpVPadIterator* AliMpSector::CreateIterator() const
{
+/// Create sector pad iterator
+
return new AliMpSectorPadIterator(this);
}
//_____________________________________________________________________________
AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const
{
-// Finds the row segment in the specified position.
-// Returns 0 if no motif is found.
-// ---
+/// Find the row segment in the specified position. \n
+/// Return if no motif is found.
// Find row
AliMpRow* row = FindRow(position);
//_____________________________________________________________________________
void AliMpSector::SetRowOffsets()
{
-// For each row checks consitency of the row segments
-// and calculates the row offset.
-// ---
+/// For each row check consitency of the row segments
+/// and calculate the row offset.
Double_t offset = fOffset.Y();
//_____________________________________________________________________________
void AliMpSector::SetMotifPositions()
{
-// Creates motif positions objects and fills them in the motif map.
-// ---
+/// Create motif positions objects and fills them in the motif map.
for (Int_t i=0; i<GetNofRows(); i++)
GetRow(i)->SetMotifPositions();
//_____________________________________________________________________________
void AliMpSector::SetGlobalIndices()
{
-// Set the indices limits to all indexed elements
-// (row, row segment, motif positions).
-// ---
+/// Set the indices limits to all indexed elements
+/// (row, row segment, motif positions).
AliMpIntPair indices(0,0);
AliMpRow* rowBefore=0;
}
//_____________________________________________________________________________
-void AliMpSector::SetMinPadDimensions()
+void AliMpSector::SetMinMaxPadDimensions()
{
-// Sets the minimal pad dimensions.
-// ---
+/// Set the minimal pad dimensions.
for (Int_t i=1; i<GetNofZones()+1; i++) {
TVector2 padDimensions = GetZone(i)->GetPadDimensions();
- if ( fDirection == kX &&
+ if ( fDirection == AliMp::kX &&
padDimensions.Y() > 0. && padDimensions.Y() < fMinPadDimensions.Y() ||
- fDirection == kY &&
+ fDirection == AliMp::kY &&
padDimensions.X() > 0. && padDimensions.X() < fMinPadDimensions.X())
fMinPadDimensions = padDimensions;
+
+ if ( fDirection == AliMp::kX &&
+ padDimensions.Y() > 0. && padDimensions.Y() > fMaxPadDimensions.Y() ||
+ fDirection == AliMp::kY &&
+ padDimensions.X() > 0. && padDimensions.X() > fMinPadDimensions.X())
+
+ fMaxPadDimensions = padDimensions;
}
}
+//_____________________________________________________________________________
+void AliMpSector::SetMaxPadIndices()
+{
+/// Set maximum pad indices in x, y
+
+ if ( fMaxPadIndices != AliMpIntPair::Invalid() ) return;
+
+ Int_t maxIndexInX = 0;
+ Int_t maxIndexInY = 0;
+ for (Int_t i=0; i<GetNofRows(); i++) {
+
+ Int_t ixh = GetRow(i)->GetHighIndicesLimit().GetFirst();
+ if ( ixh > maxIndexInX ) maxIndexInX = ixh;
+
+ Int_t iyh = GetRow(i)->GetHighIndicesLimit().GetSecond();
+ if ( iyh > maxIndexInY ) maxIndexInY = iyh;
+ }
+
+ fMaxPadIndices = AliMpIntPair(maxIndexInX, maxIndexInY);
+}
+
+
+//_____________________________________________________________________________
+void AliMpSector::SetNofPads()
+{
+/// Set the total number of pads
+
+ fNofPads = fMotifMap->CalculateNofPads();
+}
+
//
// public methods
//
//_____________________________________________________________________________
void AliMpSector::SetRowSegmentOffsets()
{
-// For all rows sets offset to all row segments.
-// ---
+/// For all rows set the offset to all row segments.
for (Int_t irow=0; irow<GetNofRows(); irow++)
GetRow(irow)->SetRowSegmentOffsets(fOffset);
//_____________________________________________________________________________
void AliMpSector::Initialize()
{
-// Makes needed settings after sector is read from
-// data files.
-// ---
+/// Make needed settings after sector is read from
+/// data files.
SetRowOffsets();
SetMotifPositions();
SetGlobalIndices();
- SetMinPadDimensions();
+ SetMinMaxPadDimensions();
+ SetMaxPadIndices();
+ SetNofPads();
}
//_____________________________________________________________________________
void AliMpSector::PrintGeometry() const
{
-// Prints the positions of rows, rows segments
-// ---
+/// Print the positions of rows, rows segments
for (Int_t i=0; i<GetNofRows(); i++) {
AliMpRow* row = GetRow(i);
//_____________________________________________________________________________
AliMpRow* AliMpSector::FindRow(const TVector2& position) const
{
-// Finds the row for the specified y position.
-// If y is on border the lowest row is returned.
-// ---
+/// Find the row for the specified y position. \n
+/// If y is on border the lowest row is returned.
Double_t y = position.Y();
//_____________________________________________________________________________
AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const
{
-// Finds the motif in the specified position.
-// Returns 0 if no motif is found.
-// ---
+/// Find the motif in the specified position. \n
+/// Return 0 if no motif is found.
// Find the row segment
AliMpVRowSegment* rowSegment = FindRowSegment(position);
// Find motif
return rowSegment->FindMotif(position);
}
-
//_____________________________________________________________________________
Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const
{
-// Finds the motif position ID in the specified position.
-// Returns 0 if no motif is found.
-// ---
-
+/// Find the motif position ID in the specified position. \n
+/// Return 0 if no motif is found.
+
// Find the row segment
AliMpVRowSegment* rowSegment = FindRowSegment(position);
//_____________________________________________________________________________
AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
{
-// Finds the row with the the specified motif position.
-// Returns 0 if no row is found.
-// ---
+/// Find the row with the the specified motif position. \n
+/// Return 0 if no row is found.
AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
//_____________________________________________________________________________
AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
{
-// Finds the row segment with the the specified motif position.
-// Returns 0 if no row segment is found.
-// ---
+/// Find the row segment with the the specified motif position. \n
+/// Return 0 if no row segment is found.
for (Int_t irow=0; irow<GetNofRows(); irow++) {
//_____________________________________________________________________________
TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const
{
-// Finds the position of the motif specified by its position Id.
-// Returns 0 if no row segment is found.
-// ---
+/// Find the position of the motif specified by its position Id. \n
+/// Return 0 if no row segment is found.
AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
if (!segment) {
- Warning("FindPosition", "Given motifPositionId not found.");
+ AliWarningStream() << "Given motifPositionId not found." << endl;
return TVector2();
}
//_____________________________________________________________________________
AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const
{
-// Finds the zone with specified padDimensions.
-// ---
+/// Find the zone with specified padDimensions.
for (Int_t i=0; i<GetNofZones(); i++) {
AliMpZone* zone = GetZone(i+1);
//_____________________________________________________________________________
TVector2 AliMpSector::Position() const
{
-// Returns the offset.
-// ---
+/// Return the sector offset.
return fOffset;
}
//_____________________________________________________________________________
TVector2 AliMpSector::Dimensions() const
{
-// Returns the maximum halflength in x, y.
-// ---
+/// Return the maximum halflengths in x, y.
Double_t x = 0.;
Double_t y = 0.;
//_____________________________________________________________________________
Int_t AliMpSector::GetNofZones() const
{
-// Returns the number of zones.
-// ---
+/// Return the number of zones.
#ifdef WITH_STL
return fZones.size();
//_____________________________________________________________________________
AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
{
-// Returns zone with specified ID.
-// ---
+/// Return zone with specified ID.
if (zoneID < 1 || zoneID > GetNofZones()) {
- Warning("GetZone", "Index outside range");
+ AliWarningStream() << "Index outside range" << endl;
return 0;
}
//_____________________________________________________________________________
Int_t AliMpSector::GetNofRows() const
{
-// Returns the number of rows.
-// ---
+/// Return the number of rows.
#ifdef WITH_STL
return fRows.size();
//_____________________________________________________________________________
AliMpRow* AliMpSector::GetRow(Int_t rowID) const
{
-// Returns row with specified ID.
-// ---
+/// Return row with specified ID.
if (rowID < 0 || rowID >= GetNofRows()) {
- Warning("GetRow", "Index outside range");
+ AliWarningStream() << "Index outside range" << endl;
return 0;
}
return (AliMpRow*)fRows[rowID];
#endif
}
+
+//_____________________________________________________________________________
+AliMp::PlaneType
+AliMpSector::GetPlaneType() const
+{
+/// Return the plane type
+
+ return GetDirection()==AliMp::kY ? AliMp::kBendingPlane : AliMp::kNonBendingPlane;
+}
+
+//_____________________________________________________________________________
+void
+AliMpSector::GetAllMotifPositionsIDs(TArrayI& ecn) const
+{
+/// Return the array of all motif positions IDs
+
+ fMotifMap->GetAllMotifPositionsIDs(ecn);
+}
+
+//_____________________________________________________________________________
+void
+AliMpSector::Print(Option_t* opt) const
+{
+/// Print the map of motifs
+
+ cout << "Sector," << PlaneTypeName(GetPlaneType()) << endl;
+ fMotifMap->Print(opt);
+}