4 // Class AliMpMotifSpecial
5 // -----------------------
6 // Class that defines a motif with its unique ID
9 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
13 #include "AliMpMotifSpecial.h"
14 #include "AliMpMotifType.h"
15 #include "AliMpIntPair.h"
16 #include "AliMpConstants.h"
18 ClassImp(AliMpMotifSpecial)
22 //______________________________________________________________________________
23 Int_t AliMpMotifSpecial::VectorIndex(const AliMpIntPair& indices) const
25 // transform indices to linear vector index
26 return indices.GetFirst()*GetMotifType()->GetNofPadsY() + indices.GetSecond();
32 //______________________________________________________________________________
33 AliMpMotifSpecial::AliMpMotifSpecial():
35 fPadDimensionsVector(),
36 fPadDimensionsVector2()
38 //default dummy constructor
42 //______________________________________________________________________________
43 AliMpMotifSpecial::AliMpMotifSpecial(const TString &id,
44 AliMpMotifType *motifType)
45 : AliMpVMotif(id,motifType),
46 fPadDimensionsVector(),
47 fPadDimensionsVector2()
50 // Normal constructor.
52 fPadDimensionsVector.resize(motifType->GetNofPadsX()*motifType->GetNofPadsY());
55 //______________________________________________________________________________
56 AliMpMotifSpecial::~AliMpMotifSpecial()
62 //______________________________________________________________________________
64 AliMpMotifSpecial::GetPadDimensions(const AliMpIntPair& localIndices) const
66 // returns the dimensions of pad located at the given indices
67 if (GetMotifType()->HasPad(localIndices))
68 return fPadDimensionsVector[VectorIndex(localIndices)];
70 Warning("GetPadDimensions","Indices outside limits");
71 return TVector2(0.,0.);
75 //______________________________________________________________________________
76 Int_t AliMpMotifSpecial::GetNofPadDimensions() const
78 // returns number of different pad dimensions in this motif
80 return fPadDimensionsVector2.size();
83 //______________________________________________________________________________
84 TVector2 AliMpMotifSpecial::GetPadDimensions(Int_t i) const
86 // returns the i-th different pad dimensions
88 if (i<0 || i>GetNofPadDimensions()) {
89 Fatal("GetPadDimensions(i)", "Index outside limits.");
93 return fPadDimensionsVector2[i];
96 //______________________________________________________________________________
97 TVector2 AliMpMotifSpecial::Dimensions() const
99 // gives the dimension of the motif
106 Double_t* tabSizeX = new Double_t[GetMotifType()->GetNofPadsY()];
107 for (j=0;j<GetMotifType()->GetNofPadsY();++j) tabSizeX[j]=0.0;
109 for (i=0;i<GetMotifType()->GetNofPadsX();++i) {
111 for (j=0;j<GetMotifType()->GetNofPadsY();++j) {
112 TVector2 dim = GetPadDimensions(AliMpIntPair(i,j));
114 tabSizeX[j]+=dim.X();
116 if (trSizeY>sizeY) sizeY=trSizeY;
118 for (j=0;j<GetMotifType()->GetNofPadsY();++j) {
119 if (tabSizeX[j]>sizeX) sizeX = tabSizeX[j];
124 return TVector2(sizeX,sizeY);
127 //______________________________________________________________________________
129 AliMpMotifSpecial::PadPositionLocal(const AliMpIntPair& localIndices) const
131 // gives the local position of the pad number (ix,iy)
132 // (0,0 is the center of the motif)
134 TVector2 dim = GetPadDimensions(localIndices);
136 Double_t posX= dim.X();
137 for (Int_t i=0;i<localIndices.GetFirst();++i) {
138 posX+=2.*GetPadDimensions(AliMpIntPair(i,localIndices.GetSecond())).X();
141 Double_t posY= dim.Y();
142 for (Int_t j=0;j<localIndices.GetSecond();++j) {
143 posY+=2.*GetPadDimensions(AliMpIntPair(localIndices.GetFirst(),j)).Y();
146 return TVector2(posX,posY)-Dimensions();
149 //______________________________________________________________________________
150 AliMpIntPair AliMpMotifSpecial::PadIndicesLocal(const TVector2& localPos) const
152 // return the pad indices from a given local position
153 // or AliMpIntPair::Invalid() if this position doesn't correspond to any valid
156 // *SOLEIL* : This code suppose that
157 // 1) all cells have the same size along the Y direction
158 // 2) the column 0 is entierly filled
161 // First : find the j index
162 TVector2 pos = localPos + Dimensions();
166 while (j<GetMotifType()->GetNofPadsY()) {
167 TVector2 padDim = GetPadDimensions(AliMpIntPair(0,j));
173 // Test if it's outside limits
174 if (j==GetMotifType()->GetNofPadsY()){
175 Warning("PadIndicesLocal","The position is outside the motif");
176 return AliMpIntPair::Invalid();
180 // now find the i index, in the j_th row
184 while (i<GetMotifType()->GetNofPadsX()) {
185 TVector2 padDim = GetPadDimensions(AliMpIntPair(i,j));
192 // Test if it's outside limits
194 if (i==GetMotifType()->GetNofPadsX()){
195 Warning("PadIndicesLocal","The position is outside the motif");
196 return AliMpIntPair::Invalid();
199 // then return the found (i,j)
200 return AliMpIntPair(i,j);
202 //______________________________________________________________________________
203 void AliMpMotifSpecial::SetPadDimensions(const AliMpIntPair& localIndices,
204 const TVector2& dimensions)
206 // set the dimensions of the pad located at <localIndices> to the given
209 if ( !GetMotifType()->HasPad(localIndices)){
210 Warning("SetPadDimensions","Pad indices outside limits");
214 // fill the dimensions map vector
215 fPadDimensionsVector[VectorIndex(localIndices)]=dimensions;
217 // fill the vector of different pad dimensions
218 // only if these dimensions are not yet present
219 Bool_t isPresent = false;
220 for (Int_t i=0; i<GetNofPadDimensions(); i++) {
221 if (AliMpConstants::IsEqual(fPadDimensionsVector2[i], dimensions))
225 if (!isPresent) fPadDimensionsVector2.push_back(dimensions);