]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpTriggerSegmentation.cxx
Option for customized binning (as in AliUEHist), EventMixing binning now derived...
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpTriggerSegmentation.cxx
index 3c61605329e27bf2a6de38c4031dae8a1cbefaf4..caced37e65ebf2081f50e4bcf186619cc8011290 100644 (file)
@@ -14,7 +14,7 @@
 **************************************************************************/
 
 // $Id$
-// $MpId$
+// $MpId: AliMpTriggerSegmentation.cxx,v 1.7 2006/05/24 13:58:52 ivana Exp $
 
 #include "AliMpTriggerSegmentation.h"
 
 #include "AliMpMotifType.h"
 #include "AliMpPCB.h"
 #include "AliMpSlat.h"
-#include "AliMpSlatSegmentation.h"
 #include "AliMpTrigger.h"
 
+//-----------------------------------------------------------------------------
+/// \class AliMpTriggerSegmentation
+///
+/// Implementation of AliMpVSegmentation for trigger slats.
+///
+/// \todo Implement CreateIterator method, if needed.
+///
+/// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
+
+/// \cond CLASSIMP
 ClassImp(AliMpTriggerSegmentation)
+/// \endcond
 
 //_____________________________________________________________________________
 AliMpTriggerSegmentation::AliMpTriggerSegmentation() 
 : AliMpVSegmentation(),
-fkSlat(0)
+  fkSlat(0),
+  fIsOwner(false),
+  fNofStrips(0)
 {
-  //
-  // Default ctor. Not to be used really.
-  //
+  ///
+  /// Default ctor. Not to be used really.
+  ///
   AliDebug(1,Form("this=%p Empty ctor",this));
 }
 
 //_____________________________________________________________________________
-AliMpTriggerSegmentation::AliMpTriggerSegmentation(const AliMpTrigger* slat) 
+AliMpTriggerSegmentation::AliMpTriggerSegmentation(
+                               const AliMpTrigger* slat, Bool_t own) 
 : AliMpVSegmentation(), 
-fkSlat(slat)
+  fkSlat(slat),
+  fIsOwner(own),
+  fNofStrips(0)
 {
-  //
-  // Normal ctor.
-  //
+  ///
+  /// Normal ctor.
+  ///
   AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
+  
+  // Compute the number of strips.
+  // We have to loop over all possible pads, in order to properly take
+  // into account the fact that a given strip might be part of several
+  // layer. Otherwise we would double count pads.
+
+
+  for ( Int_t ix = 0; ix <= MaxPadIndexX(); ++ix )
+  {
+    for ( Int_t iy = 0; iy <= MaxPadIndexY(); ++iy )
+    {
+      if ( HasPadByIndices(ix,iy) )
+      {
+        ++fNofStrips;
+      }
+    }
+  }
 }
 
 //_____________________________________________________________________________
 AliMpTriggerSegmentation::~AliMpTriggerSegmentation()
 {
-  //
-  // Dtor (empty).
-  //
+  ///
+  /// Dtor (empty).
+  ///
+
+  if ( fIsOwner ) delete fkSlat;
+
   AliDebug(1,Form("this=%p",this));                    
 }
 
@@ -65,17 +101,67 @@ AliMpTriggerSegmentation::~AliMpTriggerSegmentation()
 AliMpVPadIterator*
 AliMpTriggerSegmentation::CreateIterator(const AliMpArea&) const
 {
-  //
-  // Returns an iterator to loop over the pad contained within given area.
-  // Not implemented for trigger.
+  ///
+  /// Returns an iterator to loop over the pad contained within given area.
+  /// Not implemented for trigger.
+  AliError("Not implemented for trigger");
+  return 0;
+}
+
+//_____________________________________________________________________________
+AliMpVPadIterator*
+AliMpTriggerSegmentation::CreateIterator() const
+{
+  ///
+  /// Returns an iterator to loop over all the pads
+  /// Not implemented for trigger.
+  AliError("Not implemented for trigger");
   
   return 0;
 }
 
