A bunch of changes :
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 20 Oct 2005 16:58:11 +0000 (16:58 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 20 Oct 2005 16:58:11 +0000 (16:58 +0000)
- TExMap to AliMpExMap to allow persistency
- ctor now takes the planeType
- slat has now a position that can be forced upon( required by trigger
)
- can now returns the list of electronic cards (manu for st345, local

  board for st67) it contains
(Laurent)
----------------------------------------------------------------------

MUON/mapping/AliMpSlat.cxx
MUON/mapping/AliMpSlat.h

index 74c47432e457a42b56e48077bc310671d54b614c..2b82d57ae86c60b24149e2ecb8781bc50106d8aa 100644 (file)
@@ -36,10 +36,12 @@ ClassImp(AliMpSlat)
 AliMpSlat::AliMpSlat() 
 : TObject(), 
   fId(""), 
+  fPlaneType(kNonBendingPlane),
   fDX(0), 
   fDY(0),
   fNofPadsX(0), 
-  fMaxNofPadsY(0)
+  fMaxNofPadsY(0),
+  fManuMap()
 {
     //
     // Empty ctor.
@@ -48,13 +50,15 @@ AliMpSlat::AliMpSlat()
 }
 
 //_____________________________________________________________________________
-AliMpSlat::AliMpSlat(const char* id)
+AliMpSlat::AliMpSlat(const char* id, AliMpPlaneType bendingOrNonBending)
 : TObject(), 
   fId(id), 
+  fPlaneType(bendingOrNonBending),
   fDX(0), 
   fDY(0),
   fNofPadsX(0), 
-  fMaxNofPadsY(0)
+  fMaxNofPadsY(0),
+  fManuMap(kTRUE)
 {
     //
     // Normal ctor
@@ -86,6 +90,10 @@ AliMpSlat::Add(AliMpPCB* pcbType, const TArrayI& manuList)
        {
                ixOffset = GetPCB(GetSize()-1)->Ixmax()+1;
        }
+  else
+  {
+    ixOffset = pcbType->Ixmin();
+  }
   Double_t xOffset = DX()*2;
   AliMpPCB* pcb = pcbType->Clone(manuList,ixOffset,xOffset);
 #ifdef WITH_ROOT
@@ -93,7 +101,7 @@ AliMpSlat::Add(AliMpPCB* pcbType, const TArrayI& manuList)
 #else
   fPCBs.push_back(pcb);
 #endif  
-  fDY = pcb->DY();
+  fDY = TMath::Max(pcb->DY(),fDY);
   fDX += pcb->DX();
   fNofPadsX += pcb->GetNofPadsX();
   fMaxNofPadsY = std::max(fMaxNofPadsY,pcb->GetNofPadsY());
@@ -103,10 +111,10 @@ AliMpSlat::Add(AliMpPCB* pcbType, const TArrayI& manuList)
                Int_t manuID = mp->GetID();
     // Before inserting a new key, check if it's already there
 #ifdef WITH_ROOT
-    Long_t there = fManuMap.GetValue((Long_t)manuID);
+    TObject* there = fManuMap.GetValue(manuID);
     if ( there == 0 )
     {
-      fManuMap.Add((Long_t)manuID,(Long_t)mp);
+      fManuMap.Add(manuID,(TObject*)mp);
     }
     else
     {
@@ -116,6 +124,7 @@ AliMpSlat::Add(AliMpPCB* pcbType, const TArrayI& manuList)
   fManuMap[manuID] = mp;
 #endif  
        }
+  fPosition.Set(DX(),DY());
 }
 
 //_____________________________________________________________________________
@@ -156,7 +165,7 @@ AliMpSlat::FindMotifPosition(Int_t manuID) const
   // Returns the motifPosition referenced by it manuID
   //
 #ifdef WITH_ROOT
-  Long_t rv = fManuMap.GetValue((Long_t)manuID);
+  TObject* rv = fManuMap.GetValue(manuID);
   if ( rv )
   {
     return (AliMpMotifPosition*)(rv);
@@ -289,6 +298,35 @@ AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
   return -1;
 }
 
+//_____________________________________________________________________________
+void
+AliMpSlat::ForcePosition(const TVector2& pos)
+{
+  //
+  // Force the position to be different from (DX(),DY()).
+  // Normally only used by triggerSlats (for layers).
+  // Beware that this method must be called once all PCB have been added,
+  // as the Add() method resets the position.
+  //
+  fPosition = pos;
+}
+
+//_____________________________________________________________________________
+void
+AliMpSlat::GetAllElectronicCardNumbers(TArrayI& ecn) const
+{
+  ecn.Set(GetNofElectronicCards());
+  TExMapIter it(fManuMap.GetIterator());
+  Long_t key;
+  Long_t value;
+  Int_t n(0);
+  while ( it.Next(key,value) == kTRUE )
+  {
+    ecn.AddAt((Int_t)(key),n);
+    ++n;
+  }
+}
+
 //_____________________________________________________________________________
 const char*
 AliMpSlat::GetID() const
@@ -309,6 +347,33 @@ AliMpSlat::GetMaxNofPadsY() const
   return fMaxNofPadsY;
 }
 
+//_____________________________________________________________________________
+const char*
+AliMpSlat::GetName() const
+{
+  TString name(GetID());
+  if ( fPlaneType == kBendingPlane )
+  {
+    name += ".Bending";
+  }
+  else if ( fPlaneType == kNonBendingPlane )
+  {
+    name += ".NonBending";
+  }
+  else
+  {
+    name += ".Invalid";
+  }
+  return name.Data();  
+}
+
+//_____________________________________________________________________________
+Int_t
+AliMpSlat::GetNofElectronicCards() const
+{
+  return fManuMap.GetSize();
+}
+
 //_____________________________________________________________________________
 Int_t
 AliMpSlat::GetNofPadsX() const
