]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
5f91c9e8 | 16 | // $Id$ |
2c605e66 | 17 | // $MpId: AliMpMotifType.cxx,v 1.9 2006/03/17 11:38:06 ivana Exp $ |
5f91c9e8 | 18 | // Category: motif |
19 | // | |
20 | // Class AliMpMotifType | |
21 | // -------------------- | |
22 | // Class that defines the motif properties. | |
dbe945cc | 23 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 24 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
25 | ||
5f91c9e8 | 26 | #include "AliMpMotifType.h" |
27 | #include "AliMpMotifTypePadIterator.h" | |
28 | #include "AliMpConnection.h" | |
29 | ||
63ed9c6b | 30 | #include <Riostream.h> |
31 | ||
32 | #include <stdlib.h> | |
5f91c9e8 | 33 | |
34 | const Int_t AliMpMotifType::fgkPadNumForA = 65; | |
5f91c9e8 | 35 | |
63ed9c6b | 36 | ClassImp(AliMpMotifType) |
37 | ||
5f91c9e8 | 38 | //______________________________________________________________________________ |
39 | AliMpMotifType::AliMpMotifType(const TString &id) | |
40 | : TObject(), | |
41 | fID(id), | |
42 | fNofPadsX(0), | |
43 | fNofPadsY(0), | |
44 | fVerboseLevel(0), | |
5006ec94 | 45 | #ifdef WITH_STL |
5f91c9e8 | 46 | fConnections() |
5006ec94 | 47 | #endif |
48 | #ifdef WITH_ROOT | |
49 | fConnections(true) | |
50 | #endif | |
5f91c9e8 | 51 | { |
dee1d5f1 | 52 | /// Standard constructor |
5f91c9e8 | 53 | } |
54 | ||
55 | //______________________________________________________________________________ | |
56 | AliMpMotifType::AliMpMotifType() | |
57 | : TObject(), | |
58 | fID(""), | |
59 | fNofPadsX(0), | |
60 | fNofPadsY(0), | |
61 | fVerboseLevel(0), | |
62 | fConnections() | |
63 | { | |
dee1d5f1 | 64 | /// Default constructor |
5f91c9e8 | 65 | } |
66 | ||
67 | //______________________________________________________________________________ | |
dee1d5f1 | 68 | AliMpMotifType::~AliMpMotifType() |
69 | { | |
70 | /// Destructor | |
5f91c9e8 | 71 | |
f79c58a5 | 72 | #ifdef WITH_STL |
2f2452f8 | 73 | for(ConnectionMapCIterator i = fConnections.begin(); |
5f91c9e8 | 74 | i!=fConnections.end();++i) |
75 | delete i->second; | |
76 | ||
77 | fConnections.erase(fConnections.begin(),fConnections.end()); | |
f79c58a5 | 78 | #endif |
5f91c9e8 | 79 | } |
80 | ||
81 | //______________________________________________________________________________ | |
82 | AliMpVPadIterator* AliMpMotifType::CreateIterator() const | |
83 | { | |
dee1d5f1 | 84 | /// Create new motif type iterator |
85 | ||
5f91c9e8 | 86 | return new AliMpMotifTypePadIterator(this); |
87 | } | |
88 | ||
89 | //______________________________________________________________________________ | |
90 | void AliMpMotifType::SetNofPads(Int_t nofPadsX, Int_t nofPadsY) | |
91 | { | |
dee1d5f1 | 92 | /// Change the number of pads in this motif |
5f91c9e8 | 93 | |
94 | fNofPadsX = nofPadsX; | |
95 | fNofPadsY = nofPadsY; | |
96 | } | |
97 | ||
98 | ||
99 | //______________________________________________________________________________ | |
100 | Int_t AliMpMotifType::PadNum(const TString &padName) const | |
101 | { | |
dee1d5f1 | 102 | /// Transform a pad name into the equivalent pad number |
103 | ||
5f91c9e8 | 104 | if ( (padName[0]>='A') && (padName[0]<='Z') ) |
105 | return fgkPadNumForA+padName[0]-'A'; | |
106 | else | |
107 | return atoi(padName.Data()); | |
108 | } | |
109 | ||
110 | //______________________________________________________________________________ | |
111 | TString AliMpMotifType::PadName(Int_t padNum) const | |
112 | { | |
dee1d5f1 | 113 | /// Transform a pad number into its equivalent pad name |
114 | ||
5f91c9e8 | 115 | if (padNum<fgkPadNumForA) |
116 | return Form("%d",padNum); | |
117 | else | |
118 | return char('A'+padNum-fgkPadNumForA); | |
119 | } | |
120 | ||
121 | //______________________________________________________________________________ | |
122 | void AliMpMotifType::AddConnection(const AliMpIntPair &localIndices, | |
123 | AliMpConnection* connection) | |
124 | { | |
dee1d5f1 | 125 | /// Add the connection to the map |
5f91c9e8 | 126 | |
f79c58a5 | 127 | #ifdef WITH_STL |
5f91c9e8 | 128 | fConnections[localIndices]=connection; |
f79c58a5 | 129 | #endif |
130 | ||
131 | #ifdef WITH_ROOT | |
5006ec94 | 132 | fConnections.Add(localIndices, connection); |
f79c58a5 | 133 | #endif |
134 | ||
5f91c9e8 | 135 | connection->SetOwner(this); |
136 | } | |
f79c58a5 | 137 | |
5f91c9e8 | 138 | //______________________________________________________________________________ |
139 | AliMpConnection *AliMpMotifType::FindConnectionByPadNum(Int_t padNum) const | |
140 | { | |
dee1d5f1 | 141 | /// Retrieve the AliMpConnection pointer from its pad num |
142 | ||
f79c58a5 | 143 | #ifdef WITH_STL |
2f2452f8 | 144 | for(ConnectionMapCIterator i = fConnections.begin(); |
5f91c9e8 | 145 | i!=fConnections.end();++i) |
146 | if (i->second->GetPadNum()==padNum) return i->second; | |
147 | return 0; | |
f79c58a5 | 148 | #endif |
149 | ||
150 | #ifdef WITH_ROOT | |
5006ec94 | 151 | TExMapIter i = fConnections.GetIterator(); |
f79c58a5 | 152 | Long_t key, value; |
153 | while ( i.Next(key, value) ) { | |
154 | AliMpConnection* connection = (AliMpConnection*)value; | |
155 | if (connection->GetPadNum()==padNum) return connection; | |
156 | } | |
157 | return 0; | |
158 | #endif | |
5f91c9e8 | 159 | } |
160 | ||
161 | //______________________________________________________________________________ | |
162 | AliMpConnection *AliMpMotifType::FindConnectionByLocalIndices( | |
2f2452f8 | 163 | const AliMpIntPair& localIndices) const |
5f91c9e8 | 164 | { |
dee1d5f1 | 165 | /// Retrieve the AliMpConnection pointer from its position (in pad unit) |
166 | ||
5f91c9e8 | 167 | if (!localIndices.IsValid()) return 0; |
168 | ||
f79c58a5 | 169 | #ifdef WITH_STL |
2f2452f8 | 170 | ConnectionMapCIterator i = fConnections.find(localIndices); |
5f91c9e8 | 171 | if (i != fConnections.end()) |
172 | return i->second; | |
173 | else return 0; | |
f79c58a5 | 174 | #endif |
175 | ||
176 | #ifdef WITH_ROOT | |
5006ec94 | 177 | return (AliMpConnection*)fConnections.GetValue(localIndices); |
f79c58a5 | 178 | #endif |
5f91c9e8 | 179 | } |
180 | ||
181 | //______________________________________________________________________________ | |
182 | AliMpConnection *AliMpMotifType::FindConnectionByGassiNum(Int_t gassiNum) const | |
183 | { | |
dee1d5f1 | 184 | /// Return the connection for the given gassiplex number |
185 | ||
f79c58a5 | 186 | #ifdef WITH_STL |
2f2452f8 | 187 | for(ConnectionMapCIterator i = fConnections.begin(); |
5f91c9e8 | 188 | i!=fConnections.end();++i) |
189 | if (i->second->GetGassiNum()==gassiNum) return i->second; | |
190 | return 0; | |
f79c58a5 | 191 | #endif |
192 | ||
193 | #ifdef WITH_ROOT | |
5006ec94 | 194 | TExMapIter i = fConnections.GetIterator(); |
f79c58a5 | 195 | Long_t key, value; |
196 | while ( i.Next(key, value) ) { | |
197 | AliMpConnection* connection = (AliMpConnection*)value; | |
198 | if (connection->GetGassiNum()==gassiNum) return connection; | |
199 | } | |
200 | return 0; | |
201 | #endif | |
5f91c9e8 | 202 | } |
f79c58a5 | 203 | |
5f91c9e8 | 204 | //______________________________________________________________________________ |
205 | AliMpConnection *AliMpMotifType::FindConnectionByKaptonNum(Int_t kaptonNum) const | |
206 | { | |
dee1d5f1 | 207 | /// Give the connection related to the given kapton number |
208 | ||
f79c58a5 | 209 | #ifdef WITH_STL |
2f2452f8 | 210 | for(ConnectionMapCIterator i = fConnections.begin(); |
5f91c9e8 | 211 | i!=fConnections.end();++i) |
212 | if (i->second->GetKaptonNum()==kaptonNum) return i->second; | |
213 | return 0; | |
f79c58a5 | 214 | #endif |
215 | ||
216 | #ifdef WITH_ROOT | |
5006ec94 | 217 | TExMapIter i = fConnections.GetIterator(); |
f79c58a5 | 218 | Long_t key, value; |
219 | while ( i.Next(key, value) ) { | |
220 | AliMpConnection* connection = (AliMpConnection*)value; | |
221 | if (connection->GetKaptonNum()==kaptonNum) return connection; | |
222 | } | |
223 | return 0; | |
224 | #endif | |
5f91c9e8 | 225 | } |
226 | //______________________________________________________________________________ | |
227 | AliMpConnection *AliMpMotifType::FindConnectionByBergNum(Int_t bergNum) const | |
228 | { | |
dee1d5f1 | 229 | /// Retrieve the connection from a Berg connector number |
230 | ||
f79c58a5 | 231 | #ifdef WITH_STL |
2f2452f8 | 232 | for(ConnectionMapCIterator i = fConnections.begin(); |
5f91c9e8 | 233 | i!=fConnections.end();++i) |
234 | if (i->second->GetBergNum()==bergNum) return i->second; | |
235 | return 0; | |
f79c58a5 | 236 | #endif |
237 | ||
238 | #ifdef WITH_ROOT | |
5006ec94 | 239 | TExMapIter i = fConnections.GetIterator(); |
f79c58a5 | 240 | Long_t key, value; |
241 | while ( i.Next(key, value) ) { | |
242 | AliMpConnection* connection = (AliMpConnection*)value; | |
243 | if (connection->GetBergNum()==bergNum) return connection; | |
244 | } | |
245 | return 0; | |
246 | #endif | |
5f91c9e8 | 247 | } |
248 | ||
249 | ||
250 | //______________________________________________________________________________ | |
251 | AliMpIntPair AliMpMotifType::FindLocalIndicesByConnection( | |
f79c58a5 | 252 | const AliMpConnection* connection) const |
5f91c9e8 | 253 | { |
dee1d5f1 | 254 | /// Retrieve the pad position from the connection pointer. |
255 | /// Not to be used widely, since it use a search in the | |
256 | /// connection list... | |
5f91c9e8 | 257 | |
f79c58a5 | 258 | #ifdef WITH_STL |
2f2452f8 | 259 | for(ConnectionMapCIterator i = fConnections.begin(); |
5f91c9e8 | 260 | i!=fConnections.end();++i) |
261 | if (i->second==connection) return i->first; | |
f79c58a5 | 262 | #endif |
263 | ||
264 | #ifdef WITH_ROOT | |
5006ec94 | 265 | TExMapIter i = fConnections.GetIterator(); |
f79c58a5 | 266 | Long_t key, value; |
267 | while ( i.Next(key, value) ) { | |
268 | AliMpConnection* aConnection = (AliMpConnection*)value; | |
5006ec94 | 269 | if (aConnection == connection) return AliMpExMap::GetPair(key); |
f79c58a5 | 270 | } |
271 | #endif | |
272 | ||
273 | return AliMpIntPair::Invalid(); | |
5f91c9e8 | 274 | } |
275 | ||
276 | //______________________________________________________________________________ | |
277 | AliMpIntPair AliMpMotifType::FindLocalIndicesByPadNum(Int_t padNum) const | |
278 | { | |
dee1d5f1 | 279 | /// Retrieve the AliMpConnection pointer from its pad num |
280 | ||
f79c58a5 | 281 | #ifdef WITH_STL |
2f2452f8 | 282 | for(ConnectionMapCIterator i = fConnections.begin(); |
5f91c9e8 | 283 | i!=fConnections.end();++i) |
284 | if (i->second->GetPadNum()==padNum) return i->first; | |
f79c58a5 | 285 | #endif |
5f91c9e8 | 286 | |
f79c58a5 | 287 | #ifdef WITH_ROOT |
5006ec94 | 288 | TExMapIter i = fConnections.GetIterator(); |
f79c58a5 | 289 | Long_t key, value; |
290 | while ( i.Next(key, value) ) { | |
291 | AliMpConnection* connection = (AliMpConnection*)value; | |
5006ec94 | 292 | if (connection->GetPadNum() == padNum) return AliMpExMap::GetPair(key); |
f79c58a5 | 293 | } |
294 | #endif | |
5f91c9e8 | 295 | return AliMpIntPair::Invalid(); |
296 | } | |
297 | ||
298 | //______________________________________________________________________________ | |
299 | AliMpIntPair AliMpMotifType::FindLocalIndicesByGassiNum(Int_t gassiNum) const | |
300 | { | |
dee1d5f1 | 301 | /// Return the connection for the given gassiplex number |
302 | ||
f79c58a5 | 303 | #ifdef WITH_STL |
2f2452f8 | 304 | for(ConnectionMapCIterator i = fConnections.begin(); |
5f91c9e8 | 305 | i!=fConnections.end();++i) |
306 | if (i->second->GetGassiNum()==gassiNum) return i->first; | |
f79c58a5 | 307 | #endif |
308 | ||
309 | #ifdef WITH_ROOT | |
5006ec94 | 310 | TExMapIter i = fConnections.GetIterator(); |
f79c58a5 | 311 | Long_t key, value; |
312 | while ( i.Next(key, value) ) { | |
313 | AliMpConnection* connection = (AliMpConnection*)value; | |
5006ec94 | 314 | if (connection->GetGassiNum()==gassiNum) return AliMpExMap::GetPair(key); |
f79c58a5 | 315 | } |
316 | #endif | |
5f91c9e8 | 317 | |
318 | return AliMpIntPair::Invalid(); | |
319 | } | |
320 | ||
321 | //______________________________________________________________________________ | |
322 | AliMpIntPair AliMpMotifType::FindLocalIndicesByKaptonNum(Int_t kaptonNum) const | |
323 | { | |
dee1d5f1 | 324 | /// Give the connection related to the given kapton number |
325 | ||
f79c58a5 | 326 | #ifdef WITH_STL |
2f2452f8 | 327 | for(ConnectionMapCIterator i = fConnections.begin(); |
5f91c9e8 | 328 | i!=fConnections.end();++i) |
329 | if (i->second->GetKaptonNum()==kaptonNum) return i->first; | |
f79c58a5 | 330 | #endif |
331 | ||
332 | #ifdef WITH_ROOT | |
5006ec94 | 333 | TExMapIter i = fConnections.GetIterator(); |
f79c58a5 | 334 | Long_t key, value; |
335 | while ( i.Next(key, value) ) { | |
336 | AliMpConnection* connection = (AliMpConnection*)value; | |
5006ec94 | 337 | if (connection->GetKaptonNum()==kaptonNum) return AliMpExMap::GetPair(key); |
f79c58a5 | 338 | } |
339 | #endif | |
5f91c9e8 | 340 | |
341 | return AliMpIntPair::Invalid(); | |
342 | } | |
343 | ||
344 | //______________________________________________________________________________ | |
345 | AliMpIntPair AliMpMotifType::FindLocalIndicesByBergNum(Int_t bergNum) const | |
346 | { | |
dee1d5f1 | 347 | /// Retrieve the connection from a Berg connector number |
348 | ||
f79c58a5 | 349 | #ifdef WITH_STL |
2f2452f8 | 350 | for(ConnectionMapCIterator i = fConnections.begin(); |
5f91c9e8 | 351 | i!=fConnections.end();++i) |
352 | if (i->second->GetBergNum()==bergNum) return i->first; | |
f79c58a5 | 353 | #endif |
354 | ||
355 | #ifdef WITH_ROOT | |
5006ec94 | 356 | TExMapIter i = fConnections.GetIterator(); |
f79c58a5 | 357 | Long_t key, value; |
358 | while ( i.Next(key, value) ) { | |
359 | AliMpConnection* connection = (AliMpConnection*)value; | |
5006ec94 | 360 | if (connection->GetBergNum()==bergNum) return AliMpExMap::GetPair(key); |
f79c58a5 | 361 | } |
362 | #endif | |
5f91c9e8 | 363 | |
364 | return AliMpIntPair::Invalid(); | |
365 | } | |
366 | ||
f79c58a5 | 367 | //______________________________________________________________________________ |
368 | Int_t AliMpMotifType::GetNofPads() const | |
369 | { | |
dee1d5f1 | 370 | /// Return the number of pads |
f79c58a5 | 371 | |
372 | #ifdef WITH_STL | |
373 | return fConnections.size(); | |
374 | #endif | |
375 | ||
376 | #ifdef WITH_ROOT | |
377 | return fConnections.GetSize(); | |
378 | #endif | |
379 | } | |
380 | ||
5f91c9e8 | 381 | //______________________________________________________________________________ |
382 | Bool_t AliMpMotifType::HasPad(const AliMpIntPair& localIndices) const | |
383 | { | |
dee1d5f1 | 384 | /// Return true if the pad indexed by <localIndices> has a connection |
385 | ||
5f91c9e8 | 386 | if (!localIndices.IsValid()) return false; |
387 | ||
f79c58a5 | 388 | #ifdef WITH_STL |
5f91c9e8 | 389 | return fConnections.find(localIndices)!=fConnections.end(); |
f79c58a5 | 390 | #endif |
5f91c9e8 | 391 | |
f79c58a5 | 392 | #ifdef WITH_ROOT |
5006ec94 | 393 | TObject* value = fConnections.GetValue(localIndices); |
f79c58a5 | 394 | return value!=0; |
395 | #endif | |
5f91c9e8 | 396 | } |
397 | ||
398 | //______________________________________________________________________________ | |
399 | void AliMpMotifType::Print(Option_t *option) const | |
400 | { | |
dee1d5f1 | 401 | /// Print the map of the motif. In each cell, the value |
402 | /// printed depends of option, as the following: | |
403 | /// - option="N" the "name" of the pad is written | |
404 | /// - option="K" the Kapton connect. number attached to the pad is written | |
405 | /// - option="B" the Berg connect. number attached to the pad is written | |
406 | /// - option="G" the Gassiplex channel number attached to the pad is written | |
407 | /// otherwise the number of the pad is written | |
408 | /// | |
409 | /// NOTE : this method is really not optimized, in case 'N' or '', | |
410 | /// but the Print() this should not be very important in a Print() method | |
5f91c9e8 | 411 | |
412 | switch (option[0]){ | |
413 | case 'N':cout<<"Name mapping"; | |
414 | break; | |
415 | case 'K':cout<<"Kapton mapping"; | |
416 | break; | |
417 | case 'B':cout<<"Berg mapping"; | |
418 | break; | |
419 | case 'G':cout<<"Gassiplex number mapping"; | |
420 | break; | |
421 | default:cout<<"Pad mapping"; | |
422 | } | |
423 | cout<<" in the motif "<<fID<<endl; | |
424 | cout<<"-----------------------------------"<<endl; | |
425 | ||
426 | for (Int_t j=fNofPadsY-1;j>=0;j--){ | |
427 | for (Int_t i=0;i<fNofPadsX;i++){ | |
428 | AliMpConnection *connexion = FindConnectionByLocalIndices(AliMpIntPair(i,j)); | |
429 | TString str; | |
430 | if (connexion){ | |
431 | switch (option[0]){ | |
432 | case 'N':str=PadName(connexion->GetPadNum()); | |
433 | break; | |
434 | case 'K':str=Form("%d",connexion->GetKaptonNum()); | |
435 | break; | |
436 | case 'B':str=Form("%d",connexion->GetBergNum()); | |
437 | break; | |
438 | case 'G':str=Form("%d",connexion->GetGassiNum()); | |
439 | break; | |
440 | default:str= Form("%d",connexion->GetPadNum()); | |
441 | } | |
442 | cout<<setw(2)<<str; | |
443 | } else cout<<setw(2)<<"--"; | |
444 | cout<<" "; | |
445 | } | |
446 | cout<<endl; | |
447 | } | |
448 | } |