+//_____________________________________________________________________________
+Int_t 
+AliMpTriggerSegmentation::GetNeighbours(const AliMpPad& /*pad*/, 
+                                        TObjArray& /*neighbours*/,
+                                        Bool_t /*includeSelf*/,
+                                        Bool_t /*includeVoid*/) const
+{
+  /// not implemented.
+  AliError("Not implemented for trigger");
+  return 0;
+}
+
+//_____________________________________________________________________________
+Double_t  
+AliMpTriggerSegmentation::GetDimensionX() const
+{
+/// Return slat x dimensions
+  return Slat()->GetDimensionX();
+}
+
+//_____________________________________________________________________________
+Double_t  
+AliMpTriggerSegmentation::GetDimensionY() const
+{
+/// Return slat y dimensions
+  return Slat()->GetDimensionY();
+}
+
+//_____________________________________________________________________________
+void 
+AliMpTriggerSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
+{
+/// Fill the array ecn with all manuIds
+
+  Slat()->GetAllLocalBoardNumbers(ecn);
+}
+
 //_____________________________________________________________________________
 const char*
 AliMpTriggerSegmentation::GetName() const
 {
+  /// Name of that segmentation = TriggerSegmentation + slatName
   TString name("TriggerSegmentation");
   if ( fkSlat) 
   {
@@ -85,121 +171,102 @@ 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()
+AliMpTriggerSegmentation::MaxPadIndexX() const
 {
-  //
-  // Returns the value of the largest pad index in x-direction.
-  //
+  ///
+  /// Returns the value of the largest pad index in x-direction.
+  ///
   
   return fkSlat->GetNofPadsX()-1;
 }
 
 //_____________________________________________________________________________
 Int_t 
-AliMpTriggerSegmentation::MaxPadIndexY()
+AliMpTriggerSegmentation::MaxPadIndexY() const
 {
-  //
-  // Returns the value of the largest pad index in y-direction.
-  //
+  ///
+  /// Returns the value of the largest pad index in y-direction.
+  ///
   
   return fkSlat->GetMaxNofPadsY()-1;
 }
 
 //_____________________________________________________________________________
 AliMpPad
-AliMpTriggerSegmentation::PadByLocation(const AliMpIntPair& location
+AliMpTriggerSegmentation::PadByLocation(Int_t manuId, Int_t manuChannel
                                         Bool_t warning) const
 {
-  //
-  // Returns the pad specified by its location, where location is the 
-  // pair (ManuID,ManuChannel).
-  // If warning=kTRUE and the pad does not exist, a warning message is 
-  // printed.
-  //
-  // AliMpPad::Invalid() is returned if there's no pad at the given location.
-  //
+  ///
+  /// Returns the pad specified by its location, where location is the 
+  /// pair (ManuID,ManuChannel).
+  /// If warning=kTRUE and the pad does not exist, a warning message is 
+  /// printed.
+  ///
+  /// 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 )
   {
-    const AliMpSlat* slat = fkSlat->GetLayer(i);
-    AliMpSlatSegmentation seg(slat);
-    AliMpPad p_i = seg.PadByLocation(location,kFALSE);
-    if ( p_i.IsValid() ) 
+    AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
+    AliMpPad pi = seg->PadByLocation(manuId,manuChannel,kFALSE);
+    if ( pi.IsValid() ) 
     {
       if ( !pad.IsValid() )
       {
-        pad = AliMpPad(invloc,p_i.GetIndices(),p_i.Position(),p_i.Dimensions());
-        pad.AddLocation(p_i.GetLocation());
+       // uses PadByIndices to get the complete list of locations
+       return PadByIndices(pi.GetIx(), pi.GetIy(), warning);
       }
-      else
-      {
-        pad.AddLocation(p_i.GetLocation());
-      }  
     }
   }
   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.
-  // If warning=kTRUE and the pad does not exist, a warning message is 
-  // printed.
-  //
-  // AliMpPad::Invalid() is returned if there's no pad at the given location.
-  //
-  //  
+  ///
+  /// Returns the pad specified by its integer indices.
+  /// If warning=kTRUE and the pad does not exist, a warning message is 
+  /// printed.
+  ///
+  /// 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 )
   {
-    const AliMpSlat* slat = fkSlat->GetLayer(i);
-    AliMpSlatSegmentation seg(slat);
-    AliMpPad p_i = seg.PadByIndices(indices,kFALSE);
-    if ( p_i.IsValid() ) 
+    AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
+    AliMpPad pi = seg->PadByIndices(ix,iy,kFALSE);
+    if ( pi.IsValid() ) 
     {      
       if ( !pad.IsValid() )
       {
-        pad = AliMpPad(invloc,p_i.GetIndices(),p_i.Position(),p_i.Dimensions());
-        pad.AddLocation(p_i.GetLocation());
+        pad = AliMpPad(0, 0,
+                       pi.GetIndices(),
+                       pi.GetPositionX(),pi.GetPositionY(),
+                       pi.GetDimensionX(), pi.GetDimensionY());
+        pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
       }
       else
       {
-        pad.AddLocation(p_i.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;
@@ -207,53 +274,106 @@ AliMpTriggerSegmentation::PadByIndices(const AliMpIntPair& indices,
 
 //_____________________________________________________________________________
 AliMpPad
-AliMpTriggerSegmentation::PadByPosition(const TVector2& position
+AliMpTriggerSegmentation::PadByPosition(Double_t x, Double_t y
                                      Bool_t warning) const
 {
-  //
-  // Returns the pad specified by its (floating point) position.
-  // If warning=kTRUE and the pad does not exist, a warning message is 
-  // printed.
-  //
-  // AliMpPad::Invalid() is returned if there's no pad at the given location.
-  //
+  ///
+  /// Returns the pad specified by its (floating point) position.
+  /// If warning=kTRUE and the pad does not exist, a warning message is 
+  /// printed.
+  ///
+  /// 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 )
   {
-    const AliMpSlat* slat = fkSlat->GetLayer(i);
-    AliMpSlatSegmentation seg(slat);
-    AliMpPad p_i = seg.PadByPosition(position,kFALSE);
-    if ( p_i.IsValid() ) 
+    AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
+    AliMpPad pi = seg->PadByPosition(x,y,kFALSE);
+    if ( pi.IsValid() ) 
     {
       if ( !pad.IsValid() )
       {
-        pad = AliMpPad(invloc,p_i.GetIndices(),p_i.Position(),p_i.Dimensions());
-        pad.AddLocation(p_i.GetLocation());
+        pad = AliMpPad(0, 0,
+                       pi.GetIndices(),
+                       pi.GetPositionX(),pi.GetPositionY(),
+                       pi.GetDimensionX(), pi.GetDimensionY());
+        pad.AddLocation(pi.GetManuId(), pi.GetManuChannel());
       }
       else
       {
-        pad.AddLocation(p_i.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;  
 }
 
+//_____________________________________________________________________________
+AliMp::PlaneType
+AliMpTriggerSegmentation::PlaneType() const
+{
+  /// Return plane type
+
+  return Slat()->PlaneType();
+}
+
 //_____________________________________________________________________________
 const AliMpTrigger* 
 AliMpTriggerSegmentation::Slat() const
 {
-  //
-  // Returns the pointer to the referenced slat.
-  //
+  ///
+  /// Returns the pointer to the referenced slat.
+  ///
   
   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);
+}