1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpMotifType.cxx,v 1.10 2006/05/24 13:58:41 ivana Exp $
20 // Class AliMpMotifType
21 // --------------------
22 // Class that defines the motif properties.
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 #include "AliMpMotifType.h"
27 #include "AliMpMotifTypePadIterator.h"
28 #include "AliMpConnection.h"
30 #include <Riostream.h>
35 ClassImp(AliMpMotifType)
38 const Int_t AliMpMotifType::fgkPadNumForA = 65;
40 //______________________________________________________________________________
41 AliMpMotifType::AliMpMotifType(const TString &id)
54 /// Standard constructor
57 //______________________________________________________________________________
58 AliMpMotifType::AliMpMotifType()
66 /// Default constructor
69 //______________________________________________________________________________
70 AliMpMotifType::~AliMpMotifType()
75 for(ConnectionMapCIterator i = fConnections.begin();
76 i!=fConnections.end();++i)
79 fConnections.erase(fConnections.begin(),fConnections.end());
83 //______________________________________________________________________________
84 AliMpVPadIterator* AliMpMotifType::CreateIterator() const
86 /// Create new motif type iterator
88 return new AliMpMotifTypePadIterator(this);
91 //______________________________________________________________________________
92 void AliMpMotifType::SetNofPads(Int_t nofPadsX, Int_t nofPadsY)
94 /// Change the number of pads in this motif
101 //______________________________________________________________________________
102 Int_t AliMpMotifType::PadNum(const TString &padName) const
104 /// Transform a pad name into the equivalent pad number
106 if ( (padName[0]>='A') && (padName[0]<='Z') )
107 return fgkPadNumForA+padName[0]-'A';
109 return atoi(padName.Data());
112 //______________________________________________________________________________
113 TString AliMpMotifType::PadName(Int_t padNum) const
115 /// Transform a pad number into its equivalent pad name
117 if (padNum<fgkPadNumForA)
118 return Form("%d",padNum);
120 return char('A'+padNum-fgkPadNumForA);
123 //______________________________________________________________________________
124 void AliMpMotifType::AddConnection(const AliMpIntPair &localIndices,
125 AliMpConnection* connection)
127 /// Add the connection to the map
130 fConnections[localIndices]=connection;
134 fConnections.Add(localIndices, connection);
137 connection->SetOwner(this);
140 //______________________________________________________________________________
141 AliMpConnection *AliMpMotifType::FindConnectionByPadNum(Int_t padNum) const
143 /// Retrieve the AliMpConnection pointer from its pad num
146 for(ConnectionMapCIterator i = fConnections.begin();
147 i!=fConnections.end();++i)
148 if (i->second->GetPadNum()==padNum) return i->second;
153 TExMapIter i = fConnections.GetIterator();
155 while ( i.Next(key, value) ) {
156 AliMpConnection* connection = (AliMpConnection*)value;
157 if (connection->GetPadNum()==padNum) return connection;
163 //______________________________________________________________________________
164 AliMpConnection *AliMpMotifType::FindConnectionByLocalIndices(
165 const AliMpIntPair& localIndices) const
167 /// Retrieve the AliMpConnection pointer from its position (in pad unit)
169 if (!localIndices.IsValid()) return 0;
172 ConnectionMapCIterator i = fConnections.find(localIndices);
173 if (i != fConnections.end())
179 return (AliMpConnection*)fConnections.GetValue(localIndices);
183 //______________________________________________________________________________
184 AliMpConnection *AliMpMotifType::FindConnectionByGassiNum(Int_t gassiNum) const
186 /// Return the connection for the given gassiplex number
189 for(ConnectionMapCIterator i = fConnections.begin();
190 i!=fConnections.end();++i)
191 if (i->second->GetGassiNum()==gassiNum) return i->second;
196 TExMapIter i = fConnections.GetIterator();
198 while ( i.Next(key, value) ) {
199 AliMpConnection* connection = (AliMpConnection*)value;
200 if (connection->GetGassiNum()==gassiNum) return connection;
206 //______________________________________________________________________________
207 AliMpConnection *AliMpMotifType::FindConnectionByKaptonNum(Int_t kaptonNum) const
209 /// Give the connection related to the given kapton number
212 for(ConnectionMapCIterator i = fConnections.begin();
213 i!=fConnections.end();++i)
214 if (i->second->GetKaptonNum()==kaptonNum) return i->second;
219 TExMapIter i = fConnections.GetIterator();
221 while ( i.Next(key, value) ) {
222 AliMpConnection* connection = (AliMpConnection*)value;
223 if (connection->GetKaptonNum()==kaptonNum) return connection;
228 //______________________________________________________________________________
229 AliMpConnection *AliMpMotifType::FindConnectionByBergNum(Int_t bergNum) const
231 /// Retrieve the connection from a Berg connector number
234 for(ConnectionMapCIterator i = fConnections.begin();
235 i!=fConnections.end();++i)
236 if (i->second->GetBergNum()==bergNum) return i->second;
241 TExMapIter i = fConnections.GetIterator();
243 while ( i.Next(key, value) ) {
244 AliMpConnection* connection = (AliMpConnection*)value;
245 if (connection->GetBergNum()==bergNum) return connection;
252 //______________________________________________________________________________
253 AliMpIntPair AliMpMotifType::FindLocalIndicesByConnection(
254 const AliMpConnection* connection) const
256 /// Retrieve the pad position from the connection pointer.
257 /// Not to be used widely, since it use a search in the
258 /// connection list...
261 for(ConnectionMapCIterator i = fConnections.begin();
262 i!=fConnections.end();++i)
263 if (i->second==connection) return i->first;
267 TExMapIter i = fConnections.GetIterator();
269 while ( i.Next(key, value) ) {
270 AliMpConnection* aConnection = (AliMpConnection*)value;
271 if (aConnection == connection) return AliMpExMap::GetPair(key);
275 return AliMpIntPair::Invalid();
278 //______________________________________________________________________________
279 AliMpIntPair AliMpMotifType::FindLocalIndicesByPadNum(Int_t padNum) const
281 /// Retrieve the AliMpConnection pointer from its pad num
284 for(ConnectionMapCIterator i = fConnections.begin();
285 i!=fConnections.end();++i)
286 if (i->second->GetPadNum()==padNum) return i->first;
290 TExMapIter i = fConnections.GetIterator();
292 while ( i.Next(key, value) ) {
293 AliMpConnection* connection = (AliMpConnection*)value;
294 if (connection->GetPadNum() == padNum) return AliMpExMap::GetPair(key);
297 return AliMpIntPair::Invalid();
300 //______________________________________________________________________________
301 AliMpIntPair AliMpMotifType::FindLocalIndicesByGassiNum(Int_t gassiNum) const
303 /// Return the connection for the given gassiplex number
306 for(ConnectionMapCIterator i = fConnections.begin();
307 i!=fConnections.end();++i)
308 if (i->second->GetGassiNum()==gassiNum) return i->first;
312 TExMapIter i = fConnections.GetIterator();
314 while ( i.Next(key, value) ) {
315 AliMpConnection* connection = (AliMpConnection*)value;
316 if (connection->GetGassiNum()==gassiNum) return AliMpExMap::GetPair(key);
320 return AliMpIntPair::Invalid();
323 //______________________________________________________________________________
324 AliMpIntPair AliMpMotifType::FindLocalIndicesByKaptonNum(Int_t kaptonNum) const
326 /// Give the connection related to the given kapton number
329 for(ConnectionMapCIterator i = fConnections.begin();
330 i!=fConnections.end();++i)
331 if (i->second->GetKaptonNum()==kaptonNum) return i->first;
335 TExMapIter i = fConnections.GetIterator();
337 while ( i.Next(key, value) ) {
338 AliMpConnection* connection = (AliMpConnection*)value;
339 if (connection->GetKaptonNum()==kaptonNum) return AliMpExMap::GetPair(key);
343 return AliMpIntPair::Invalid();
346 //______________________________________________________________________________
347 AliMpIntPair AliMpMotifType::FindLocalIndicesByBergNum(Int_t bergNum) const
349 /// Retrieve the connection from a Berg connector number
352 for(ConnectionMapCIterator i = fConnections.begin();
353 i!=fConnections.end();++i)
354 if (i->second->GetBergNum()==bergNum) return i->first;
358 TExMapIter i = fConnections.GetIterator();
360 while ( i.Next(key, value) ) {
361 AliMpConnection* connection = (AliMpConnection*)value;
362 if (connection->GetBergNum()==bergNum) return AliMpExMap::GetPair(key);
366 return AliMpIntPair::Invalid();
369 //______________________________________________________________________________
370 Int_t AliMpMotifType::GetNofPads() const
372 /// Return the number of pads
375 return fConnections.size();
379 return fConnections.GetSize();
383 //______________________________________________________________________________
384 Bool_t AliMpMotifType::HasPad(const AliMpIntPair& localIndices) const
386 /// Return true if the pad indexed by \a localIndices has a connection
388 if (!localIndices.IsValid()) return false;
391 return fConnections.find(localIndices)!=fConnections.end();
395 TObject* value = fConnections.GetValue(localIndices);
400 //______________________________________________________________________________
401 void AliMpMotifType::Print(Option_t *option) const
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
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
415 case 'N':cout<<"Name mapping";
417 case 'K':cout<<"Kapton mapping";
419 case 'B':cout<<"Berg mapping";
421 case 'G':cout<<"Gassiplex number mapping";
423 default:cout<<"Pad mapping";
425 cout<<" in the motif "<<fID<<endl;
426 cout<<"-----------------------------------"<<endl;
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));
434 case 'N':str=PadName(connexion->GetPadNum());
436 case 'K':str=Form("%d",connexion->GetKaptonNum());
438 case 'B':str=Form("%d",connexion->GetBergNum());
440 case 'G':str=Form("%d",connexion->GetGassiNum());
442 default:str= Form("%d",connexion->GetPadNum());
445 } else cout<<setw(2)<<"--";