4 // Class AliMpMotifSpecial
5 // -----------------------
6 // Class that defines a motif with its unique ID
9 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
11 #include "AliMpMotifSpecial.h"
12 #include "AliMpMotifType.h"
13 #include "AliMpIntPair.h"
14 #include "AliMpConstants.h"
16 ClassImp(AliMpMotifSpecial)
20 //______________________________________________________________________________
21 Int_t AliMpMotifSpecial::VectorIndex(const AliMpIntPair& indices) const
23 // transform indices to linear vector index
24 return indices.GetFirst()*GetMotifType()->GetNofPadsY() + indices.GetSecond();
30 //______________________________________________________________________________
31 AliMpMotifSpecial::AliMpMotifSpecial():
33 fPadDimensionsVector(),
34 fPadDimensionsVector2()
36 //default dummy constructor
40 //______________________________________________________________________________
41 AliMpMotifSpecial::AliMpMotifSpecial(const TString &id,
42 AliMpMotifType *motifType)
43 : AliMpVMotif(id,motifType),
44 fPadDimensionsVector(),
45 fPadDimensionsVector2()
48 // Normal constructor.
50 fPadDimensionsVector.resize(motifType->GetNofPadsX()*motifType->GetNofPadsY());
53 //______________________________________________________________________________
55 AliMpMotifSpecial::GetPadDimensions(const AliMpIntPair& localIndices) const
57 // returns the dimensions of pad located at the given indices
58 if (GetMotifType()->HasPad(localIndices))
59 return fPadDimensionsVector[VectorIndex(localIndices)];
61 Warning("GetPadDimensions","Indices outside limits");
62 return TVector2(0.,0.);
66 //______________________________________________________________________________
67 Int_t AliMpMotifSpecial::GetNofPadDimensions() const
69 // returns number of different pad dimensions in this motif
71 return fPadDimensionsVector2.size();
74 //______________________________________________________________________________
75 TVector2 AliMpMotifSpecial::GetPadDimensions(Int_t i) const
77 // returns the i-th different pad dimensions
79 if (i<0 || i>GetNofPadDimensions()) {
80 Fatal("GetPadDimensions(i)", "Index outside limits.");
84 return fPadDimensionsVector2[i];
87 //______________________________________________________________________________
88 TVector2 AliMpMotifSpecial::Dimensions() const
90 // gives the dimension of the motif
97 Double_t* tabSizeX = new Double_t[GetMotifType()->GetNofPadsY()];
98 for (j=0;j<GetMotifType()->GetNofPadsY();++j) tabSizeX[j]=0.0;
100 for (i=0;i<GetMotifType()->GetNofPadsX();++i) {
102 for (j=0;j<GetMotifType()->GetNofPadsY();++j) {
103 TVector2 dim = GetPadDimensions(AliMpIntPair(i,j));
105 tabSizeX[j]+=dim.X();
107 if (trSizeY>sizeY) sizeY=trSizeY;
109 for (j=0;j<GetMotifType()->GetNofPadsY();++j) {
110 if (tabSizeX[j]>sizeX) sizeX = tabSizeX[j];
115 return TVector2(sizeX,sizeY);
118 //______________________________________________________________________________
120 AliMpMotifSpecial::PadPositionLocal(const AliMpIntPair& localIndices) const
122 // gives the local position of the pad number (ix,iy)
123 // (0,0 is the center of the motif)
125 TVector2 dim = GetPadDimensions(localIndices);
127 Double_t posX= dim.X();
128 for (Int_t i=0;i<localIndices.GetFirst();++i) {
129 posX+=2.*GetPadDimensions(AliMpIntPair(i,localIndices.GetSecond())).X();
132 Double_t posY= dim.Y();
133 for (Int_t j=0;j<localIndices.GetSecond();++j) {
134 posY+=2.*GetPadDimensions(AliMpIntPair(localIndices.GetFirst(),j)).Y();
137 return TVector2(posX,posY)-Dimensions();
140 //______________________________________________________________________________
141 AliMpIntPair AliMpMotifSpecial::PadIndicesLocal(const TVector2& localPos) const
143 // return the pad indices from a given local position
144 // or AliMpIntPair::Invalid() if this position doesn't correspond to any valid
147 // *SOLEIL* : This code suppose that
148 // 1) all cells have the same size along the Y direction
149 // 2) the column 0 is entierly filled
152 // First : find the j index
153 TVector2 pos = localPos + Dimensions();
157 while (j<GetMotifType()->GetNofPadsY()) {
158 TVector2 padDim = GetPadDimensions(AliMpIntPair(0,j));
164 // Test if it's outside limits
165 if (j==GetMotifType()->GetNofPadsY()){
166 Warning("PadIndicesLocal","The position is outside the motif");
167 return AliMpIntPair::Invalid();
171 // now find the i index, in the j_th row
175 while (i<GetMotifType()->GetNofPadsX()) {
176 TVector2 padDim = GetPadDimensions(AliMpIntPair(i,j));
183 // Test if it's outside limits
185 if (i==GetMotifType()->GetNofPadsX()){
186 Warning("PadIndicesLocal","The position is outside the motif");
187 return AliMpIntPair::Invalid();
190 // then return the found (i,j)
191 return AliMpIntPair(i,j);
193 //______________________________________________________________________________
194 void AliMpMotifSpecial::SetPadDimensions(const AliMpIntPair& localIndices,
195 const TVector2& dimensions)
197 // set the dimensions of the pad located at <localIndices> to the given
200 if ( !GetMotifType()->HasPad(localIndices)){
201 Warning("SetPadDimensions","Pad indices outside limits");
205 // fill the dimensions map vector
206 fPadDimensionsVector[VectorIndex(localIndices)]=dimensions;
208 // fill the vector of different pad dimensions
209 // only if these dimensions are not yet present
210 Bool_t isPresent = false;
211 for (Int_t i=0; i<GetNofPadDimensions(); i++) {
212 if (AliMpConstants::IsEqual(fPadDimensionsVector2[i], dimensions))
216 if (!isPresent) fPadDimensionsVector2.push_back(dimensions);