#include "AliMpVRowSegment.h"
#include "AliMpVMotif.h"
#include "AliMpMotifMap.h"
-#include "AliMpIntPair.h"
+#include "AliMpEncodePair.h"
#include "AliMpConstants.h"
#include "AliLog.h"
//_____________________________________________________________________________
AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows,
- AliMp::Direction direction, const TVector2& offset)
+ AliMp::Direction direction,
+ Double_t offsetx, Double_t offsety)
: TNamed("Sector", ""),
fID(id),
- fOffset(offset),
+ fOffsetX(offsetx),
+ fOffsetY(offsety),
+ fDimensionX(0.),
+ fDimensionY(0.),
fZones(),
fRows(),
fMotifMap(0),
fDirection(direction),
- fMinPadDimensions(TVector2(1.e6, 1.e6)),
- fMaxPadDimensions(),
- fMaxPadIndices(AliMpIntPair::Invalid()),
+ fMinPadDimensionX(1.e6),
+ fMinPadDimensionY(1.e6),
+ fMaxPadDimensionX(0.),
+ fMaxPadDimensionY(0.),
+ fLMaxPadIndices(0),
fNofPads(0)
{
/// Standard constructor
fMotifMap = new AliMpMotifMap;
-#ifdef WITH_STL
- for (Int_t izone = 0; izone<nofZones; izone++)
- fZones.push_back(new AliMpZone(izone+1));
-
- for (Int_t irow = 0; irow<nofRows; irow++)
- fRows.push_back(new AliMpRow(irow, fMotifMap));
-#endif
-
-#ifdef WITH_ROOT
for (Int_t izone = 0; izone<nofZones; izone++)
fZones.Add(new AliMpZone(izone+1));
for (Int_t irow = 0; irow<nofRows; irow++)
fRows.Add(new AliMpRow(irow, fMotifMap));
-#endif
+
}
//_____________________________________________________________________________
AliMpSector::AliMpSector()
: TNamed(),
fID(""),
- fOffset(TVector2(0., 0.)),
+ fOffsetX(0.),
+ fOffsetY(0.),
+ fDimensionX(0.),
+ fDimensionY(0.),
fZones(),
fRows(),
fMotifMap(0),
fDirection(AliMp::kX),
- fMinPadDimensions(TVector2(0., 0.)),
- fMaxPadDimensions(),
- fMaxPadIndices(AliMpIntPair::Invalid()),
+ fMinPadDimensionX(0.),
+ fMinPadDimensionY(0.),
+ fMaxPadDimensionX(0.),
+ fMaxPadDimensionY(0.),
+ fLMaxPadIndices(0),
fNofPads(0)
{
/// Default constructor
//
//_____________________________________________________________________________
-AliMpVPadIterator* AliMpSector::CreateIterator() const
+AliMpRow* AliMpSector::FindRow(Double_t y) const
{
-/// Create sector pad iterator
-
- return new AliMpSectorPadIterator(this);
+/// Find the row for the specified y position. \n
+/// If y is on border the lowest row is returned.
+
+ for (Int_t i=0; i<GetNofRows(); i++) {
+ if ( y >= ((AliMpRow*)fRows[i])->LowBorderY() &&
+ y <= ((AliMpRow*)fRows[i])->UpperBorderY())
+ return (AliMpRow*)fRows[i];
+ }
+
+ return 0;
}
+//_____________________________________________________________________________
+Int_t AliMpSector::FindMotifPositionId(Double_t x, Double_t y) const
+{
+/// Find the motif position ID in the specified position. \n
+/// Return 0 if no motif is found.
+
+ // Find the row segment
+ AliMpVRowSegment* rowSegment = FindRowSegment(x,y);
+
+ if ( ! rowSegment ) return 0;
+
+ // Find motif position ID
+ return rowSegment->FindMotifPositionId(x, y);
+}
//_____________________________________________________________________________
-AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const
+AliMpVRowSegment* AliMpSector::FindRowSegment(Double_t x, Double_t y) const
{
/// Find the row segment in the specified position. \n
/// Return if no motif is found.
// Find row
- AliMpRow* row = FindRow(position);
+ AliMpRow* row = FindRow(y);
if (!row) return 0;
// Find the row segment and return its motif
- AliMpVRowSegment* rowSegment = row->FindRowSegment(position.X());
+ AliMpVRowSegment* rowSegment = row->FindRowSegment(x);
return rowSegment;
}
/// For each row check consitency of the row segments
/// and calculate the row offset.
- Double_t offset = fOffset.Y();
+ Double_t offset = fOffsetY;
for (Int_t irow=0; irow<GetNofRows(); irow++)
offset = GetRow(irow)->SetOffsetY(offset);
/// Set the indices limits to all indexed elements
/// (row, row segment, motif positions).
- AliMpIntPair indices(0,0);
AliMpRow* rowBefore=0;
for (Int_t i=0; i<GetNofRows(); i++) {
GetRow(i)->SetGlobalIndices(fDirection, rowBefore);
/// Set the minimal pad dimensions.
for (Int_t i=1; i<GetNofZones()+1; i++) {
- TVector2 padDimensions = GetZone(i)->GetPadDimensions();
+ Double_t dx = GetZone(i)->GetPadDimensionX();
+ Double_t dy = GetZone(i)->GetPadDimensionY();
- if ( (fDirection == AliMp::kX &&
- padDimensions.Y() > 0. && padDimensions.Y() < fMinPadDimensions.Y()) ||
- (fDirection == AliMp::kY &&
- padDimensions.X() > 0. && padDimensions.X() < fMinPadDimensions.X()))
+ if ( ( fDirection == AliMp::kX && dy > 0. && dy < fMinPadDimensionY ) ||
+ ( fDirection == AliMp::kY && dx > 0. && dx < fMinPadDimensionX ) ) {
- fMinPadDimensions = padDimensions;
+ fMinPadDimensionX = dx;
+ fMinPadDimensionY = dy;
+ }
- if ( (fDirection == AliMp::kX &&
- padDimensions.Y() > 0. && padDimensions.Y() > fMaxPadDimensions.Y()) ||
- (fDirection == AliMp::kY &&
- padDimensions.X() > 0. && padDimensions.X() > fMinPadDimensions.X()))
+ if ( ( fDirection == AliMp::kX && dy > 0. && dy > fMaxPadDimensionY ) ||
+ ( fDirection == AliMp::kY && dx > 0. && dx > fMinPadDimensionX ) ) {
- fMaxPadDimensions = padDimensions;
+ fMaxPadDimensionX = dx;
+ fMaxPadDimensionY = dy;
+ }
}
}
{
/// Set maximum pad indices in x, y
- if ( fMaxPadIndices != AliMpIntPair::Invalid() ) return;
+ if ( fLMaxPadIndices != 0 ) return;
Int_t maxIndexInX = 0;
Int_t maxIndexInY = 0;
for (Int_t i=0; i<GetNofRows(); i++) {
- Int_t ixh = GetRow(i)->GetHighIndicesLimit().GetFirst();
+ Int_t ixh = GetRow(i)->GetHighLimitIx();
if ( ixh > maxIndexInX ) maxIndexInX = ixh;
- Int_t iyh = GetRow(i)->GetHighIndicesLimit().GetSecond();
+ Int_t iyh = GetRow(i)->GetHighLimitIy();
if ( iyh > maxIndexInY ) maxIndexInY = iyh;
}
- fMaxPadIndices = AliMpIntPair(maxIndexInX, maxIndexInY);
+ fLMaxPadIndices = AliMp::Pair(maxIndexInX, maxIndexInY);
}
fNofPads = fMotifMap->CalculateNofPads();
}
+//_____________________________________________________________________________
+void AliMpSector::SetDimensions()
+{
+/// Set the maximum halflengths in x, y.
+
+ fDimensionX = 0.;
+ fDimensionY = 0.;
+
+ for (Int_t i=0; i<GetNofRows(); i++) {
+
+ // take the largest x row dimension
+ if ( ((AliMpRow*)fRows[i])->GetDimensionX() > fDimensionX )
+ fDimensionX = ((AliMpRow*)fRows[i])->GetDimensionX();
+
+ // add all rows y dimensions
+ fDimensionY += ((AliMpRow*)fRows[i])->GetDimensionY();
+ }
+}
+
//
// public methods
//
+//_____________________________________________________________________________
+AliMpVPadIterator* AliMpSector::CreateIterator() const
+{
+/// Create sector pad iterator
+
+ return new AliMpSectorPadIterator(this);
+}
+
+
//_____________________________________________________________________________
void AliMpSector::SetRowSegmentOffsets()
{
/// For all rows set the offset to all row segments.
for (Int_t irow=0; irow<GetNofRows(); irow++)
- GetRow(irow)->SetRowSegmentOffsets(fOffset);
+ GetRow(irow)->SetRowSegmentOffsets(fOffsetX);
}
//_____________________________________________________________________________
SetMinMaxPadDimensions();
SetMaxPadIndices();
SetNofPads();
+ SetDimensions();
}
//_____________________________________________________________________________
AliMpRow* row = GetRow(i);
cout << "ROW " << row->GetID()
- << " center Y " << row->Position().Y() << endl;
+ << " center Y " << row->GetPositionY() << endl;
for (Int_t j=0; j<row->GetNofRowSegments(); j++) {
AliMpVRowSegment* rowSegment = row->GetRowSegment(j);
<< rowSegment->LeftBorderX() << " "
<< rowSegment->RightBorderX()
<< " x-size "
- << 2*rowSegment->Dimensions().X() << " "
+ << 2*rowSegment->GetDimensionX() << " "
<< endl;
}
}
}
-//_____________________________________________________________________________
-AliMpRow* AliMpSector::FindRow(const TVector2& position) const
-{
-/// Find the row for the specified y position. \n
-/// If y is on border the lowest row is returned.
-
- Double_t y = position.Y();
-
-#ifdef WITH_STL
- for (Int_t i=0; i<GetNofRows(); i++) {
- if ( y >= fRows[i]->LowBorderY() && y <= fRows[i]->UpperBorderY())
- return fRows[i];
- }
-#endif
-
-#ifdef WITH_ROOT
- for (Int_t i=0; i<GetNofRows(); i++) {
- if ( y >= ((AliMpRow*)fRows[i])->LowBorderY() &&
- y <= ((AliMpRow*)fRows[i])->UpperBorderY())
- return (AliMpRow*)fRows[i];
- }
-#endif
-
- return 0;
-}
-
-//_____________________________________________________________________________
-AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const
-{
-/// Find the motif in the specified position. \n
-/// Return 0 if no motif is found.
-
- // Find the row segment
- AliMpVRowSegment* rowSegment = FindRowSegment(position);
-
- if (!rowSegment) return 0;
-
- // Find motif
- return rowSegment->FindMotif(position);
-}
-//_____________________________________________________________________________
-Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const
-{
-/// 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);
-
- if (!rowSegment) return 0;
-
- // Find motif position ID
- return rowSegment->FindMotifPositionId(position);
-}
-
//_____________________________________________________________________________
AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
{
for (Int_t irow=0; irow<GetNofRows(); irow++) {
-#ifdef WITH_STL
- AliMpRow* row = fRows[irow];
-#endif
-#ifdef WITH_ROOT
AliMpRow* row = (AliMpRow*)fRows[irow];
-#endif
-
+
for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) {
AliMpVRowSegment* segment = row->GetRowSegment(iseg);
if (segment->HasMotifPosition(motifPositionId)) return segment;
}
//_____________________________________________________________________________
-TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const
+Double_t AliMpSector::GetPositionX() const
{
-/// Find the position of the motif specified by its position Id. \n
-/// Return 0 if no row segment is found.
+/// Return the sector offset.
- AliMpVRowSegment* segment = FindRowSegment(motifPositionId);
+ return fOffsetX;
+}
- if (!segment) {
- AliWarningStream() << "Given motifPositionId not found." << endl;
- return TVector2();
- }
- return segment->MotifCenter(motifPositionId);
-}
-
//_____________________________________________________________________________
-AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const
+Double_t AliMpSector::GetPositionY() const
{
-/// Find the zone with specified padDimensions.
+/// Return the sector offset.
- for (Int_t i=0; i<GetNofZones(); i++) {
- AliMpZone* zone = GetZone(i+1);
- if (AliMpConstants::IsEqual(padDimensions, zone->GetPadDimensions()))
- return zone;
- }
-
- // Return 0 if not found
- return 0;
-}
+ return fOffsetY;
+}
//_____________________________________________________________________________
-TVector2 AliMpSector::Position() const
+Double_t AliMpSector::GetDimensionX() const
{
-/// Return the sector offset.
+/// Return the maximum halflengths in x.
- return fOffset;
+ return fDimensionX;
}
-
//_____________________________________________________________________________
-TVector2 AliMpSector::Dimensions() const
+Double_t AliMpSector::GetDimensionY() const
{
-/// Return the maximum halflengths in x, y.
-
- Double_t x = 0.;
- Double_t y = 0.;
- for (Int_t i=0; i<GetNofRows(); i++) {
-
-#ifdef WITH_STL
- // take the largest x row dimension
- if (fRows[i]->Dimensions().X() > x)
- x = fRows[i]->Dimensions().X();
-
- // add all rows y dimensions
- y += fRows[i]->Dimensions().Y();
-#endif
+/// Return the maximum halflengths in y.
-#ifdef WITH_ROOT
- // take the largest x row dimension
- if ( ((AliMpRow*)fRows[i])->Dimensions().X() > x)
- x = ((AliMpRow*)fRows[i])->Dimensions().X();
-
- // add all rows y dimensions
- y += ((AliMpRow*)fRows[i])->Dimensions().Y();
-#endif
- }
-
- return TVector2(x, y);
+ return fDimensionY;
}
//_____________________________________________________________________________
{
/// Return the number of zones.
-#ifdef WITH_STL
- return fZones.size();
-#endif
-
-#ifdef WITH_ROOT
return fZones.GetEntriesFast();
-#endif
}
//_____________________________________________________________________________
return 0;
}
-#ifdef WITH_STL
- return fZones[zoneID-1];
-#endif
-
-#ifdef WITH_ROOT
return (AliMpZone*)fZones[zoneID-1];
-#endif
}
//_____________________________________________________________________________
{
/// Return the number of rows.
-#ifdef WITH_STL
- return fRows.size();
-#endif
-
-#ifdef WITH_ROOT
return fRows.GetEntriesFast();
-#endif
}
//_____________________________________________________________________________
return 0;
}
-#ifdef WITH_STL
- return fRows[rowID];
-#endif
-
-#ifdef WITH_ROOT
return (AliMpRow*)fRows[rowID];
-#endif
}
//_____________________________________________________________________________
return GetDirection()==AliMp::kY ? AliMp::kBendingPlane : AliMp::kNonBendingPlane;
}
+//_____________________________________________________________________________
+Int_t
+AliMpSector::GetNofMotifPositions() const
+{
+ /// Return the number of manus
+
+ return fMotifMap->GetNofMotifPositions();
+}
+
//_____________________________________________________________________________
void
AliMpSector::GetAllMotifPositionsIDs(TArrayI& ecn) const