]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpTriggerSegmentation.cxx
Fix floating exception bug which can appear in few specific cases.
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpTriggerSegmentation.cxx
index a4d31359a4328bc0d4714d5d81e17805c77a5bd2..caced37e65ebf2081f50e4bcf186619cc8011290 100644 (file)
@@ -27,7 +27,7 @@
 #include "AliMpSlat.h"
 #include "AliMpTrigger.h"
 
-//
+//-----------------------------------------------------------------------------
 /// \class AliMpTriggerSegmentation
 ///
 /// Implementation of AliMpVSegmentation for trigger slats.
@@ -35,6 +35,7 @@
 /// \todo Implement CreateIterator method, if needed.
 ///
 /// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
 
 /// \cond CLASSIMP
 ClassImp(AliMpTriggerSegmentation)
@@ -76,7 +77,7 @@ AliMpTriggerSegmentation::AliMpTriggerSegmentation(
   {
     for ( Int_t iy = 0; iy <= MaxPadIndexY(); ++iy )
     {
-      if ( HasPad(AliMpIntPair(ix,iy)) )
+      if ( HasPadByIndices(ix,iy) )
       {
         ++fNofStrips;
       }
@@ -132,12 +133,19 @@ AliMpTriggerSegmentation::GetNeighbours(const AliMpPad& /*pad*/,
 }
 
 //_____________________________________________________________________________
-TVector2
-AliMpTriggerSegmentation::Dimensions() const
+Double_t  
+AliMpTriggerSegmentation::GetDimensionX() const
 {
-/// Return dimensions
+/// Return slat x dimensions
+  return Slat()->GetDimensionX();
+}
 
-  return Slat()->Dimensions();
+//_____________________________________________________________________________
+Double_t  
+AliMpTriggerSegmentation::GetDimensionY() const
+{
+/// Return slat y dimensions
+  return Slat()->GetDimensionY();
 }
 
 //_____________________________________________________________________________
@@ -163,18 +171,6 @@ AliMpTriggerSegmentation::GetName() const
   return name.Data();
 }
 
-//_____________________________________________________________________________
-Bool_t
-AliMpTriggerSegmentation::HasPad(const AliMpIntPair& indices) const
-{
-  ///
-  /// Test if this slat has a pad located at the position referenced
-  /// by the integer indices.
-  ///
-  
-  return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
-}
-
 //_____________________________________________________________________________
 Int_t 
 AliMpTriggerSegmentation::MaxPadIndexX() const
@@ -199,7 +195,7 @@ AliMpTriggerSegmentation::MaxPadIndexY() const
 
 //_____________________________________________________________________________
 AliMpPad
-AliMpTriggerSegmentation::PadByLocation(const AliMpIntPair& location
+AliMpTriggerSegmentation::PadByLocation(Int_t manuId, Int_t manuChannel
                                         Bool_t warning) const
 {
   ///
@@ -211,33 +207,31 @@ AliMpTriggerSegmentation::PadByLocation(const AliMpIntPair& location,
   /// AliMpPad::Invalid() is returned if there's no pad at the given location.
   ///
   AliMpPad pad;
-  AliMpIntPair invloc;
   
   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
   {
     AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
-    AliMpPad pi = seg->PadByLocation(location,kFALSE);
+    AliMpPad pi = seg->PadByLocation(manuId,manuChannel,kFALSE);
     if ( pi.IsValid() ) 
     {
       if ( !pad.IsValid() )
       {
        // uses PadByIndices to get the complete list of locations
-       return PadByIndices(pi.GetIndices(),warning);
+       return PadByIndices(pi.GetIx(), pi.GetIy(), warning);
       }
     }
   }
   if ( warning && !pad.IsValid()  )
   {
-    AliWarning(Form("No pad found at location (%d,%d)",location.GetFirst(),
-                    location.GetSecond()));
+    AliWarning(Form("No pad found at location (%d,%d)", manuId, manuChannel));
   }
   return pad;
 }
 
 //_____________________________________________________________________________
 AliMpPad
-AliMpTriggerSegmentation::PadByIndices(const AliMpIntPair& indices
-                                    Bool_t warning) const
+AliMpTriggerSegmentation::PadByIndices(Int_t ix, Int_t iy
+                                       Bool_t warning) const
 {
   ///
   /// Returns the pad specified by its integer indices.
@@ -249,29 +243,30 @@ AliMpTriggerSegmentation::PadByIndices(const AliMpIntPair& indices,
   ///  
  
   AliMpPad pad;
-  AliMpIntPair invloc;
-  
+
   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
   {
     AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
-    AliMpPad pi = seg->PadByIndices(indices,kFALSE);
+    AliMpPad pi = seg->PadByIndices(ix,iy,kFALSE);
     if ( pi.IsValid() ) 
     {      
       if ( !pad.IsValid() )
       {
-        pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
-        pad.AddLocation(pi.GetLocation());
+        pad = AliMpPad(0, 0,
+                       pi.GetIndices(),
+                       pi.GetPositionX(),pi.GetPositionY(),
+                       pi.GetDimensionX(), pi.GetDimensionY());
+        pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
       }
       else
       {
-        pad.AddLocation(pi.GetLocation());
+        pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
       }  
     }
   }
   if ( warning && !pad.IsValid()  )
   {
-    AliWarning(Form("No pad found at indices (%d,%d)",indices.GetFirst(),
-                    indices.GetSecond()));
+    AliWarning(Form("No pad found at indices (%d,%d)",ix, iy));
   }
   
   return pad;
@@ -279,7 +274,7 @@ AliMpTriggerSegmentation::PadByIndices(const AliMpIntPair& indices,
 
 //_____________________________________________________________________________
 AliMpPad
-AliMpTriggerSegmentation::PadByPosition(const TVector2& position
+AliMpTriggerSegmentation::PadByPosition(Double_t x, Double_t y
                                      Bool_t warning) const
 {
   ///
@@ -290,29 +285,30 @@ AliMpTriggerSegmentation::PadByPosition(const TVector2& position,
   /// AliMpPad::Invalid() is returned if there's no pad at the given location.
   ///
   AliMpPad pad;
-  AliMpIntPair invloc;
   
   for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
   {
     AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
-    AliMpPad pi = seg->PadByPosition(position,kFALSE);
+    AliMpPad pi = seg->PadByPosition(x,y,kFALSE);
     if ( pi.IsValid() ) 
     {
       if ( !pad.IsValid() )
       {
-        pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
-        pad.AddLocation(pi.GetLocation());
+        pad = AliMpPad(0, 0,
+                       pi.GetIndices(),
+                       pi.GetPositionX(),pi.GetPositionY(),
+                       pi.GetDimensionX(), pi.GetDimensionY());
+        pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
       }
       else
       {
-        pad.AddLocation(pi.GetLocation());
+        pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
       }  
     }
   }
   if ( warning && !pad.IsValid()  )
   {
-    AliWarning(Form("No pad found at position (%e,%e)",position.X(),
-                    position.Y()));
+    AliWarning(Form("No pad found at position (%e,%e)",x,y));
   }
   
   return pad;  
@@ -337,3 +333,47 @@ AliMpTriggerSegmentation::Slat() const
   
   return fkSlat;
 }
+
+//_____________________________________________________________________________
+Int_t 
+AliMpTriggerSegmentation::GetNofElectronicCards() const
+{
+  /// Get the number of local board numbers
+  
+  TArrayI ecn;
+  fkSlat->GetAllLocalBoardNumbers(ecn);
+  return ecn.GetSize();  
+}
+
+//_____________________________________________________________________________
+Double_t  
+AliMpTriggerSegmentation::GetPositionX() const
+{
+  /// Return x position of origin
+  return Slat()->GetPositionX();
+}
+
+//_____________________________________________________________________________
+Double_t  
+AliMpTriggerSegmentation::GetPositionY() const
+{
+  /// Return y position of origin
+  return Slat()->GetPositionY();
+}
+
+//_____________________________________________________________________________
+AliMpMotifPosition* 
+AliMpTriggerSegmentation::MotifPosition(Int_t /* manuId */) const
+{
+  /// No implemented (yet ?)
+  AliError("Not implemented");
+  return 0x0;
+}
+
+//_____________________________________________________________________________
+Bool_t 
+AliMpTriggerSegmentation::HasMotifPosition(Int_t manuId) const
+{
+  /// Uses default implementation
+  return AliMpVSegmentation::HasMotifPosition(manuId);
+}