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