@@ -349,6 +414,13 @@ AliMpSlat::GetSize() const
 #endif  
 }
 
+//_____________________________________________________________________________
+TVector2
+AliMpSlat::Position() const
+{
+  return fPosition;
+}
+
 //_____________________________________________________________________________
 void
 AliMpSlat::Print(Option_t* option) const
@@ -357,9 +429,14 @@ AliMpSlat::Print(Option_t* option) const
   // Prints the slat characteristics.
   //
   cout << "SLAT " << GetID() <<  " 1/2 DIM = (" << DX() << "," << DY() << ")"
-       << " NPADSX = " << GetNofPadsX() << " NPCBs=" << GetSize() << endl;
+  << " POS = " << Position().X() << "," << Position().Y()
+       << " NPADSX = " << GetNofPadsX() 
+  << " MAXNPADSY = " << GetMaxNofPadsY()
+  << " NPCBs=" << GetSize() << endl;
+  
+  TString soption(option);
   
-  if ( option && option[0] == 'P' )
+  if ( soption.Contains("P") )
        {
     for ( Size_t i = 0; i < GetSize() ; ++i )
                {
@@ -374,4 +451,18 @@ AliMpSlat::Print(Option_t* option) const
            }
                }
        }
+  
+  if ( soption.Contains("M") || soption.Contains("L") )
+  {
+    cout << fManuMap.GetSize() << " ";
+    cout << "Electronic card (manu or local board) Ids : ";
+    
+    TExMapIter iter(fManuMap.GetIterator());
+    Long_t key, value;
+    while ( iter.Next(key,value) )
+    {
+      cout << key << " ";
+    }
+    cout << endl;
+  }
 }
index 2260190924df2376b02090f7836c25b51638350e..d9b11a8725bea587da540360062c9861a2610ea9 100644 (file)
 #include <TObject.h>
 
 #ifndef ROOT_TString
-#include "TString.h"
+#  include "TString.h"
+#endif
+
+#ifndef ALI_MP_PAD_H
+#  include "AliMpPad.h"
 #endif
 
 #ifndef ALI_MP_V_SEGMENTATION_H
-#include "AliMpVSegmentation.h"
+#  include "AliMpVSegmentation.h"
 #endif
 
-#ifndef ALI_MP_PAD_H
-#include "AliMpPad.h"
+#ifndef ALI_MP_PLANE_TYPE_H
+#  include "AliMpPlaneType.h"
 #endif
 
 #include "AliMpContainers.h"
@@ -32,7 +36,7 @@
 class TArrayI;
 
 #ifdef WITH_ROOT
-#  include "TExMap.h"
+#  include "AliMpExMap.h"
 #  include "TObjArray.h"
 #else
 #  include <vector>
@@ -41,6 +45,7 @@ class TArrayI;
 
 class AliMpMotifPosition;
 class AliMpPCB;
+class TArrayI;
 
 class AliMpSlat : public TObject
 {
@@ -53,11 +58,14 @@ class AliMpSlat : public TObject
 #endif  
   
   AliMpSlat();
-  AliMpSlat(const char* id);
+  AliMpSlat(const char* id, AliMpPlaneType bendingOrNonBending);
   virtual ~AliMpSlat();
 
   TVector2 Dimensions() const;
-
+  TVector2 Position() const;
+  
+  const char* GetName() const;
+  
   const char* GetID() const;
 
   void Add(AliMpPCB* pcbType, const TArrayI& manuList);
@@ -97,33 +105,46 @@ class AliMpSlat : public TObject
   /// Returns the MotifPosition containing the pad located at (ix,iy).
   AliMpMotifPosition* FindMotifPosition(Int_t ix, Int_t iy) const;
 
-  /// Returns the number of PCBs of this slat.
-  Size_t GetSize() const;
-
+  /// Return the ids of the electronic cards (either manu or local board).
+  void GetAllElectronicCardNumbers(TArrayI& ecn) const;
+  
+  /** Returns the max. number of pads in the x-direction contained in this slat.
+    This is a max only as for e.g. non-bending slats, the y-dimension depends
+    on the x-position.
+    */
+  Int_t GetMaxNofPadsY() const;
+  
+  /// Return the number of electronic cards (either manu or local board).
+  Int_t GetNofElectronicCards() const;
+  
   /// Returns the number of pads in the x-direction contained in this slat.
   Int_t GetNofPadsX() const;
  
-  /** Returns the max. number of pads in the x-direction contained in this slat.
-      This is a max only as for e.g. non-bending slats, the y-dimension depends
-      on the x-position.
-  */
-  Int_t GetMaxNofPadsY() const;
-
+  /// Returns the number of PCBs of this slat.
+  Size_t GetSize() const;
+    
   void Print(Option_t* option="") const;
 
+  /** This is normally only used by triggerSlats, as for ST345 slats,
+    the position is DX(),DY() simply.
+    */
+  void ForcePosition(const TVector2& pos);
+  
  private:
   TString fId;
+  AliMpPlaneType fPlaneType;
   Double_t fDX;
   Double_t fDY;
   Int_t fNofPadsX;
   Int_t fMaxNofPadsY;
 #ifdef WITH_ROOT
   TObjArray fPCBs; // array of AliMpPCB*
-  mutable TExMap fManuMap; // map of int to AliMpMotifPosition*
+  mutable AliMpExMap fManuMap; // map of int to AliMpMotifPosition*
 #else  
   std::vector<AliMpPCB*> fPCBs;
   std::map<int,AliMpMotifPosition*> fManuMap;
 #endif
+  TVector2 fPosition;
   
   ClassDef(AliMpSlat,1) // A slat for stations 3,4,5
 };