]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpMotifMap.cxx
Modifications to the trigger classes to have I/O. I
[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
102 cout << motif->GetID().Data() << " "
103 << motif->GetMotifType()->GetID() << " "
104 << motif->Dimensions().X() << " "
105 << motif->Dimensions().Y();
106}
107
108//_____________________________________________________________________________
109void AliMpMotifMap::PrintMotifType(const AliMpMotifType* motifType) const
110{
dee1d5f1 111/// Print the motif type.
f79c58a5 112
113 cout << motifType->GetID().Data() << " "
114 << motifType->GetNofPadsX() << " "
115 << motifType->GetNofPadsY() << " ";
116}
117
118//_____________________________________________________________________________
119void AliMpMotifMap::PrintMotifPosition(
120 const AliMpMotifPosition* motifPosition) const
121{
dee1d5f1 122/// Print the motif position.
f79c58a5 123
6d5f608a 124 cout << " ID " << motifPosition->GetID() << " "
125 << " Motif ID " << motifPosition->GetMotif()->GetID() << " "
126 << " Pos (X,Y) = (" << motifPosition->Position().X() << ","
127 << motifPosition->Position().Y() << ")";
f79c58a5 128}
129
130//_____________________________________________________________________________
131void AliMpMotifMap::PrintMotifPosition2(
132 const AliMpMotifPosition* motifPosition) const
133{
dee1d5f1 134/// Print the motif position.
f79c58a5 135
136 cout << setw(3) << motifPosition->GetLowIndicesLimit().GetFirst() << " "
137 << setw(3) << motifPosition->GetLowIndicesLimit().GetSecond() << " "
138 << setw(3) << motifPosition->GetHighIndicesLimit().GetFirst() << " "
139 << setw(3) << motifPosition->GetHighIndicesLimit().GetSecond() << " "
140 << motifPosition->GetID() << " ";
141}
142
5f91c9e8 143//_____________________________________________________________________________
144void AliMpMotifMap::PrintMotifs() const
145{
dee1d5f1 146/// Print all the motifs and their motif types
147/// for all motifs in the motifs map.
5f91c9e8 148
f79c58a5 149#ifdef WITH_STL
5f91c9e8 150 if (fMotifs.size()) {
151 cout << "Dump of Motif Map - " << fMotifs.size() << " entries:" << endl;
152 Int_t counter = 0;
153 for (MotifMapIterator i=fMotifs.begin(); i != fMotifs.end(); i++) {
154 const TString& id = (*i).first;
5f91c9e8 155 cout << "Map element "
156 << setw(3) << counter++ << " "
f79c58a5 157 << id.Data() << " " ;
158 PrintMotif((*i).second);
159 cout << endl;
5f91c9e8 160 }
161 cout << endl;
162 }
f79c58a5 163#endif
164
165#ifdef WITH_ROOT
166 if (fMotifs.GetSize()) {
167 cout << "Dump of Motif Map - " << fMotifs.GetSize() << " entries:" << endl;
168 Int_t counter = 0;
5006ec94 169 TExMapIter i = fMotifs.GetIterator();
f79c58a5 170 Long_t key, value;
171 while ( i.Next(key, value) ) {
5006ec94 172 TString id = fMotifs.AliMpExMap::GetString(key);
f79c58a5 173 AliMpVMotif* motif = (AliMpVMotif*)value;
174 cout << "Map element "
175 << setw(3) << counter++ << " "
176 << id.Data() << " " ;
177 PrintMotif(motif);
178 cout << endl;
179 }
180 cout << endl;
181 }
182#endif
5f91c9e8 183}
184
185//_____________________________________________________________________________
186void AliMpMotifMap::PrintMotifTypes() const
187{
dee1d5f1 188/// Print all the the motifs types and their motif dimensions
189/// for all motif types in the motif types map.
5f91c9e8 190
f79c58a5 191#ifdef WITH_STL
5f91c9e8 192 if (fMotifTypes.size()) {
193 cout << "Dump of Motif Type Map - " << fMotifTypes.size() << " entries:" << endl;
194 Int_t counter = 0;
195 for (MotifTypeMapIterator i=fMotifTypes.begin(); i != fMotifTypes.end(); i++) {
196 const TString& id = (*i).first;
5f91c9e8 197 cout << "Map element "
198 << setw(3) << counter++ << " "
f79c58a5 199 << id.Data() << " ";
200 PrintMotifType((*i).second);
201 cout << endl;
202 }
203 cout << endl;
204 }
205#endif
206
207#ifdef WITH_ROOT
208 if (fMotifTypes.GetSize()) {
209 cout << "Dump of Motif Type Map - " << fMotifTypes.GetSize() << " entries:" << endl;
210 Int_t counter = 0;
5006ec94 211 TExMapIter i = fMotifTypes.GetIterator();
f79c58a5 212 Long_t key, value;
213 while ( i.Next(key, value) ) {
5006ec94 214 TString id = AliMpExMap::GetString(key);
f79c58a5 215 AliMpMotifType* motifType = (AliMpMotifType*)value;
216 cout << "Map element "
217 << setw(3) << counter++ << " "
218 << id.Data() << " " ;
219 PrintMotifType(motifType);
220 cout << endl;
5f91c9e8 221 }
222 cout << endl;
223 }
f79c58a5 224#endif
5f91c9e8 225}
226
6d5f608a 227//_____________________________________________________________________________
228void
229AliMpMotifMap::GetAllMotifPositionsIDs(TArrayI& ecn) const
230{
490da820 231/// Fill the given array with all motif positions IDs (electronic card numbers)
232/// defined in the map
233
6d5f608a 234#ifdef WITH_STL
235 ecn.Set(fMotifPositions.size());
236 Int_t i(0);
237 MotifPositionMapIterator it;
238 for (it=fMotifPositions.begin(); it != fMotifPositions.end(); it++) {
239 AliMpMotifPosition* motifPosition = (*it).second;
240 ecn[i++] = motifPosition->GetID();
241 }
242#endif
243
244#ifdef WITH_ROOT
245 ecn.Set(fMotifPositions.GetSize());
246 TExMapIter it = fMotifPositions.GetIterator();
247 Long_t key, value;
248 Int_t i(0);
249
250 while ( it.Next(key, value) )
251 {
252 AliMpMotifPosition* motifPosition = reinterpret_cast<AliMpMotifPosition*>(value);
253 ecn[i] = motifPosition->GetID();
254 ++i;
255 }
256
257#endif
258}
259
3283cfc7 260//_____________________________________________________________________________
261Int_t AliMpMotifMap::CalculateNofPads() const
262{
263 Int_t nofPads = 0;
264
265#ifdef WITH_STL
266 MotifPositionMapIterator it;
267 for (it=fMotifPositions.begin(); it != fMotifPositions.end(); it++) {
268 AliMpMotifPosition* motifPosition = (*it).second;
269 nofPads += motifPosition->GetMotif()->GetMotifType()->GetNofPads();
270 }
271#endif
272
273#ifdef WITH_ROOT
274 TExMapIter it = fMotifPositions.GetIterator();
275 Long_t key, value;
276
277 while ( it.Next(key, value) ) {
278 AliMpMotifPosition* motifPosition = reinterpret_cast<AliMpMotifPosition*>(value);
279 nofPads += motifPosition->GetMotif()->GetMotifType()->GetNofPads();
280 }
281#endif
282
3283cfc7 283 return nofPads;
284}
285
5f91c9e8 286//_____________________________________________________________________________
287void AliMpMotifMap::PrintMotifPositions() const
288{
dee1d5f1 289/// Print all the the motifs positions.
5f91c9e8 290
f79c58a5 291#ifdef WITH_STL
5f91c9e8 292 if (fMotifPositions.size()) {
293 cout << "Dump of Motif Position Map - " << fMotifPositions.size() << " entries:" << endl;
294 Int_t counter = 0;
295 for (MotifPositionMapIterator i=fMotifPositions.begin();
296 i != fMotifPositions.end(); i++) {
297
5f91c9e8 298 cout << "Map element "
f79c58a5 299 << setw(3) << counter++ << " ";
300 PrintMotifPosition((*i).second);
301 cout << endl;
5f91c9e8 302 }
303 cout << endl;
304 }
f79c58a5 305#endif
306
307#ifdef WITH_ROOT
308 if (fMotifPositions.GetSize()) {
dee1d5f1 309 cout << "Dump of Motif Position Map - " << fMotifPositions.GetSize() << " entries:" << endl;
f79c58a5 310 Int_t counter = 0;
5006ec94 311 TExMapIter i = fMotifPositions.GetIterator();
f79c58a5 312 Long_t key, value;
313 while ( i.Next(key, value) ) {
314 AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
315 cout << "Map element "
316 << setw(3) << counter++ << " ";
317 PrintMotifPosition(motifPosition);
318 cout << endl;
319 }
320 cout << endl;
321 }
322#endif
5f91c9e8 323}
324
325//_____________________________________________________________________________
326void AliMpMotifMap::PrintMotifPositions2() const
327{
dee1d5f1 328/// Print all the the motifs positions from the second map
329/// (by global indices)
5f91c9e8 330
f79c58a5 331#ifdef WITH_STL
5f91c9e8 332 if (fMotifPositions2.size()) {
333 cout << "Dump of Motif Position Map 2 - " << fMotifPositions2.size() << " entries:" << endl;
334 Int_t counter = 0;
335 for (MotifPositionMap2Iterator i=fMotifPositions2.begin();
336 i != fMotifPositions2.end(); i++) {
337
5f91c9e8 338 cout << "Map element "
f79c58a5 339 << setw(3) << counter++ << " ";
340 PrintMotifPosition2((*i).second);
341 cout << endl;
342 }
343 cout << endl;
344 }
345#endif
346
347#ifdef WITH_ROOT
348 if (fMotifPositions2.GetSize()) {
349 cout << "Dump of Motif Position Map 2 - " << fMotifPositions2.GetSize() << " entries:" << endl;
350 Int_t counter = 0;
5006ec94 351 TExMapIter i = fMotifPositions2.GetIterator();
f79c58a5 352 Long_t key, value;
353 while ( i.Next(key, value) ) {
354 AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
355 cout << "Map element "
356 << setw(3) << counter++ << " ";
357 PrintMotifPosition2(motifPosition);
358 cout << endl;
5f91c9e8 359 }
360 cout << endl;
361 }
f79c58a5 362#endif
5f91c9e8 363}
364
365//
366// public methods
367//
368
369//_____________________________________________________________________________
370Bool_t AliMpMotifMap::AddMotif(AliMpVMotif* motif, Bool_t warn)
371{
dee1d5f1 372/// Add the specified motif
373/// if the motif with this ID is not yet present.
5f91c9e8 374
375 AliMpVMotif* found = FindMotif(motif->GetID());
376 if (found) {
377 if (warn && found == motif)
2c605e66 378 AliWarningStream() << "The motif is already in map." << endl;
379
380 if (warn && found != motif) {
381 AliWarningStream()
382 << "Another motif with the same ID is already in map." << endl;
383 }
5f91c9e8 384 return false;
385 }
386
f79c58a5 387#ifdef WITH_STL
5f91c9e8 388 fMotifs[motif->GetID()] = motif;
f79c58a5 389#endif
390
391#ifdef WITH_ROOT
5006ec94 392 fMotifs.Add(motif->GetID(), motif);
f79c58a5 393#endif
394
5f91c9e8 395 return true;
396}
397
398//_____________________________________________________________________________
399Bool_t AliMpMotifMap::AddMotifType(AliMpMotifType* motifType, Bool_t warn)
400{
dee1d5f1 401/// Add the specified motif type
402/// if the motif with this ID is not yet present.
5f91c9e8 403
404 AliMpMotifType* found = FindMotifType(motifType->GetID());
405 if (found) {
406 if (warn && found == motifType)
2c605e66 407 AliWarningStream() << "The motif type is already in map." << endl;
408
409 if (warn && found != motifType) {
410 AliWarningStream()
411 << "Another motif type with the same ID is already in map." << endl;
412 }
5f91c9e8 413 return false;
414 }
415
f79c58a5 416#ifdef WITH_STL
5f91c9e8 417 fMotifTypes[motifType->GetID()] = motifType;
f79c58a5 418#endif
419
420#ifdef WITH_ROOT
5006ec94 421 fMotifTypes.Add(motifType->GetID(), motifType);
f79c58a5 422#endif
423
5f91c9e8 424 return true;
425}
426
427//_____________________________________________________________________________
428Bool_t AliMpMotifMap::AddMotifPosition(AliMpMotifPosition* motifPosition, Bool_t warn)
429{
dee1d5f1 430/// Add the specified motif position
431/// if this position is not yet present.
5f91c9e8 432
433 AliMpMotifPosition* found = FindMotifPosition(motifPosition->GetID());
7a854749 434 if (found) {
435 if (warn && found == motifPosition) {
2c605e66 436 AliWarningStream()
437 << "ID: " << motifPosition->GetID()
7a854749 438 << " found: " << found
2c605e66 439 << " new: " << motifPosition << endl
440 << "This motif position is already in map." << endl;
7a854749 441 }
2c605e66 442
7a854749 443 if (warn && found != motifPosition) {
2c605e66 444 AliWarningStream()
445 << "ID: " << motifPosition->GetID()
7a854749 446 << " found: " << found
2c605e66 447 << " new: " << motifPosition << endl
448 << "Another motif position with the same ID is already in map."
449 << endl;
450 }
451
5f91c9e8 452 return false;
453 }
454
f79c58a5 455#ifdef WITH_STL
5f91c9e8 456 fMotifPositions[motifPosition->GetID()] = motifPosition;
f79c58a5 457#endif
458
459#ifdef WITH_ROOT
5006ec94 460 fMotifPositions.Add(motifPosition->GetID(), motifPosition);
f79c58a5 461#endif
462
5f91c9e8 463 return true;
464}
465
466//_____________________________________________________________________________
467void AliMpMotifMap::FillMotifPositionMap2()
468{
dee1d5f1 469/// Fill the second map (by global indices) of motif positions.
5f91c9e8 470
f79c58a5 471#ifdef WITH_STL
5f91c9e8 472 if (fMotifPositions2.size() > 0 ) {
2c605e66 473 AliWarningStream() << "Map has been already filled." << endl;
5f91c9e8 474 return;
475 }
476
477 for (MotifPositionMapIterator ip=fMotifPositions.begin();
478 ip != fMotifPositions.end(); ip++) {
479
480 fMotifPositions2[(*ip).second->GetLowIndicesLimit()] = (*ip).second;
481 }
f79c58a5 482#endif
483
484#ifdef WITH_ROOT
485 if (fMotifPositions2.GetSize() > 0 ) {
2c605e66 486 AliWarningStream() <<"Map has been already filled." << endl;
f79c58a5 487 return;
488 }
489
5006ec94 490 TExMapIter i = fMotifPositions.GetIterator();
f79c58a5 491 Long_t key, value;
492 while ( i.Next(key, value) ) {
493 AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
5006ec94 494 fMotifPositions2.Add(motifPosition->GetLowIndicesLimit(), motifPosition);
f79c58a5 495 }
496#endif
5f91c9e8 497
498}
499
500//_____________________________________________________________________________
6d5f608a 501void AliMpMotifMap::Print(const char* opt) const
5f91c9e8 502{
dee1d5f1 503/// Print the motifs and motif types maps.
5f91c9e8 504
6d5f608a 505 TString sopt(opt);
506
507 sopt.ToUpper();
508
509 if ( sopt.Contains("MOTIFS") || sopt == "ALL" ) PrintMotifs();
510 if ( sopt.Contains("MOTIFTYPES") || sopt == "ALL" ) PrintMotifTypes();
511 if ( sopt.Contains("MOTIFPOSITIONS") || sopt == "ALL" ) PrintMotifPositions();
512 if ( sopt.Contains("MOTIFPOSITIONS2") || sopt == "ALL" ) PrintMotifPositions2();
5f91c9e8 513}
514
515//_____________________________________________________________________________
516void AliMpMotifMap::PrintGlobalIndices(const char* fileName) const
517{
dee1d5f1 518/// Print all the motifs positions and their global indices.
5f91c9e8 519
520 ofstream out(fileName, ios::out);
521
f79c58a5 522#ifdef WITH_STL
5f91c9e8 523 if (fMotifPositions.size()) {
524 for (MotifPositionMapIterator i=fMotifPositions.begin();
525 i != fMotifPositions.end(); i++) {
526
527 AliMpMotifPosition* motifPosition = (*i).second;
528 out << setw(5) << motifPosition->GetID() << " "
529 << setw(3) << motifPosition->GetLowIndicesLimit().GetFirst() << " "
530 << setw(3) << motifPosition->GetLowIndicesLimit().GetSecond()
531 << endl;
532 }
533 out << endl;
534 }
f79c58a5 535#endif
536
537#ifdef WITH_ROOT
538 if (fMotifPositions.GetSize()) {
5006ec94 539 TExMapIter i = fMotifPositions.GetIterator();
f79c58a5 540 Long_t key, value;
541 while ( i.Next(key, value) ) {
542 AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
543 out << setw(5) << motifPosition->GetID() << " "
544 << setw(3) << motifPosition->GetLowIndicesLimit().GetFirst() << " "
545 << setw(3) << motifPosition->GetLowIndicesLimit().GetSecond()
546 << endl;
547 }
548 out << endl;
549 }
550#endif
5f91c9e8 551}
552
553//_____________________________________________________________________________
554void AliMpMotifMap::UpdateGlobalIndices(const char* fileName)
555{
dee1d5f1 556/// Updates the motifs positions global indices
557/// 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{
dee1d5f1 600/// Finds 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{
dee1d5f1 620/// Finds the motif with the specified ID and returns it
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*/