]>
Commit | Line | Data |
---|---|---|
5f91c9e8 | 1 | // $Id$ |
2 | // Category: motif | |
3 | // | |
4 | // Class AliMpMotifType | |
5 | // -------------------- | |
6 | // Class that defines the motif properties. | |
7 | // | |
8 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay | |
9 | ||
10 | #include <Riostream.h> | |
11 | ||
12 | #include "AliMpMotifType.h" | |
13 | #include "AliMpMotifTypePadIterator.h" | |
14 | #include "AliMpConnection.h" | |
15 | ||
16 | ClassImp(AliMpMotifType) | |
17 | ||
18 | const Int_t AliMpMotifType::fgkPadNumForA = 65; | |
19 | ||
20 | ||
21 | ||
22 | //______________________________________________________________________________ | |
23 | AliMpMotifType::AliMpMotifType(const TString &id) | |
24 | : TObject(), | |
25 | fID(id), | |
26 | fNofPadsX(0), | |
27 | fNofPadsY(0), | |
28 | fVerboseLevel(0), | |
29 | fConnections() | |
30 | { | |
31 | // Constructor | |
32 | } | |
33 | ||
34 | //______________________________________________________________________________ | |
35 | AliMpMotifType::AliMpMotifType() | |
36 | : TObject(), | |
37 | fID(""), | |
38 | fNofPadsX(0), | |
39 | fNofPadsY(0), | |
40 | fVerboseLevel(0), | |
41 | fConnections() | |
42 | { | |
43 | // Default constructor (dummy) | |
44 | } | |
45 | ||
46 | //______________________________________________________________________________ | |
47 | AliMpMotifType::~AliMpMotifType() { | |
48 | // Destructor | |
49 | ||
50 | for(ConnectionMap_t::const_iterator i = fConnections.begin(); | |
51 | i!=fConnections.end();++i) | |
52 | delete i->second; | |
53 | ||
54 | fConnections.erase(fConnections.begin(),fConnections.end()); | |
55 | } | |
56 | ||
57 | //______________________________________________________________________________ | |
58 | AliMpVPadIterator* AliMpMotifType::CreateIterator() const | |
59 | { | |
60 | return new AliMpMotifTypePadIterator(this); | |
61 | } | |
62 | ||
63 | //______________________________________________________________________________ | |
64 | void AliMpMotifType::SetNofPads(Int_t nofPadsX, Int_t nofPadsY) | |
65 | { | |
66 | // Change the number of pads in this motif | |
67 | ||
68 | fNofPadsX = nofPadsX; | |
69 | fNofPadsY = nofPadsY; | |
70 | } | |
71 | ||
72 | ||
73 | //______________________________________________________________________________ | |
74 | Int_t AliMpMotifType::PadNum(const TString &padName) const | |
75 | { | |
76 | // Transform a pad name into the equivalent pad number | |
77 | if ( (padName[0]>='A') && (padName[0]<='Z') ) | |
78 | return fgkPadNumForA+padName[0]-'A'; | |
79 | else | |
80 | return atoi(padName.Data()); | |
81 | } | |
82 | ||
83 | //______________________________________________________________________________ | |
84 | TString AliMpMotifType::PadName(Int_t padNum) const | |
85 | { | |
86 | // Transform a pad number into its equivalent pad name | |
87 | if (padNum<fgkPadNumForA) | |
88 | return Form("%d",padNum); | |
89 | else | |
90 | return char('A'+padNum-fgkPadNumForA); | |
91 | } | |
92 | ||
93 | //______________________________________________________________________________ | |
94 | void AliMpMotifType::AddConnection(const AliMpIntPair &localIndices, | |
95 | AliMpConnection* connection) | |
96 | { | |
97 | // Add the connection to the map | |
98 | ||
99 | fConnections[localIndices]=connection; | |
100 | connection->SetOwner(this); | |
101 | } | |
102 | //______________________________________________________________________________ | |
103 | AliMpConnection *AliMpMotifType::FindConnectionByPadNum(Int_t padNum) const | |
104 | { | |
105 | // Retrive the AliMpConnection pointer from its pad num | |
106 | for(ConnectionMap_t::const_iterator i = fConnections.begin(); | |
107 | i!=fConnections.end();++i) | |
108 | if (i->second->GetPadNum()==padNum) return i->second; | |
109 | return 0; | |
110 | } | |
111 | ||
112 | //______________________________________________________________________________ | |
113 | AliMpConnection *AliMpMotifType::FindConnectionByLocalIndices( | |
114 | AliMpIntPair localIndices) const | |
115 | { | |
116 | if (!localIndices.IsValid()) return 0; | |
117 | ||
118 | // Retrive the AliMpConnection pointer from its position (in pad unit) | |
119 | ConnectionMap_t::const_iterator i = fConnections.find(localIndices); | |
120 | if (i != fConnections.end()) | |
121 | return i->second; | |
122 | else return 0; | |
123 | } | |
124 | ||
125 | //______________________________________________________________________________ | |
126 | AliMpConnection *AliMpMotifType::FindConnectionByGassiNum(Int_t gassiNum) const | |
127 | { | |
128 | // return the connection for the given gassiplex number | |
129 | for(ConnectionMap_t::const_iterator i = fConnections.begin(); | |
130 | i!=fConnections.end();++i) | |
131 | if (i->second->GetGassiNum()==gassiNum) return i->second; | |
132 | return 0; | |
133 | } | |
134 | //______________________________________________________________________________ | |
135 | AliMpConnection *AliMpMotifType::FindConnectionByKaptonNum(Int_t kaptonNum) const | |
136 | { | |
137 | // Gives the connection related to the given kapton number | |
138 | for(ConnectionMap_t::const_iterator i = fConnections.begin(); | |
139 | i!=fConnections.end();++i) | |
140 | if (i->second->GetKaptonNum()==kaptonNum) return i->second; | |
141 | return 0; | |
142 | } | |
143 | //______________________________________________________________________________ | |
144 | AliMpConnection *AliMpMotifType::FindConnectionByBergNum(Int_t bergNum) const | |
145 | { | |
146 | // Retrieve the connection from a Berg connector number | |
147 | for(ConnectionMap_t::const_iterator i = fConnections.begin(); | |
148 | i!=fConnections.end();++i) | |
149 | if (i->second->GetBergNum()==bergNum) return i->second; | |
150 | return 0; | |
151 | } | |
152 | ||
153 | ||
154 | //______________________________________________________________________________ | |
155 | AliMpIntPair AliMpMotifType::FindLocalIndicesByConnection( | |
156 | const AliMpConnection* connection) | |
157 | { | |
158 | // Retrieve the pad position from the connection pointer. | |
159 | // Not to be used widely, since it use a search in the | |
160 | // connection list... | |
161 | ||
162 | for(ConnectionMap_t::const_iterator i = fConnections.begin(); | |
163 | i!=fConnections.end();++i) | |
164 | if (i->second==connection) return i->first; | |
165 | ||
166 | return AliMpIntPair::Invalid(); | |
167 | } | |
168 | ||
169 | //______________________________________________________________________________ | |
170 | AliMpIntPair AliMpMotifType::FindLocalIndicesByPadNum(Int_t padNum) const | |
171 | { | |
172 | // Retrive the AliMpConnection pointer from its pad num | |
173 | for(ConnectionMap_t::const_iterator i = fConnections.begin(); | |
174 | i!=fConnections.end();++i) | |
175 | if (i->second->GetPadNum()==padNum) return i->first; | |
176 | ||
177 | return AliMpIntPair::Invalid(); | |
178 | } | |
179 | ||
180 | //______________________________________________________________________________ | |
181 | AliMpIntPair AliMpMotifType::FindLocalIndicesByGassiNum(Int_t gassiNum) const | |
182 | { | |
183 | // return the connection for the given gassiplex number | |
184 | for(ConnectionMap_t::const_iterator i = fConnections.begin(); | |
185 | i!=fConnections.end();++i) | |
186 | if (i->second->GetGassiNum()==gassiNum) return i->first; | |
187 | ||
188 | return AliMpIntPair::Invalid(); | |
189 | } | |
190 | ||
191 | //______________________________________________________________________________ | |
192 | AliMpIntPair AliMpMotifType::FindLocalIndicesByKaptonNum(Int_t kaptonNum) const | |
193 | { | |
194 | // Gives the connection related to the given kapton number | |
195 | for(ConnectionMap_t::const_iterator i = fConnections.begin(); | |
196 | i!=fConnections.end();++i) | |
197 | if (i->second->GetKaptonNum()==kaptonNum) return i->first; | |
198 | ||
199 | return AliMpIntPair::Invalid(); | |
200 | } | |
201 | ||
202 | //______________________________________________________________________________ | |
203 | AliMpIntPair AliMpMotifType::FindLocalIndicesByBergNum(Int_t bergNum) const | |
204 | { | |
205 | // Retrieve the connection from a Berg connector number | |
206 | for(ConnectionMap_t::const_iterator i = fConnections.begin(); | |
207 | i!=fConnections.end();++i) | |
208 | if (i->second->GetBergNum()==bergNum) return i->first; | |
209 | ||
210 | return AliMpIntPair::Invalid(); | |
211 | } | |
212 | ||
213 | //______________________________________________________________________________ | |
214 | Bool_t AliMpMotifType::HasPad(const AliMpIntPair& localIndices) const | |
215 | { | |
216 | if (!localIndices.IsValid()) return false; | |
217 | ||
218 | // return true if the pad indexed by <localIndices> has a connection | |
219 | return fConnections.find(localIndices)!=fConnections.end(); | |
220 | ||
221 | } | |
222 | ||
223 | //______________________________________________________________________________ | |
224 | void AliMpMotifType::Print(Option_t *option) const | |
225 | { | |
226 | // Print the map of the motif. In each cel, the value | |
227 | // printed depends of option, as the following: | |
228 | // option="N" the "name" of the pad is written | |
229 | // option="K" the Kapton connect. number attached to the pad is written | |
230 | // option="B" the Berg connect. number attached to the pad is written | |
231 | // option="G" the Gassiplex channel number attached to the pad is written | |
232 | // otherwise the number of the pad is written | |
233 | ||
234 | // NOTE : this method is really not optimized, in case 'N' or '', | |
235 | // but the Print() this should not be very important in a Print() method | |
236 | ||
237 | switch (option[0]){ | |
238 | case 'N':cout<<"Name mapping"; | |
239 | break; | |
240 | case 'K':cout<<"Kapton mapping"; | |
241 | break; | |
242 | case 'B':cout<<"Berg mapping"; | |
243 | break; | |
244 | case 'G':cout<<"Gassiplex number mapping"; | |
245 | break; | |
246 | default:cout<<"Pad mapping"; | |
247 | } | |
248 | cout<<" in the motif "<<fID<<endl; | |
249 | cout<<"-----------------------------------"<<endl; | |
250 | ||
251 | for (Int_t j=fNofPadsY-1;j>=0;j--){ | |
252 | for (Int_t i=0;i<fNofPadsX;i++){ | |
253 | AliMpConnection *connexion = FindConnectionByLocalIndices(AliMpIntPair(i,j)); | |
254 | TString str; | |
255 | if (connexion){ | |
256 | switch (option[0]){ | |
257 | case 'N':str=PadName(connexion->GetPadNum()); | |
258 | break; | |
259 | case 'K':str=Form("%d",connexion->GetKaptonNum()); | |
260 | break; | |
261 | case 'B':str=Form("%d",connexion->GetBergNum()); | |
262 | break; | |
263 | case 'G':str=Form("%d",connexion->GetGassiNum()); | |
264 | break; | |
265 | default:str= Form("%d",connexion->GetPadNum()); | |
266 | } | |
267 | cout<<setw(2)<<str; | |
268 | } else cout<<setw(2)<<"--"; | |
269 | cout<<" "; | |
270 | } | |
271 | cout<<endl; | |
272 | } | |
273 | } |