]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/mapping/AliMpTriggerSegmentation.cxx
Fix for the problem during PbPb run of Nov 2010 (Indra)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpTriggerSegmentation.cxx
index b2eb4ae8380714b1040b1139bf8d94483ca4000f..caced37e65ebf2081f50e4bcf186619cc8011290 100644 (file)
 #include "AliMpMotifType.h"
 #include "AliMpPCB.h"
 #include "AliMpSlat.h"
-#include "AliMpSlatSegmentation.h"
 #include "AliMpTrigger.h"
 
-//
+//-----------------------------------------------------------------------------
 /// \class AliMpTriggerSegmentation
 ///
 /// Implementation of AliMpVSegmentation for trigger slats.
@@ -36,6 +35,7 @@
 /// \todo Implement CreateIterator method, if needed.
 ///
 /// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
 
 /// \cond CLASSIMP
 ClassImp(AliMpTriggerSegmentation)
@@ -44,24 +44,27 @@ ClassImp(AliMpTriggerSegmentation)
 //_____________________________________________________________________________
 AliMpTriggerSegmentation::AliMpTriggerSegmentation() 
 : AliMpVSegmentation(),
-fkSlat(0),
-fNofStrips(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),
+  fIsOwner(own),
   fNofStrips(0)
 {
-  //
-  // Normal ctor.
-  //
+  ///
+  /// Normal ctor.
+  ///
   AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
   
   // Compute the number of strips.
@@ -74,7 +77,7 @@ AliMpTriggerSegmentation::AliMpTriggerSegmentation(const AliMpTrigger* slat)
   {
     for ( Int_t iy = 0; iy <= MaxPadIndexY(); ++iy )
     {
-      if ( HasPad(AliMpIntPair(ix,iy)) )
+      if ( HasPadByIndices(ix,iy) )
       {
         ++fNofStrips;
       }
@@ -82,62 +85,75 @@ AliMpTriggerSegmentation::AliMpTriggerSegmentation(const AliMpTrigger* slat)
   }
 }
 
-//______________________________________________________________________________
-AliMpTriggerSegmentation::AliMpTriggerSegmentation(const AliMpTriggerSegmentation& right) 
-    : AliMpVSegmentation(right),
-      fkSlat(right.fkSlat),
-      fNofStrips(right.fNofStrips)
-{  
-/// Protected copy constructor (not implemented)
-
-  AliFatal("Copy constructor not provided.");
-}
-
 //_____________________________________________________________________________
 AliMpTriggerSegmentation::~AliMpTriggerSegmentation()
 {
-  //
-  // Dtor (empty).
-  //
+  ///
+  /// Dtor (empty).
+  ///
+
+  if ( fIsOwner ) delete fkSlat;
+
   AliDebug(1,Form("this=%p",this));                    
 }
 
-//______________________________________________________________________________
-AliMpTriggerSegmentation& 
-AliMpTriggerSegmentation::operator=(const AliMpTriggerSegmentation& right)
+//_____________________________________________________________________________
+AliMpVPadIterator*
+AliMpTriggerSegmentation::CreateIterator(const AliMpArea&) const
 {
-/// Protected assignement operator (not implemented)
-
-  // check assignement to self
-  if (this == &right) return *this;
-
-  AliFatal("Assignement operator not provided.");
-    
-  return *this;  
-}    
+  ///
+  /// 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 AliMpArea&) const
+AliMpTriggerSegmentation::CreateIterator() const
 {
-  //
-  // Returns an iterator to loop over the pad contained within given area.
-  // Not implemented for trigger.
+  ///
+  /// Returns an iterator to loop over all the pads
+  /// Not implemented for trigger.
+  AliError("Not implemented for trigger");
   
   return 0;
 }
 
 //_____________________________________________________________________________
-TVector2
-AliMpTriggerSegmentation::Dimensions() const
+Int_t 
+AliMpTriggerSegmentation::GetNeighbours(const AliMpPad& /*pad*/, 
+                                        TObjArray& /*neighbours*/,
+                                        Bool_t /*includeSelf*/,
+                                        Bool_t /*includeVoid*/) const
 {
-  return Slat()->Dimensions();
+  /// 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);
 }
 
@@ -145,7 +161,7 @@ AliMpTriggerSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
 const char*
 AliMpTriggerSegmentation::GetName() const
 {
-  // Name of that segmentation = TriggerSegmentation + slatName
+  /// Name of that segmentation = TriggerSegmentation + slatName
   TString name("TriggerSegmentation");
   if ( fkSlat) 
   {
@@ -155,25 +171,13 @@ 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
 {
-  //
-  // 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;
 }
@@ -182,94 +186,87 @@ AliMpTriggerSegmentation::MaxPadIndexX() const
 Int_t 
 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 pi = seg.PadByLocation(location,kFALSE);
+    AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
+    AliMpPad pi = seg->PadByLocation(manuId,manuChannel,kFALSE);
     if ( pi.IsValid() ) 
     {
       if ( !pad.IsValid() )
       {
-        pad = AliMpPad(invloc,pi.GetIndices(),pi.Position(),pi.Dimensions());
-        pad.AddLocation(pi.GetLocation());
+       // uses PadByIndices to get the complete list of locations
+       return PadByIndices(pi.GetIx(), pi.GetIy(), warning);
       }
-      else
-      {
-        pad.AddLocation(pi.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 pi = seg.PadByIndices(indices,kFALSE);
+    AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
+    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;
@@ -277,50 +274,52 @@ 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 pi = seg.PadByPosition(position,kFALSE);
+    AliMpVSegmentation* seg = fkSlat->GetLayerSegmentation(i);
+    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;  
 }
 
 //_____________________________________________________________________________
-AliMpPlaneType
+AliMp::PlaneType
 AliMpTriggerSegmentation::PlaneType() const
 {
+  /// Return plane type
+
   return Slat()->PlaneType();
 }
 
@@ -328,9 +327,53 @@ AliMpTriggerSegmentation::PlaneType() const
 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);
+}