**************************************************************************/
// $Id$
-// $MpId: AliMpSlat.cxx,v 1.5 2006/03/17 16:42:33 ivana Exp $
+// $MpId: AliMpSlat.cxx,v 1.6 2006/05/24 13:58:50 ivana Exp $
#include "AliMpSlat.h"
+#include "AliMpExMapIterator.h"
#include "AliLog.h"
#include "AliMpMotifPosition.h"
#include "AliMpPCB.h"
#include "TArrayI.h"
-///
+#include <cassert>
+
+//-----------------------------------------------------------------------------
/// Representation of a slat cathode (bending or non-bending).
///
/// A slat can be viewed as a "collection" of PCBs of various densities
/// All the PCBs have a least the same height, if not the same width. In most
/// of the case, height=width=40 cm, at least for St345 (for trigger,
/// width varies)
-///
+//
+/// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
+/// \cond CLASSIMP
ClassImp(AliMpSlat)
+/// \endcond
//_____________________________________________________________________________
-AliMpSlat::AliMpSlat()
+AliMpSlat::AliMpSlat(TRootIOCtor* ioCtor)
: TObject(),
fId(""),
- fPlaneType(kNonBendingPlane),
+ fPlaneType(AliMp::kNonBendingPlane),
fDX(0),
fDY(0),
fNofPadsX(0),
fMaxNofPadsY(0),
- fManuMap(),
+ fManuMap(ioCtor),
+ fPCBs(),
+ fPositionX(0.),
+ fPositionY(0.),
fNofPads(0)
{
- //
- // Empty ctor.
- //
+ ///
+ /// Empty ctor.
+ ///
AliDebug(1,Form("this=%p Empty ctor",this));
+
+ fPCBs.SetOwner(kTRUE);
+ fManuMap.SetOwner(kFALSE);
}
//_____________________________________________________________________________
-AliMpSlat::AliMpSlat(const char* id, AliMpPlaneType bendingOrNonBending)
+AliMpSlat::AliMpSlat(const char* id, AliMp::PlaneType bendingOrNonBending)
: TObject(),
fId(id),
fPlaneType(bendingOrNonBending),
fDY(0),
fNofPadsX(0),
fMaxNofPadsY(0),
-//#ifdef WITH_ROOT
- fManuMap(kTRUE),
-//#else
-// fManuMap(),
-//#endif
+ fManuMap(),
+ fPCBs(),
+ fPositionX(0.),
+ fPositionY(0.),
fNofPads(0)
{
- //
- // Normal ctor
- //
- AliDebug(1,Form("this=%p id=%s",this,id));
-}
+ ///
+ /// Normal ctor
+ ///
+ AliDebug(1,Form("this=%p id=%s",this,id));
-//_____________________________________________________________________________
-AliMpSlat::AliMpSlat(const AliMpSlat&) : TObject()
-{
- //
- AliFatal("Implement me if needed");
-}
-
-//_____________________________________________________________________________
-AliMpSlat&
-AliMpSlat::operator=(const AliMpSlat&)
-{
- //
- AliFatal("Implement me if needed");
- return *this;
+ fPCBs.SetOwner(kTRUE);
+ fManuMap.SetOwner(kFALSE);
}
//_____________________________________________________________________________
AliMpSlat::~AliMpSlat()
{
- //
- // Dtor.
- //
- AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
+ ///
+ /// Dtor.
+ ///
+ AliDebug(1,Form("this=%p fId=%s",this,fId.Data()));
+
+ fPCBs.Delete();
}
//_____________________________________________________________________________
void
-AliMpSlat::Add(AliMpPCB* pcbType, const TArrayI& manuList)
+AliMpSlat::Add(const AliMpPCB& pcbType, const TArrayI& manuList)
{
- //
- // Adds a PCB to this slat. The manuList specifies the ids of the manu
- // that compose the PCB. The manuList ordering is important, as the
- // assumption is that it's ordered counter-clockwise, starting from
- // the lower-left of the PCB.
- //
+ ///
+ /// Adds a PCB to this slat. The manuList specifies the ids of the manu
+ /// that compose the PCB. The manuList ordering is important, as the
+ /// assumption is that it's ordered counter-clockwise, starting from
+ /// the lower-left of the PCB.
+ ///
Int_t ixOffset = 0;
if ( GetSize() )
{
}
else
{
- ixOffset = pcbType->Ixmin();
+ ixOffset = pcbType.Ixmin();
}
Double_t xOffset = DX()*2;
- AliMpPCB* pcb = pcbType->Clone(manuList,ixOffset,xOffset);
-#ifdef WITH_ROOT
+ AliMpPCB* pcb = pcbType.Clone(manuList,ixOffset,xOffset);
fPCBs.AddLast(pcb);
-#else
- fPCBs.push_back(pcb);
-#endif
fDY = TMath::Max(pcb->DY(),fDY);
fDX += pcb->DX();
fNofPadsX += pcb->GetNofPadsX();
- fMaxNofPadsY = std::max(fMaxNofPadsY,pcb->GetNofPadsY());
- for ( AliMpPCB::Size_t i = 0; i < pcb->GetSize(); ++i )
+ fMaxNofPadsY = TMath::Max(fMaxNofPadsY,pcb->GetNofPadsY());
+ Int_t n(0);
+ for ( Int_t i = 0; i < pcb->GetSize(); ++i )
{
AliMpMotifPosition* mp = pcb->GetMotifPosition(i);
Int_t manuID = mp->GetID();
// Before inserting a new key, check if it's already there
-//#ifdef WITH_ROOT
TObject* there = fManuMap.GetValue(manuID);
if ( there == 0 )
{
+ ++n;
+ AliDebug(1,Form("Adding %d-th manuId=%d (%d) to ManuMap (size=%d)",n,manuID,mp->GetID(),fManuMap.GetSize()));
fManuMap.Add(manuID,(TObject*)mp);
}
else
{
- AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType->GetID()));
+ AliError(Form("ManuID %d is duplicated for PCB %s",manuID,pcbType.GetID()));
}
-//#else
-// fManuMap[manuID] = mp;
-//#endif
- }
- fPosition.Set(DX(),DY());
+ }
+ fPositionX = DX();
+ fPositionY = DY();
fNofPads += pcb->NofPads();
}
-//_____________________________________________________________________________
-TVector2
-AliMpSlat::Dimensions() const
-{
- //
- // Returns the half-sizes of the slat.
- //
- return TVector2(DX(),DY());
-}
-
//_____________________________________________________________________________
Double_t
AliMpSlat::DX() const
{
- //
- // Returns the x-half-size of the slat.
- //
+ ///
+ /// Returns the x-half-size of the slat.
+ ///
return fDX;
}
Double_t
AliMpSlat::DY() const
{
- //
- // Returns the y-half-size of the slat.
- //
+ ///
+ /// Returns the y-half-size of the slat.
+ ///
return fDY;
}
AliMpMotifPosition*
AliMpSlat::FindMotifPosition(Int_t manuID) const
{
- //
- // Returns the motifPosition referenced by it manuID
- //
-//#ifdef WITH_ROOT
+ ///
+ /// Returns the motifPosition referenced by it manuID
+ ///
return static_cast<AliMpMotifPosition*>(fManuMap.GetValue(manuID));
-//#else
-// std::map<int,AliMpMotifPosition*>::const_iterator it = fManuMap.find(manuID);
-// if ( it != fManuMap.end() )
-// {
-// return it->second;
-// }
-// else
-// {
-// return 0;
-// }
-//#endif
}
//_____________________________________________________________________________
AliMpMotifPosition*
AliMpSlat::FindMotifPosition(Int_t ix, Int_t iy) const
{
- //
- // 1. Find the PCB containing ix (iy not needed for this)
- // 2. Forward the request to the PCB, using pcb local indices.
+ ///
+ /// - 1. Find the PCB containing ix (iy not needed for this)
+ /// - 2. Forward the request to the PCB, using pcb local indices.
//
const AliMpPCB* pcb = FindPCB(ix);
if ( pcb )
AliMpMotifPosition*
AliMpSlat::FindMotifPosition(Double_t x, Double_t y) const
{
- //
- // Returns the motifPosition containing position (x,y)
- //
+ ///
+ /// Returns the motifPosition containing position (x,y)
+ ///
const AliMpPCB* pcb = FindPCB(x,y);
if (pcb)
{
AliMpPCB*
AliMpSlat::FindPCB(Int_t ix) const
{
- //
- // Returns the PCB containing x-integer-position ix
- //
- for ( Size_t i = 0; i < GetSize(); ++i )
+ ///
+ /// Returns the PCB containing x-integer-position ix
+ ///
+ for ( Int_t i = 0; i < GetSize(); ++i )
{
AliMpPCB* pcb = GetPCB(i);
if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
Int_t
AliMpSlat::FindPCBIndex(Int_t ix) const
{
- //
- // Returns the index of the PCB containing x-integer-position ix.
- //
- for ( Size_t i = 0; i < GetSize(); ++i )
+ ///
+ /// Returns the index of the PCB containing x-integer-position ix.
+ ///
+ for ( Int_t i = 0; i < GetSize(); ++i )
{
AliMpPCB* pcb = GetPCB(i);
if ( ix >= pcb->Ixmin() && ix <= pcb->Ixmax() )
AliMpPCB*
AliMpSlat::FindPCB(Double_t x, Double_t y) const
{
- //
- // Returns the PCB containing position (x,y)
- //
- for ( Size_t i = 0; i < GetSize(); ++i )
+ ///
+ /// Returns the PCB containing position (x,y)
+ ///
+ for ( Int_t i = 0; i < GetSize(); ++i )
{
AliMpPCB* pcb = GetPCB(i);
- if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
- y >= pcb->Ymin() && y < pcb->Ymax() )
- {
- return pcb;
- }
+// if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
+// y >= pcb->Ymin() && y < pcb->Ymax() )
+// {
+// return pcb;
+// }
+ if ( x < pcb->Xmin() || x >= pcb->Xmax() ||
+ y < pcb->Ymin() || y >= pcb->Ymax() )
+ {
+ continue;
+ }
+ return pcb;
}
return 0;
}
Int_t
AliMpSlat::FindPCBIndex(Double_t x, Double_t y) const
{
- //
- // Returns the index of the PCB containing position (x,y)
- //
- for ( Size_t i = 0; i < GetSize(); ++i )
+ ///
+ /// Returns the index of the PCB containing position (x,y)
+ ///
+ for ( Int_t i = 0; i < GetSize(); ++i )
{
AliMpPCB* pcb = GetPCB(i);
if ( x >= pcb->Xmin() && x < pcb->Xmax() &&
return -1;
}
+//_____________________________________________________________________________
+Int_t
+AliMpSlat::FindPCBIndexByMotifPositionID(Int_t manuId) const
+{
+ /// Find the index of the PCB containing a given manu
+ for ( Int_t i = 0; i< GetSize(); ++i )
+ {
+ AliMpPCB* pcb = GetPCB(i);
+ if ( pcb->HasMotifPositionID(manuId) ) return i;
+ }
+ return -1;
+}
+
//_____________________________________________________________________________
void
-AliMpSlat::ForcePosition(const TVector2& pos)
+AliMpSlat::ForcePosition(Double_t x, Double_t y)
{
- //
- // 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;
+ ///
+ /// 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.
+ ///
+ fPositionX = x;
+ fPositionY = y;
}
//_____________________________________________________________________________
void
AliMpSlat::GetAllMotifPositionsIDs(TArrayI& ecn) const
{
- //
- // Return all the manuIds (=MotifPositionIDs) of this slat
- //
- ecn.Set(GetNofElectronicCards());
-//#ifdef WITH_ROOT
- TExMapIter it(fManuMap.GetIterator());
- Long_t key;
- Long_t value;
+ ///
+ /// Return all the manuIds (=MotifPositionIDs) of this slat
+ ///
+ Int_t nofElectronicCards(GetNofElectronicCards());
+ assert(nofElectronicCards>0);
+ ecn.Set(nofElectronicCards);
+ TIter next(fManuMap.CreateIterator());
+ AliMpMotifPosition* mp;
Int_t n(0);
- while ( it.Next(key,value) == kTRUE )
+ while ( ( mp = static_cast<AliMpMotifPosition*>(next()) ) )
{
- ecn.AddAt((Int_t)(key),n);
+ ecn.AddAt(mp->GetID(),n);
++n;
}
-//#else
- // missing here
-//#endif
+ assert(n==nofElectronicCards);
}
//_____________________________________________________________________________
const char*
AliMpSlat::GetID() const
{
- //
- // Returns the name of this slat.
- //
+ ///
+ /// Returns the name of this slat.
+ ///
return fId.Data();
}
Int_t
AliMpSlat::GetMaxNofPadsY() const
{
- //
- // Returns the maximum number of pads to be found in this slat y-direction.
- //
+ ///
+ /// Returns the maximum number of pads to be found in this slat y-direction.
+ ///
return fMaxNofPadsY;
}
Int_t
AliMpSlat::GetMaxPadIndexX() const
{
- //
- // Returns the max ix that is valid for this slat.
- //
+ ///
+ /// Returns the max ix that is valid for this slat.
+ ///
AliMpPCB* last = GetPCB(GetSize()-1);
if (last)
{
const char*
AliMpSlat::GetName() const
{
- //
- // Returns the name of this slat, which is composed of its ID with
- // the plane type as a suffix.
- //
+ ///
+ /// Returns the name of this slat, which is composed of its ID with
+ /// the plane type as a suffix.
+ ///
TString name(GetID());
- if ( fPlaneType == kBendingPlane )
+ if ( fPlaneType == AliMp::kBendingPlane )
{
name += ".Bending";
}
- else if ( fPlaneType == kNonBendingPlane )
+ else if ( fPlaneType == AliMp::kNonBendingPlane )
{
name += ".NonBending";
}
Int_t
AliMpSlat::GetNofElectronicCards() const
{
- //
- // Returns the number of manus that compose the readout of this slat.
- //
+ ///
+ /// Returns the number of manus that compose the readout of this slat.
+ ///
return fManuMap.GetSize();
}
Int_t
AliMpSlat::GetNofPadsX() const
{
- //
- // Returns the number of pad in x-direction.
- //
+ ///
+ /// Returns the number of pad in x-direction.
+ ///
return fNofPadsX;
}
//_____________________________________________________________________________
AliMpPCB*
-AliMpSlat::GetPCB(AliMpSlat::Size_t i) const
+AliMpSlat::GetPCB(Int_t i) const
{
- //
- // Returns the i-th PCB of this slat.
- //
-#ifdef WITH_ROOT
+ ///
+ /// Returns the i-th PCB of this slat.
+ ///
if ( i >= fPCBs.GetEntriesFast() ) return 0;
return (AliMpPCB*)fPCBs[i];
-#else
- if ( i >= fPCBs.size() ) return 0;
- return fPCBs[i];
-#endif
}
//_____________________________________________________________________________
-AliMpSlat::Size_t
+Int_t
AliMpSlat::GetSize() const
{
- //
- // Returns the number of PCB in this slat.
- //
-#ifdef WITH_ROOT
+ ///
+ /// Returns the number of PCB in this slat.
+ ///
return fPCBs.GetEntriesFast();
-#else
- return fPCBs.size();
-#endif
}
//_____________________________________________________________________________
void
AliMpSlat::Print(Option_t* option) const
{
- //
- // Prints the slat characteristics.
- //
+ ///
+ /// Prints the slat characteristics.
+ ///
cout << "SLAT " << GetID() << " 1/2 DIM = (" << DX() << "," << DY() << ")"
- << " POS = " << Position().X() << "," << Position().Y()
+ << " POS = " << GetPositionX() << "," << GetPositionY()
<< " NPADSX = " << GetNofPadsX()
<< " MAXNPADSY = " << GetMaxNofPadsY()
<< " NPCBs=" << GetSize() << endl;
if ( soption.Contains("P") )
{
- for ( Size_t i = 0; i < GetSize() ; ++i )
+ for ( Int_t i = 0; i < GetSize() ; ++i )
{
cout << " ";
if ( option )
{
cout << fManuMap.GetSize() << " ";
cout << "Electronic card (manu or local board) Ids : ";
-
- TExMapIter iter(fManuMap.GetIterator());
- Long_t key, value;
- while ( iter.Next(key,value) )
+ TIter next(fManuMap.CreateIterator());
+ AliMpMotifPosition* mp;
+ while ( ( mp = static_cast<AliMpMotifPosition*>(next())) )
{
- cout << key << " ";
+ cout << mp->GetID() << " ";
}
cout << endl;
}