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