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