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.7 2005/09/26 16:11:20 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
27 #include <Riostream.h>
29 #include "AliMpMotifType.h"
30 #include "AliMpMotifTypePadIterator.h"
31 #include "AliMpConnection.h"
33 ClassImp(AliMpMotifType)
35 const Int_t AliMpMotifType::fgkPadNumForA = 65;
37 //______________________________________________________________________________
38 AliMpMotifType::AliMpMotifType(const TString &id)
51 /// Standard constructor
54 //______________________________________________________________________________
55 AliMpMotifType::AliMpMotifType()
63 /// Default constructor
66 //______________________________________________________________________________
67 AliMpMotifType::~AliMpMotifType()
72 for(ConnectionMapCIterator i = fConnections.begin();
73 i!=fConnections.end();++i)
76 fConnections.erase(fConnections.begin(),fConnections.end());
80 //______________________________________________________________________________
81 AliMpVPadIterator* AliMpMotifType::CreateIterator() const
83 /// Create new motif type iterator
85 return new AliMpMotifTypePadIterator(this);
88 //______________________________________________________________________________
89 void AliMpMotifType::SetNofPads(Int_t nofPadsX, Int_t nofPadsY)
91 /// Change the number of pads in this motif
98 //______________________________________________________________________________
99 Int_t AliMpMotifType::PadNum(const TString &padName) const
101 /// Transform a pad name into the equivalent pad number
103 if ( (padName[0]>='A') && (padName[0]<='Z') )
104 return fgkPadNumForA+padName[0]-'A';
106 return atoi(padName.Data());
109 //______________________________________________________________________________
110 TString AliMpMotifType::PadName(Int_t padNum) const
112 /// Transform a pad number into its equivalent pad name
114 if (padNum<fgkPadNumForA)
115 return Form("%d",padNum);
117 return char('A'+padNum-fgkPadNumForA);
120 //______________________________________________________________________________
121 void AliMpMotifType::AddConnection(const AliMpIntPair &localIndices,
122 AliMpConnection* connection)
124 /// Add the connection to the map
127 fConnections[localIndices]=connection;
131 fConnections.Add(localIndices, connection);
134 connection->SetOwner(this);
137 //______________________________________________________________________________
138 AliMpConnection *AliMpMotifType::FindConnectionByPadNum(Int_t padNum) const
140 /// Retrieve the AliMpConnection pointer from its pad num
143 for(ConnectionMapCIterator i = fConnections.begin();
144 i!=fConnections.end();++i)
145 if (i->second->GetPadNum()==padNum) return i->second;
150 TExMapIter i = fConnections.GetIterator();
152 while ( i.Next(key, value) ) {
153 AliMpConnection* connection = (AliMpConnection*)value;
154 if (connection->GetPadNum()==padNum) return connection;
160 //______________________________________________________________________________
161 AliMpConnection *AliMpMotifType::FindConnectionByLocalIndices(
162 const AliMpIntPair& localIndices) const
164 /// Retrieve the AliMpConnection pointer from its position (in pad unit)
166 if (!localIndices.IsValid()) return 0;
169 ConnectionMapCIterator i = fConnections.find(localIndices);
170 if (i != fConnections.end())
176 return (AliMpConnection*)fConnections.GetValue(localIndices);
180 //______________________________________________________________________________
181 AliMpConnection *AliMpMotifType::FindConnectionByGassiNum(Int_t gassiNum) const
183 /// Return the connection for the given gassiplex number
186 for(ConnectionMapCIterator i = fConnections.begin();
187 i!=fConnections.end();++i)
188 if (i->second->GetGassiNum()==gassiNum) return i->second;
193 TExMapIter i = fConnections.GetIterator();
195 while ( i.Next(key, value) ) {
196 AliMpConnection* connection = (AliMpConnection*)value;
197 if (connection->GetGassiNum()==gassiNum) return connection;
203 //______________________________________________________________________________
204 AliMpConnection *AliMpMotifType::FindConnectionByKaptonNum(Int_t kaptonNum) const
206 /// Give the connection related to the given kapton number
209 for(ConnectionMapCIterator i = fConnections.begin();
210 i!=fConnections.end();++i)
211 if (i->second->GetKaptonNum()==kaptonNum) return i->second;
216 TExMapIter i = fConnections.GetIterator();
218 while ( i.Next(key, value) ) {
219 AliMpConnection* connection = (AliMpConnection*)value;
220 if (connection->GetKaptonNum()==kaptonNum) return connection;
225 //______________________________________________________________________________
226 AliMpConnection *AliMpMotifType::FindConnectionByBergNum(Int_t bergNum) const
228 /// Retrieve the connection from a Berg connector number
231 for(ConnectionMapCIterator i = fConnections.begin();
232 i!=fConnections.end();++i)
233 if (i->second->GetBergNum()==bergNum) return i->second;
238 TExMapIter i = fConnections.GetIterator();
240 while ( i.Next(key, value) ) {
241 AliMpConnection* connection = (AliMpConnection*)value;
242 if (connection->GetBergNum()==bergNum) return connection;
249 //______________________________________________________________________________
250 AliMpIntPair AliMpMotifType::FindLocalIndicesByConnection(
251 const AliMpConnection* connection) const
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...
258 for(ConnectionMapCIterator i = fConnections.begin();
259 i!=fConnections.end();++i)
260 if (i->second==connection) return i->first;
264 TExMapIter i = fConnections.GetIterator();
266 while ( i.Next(key, value) ) {
267 AliMpConnection* aConnection = (AliMpConnection*)value;
268 if (aConnection == connection) return AliMpExMap::GetPair(key);
272 return AliMpIntPair::Invalid();
275 //______________________________________________________________________________
276 AliMpIntPair AliMpMotifType::FindLocalIndicesByPadNum(Int_t padNum) const
278 /// Retrieve the AliMpConnection pointer from its pad num
281 for(ConnectionMapCIterator i = fConnections.begin();
282 i!=fConnections.end();++i)
283 if (i->second->GetPadNum()==padNum) return i->first;
287 TExMapIter i = fConnections.GetIterator();
289 while ( i.Next(key, value) ) {
290 AliMpConnection* connection = (AliMpConnection*)value;
291 if (connection->GetPadNum() == padNum) return AliMpExMap::GetPair(key);
294 return AliMpIntPair::Invalid();
297 //______________________________________________________________________________
298 AliMpIntPair AliMpMotifType::FindLocalIndicesByGassiNum(Int_t gassiNum) const
300 /// Return the connection for the given gassiplex number
303 for(ConnectionMapCIterator i = fConnections.begin();
304 i!=fConnections.end();++i)
305 if (i->second->GetGassiNum()==gassiNum) return i->first;
309 TExMapIter i = fConnections.GetIterator();
311 while ( i.Next(key, value) ) {
312 AliMpConnection* connection = (AliMpConnection*)value;
313 if (connection->GetGassiNum()==gassiNum) return AliMpExMap::GetPair(key);
317 return AliMpIntPair::Invalid();
320 //______________________________________________________________________________
321 AliMpIntPair AliMpMotifType::FindLocalIndicesByKaptonNum(Int_t kaptonNum) const
323 /// Give the connection related to the given kapton number
326 for(ConnectionMapCIterator i = fConnections.begin();
327 i!=fConnections.end();++i)
328 if (i->second->GetKaptonNum()==kaptonNum) return i->first;
332 TExMapIter i = fConnections.GetIterator();
334 while ( i.Next(key, value) ) {
335 AliMpConnection* connection = (AliMpConnection*)value;
336 if (connection->GetKaptonNum()==kaptonNum) return AliMpExMap::GetPair(key);
340 return AliMpIntPair::Invalid();
343 //______________________________________________________________________________
344 AliMpIntPair AliMpMotifType::FindLocalIndicesByBergNum(Int_t bergNum) const
346 /// Retrieve the connection from a Berg connector number
349 for(ConnectionMapCIterator i = fConnections.begin();
350 i!=fConnections.end();++i)
351 if (i->second->GetBergNum()==bergNum) return i->first;
355 TExMapIter i = fConnections.GetIterator();
357 while ( i.Next(key, value) ) {
358 AliMpConnection* connection = (AliMpConnection*)value;
359 if (connection->GetBergNum()==bergNum) return AliMpExMap::GetPair(key);
363 return AliMpIntPair::Invalid();
366 //______________________________________________________________________________
367 Int_t AliMpMotifType::GetNofPads() const
369 /// Return the number of pads
372 return fConnections.size();
376 return fConnections.GetSize();
380 //______________________________________________________________________________
381 Bool_t AliMpMotifType::HasPad(const AliMpIntPair& localIndices) const
383 /// Return true if the pad indexed by <localIndices> has a connection
385 //cout << "AliMpMotifType::HasPad: " << localIndices
386 // << "Connections size: " << fConnections.size() << endl;
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)<<"--";