]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpMotifMap.cxx
Adding includes required by ROOT
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotifMap.cxx
CommitLineData
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$
13985652 17// $MpId: AliMpMotifMap.cxx,v 1.16 2006/05/24 13:58:41 ivana Exp $
5f91c9e8 18// Category: motif
490da820 19// -------------------
5f91c9e8 20// Class AliMpMotifMap
21// -------------------
22// Class describing the motif map container, where motifs are
23// mapped to their string IDs.
dbe945cc 24// Included in AliRoot: 2003/05/02
5f91c9e8 25// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26
5f91c9e8 27#include "AliMpMotifMap.h"
28#include "AliMpVMotif.h"
29#include "AliMpMotif.h"
30#include "AliMpMotifSpecial.h"
31#include "AliMpMotifType.h"
32#include "AliMpMotifPosition.h"
2c605e66 33
34#include "AliLog.h"
35
36#include <Riostream.h>
37#include <TVector2.h>
38#include <TArrayI.h>
5f91c9e8 39
13985652 40/// \cond CLASSIMP
5f91c9e8 41ClassImp(AliMpMotifMap)
13985652 42/// \endcond
5f91c9e8 43
5006ec94 44//_____________________________________________________________________________
45AliMpMotifMap::AliMpMotifMap(Bool_t /*standardConstructor*/)
46 : TObject()
f79c58a5 47#ifdef WITH_ROOT
5006ec94 48 ,fMotifs(true),
49 fMotifTypes(true),
50 fMotifPositions(true),
51 fMotifPositions2(true)
3283cfc7 52#endif
5006ec94 53{
54/// Standard constructor
55
56 //fMotifPositions2.SetOwner(false);
57}
f79c58a5 58
5f91c9e8 59//_____________________________________________________________________________
60AliMpMotifMap::AliMpMotifMap()
5006ec94 61 : TObject(),
62 fMotifs(),
63 fMotifTypes(),
64 fMotifPositions(),
65 fMotifPositions2()
5f91c9e8 66{
dee1d5f1 67/// Default constructor
5f91c9e8 68}
69
70//_____________________________________________________________________________
dee1d5f1 71AliMpMotifMap::~AliMpMotifMap()
72{
73/// Destructor
5f91c9e8 74
75 // Delete all registered motifs, motif types, motif positions
76
f79c58a5 77#ifdef WITH_STL
5f91c9e8 78 for (MotifMapIterator im=fMotifs.begin(); im != fMotifs.end(); im++) {
79 delete im->second;
80 }
f79c58a5 81
5f91c9e8 82 for (MotifTypeMapIterator it=fMotifTypes.begin();
83 it != fMotifTypes.end(); it++) {
84 delete it->second;
85 }
f79c58a5 86
5f91c9e8 87 for (MotifPositionMapIterator ip=fMotifPositions.begin();
88 ip != fMotifPositions.end(); ip++) {
89 delete ip->second;
90 }
f79c58a5 91#endif
5f91c9e8 92}
93
94//
95// private methods
96//
97
f79c58a5 98//_____________________________________________________________________________
99void AliMpMotifMap::PrintMotif(const AliMpVMotif* motif) const
100{
dee1d5f1 101/// Print the motif.
f79c58a5 102
103 cout << motif->GetID().Data() << " "
104 << motif->GetMotifType()->GetID() << " "
105 << motif->Dimensions().X() << " "
106 << motif->Dimensions().Y();
107}
108
109//_____________________________________________________________________________
110void AliMpMotifMap::PrintMotifType(const AliMpMotifType* motifType) const
111{
dee1d5f1 112/// Print the motif type.
f79c58a5 113
114 cout << motifType->GetID().Data() << " "
115 << motifType->GetNofPadsX() << " "
116 << motifType->GetNofPadsY() << " ";
117}
118
119//_____________________________________________________________________________
120void AliMpMotifMap::PrintMotifPosition(
121 const AliMpMotifPosition* motifPosition) const
122{
dee1d5f1 123/// Print the motif position.
f79c58a5 124
6d5f608a 125 cout << " ID " << motifPosition->GetID() << " "
126 << " Motif ID " << motifPosition->GetMotif()->GetID() << " "
127 << " Pos (X,Y) = (" << motifPosition->Position().X() << ","
128 << motifPosition->Position().Y() << ")";
f79c58a5 129}
130
131//_____________________________________________________________________________
132void AliMpMotifMap::PrintMotifPosition2(
133 const AliMpMotifPosition* motifPosition) const
134{
dee1d5f1 135/// Print the motif position.
f79c58a5 136
137 cout << setw(3) << motifPosition->GetLowIndicesLimit().GetFirst() << " "
138 << setw(3) << motifPosition->GetLowIndicesLimit().GetSecond() << " "
139 << setw(3) << motifPosition->GetHighIndicesLimit().GetFirst() << " "
140 << setw(3) << motifPosition->GetHighIndicesLimit().GetSecond() << " "
141 << motifPosition->GetID() << " ";
142}
143
5f91c9e8 144//_____________________________________________________________________________
145void AliMpMotifMap::PrintMotifs() const
146{
dee1d5f1 147/// Print all the motifs and their motif types
148/// for all motifs in the motifs map.
5f91c9e8 149
f79c58a5 150#ifdef WITH_STL
5f91c9e8 151 if (fMotifs.size()) {
152 cout << "Dump of Motif Map - " << fMotifs.size() << " entries:" << endl;
153 Int_t counter = 0;
154 for (MotifMapIterator i=fMotifs.begin(); i != fMotifs.end(); i++) {
155 const TString& id = (*i).first;
5f91c9e8 156 cout << "Map element "
157 << setw(3) << counter++ << " "
f79c58a5 158 << id.Data() << " " ;
159 PrintMotif((*i).second);
160 cout << endl;
5f91c9e8 161 }
162 cout << endl;
163 }
f79c58a5 164#endif
165
166#ifdef WITH_ROOT
167 if (fMotifs.GetSize()) {
168 cout << "Dump of Motif Map - " << fMotifs.GetSize() << " entries:" << endl;
169 Int_t counter = 0;
5006ec94 170 TExMapIter i = fMotifs.GetIterator();
f79c58a5 171 Long_t key, value;
172 while ( i.Next(key, value) ) {
5006ec94 173 TString id = fMotifs.AliMpExMap::GetString(key);
f79c58a5 174 AliMpVMotif* motif = (AliMpVMotif*)value;
175 cout << "Map element "
176 << setw(3) << counter++ << " "
177 << id.Data() << " " ;
178 PrintMotif(motif);
179 cout << endl;
180 }
181 cout << endl;
182 }
183#endif
5f91c9e8 184}
185
186//_____________________________________________________________________________
187void AliMpMotifMap::PrintMotifTypes() const
188{
dee1d5f1 189/// Print all the the motifs types and their motif dimensions
190/// for all motif types in the motif types map.
5f91c9e8 191
f79c58a5 192#ifdef WITH_STL
5f91c9e8 193 if (fMotifTypes.size()) {
194 cout << "Dump of Motif Type Map - " << fMotifTypes.size() << " entries:" << endl;
195 Int_t counter = 0;
196 for (MotifTypeMapIterator i=fMotifTypes.begin(); i != fMotifTypes.end(); i++) {
197 const TString& id = (*i).first;
5f91c9e8 198 cout << "Map element "
199 << setw(3) << counter++ << " "
f79c58a5 200 << id.Data() << " ";
201 PrintMotifType((*i).second);
202 cout << endl;
203 }
204 cout << endl;
205 }
206#endif
207
208#ifdef WITH_ROOT
209 if (fMotifTypes.GetSize()) {
210 cout << "Dump of Motif Type Map - " << fMotifTypes.GetSize() << " entries:" << endl;
211 Int_t counter = 0;
5006ec94 212 TExMapIter i = fMotifTypes.GetIterator();
f79c58a5 213 Long_t key, value;
214 while ( i.Next(key, value) ) {
5006ec94 215 TString id = AliMpExMap::GetString(key);
f79c58a5 216 AliMpMotifType* motifType = (AliMpMotifType*)value;
217 cout << "Map element "
218 << setw(3) << counter++ << " "
219 << id.Data() << " " ;
220 PrintMotifType(motifType);
221 cout << endl;
5f91c9e8 222 }
223 cout << endl;
224 }
f79c58a5 225#endif
5f91c9e8 226}
227
6d5f608a 228//_____________________________________________________________________________
229void
230AliMpMotifMap::GetAllMotifPositionsIDs(TArrayI& ecn) const
231{
490da820 232/// Fill the given array with all motif positions IDs (electronic card numbers)
233/// defined in the map
234
6d5f608a 235#ifdef WITH_STL
236 ecn.Set(fMotifPositions.size());
237 Int_t i(0);
238 MotifPositionMapIterator it;
239 for (it=fMotifPositions.begin(); it != fMotifPositions.end(); it++) {
240 AliMpMotifPosition* motifPosition = (*it).second;
241 ecn[i++] = motifPosition->GetID();
242 }
243#endif
244
245#ifdef WITH_ROOT
246 ecn.Set(fMotifPositions.GetSize());
247 TExMapIter it = fMotifPositions.GetIterator();
248 Long_t key, value;
249 Int_t i(0);
250
251 while ( it.Next(key, value) )
252 {
253 AliMpMotifPosition* motifPosition = reinterpret_cast<AliMpMotifPosition*>(value);
254 ecn[i] = motifPosition->GetID();
255 ++i;
256 }
257
258#endif
259}
260
3283cfc7 261//_____________________________________________________________________________
262Int_t AliMpMotifMap::CalculateNofPads() const
263{
abaf1dad 264/// Calculate total number of pads in the map
265
3283cfc7 266 Int_t nofPads = 0;
267
268#ifdef WITH_STL
269 MotifPositionMapIterator it;
270 for (it=fMotifPositions.begin(); it != fMotifPositions.end(); it++) {
271 AliMpMotifPosition* motifPosition = (*it).second;
272 nofPads += motifPosition->GetMotif()->GetMotifType()->GetNofPads();
273 }
274#endif
275
276#ifdef WITH_ROOT
277 TExMapIter it = fMotifPositions.GetIterator();
278 Long_t key, value;
279
280 while ( it.Next(key, value) ) {
281 AliMpMotifPosition* motifPosition = reinterpret_cast<AliMpMotifPosition*>(value);
282 nofPads += motifPosition->GetMotif()->GetMotifType()->GetNofPads();
283 }
284#endif
285
3283cfc7 286 return nofPads;
287}
288
5f91c9e8 289//_____________________________________________________________________________
290void AliMpMotifMap::PrintMotifPositions() const
291{
abaf1dad 292/// Print all motif positions.
5f91c9e8 293
f79c58a5 294#ifdef WITH_STL
5f91c9e8 295 if (fMotifPositions.size()) {
296 cout << "Dump of Motif Position Map - " << fMotifPositions.size() << " entries:" << endl;
297 Int_t counter = 0;
298 for (MotifPositionMapIterator i=fMotifPositions.begin();
299 i != fMotifPositions.end(); i++) {
300
5f91c9e8 301 cout << "Map element "
f79c58a5 302 << setw(3) << counter++ << " ";
303 PrintMotifPosition((*i).second);
304 cout << endl;
5f91c9e8 305 }
306 cout << endl;
307 }
f79c58a5 308#endif
309
310#ifdef WITH_ROOT
311 if (fMotifPositions.GetSize()) {
dee1d5f1 312 cout << "Dump of Motif Position Map - " << fMotifPositions.GetSize() << " entries:" << endl;
f79c58a5 313 Int_t counter = 0;
5006ec94 314 TExMapIter i = fMotifPositions.GetIterator();
f79c58a5 315 Long_t key, value;
316 while ( i.Next(key, value) ) {
317 AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
318 cout << "Map element "
319 << setw(3) << counter++ << " ";
320 PrintMotifPosition(motifPosition);
321 cout << endl;
322 }
323 cout << endl;
324 }
325#endif
5f91c9e8 326}
327
328//_____________________________________________________________________________
329void AliMpMotifMap::PrintMotifPositions2() const
330{
abaf1dad 331/// Print all motif positions from the second map
dee1d5f1 332/// (by global indices)
5f91c9e8 333
f79c58a5 334#ifdef WITH_STL
5f91c9e8 335 if (fMotifPositions2.size()) {
336 cout << "Dump of Motif Position Map 2 - " << fMotifPositions2.size() << " entries:" << endl;
337 Int_t counter = 0;
338 for (MotifPositionMap2Iterator i=fMotifPositions2.begin();
339 i != fMotifPositions2.end(); i++) {
340
5f91c9e8 341 cout << "Map element "
f79c58a5 342 << setw(3) << counter++ << " ";
343 PrintMotifPosition2((*i).second);
344 cout << endl;
345 }
346 cout << endl;
347 }
348#endif
349
350#ifdef WITH_ROOT
351 if (fMotifPositions2.GetSize()) {
352 cout << "Dump of Motif Position Map 2 - " << fMotifPositions2.GetSize() << " entries:" << endl;
353 Int_t counter = 0;
5006ec94 354 TExMapIter i = fMotifPositions2.GetIterator();
f79c58a5 355 Long_t key, value;
356 while ( i.Next(key, value) ) {
357 AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
358 cout << "Map element "
359 << setw(3) << counter++ << " ";
360 PrintMotifPosition2(motifPosition);
361 cout << endl;
5f91c9e8 362 }
363 cout << endl;
364 }
f79c58a5 365#endif
5f91c9e8 366}
367
368//
369// public methods
370//
371
372//_____________________________________________________________________________
373Bool_t AliMpMotifMap::AddMotif(AliMpVMotif* motif, Bool_t warn)
374{
dee1d5f1 375/// Add the specified motif
376/// if the motif with this ID is not yet present.
5f91c9e8 377
378 AliMpVMotif* found = FindMotif(motif->GetID());
379 if (found) {
380 if (warn && found == motif)
2c605e66 381 AliWarningStream() << "The motif is already in map." << endl;
382
383 if (warn && found != motif) {
384 AliWarningStream()
385 << "Another motif with the same ID is already in map." << endl;
386 }
5f91c9e8 387 return false;
388 }
389
f79c58a5 390#ifdef WITH_STL
5f91c9e8 391 fMotifs[motif->GetID()] = motif;
f79c58a5 392#endif
393
394#ifdef WITH_ROOT
5006ec94 395 fMotifs.Add(motif->GetID(), motif);
f79c58a5 396#endif
397
5f91c9e8 398 return true;
399}
400
401//_____________________________________________________________________________
402Bool_t AliMpMotifMap::AddMotifType(AliMpMotifType* motifType, Bool_t warn)
403{
dee1d5f1 404/// Add the specified motif type
405/// if the motif with this ID is not yet present.
5f91c9e8 406
407 AliMpMotifType* found = FindMotifType(motifType->GetID());
408 if (found) {
409 if (warn && found == motifType)
2c605e66 410 AliWarningStream() << "The motif type is already in map." << endl;
411
412 if (warn && found != motifType) {
413 AliWarningStream()
414 << "Another motif type with the same ID is already in map." << endl;
415 }
5f91c9e8 416 return false;
417 }
418
f79c58a5 419#ifdef WITH_STL
5f91c9e8 420 fMotifTypes[motifType->GetID()] = motifType;
f79c58a5 421#endif
422
423#ifdef WITH_ROOT
5006ec94 424 fMotifTypes.Add(motifType->GetID(), motifType);
f79c58a5 425#endif
426
5f91c9e8 427 return true;
428}
429
430//_____________________________________________________________________________
431Bool_t AliMpMotifMap::AddMotifPosition(AliMpMotifPosition* motifPosition, Bool_t warn)
432{
dee1d5f1 433/// Add the specified motif position
434/// if this position is not yet present.
5f91c9e8 435
436 AliMpMotifPosition* found = FindMotifPosition(motifPosition->GetID());
7a854749 437 if (found) {
438 if (warn && found == motifPosition) {
2c605e66 439 AliWarningStream()
440 << "ID: " << motifPosition->GetID()
7a854749 441 << " found: " << found
2c605e66 442 << " new: " << motifPosition << endl
443 << "This motif position is already in map." << endl;
7a854749 444 }
2c605e66 445
7a854749 446 if (warn && found != motifPosition) {
2c605e66 447 AliWarningStream()
448 << "ID: " << motifPosition->GetID()
7a854749 449 << " found: " << found
2c605e66 450 << " new: " << motifPosition << endl
451 << "Another motif position with the same ID is already in map."
452 << endl;
453 }
454
5f91c9e8 455 return false;
456 }
457
f79c58a5 458#ifdef WITH_STL
5f91c9e8 459 fMotifPositions[motifPosition->GetID()] = motifPosition;
f79c58a5 460#endif
461
462#ifdef WITH_ROOT
5006ec94 463 fMotifPositions.Add(motifPosition->GetID(), motifPosition);
f79c58a5 464#endif
465
5f91c9e8 466 return true;
467}
468
469//_____________________________________________________________________________
470void AliMpMotifMap::FillMotifPositionMap2()
471{
dee1d5f1 472/// Fill the second map (by global indices) of motif positions.
5f91c9e8 473
f79c58a5 474#ifdef WITH_STL
5f91c9e8 475 if (fMotifPositions2.size() > 0 ) {
2c605e66 476 AliWarningStream() << "Map has been already filled." << endl;
5f91c9e8 477 return;
478 }
479
480 for (MotifPositionMapIterator ip=fMotifPositions.begin();
481 ip != fMotifPositions.end(); ip++) {
482
483 fMotifPositions2[(*ip).second->GetLowIndicesLimit()] = (*ip).second;
484 }
f79c58a5 485#endif
486
487#ifdef WITH_ROOT
488 if (fMotifPositions2.GetSize() > 0 ) {
2c605e66 489 AliWarningStream() <<"Map has been already filled." << endl;
f79c58a5 490 return;
491 }
492
5006ec94 493 TExMapIter i = fMotifPositions.GetIterator();
f79c58a5 494 Long_t key, value;
495 while ( i.Next(key, value) ) {
496 AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
5006ec94 497 fMotifPositions2.Add(motifPosition->GetLowIndicesLimit(), motifPosition);
f79c58a5 498 }
499#endif
5f91c9e8 500
501}
502
503//_____________________________________________________________________________
6d5f608a 504void AliMpMotifMap::Print(const char* opt) const
5f91c9e8 505{
dee1d5f1 506/// Print the motifs and motif types maps.
5f91c9e8 507
6d5f608a 508 TString sopt(opt);
509
510 sopt.ToUpper();
511
512 if ( sopt.Contains("MOTIFS") || sopt == "ALL" ) PrintMotifs();
513 if ( sopt.Contains("MOTIFTYPES") || sopt == "ALL" ) PrintMotifTypes();
514 if ( sopt.Contains("MOTIFPOSITIONS") || sopt == "ALL" ) PrintMotifPositions();
515 if ( sopt.Contains("MOTIFPOSITIONS2") || sopt == "ALL" ) PrintMotifPositions2();
5f91c9e8 516}
517
518//_____________________________________________________________________________
519void AliMpMotifMap::PrintGlobalIndices(const char* fileName) const
520{
abaf1dad 521/// Print all motif positions and their global indices.
5f91c9e8 522
523 ofstream out(fileName, ios::out);
524
f79c58a5 525#ifdef WITH_STL
5f91c9e8 526 if (fMotifPositions.size()) {
527 for (MotifPositionMapIterator i=fMotifPositions.begin();
528 i != fMotifPositions.end(); i++) {
529
530 AliMpMotifPosition* motifPosition = (*i).second;
531 out << setw(5) << motifPosition->GetID() << " "
532 << setw(3) << motifPosition->GetLowIndicesLimit().GetFirst() << " "
533 << setw(3) << motifPosition->GetLowIndicesLimit().GetSecond()
534 << endl;
535 }
536 out << endl;
537 }
f79c58a5 538#endif
539
540#ifdef WITH_ROOT
541 if (fMotifPositions.GetSize()) {
5006ec94 542 TExMapIter i = fMotifPositions.GetIterator();
f79c58a5 543 Long_t key, value;
544 while ( i.Next(key, value) ) {
545 AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
546 out << setw(5) << motifPosition->GetID() << " "
547 << setw(3) << motifPosition->GetLowIndicesLimit().GetFirst() << " "
548 << setw(3) << motifPosition->GetLowIndicesLimit().GetSecond()
549 << endl;
550 }
551 out << endl;
552 }
553#endif
5f91c9e8 554}
555
556//_____________________________________________________________________________
557void AliMpMotifMap::UpdateGlobalIndices(const char* fileName)
558{
abaf1dad 559/// Update the motif positions global indices from the file.
5f91c9e8 560
561 ifstream in(fileName, ios::in);
562
563 Int_t motifPositionId, offx, offy;
564
565 do {
566 in >> motifPositionId >> offx >> offy;
567
568 if (in.eof()) {
569 FillMotifPositionMap2();
570 return;
571 }
572
573 AliMpMotifPosition* motifPosition = FindMotifPosition(motifPositionId);
574
575 if (motifPosition) {
2c605e66 576 AliDebugStream(1)
577 << "Processing "
5f91c9e8 578 << motifPosition->GetID() << " " << offx << " " << offy << endl;
579
580 motifPosition->SetLowIndicesLimit(AliMpIntPair(offx, offy));
581
582 Int_t offx2
583 = offx + motifPosition->GetMotif()->GetMotifType()->GetNofPadsX() - 1;
584
585 Int_t offy2
586 = offy + motifPosition->GetMotif()->GetMotifType()->GetNofPadsY() - 1;
587
588 motifPosition->SetHighIndicesLimit(AliMpIntPair(offx2, offy2));
589 }
590 else {
2c605e66 591 AliWarningStream()
592 << "Motif position " << motifPositionId << " not found" << endl;
5f91c9e8 593 }
594 }
595 while (!in.eof());
596}
597
598
599//_____________________________________________________________________________
600AliMpVMotif* AliMpMotifMap::FindMotif(const TString& motifID) const
601{
abaf1dad 602/// Find the motif with the specified ID.
5f91c9e8 603
f79c58a5 604#ifdef WITH_STL
5f91c9e8 605 MotifMapIterator i = fMotifs.find(motifID);
5f91c9e8 606 if (i != fMotifs.end())
607 return (*i).second;
608 else
609 return 0;
f79c58a5 610#endif
611
612#ifdef WITH_ROOT
5006ec94 613 return (AliMpVMotif*)fMotifs.GetValue(motifID);
f79c58a5 614#endif
5f91c9e8 615}
616
617//_____________________________________________________________________________
618AliMpVMotif* AliMpMotifMap::FindMotif(const TString& motifID,
7a854749 619 const TString& motifTypeID,
620 const TVector2& padDimensions ) const
5f91c9e8 621{
abaf1dad 622/// Find the motif with the specified ID and returns it
dee1d5f1 623/// only if its motif type and motif dimensions agree
624/// with the given motifTypeID and motifDimensions.
625/// Disagreement causes fatal error.
626
5f91c9e8 627 AliMpVMotif* motif = FindMotif(motifID);
628
629 if (motif && motif->GetMotifType()->GetID() != motifTypeID) {
630 Fatal("FindMotif",
631 "Motif has been already defined with a different type.");
632 return 0;
633 }
634
635 // check pad dimension in case of a normal motif
636 if (motif &&
637 dynamic_cast<AliMpMotif*>(motif) &&
638 ( motif->GetPadDimensions(0).X() != padDimensions.X() ||
639 motif->GetPadDimensions(0).Y() != padDimensions.Y())) {
640
641 Fatal("FindMotifType",
642 "Motif type has been already defined with different dimensions.");
643 return 0;
644
645 }
646
647 // check case of a special motif
648 if (motif &&
649 (padDimensions.X() == 0. && padDimensions.Y() == 0.) &&
650 !dynamic_cast<AliMpMotifSpecial*>(motif)) {
651
652 Fatal("FindMotifType",
653 "Motif type has been already defined with different dimensions.");
654 return 0;
655
656 }
657
658 return motif;
659}
660
661//_____________________________________________________________________________
662AliMpMotifType* AliMpMotifMap::FindMotifType(const TString& motifTypeID) const
663{
dee1d5f1 664/// Find the motif type with the specified motif type ID.
5f91c9e8 665
f79c58a5 666#ifdef WITH_STL
5f91c9e8 667 MotifTypeMapIterator i = fMotifTypes.find(motifTypeID);
5f91c9e8 668 if (i != fMotifTypes.end())
669 return (*i).second;
670 else
671 return 0;
f79c58a5 672#endif
673
674#ifdef WITH_ROOT
5006ec94 675 return (AliMpMotifType*)fMotifTypes.GetValue(motifTypeID);
f79c58a5 676#endif
5f91c9e8 677}
678
679//_____________________________________________________________________________
7a854749 680AliMpMotifPosition*
681AliMpMotifMap::FindMotifPosition(Int_t motifPositionID) const
5f91c9e8 682{
dee1d5f1 683/// Find the motif position with the specified motif position ID.
5f91c9e8 684
f79c58a5 685#ifdef WITH_STL
5f91c9e8 686 MotifPositionMapIterator i = fMotifPositions.find(motifPositionID);
5f91c9e8 687 if (i != fMotifPositions.end())
688 return (*i).second;
689 else
690 return 0;
f79c58a5 691#endif
692
693#ifdef WITH_ROOT
5006ec94 694 return (AliMpMotifPosition*)fMotifPositions.GetValue(motifPositionID);
f79c58a5 695#endif
5f91c9e8 696}
697
f79c58a5 698/*
5f91c9e8 699//_____________________________________________________________________________
7a854749 700AliMpMotifPosition*
701AliMpMotifMap::FindMotifPosition(const AliMpIntPair& indices) const
5f91c9e8 702{
dee1d5f1 703/// Find the last motif position which has the global indices (low limit)
704/// less then the indices specified.
5f91c9e8 705
f79c58a5 706#ifdef WITH_STL
5f91c9e8 707 MotifPositionMap2Iterator found
708 = fMotifPositions2.lower_bound(indices);
709
710 if (found == fMotifPositions2.end()) found--;
711
712 MotifPositionMap2Iterator i=found;
713 do {
714 AliMpIntPair low = (*i).second->GetLowIndicesLimit();
715 AliMpIntPair up = (*i).second->GetHighIndicesLimit();
716
717 if ( indices.GetFirst() >= low.GetFirst() &&
718 indices.GetSecond() >= low.GetSecond() &&
719 indices.GetFirst() <= up.GetFirst() &&
720 indices.GetSecond() <= up.GetSecond())
721
722 return (*i).second;
723 }
724 while ( i-- != fMotifPositions2.begin());
725
726 return 0;
f79c58a5 727#endif
728
729#ifdef WITH_ROOT
730 // HOW TO DO THIS WITH ROOT ????
731 // Fortunately it seems not to be used anywhere
732 Fatal("FindMotifPosition", "Difficult in Root to do this.");
733 return 0;
734#endif
5f91c9e8 735}
f79c58a5 736*/