]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpMotifMap.cxx
- Use new AliMpSlatMotifMap::Instance() function to instantiate
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotifMap.cxx
index 5c64b6f7c1011d8014be068e9b640ecd907429a6..a3d42dfed40b4a49d75cb83d38255a68cc39690b 100755 (executable)
  **************************************************************************/
 
 // $Id$
-// $MpId: AliMpMotifMap.cxx,v 1.14 2006/03/17 11:38:06 ivana Exp $
+// $MpId: AliMpMotifMap.cxx,v 1.16 2006/05/24 13:58:41 ivana Exp $
 // Category: motif
-// -------------------
+
+//-----------------------------------------------------------------------------
 // Class AliMpMotifMap
 // -------------------
 // Class describing the motif map container, where motifs are
 // mapped to their string IDs.
 // Included in AliRoot: 2003/05/02
 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+//-----------------------------------------------------------------------------
 
 #include "AliMpMotifMap.h"
 #include "AliMpVMotif.h"
@@ -37,7 +39,9 @@
 #include <TVector2.h>
 #include <TArrayI.h>
 
+/// \cond CLASSIMP
 ClassImp(AliMpMotifMap)
+/// \endcond
 
 //_____________________________________________________________________________
 AliMpMotifMap::AliMpMotifMap(Bool_t /*standardConstructor*/) 
@@ -97,7 +101,6 @@ AliMpMotifMap::~AliMpMotifMap()
 void  AliMpMotifMap::PrintMotif(const AliMpVMotif* motif) const
 {
 /// Print the motif.
-// ---
 
   cout << motif->GetID().Data() << "  "
        << motif->GetMotifType()->GetID() << "    "
@@ -257,9 +260,46 @@ AliMpMotifMap::GetAllMotifPositionsIDs(TArrayI& ecn) const
 #endif  
 }
 
+//_____________________________________________________________________________
+UInt_t  AliMpMotifMap::GetNofMotifPositions() const
+{
+/// Return the number of all motif positions IDs (electronic card numbers)
+
+#ifdef WITH_STL
+  return fMotifPositions.size();  
+#endif
+  
+#ifdef WITH_ROOT  
+  return fMotifPositions.GetSize();
+#endif 
+} 
+
+//_____________________________________________________________________________
+AliMpMotifPosition* AliMpMotifMap::GetMotifPosition(UInt_t index) const
+{
+/// Return the motif position which is in the map on the index-th position
+
+  if ( index >= GetNofMotifPositions() ) {
+    AliErrorStream() << "Index " << index << " outside limits." << endl;
+    return 0;
+  }   
+
+#ifdef WITH_STL
+  MotifPositionMapIterator it = fMotifPositions.begin();
+  std::advance(it, index);
+  return it->second;
+#endif
+  
+#ifdef WITH_ROOT  
+  return (AliMpMotifPosition*)fMotifPositions.GetObject(index);
+#endif 
+}
+
 //_____________________________________________________________________________
 Int_t AliMpMotifMap::CalculateNofPads() const 
 {
+/// Calculate total number of pads in the map
+
   Int_t nofPads = 0;
 
 #ifdef WITH_STL
@@ -286,7 +326,7 @@ Int_t AliMpMotifMap::CalculateNofPads() const
 //_____________________________________________________________________________
 void  AliMpMotifMap::PrintMotifPositions() const
 {
-/// Print all the the motifs positions.
+/// Print all motif positions.
 
 #ifdef WITH_STL
   if (fMotifPositions.size()) {
@@ -325,7 +365,7 @@ void  AliMpMotifMap::PrintMotifPositions() const
 //_____________________________________________________________________________
 void  AliMpMotifMap::PrintMotifPositions2() const
 {
-/// Print all the the motifs positions from the second map
+/// Print all motif positions from the second map
 /// (by global indices)
 
 #ifdef WITH_STL
@@ -515,7 +555,7 @@ void  AliMpMotifMap::Print(const char* opt) const
 //_____________________________________________________________________________
 void  AliMpMotifMap::PrintGlobalIndices(const char* fileName) const
 {
-/// Print all the motifs positions and their global indices.
+/// Print all motif positions and their global indices.
 
   ofstream out(fileName, ios::out);
 
@@ -553,8 +593,7 @@ void  AliMpMotifMap::PrintGlobalIndices(const char* fileName) const
 //_____________________________________________________________________________
 void  AliMpMotifMap::UpdateGlobalIndices(const char* fileName)
 {
-/// Updates the motifs positions global indices
-/// from the file.
+/// Update the motif positions global indices from the file.
 
   ifstream in(fileName, ios::in);
 
@@ -597,7 +636,7 @@ void  AliMpMotifMap::UpdateGlobalIndices(const char* fileName)
 //_____________________________________________________________________________
 AliMpVMotif* AliMpMotifMap::FindMotif(const TString& motifID) const
 {
-/// Finds the motif with the specified ID.
+/// Find the motif with the specified ID.
   
 #ifdef WITH_STL
   MotifMapIterator i = fMotifs.find(motifID);
@@ -617,7 +656,7 @@ AliMpVMotif* AliMpMotifMap::FindMotif(const TString& motifID,
                                       const TString& motifTypeID,
                                      const TVector2& padDimensions ) const
 {
-/// Finds the motif with the specified ID and returns it
+/// Find the motif with the specified ID and returns it
 /// only if its motif type and motif dimensions agree
 /// with the given motifTypeID and motifDimensions.
 /// Disagreement causes fatal error.