]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpSector.cxx
New classes for shuttle (Laurent)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSector.cxx
index 298c19e2d600c2ac7eabe05dc83cfc25e5749fa5..ffedea660100d3473bbadb7949c97c76800e5225 100755 (executable)
@@ -1,4 +1,20 @@
+/**************************************************************************
+ * 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
@@ -7,9 +23,6 @@
 // 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 <Riostream.h>
+
+/// \cond CLASSIMP
 ClassImp(AliMpSector)
+/// \endcond
 
 //_____________________________________________________________________________
 AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows, 
                          AliMpDirection direction, const TVector2& offset) 
-  : TObject(),
+  : TNamed("Sector", ""),
     fID(id),
     fOffset(offset),
     fZones(),
     fRows(),
+    fMotifMap(0),
     fDirection(direction),
-    fMinPadDimensions(TVector2(1.e6, 1.e6))
+    fMinPadDimensions(TVector2(1.e6, 1.e6)),
+    fMaxPadIndices(AliMpIntPair::Invalid()),
+    fNofPads(0)
 {
-//
-  fMotifMap = new AliMpMotifMap();
+/// Standard constructor
+
+  fMotifMap = new AliMpMotifMap(true);
+  //fMotifMap = new AliMpMotifMap();
 
 #ifdef WITH_STL
   for (Int_t izone = 0; izone<nofZones; izone++) 
@@ -53,30 +75,27 @@ AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows,
 #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.))
+    fMinPadDimensions(TVector2(0., 0.)),
+    fMaxPadIndices(AliMpIntPair::Invalid()),
+    fNofPads(0)
 {
-//
+/// Default constructor
 }
 
 //_____________________________________________________________________________
-AliMpSector::~AliMpSector() {
-// 
+AliMpSector::~AliMpSector() 
+{
+/// Destructor 
+
   // deletes 
   for (Int_t izone = 0; izone<GetNofZones(); izone++) 
     delete fZones[izone];
@@ -87,21 +106,6 @@ AliMpSector::~AliMpSector() {
   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
 //
@@ -109,6 +113,8 @@ AliMpSector& AliMpSector::operator=(const AliMpSector& right)
 //_____________________________________________________________________________
 AliMpVPadIterator* AliMpSector::CreateIterator() const
 {
+/// Create sector pad iterator
+
   return new AliMpSectorPadIterator(this);
 }
 
@@ -116,9 +122,8 @@ AliMpVPadIterator* AliMpSector::CreateIterator() const
 //_____________________________________________________________________________
 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);
@@ -134,9 +139,8 @@ AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const
 //_____________________________________________________________________________
 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();
   
@@ -147,8 +151,7 @@ void  AliMpSector::SetRowOffsets()
 //_____________________________________________________________________________
 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();
@@ -157,9 +160,8 @@ void  AliMpSector::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;
@@ -172,8 +174,7 @@ void  AliMpSector::SetGlobalIndices()
 //_____________________________________________________________________________
 void  AliMpSector::SetMinPadDimensions()
 {
-// Sets the minimal pad dimensions.
-// ---
+/// Set the minimal pad dimensions.
 
   for (Int_t i=1; i<GetNofZones()+1; i++) {
     TVector2 padDimensions = GetZone(i)->GetPadDimensions();
@@ -187,6 +188,36 @@ void  AliMpSector::SetMinPadDimensions()
   }
 }
 
+//_____________________________________________________________________________
+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
 //
@@ -194,8 +225,7 @@ void  AliMpSector::SetMinPadDimensions()
 //_____________________________________________________________________________
 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);    
@@ -204,21 +234,21 @@ void  AliMpSector::SetRowSegmentOffsets()
 //_____________________________________________________________________________
 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();
+  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);
@@ -244,9 +274,8 @@ void AliMpSector::PrintGeometry()  const
 //_____________________________________________________________________________
 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();
   
@@ -271,9 +300,8 @@ AliMpRow* AliMpSector::FindRow(const TVector2& position) const
 //_____________________________________________________________________________
 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);
@@ -283,14 +311,12 @@ AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const
   // 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);
   
@@ -303,9 +329,8 @@ Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const
 //_____________________________________________________________________________
 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);
   
@@ -317,9 +342,8 @@ AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const
 //_____________________________________________________________________________
 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++) {
 
@@ -342,14 +366,13 @@ AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const
 //_____________________________________________________________________________
 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();
   }   
 
@@ -359,8 +382,7 @@ TVector2  AliMpSector::FindPosition(Int_t motifPositionId) const
 //_____________________________________________________________________________
 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);
@@ -375,8 +397,7 @@ AliMpZone*  AliMpSector::FindZone(const TVector2& padDimensions) const
 //_____________________________________________________________________________
 TVector2 AliMpSector::Position() const
 {
-// Returns the offset.
-// ---
+/// Return the sector offset.
 
   return fOffset;
 }  
@@ -385,8 +406,7 @@ TVector2 AliMpSector::Position() const
 //_____________________________________________________________________________
 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.;
@@ -417,8 +437,7 @@ TVector2 AliMpSector::Dimensions() const
 //_____________________________________________________________________________
 Int_t AliMpSector::GetNofZones() const
 {    
-// Returns the number of zones.
-// ---
+/// Return the number of zones.
 
 #ifdef WITH_STL
   return fZones.size();
@@ -432,11 +451,10 @@ Int_t AliMpSector::GetNofZones() const
 //_____________________________________________________________________________
 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;
   }
   
@@ -452,8 +470,7 @@ AliMpZone* AliMpSector::GetZone(Int_t zoneID) const
 //_____________________________________________________________________________
 Int_t AliMpSector::GetNofRows() const
 {
-// Returns the number of rows.
-// ---
+/// Return the number of rows.
 
 #ifdef WITH_STL
   return fRows.size();
@@ -467,11 +484,10 @@ Int_t AliMpSector::GetNofRows() const
 //_____________________________________________________________________________
 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;
   }
   
@@ -483,3 +499,31 @@ AliMpRow* AliMpSector::GetRow(Int_t rowID) const
   return (AliMpRow*)fRows[rowID];
 #endif
 }
+
+//_____________________________________________________________________________
+AliMpPlaneType
+AliMpSector::GetPlaneType() const
+{
+/// Return the plane type
+
+  return GetDirection()==kY ? kBendingPlane : 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);
+}