#include "TMath.h"
#include <sstream>
-///
+
+//-----------------------------------------------------------------------------
/// \class AliMpPCB
///
/// A PCB for station 3,4 or 5
/// the enveloppe.
///
/// \author L. Aphecetche
+//-----------------------------------------------------------------------------
/// \cond CLASSIMP
ClassImp(AliMpPCB)
///
/// Default ctor.
///
-#ifdef WITH_ROOT
fMotifPositions.SetOwner(kTRUE);
-#endif
AliDebug(1,Form("this=%p",this));
}
/// Normal ctor. Must be fed with the PCB's name (id), the pad dimensions
/// and the global dimension of the virtual enveloppe of the PCB
/// (usually 400x400 mm)
-#ifdef WITH_ROOT
fMotifPositions.SetOwner(kTRUE);
-#endif
AliDebug(1,Form("this=%p id=%s",this,id));
}
///
/// Copy constructor
-#ifdef WITH_ROOT
- fMotifPositions.SetOwner(kTRUE);
-#endif
+ fMotifPositions.SetOwner(kTRUE);
+
AliDebug(1,Form("this=%p (copy ctor) : begin",this));
o.Copy(*this);
AliDebug(1,Form("this=%p (copy ctor) : end",this));
fId(id),
fPadSizeX(-1.0),
fPadSizeY(-1.0),
- fEnveloppeSizeX(ms->Dimensions().X()*2.0),
- fEnveloppeSizeY(ms->Dimensions().Y()*2.0),
+ fEnveloppeSizeX(ms->DimensionX()*2.0),
+ fEnveloppeSizeY(ms->DimensionY()*2.0),
fXoffset(0.0),
fActiveXmin(0.0),
fActiveXmax(fEnveloppeSizeX),
/// so far ;-)
///
- AliDebug(1,Form("this=%p (ctor special motif)",this));
+ AliDebug(1,Form("this=%p (ctor special motif)",this));
-#ifdef WITH_ROOT
- fMotifPositions.SetOwner(kTRUE);
-#endif
- TVector2 position(ms->Dimensions());
- AliMpMotifPosition* mp = new AliMpMotifPosition(-1,ms,position);
- mp->SetLowIndicesLimit(AliMpIntPair(fIxmin,fIymin));
- mp->SetHighIndicesLimit(AliMpIntPair(fIxmax,fIymax));
-#ifdef WITH_ROOT
+ fMotifPositions.SetOwner(kTRUE);
+
+ Double_t posx = ms->DimensionX();
+ Double_t posy = ms->DimensionY();
+ AliMpMotifPosition* mp = new AliMpMotifPosition(-1,ms,posx,posy);
+ mp->SetLowIndicesLimit(fIxmin,fIymin);
+ mp->SetHighIndicesLimit(fIxmax,fIymax);
fMotifPositions.AddLast(mp);
-#else
- fMotifPositions.push_back(mp);
-#endif
}
//_____________________________________________________________________________
/// Dtor.
///
AliDebug(1,Form("this=%p",this));
-#ifndef WITH_ROOT
- for ( size_t i = 0; i < fMotifPositions.size(); ++i )
- {
- delete fMotifPositions[i];
- }
-#endif
-
}
//_____________________________________________________________________________
if (!motif)
{
- motif = new AliMpMotif(id,mt,TVector2(PadSizeX()/2.0,PadSizeY()/2.0));
+ motif = new AliMpMotif(id,mt,PadSizeX()/2.0,PadSizeY()/2.0);
AliDebug(1,Form("Adding motif %s to motifMap",id.Data()));
fMotifMap->AddMotif(motif);
}
AliDebug(1,Form("Got motif %s from motifMap",id.Data()));
}
- TVector2 position;
+ Double_t posx(0.);
+ Double_t posy(0.);
Int_t ixmin(-1);
Int_t iymin(-1);
if ( ix >= 0 && iy >= 0 )
{
- position.Set(ix*PadSizeX(),iy*PadSizeY());
+ posx = ix*PadSizeX();
+ posy = iy*PadSizeY();
ixmin = ix;
iymin = iy;
}
else
if ( ix >= 0 && iy < 0 )
{
- position.Set(ix*PadSizeX(),Ymax()+iy*PadSizeY());
+ posx = ix*PadSizeX();
+ posy = Ymax()+iy*PadSizeY();
ixmin = ix;
iymin = TMath::Nint(Ymax()/PadSizeY()) + iy;
}
else
if ( ix < 0 && iy < 0 )
{
- position.Set(Xmax()+ix*PadSizeX(),Ymax()+iy*PadSizeY());
+ posx = Xmax()+ix*PadSizeX();
+ posy = Ymax()+iy*PadSizeY();
ixmin = TMath::Nint(Xmax()/PadSizeX()) + ix;
iymin = TMath::Nint(Ymax()/PadSizeY()) + iy;
}
else
if ( ix < 0 && iy >=0 )
{
- position.Set(Xmax()+ix*PadSizeX(),iy*PadSizeY());
+ posx = Xmax()+ix*PadSizeX();
+ posy = iy*PadSizeY();
ixmin = TMath::Nint(Xmax()/PadSizeX()) + ix;
iymin = iy;
}
- position += motif->Dimensions();
+ posx += motif->DimensionX();
+ posy += motif->DimensionY();
+ AliMpMotifPosition* mp
+ = new AliMpMotifPosition(-1,motif,posx, posy);
- AliMpMotifPosition* mp = new AliMpMotifPosition(-1,motif,position);
- Int_t ixmax = ixmin + mt->GetNofPadsX() - 1;
+ Int_t ixmax = ixmin + mt->GetNofPadsX() - 1;
Int_t iymax = iymin + mt->GetNofPadsY() - 1;
+ mp->SetLowIndicesLimit(ixmin,iymin);
+ mp->SetHighIndicesLimit(ixmax,iymax);
- mp->SetLowIndicesLimit(AliMpIntPair(ixmin,iymin));
- mp->SetHighIndicesLimit(AliMpIntPair(ixmax,iymax));
-
-#ifdef WITH_ROOT
fMotifPositions.AddLast(mp);
-#else
- fMotifPositions.push_back(mp);
-#endif
fIxmin = TMath::Min(fIxmin,ixmin);
fIxmax = TMath::Max(fIxmax,ixmax);
{
/// Return the area of this PCB
- return AliMpArea(TVector2( (Xmin()+Xmax())/2.0,DY()),
- TVector2( DX(), DY() ) );
+ return AliMpArea((Xmin()+Xmax())/2.0,DY(), DX(), DY() );
}
//_____________________________________________________________________________
return 0;
}
- AliMpIntPair shift(-fIxmin+ixOffset,0);
+ MpPair_t shift = AliMp::Pair(-fIxmin+ixOffset,0);
// Then change the internal MotifPositions wrt manu id
// and position (offset in x).
- for ( Size_t i = 0; i < pcb->GetSize(); ++i )
+ for ( Int_t i = 0; i < pcb->GetSize(); ++i )
{
AliMpMotifPosition* mp = pcb->GetMotifPosition(i);
mp->SetID(manuids[i]);
- TVector2 pos(mp->Position());
- pos += TVector2(xOffset,0);
- mp->SetPosition(pos);
- AliMpIntPair offset(ixOffset,0);
- AliMpIntPair low(mp->GetLowIndicesLimit());
+ Double_t posx = mp->GetPositionX() + xOffset;
+ Double_t posy = mp->GetPositionY();
+ mp->SetPosition(posx, posy);
+ MpPair_t low = mp->GetLowIndicesLimit();
low += shift;
mp->SetLowIndicesLimit(low);
- AliMpIntPair high(mp->GetHighIndicesLimit());
+ MpPair_t high = mp->GetHighIndicesLimit();
high += shift;
mp->SetHighIndicesLimit(high);
}
- pcb->fIxmin += shift.GetFirst();
- pcb->fIxmax += shift.GetFirst();
+ pcb->fIxmin += AliMp::PairFirst(shift);
+ pcb->fIxmax += AliMp::PairFirst(shift);
pcb->fXoffset = xOffset;
pcb->fActiveXmin += xOffset;
pcb.fActiveXmin = fActiveXmin;
pcb.fActiveXmax = fActiveXmax;
-#ifdef WITH_ROOT
AliDebug(1,"Deleting pcb.fMotifPositions");
pcb.fMotifPositions.Delete();
AliDebug(1,"Deleting pcb.fMotifPositions : done");
-#else
- for ( Size_t i = 0; i < pcb.fMotifPositions.size(); ++i )
- {
- delete pcb.fMotifPositions[i];
- }
-#endif
-#ifdef WITH_ROOT
- for ( Size_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i )
-#else
- for ( Size_t i = 0; i < fMotifPositions.size(); ++i )
-#endif
+ for ( Int_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i )
{
AliMpMotifPosition* pos = (AliMpMotifPosition*)fMotifPositions[i];
- AliMpMotifPosition* pcbpos = new AliMpMotifPosition(pos->GetID(),
- pos->GetMotif(),
- pos->Position());
+ AliMpMotifPosition* pcbpos
+ = new AliMpMotifPosition(pos->GetID(), pos->GetMotif(),
+ pos->GetPositionX(), pos->GetPositionY());
pcbpos->SetLowIndicesLimit(pos->GetLowIndicesLimit());
pcbpos->SetHighIndicesLimit(pos->GetHighIndicesLimit());
-#ifdef WITH_ROOT
pcb.fMotifPositions.AddLast(pcbpos);
-#else
- pcb.fMotifPositions.push_back(pcbpos);
-#endif
}
pcb.fNofPads = fNofPads;
/// integer indices (ix,iy).
///
-#ifdef WITH_ROOT
- for (Size_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i )
-#else
- for (Size_t i = 0; i < fMotifPositions.size(); ++i )
-#endif
+ for (Int_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i )
{
AliMpMotifPosition* mp = (AliMpMotifPosition*)fMotifPositions[i];
- if ( mp->HasPad(AliMpIntPair(ix,iy)) )
+ if ( mp->HasPadByIndices(AliMp::Pair(ix,iy)) )
{
return mp;
}
/// Returns the motifPosition located at position (x,y)
///
-#ifdef WITH_ROOT
- for (Size_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i )
-#else
- for (Size_t i = 0; i < fMotifPositions.size(); ++i )
-#endif
+ for (Int_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i )
{
AliMpMotifPosition* mp = (AliMpMotifPosition*)fMotifPositions[i];
- TVector2 localPos( TVector2(x,y) - mp->Position() );
+ Double_t localPosX = x - mp->GetPositionX();
+ Double_t localPosY = y - mp->GetPositionY();
- AliMpIntPair localIndices(mp->GetMotif()->PadIndicesLocal(localPos));
+ MpPair_t localIndices(
+ mp->GetMotif()->PadIndicesLocal(localPosX, localPosY));
- if ( localIndices.IsValid() && mp->GetMotif()->GetMotifType()->HasPad(localIndices) )
+ if ( localIndices >= 0 &&
+ mp->GetMotif()->GetMotifType()->HasPadByLocalIndices(localIndices) )
{
return mp;
}
//_____________________________________________________________________________
AliMpMotifPosition*
-AliMpPCB::GetMotifPosition(AliMpPCB::Size_t i) const
+AliMpPCB::GetMotifPosition(Int_t i) const
{
///
/// Get the i-th motifPosition stored in this PCB's internal array.
///
-#ifdef WITH_ROOT
if ( i >= fMotifPositions.GetEntriesFast() ) return 0;
-#else
- if ( i >= fMotifPositions.size() ) return 0;
-#endif
+
return (AliMpMotifPosition*)fMotifPositions[i];
}
}
//_____________________________________________________________________________
-AliMpPCB::Size_t
+Int_t
AliMpPCB::GetSize() const
{
///
/// Returns the number of motifPositions stored in this PCB.
///
-#ifdef WITH_ROOT
return fMotifPositions.GetEntriesFast();
-#else
- return fMotifPositions.size();
-#endif
+}
+
+//_____________________________________________________________________________
+Bool_t
+AliMpPCB::HasMotifPositionID(Int_t manuId) const
+{
+ /// Returns whether or not we have manuId
+
+ TIter next(&fMotifPositions);
+ AliMpMotifPosition* pos;
+ while ( ( pos = static_cast<AliMpMotifPosition*>(next()) ) )
+ {
+ if ( pos->GetID() == manuId ) return kTRUE;
+ }
+ return kFALSE;
}
if ( option && option[0] == 'M' )
{
-#ifdef WITH_ROOT
- for ( Size_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i )
-#else
- for ( Size_t i = 0; i < fMotifPositions.size(); ++i )
-#endif
+ for ( Int_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i )
{
if (option)
{
TList lines;
lines.SetOwner(kTRUE);
-#ifdef WITH_ROOT
- for ( Size_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i )
-#else
- for ( Size_t i = 0; i < fMotifPositions.size(); ++i )
-#endif
+ for ( Int_t i = 0; i < fMotifPositions.GetEntriesFast(); ++i )
{
AliMpMotifPosition* pos = GetMotifPosition(i);
AliMpVMotif* motif = pos->GetMotif();
- TVector2 lowerLeft(pos->Position()-pos->Dimensions());
+
+ Double_t lowerLeftX = pos->GetPositionX()-pos->GetDimensionX();
+ Double_t lowerLeftY = pos->GetPositionY()-pos->GetDimensionY();
TString id(motif->GetID());
// id is supposed to be of the form %s-%e-%e, and we're only
// interested in the %s part of it
TString motifName(id(0,index));
lines.Add(new TObjString(Form("MOTIF %s %d %d",
motifName.Data(),
- TMath::Nint(lowerLeft.X()/fPadSizeX),
- TMath::Nint(lowerLeft.Y()/fPadSizeY))));
+ TMath::Nint(lowerLeftX/fPadSizeX),
+ TMath::Nint(lowerLeftY/fPadSizeY))));
}
ofstream out(fileName.Data());