]>
Commit | Line | Data |
---|---|---|
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.14 2006/03/17 11:38:06 ivana Exp $ | |
18 | // Category: motif | |
19 | // ------------------- | |
20 | // Class AliMpMotifMap | |
21 | // ------------------- | |
22 | // Class describing the motif map container, where motifs are | |
23 | // mapped to their string IDs. | |
24 | // Included in AliRoot: 2003/05/02 | |
25 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay | |
26 | ||
27 | #include "AliMpMotifMap.h" | |
28 | #include "AliMpVMotif.h" | |
29 | #include "AliMpMotif.h" | |
30 | #include "AliMpMotifSpecial.h" | |
31 | #include "AliMpMotifType.h" | |
32 | #include "AliMpMotifPosition.h" | |
33 | ||
34 | #include "AliLog.h" | |
35 | ||
36 | #include <Riostream.h> | |
37 | #include <TVector2.h> | |
38 | #include <TArrayI.h> | |
39 | ||
40 | ClassImp(AliMpMotifMap) | |
41 | ||
42 | //_____________________________________________________________________________ | |
43 | AliMpMotifMap::AliMpMotifMap(Bool_t /*standardConstructor*/) | |
44 | : TObject() | |
45 | #ifdef WITH_ROOT | |
46 | ,fMotifs(true), | |
47 | fMotifTypes(true), | |
48 | fMotifPositions(true), | |
49 | fMotifPositions2(true) | |
50 | #endif | |
51 | { | |
52 | /// Standard constructor | |
53 | ||
54 | //fMotifPositions2.SetOwner(false); | |
55 | } | |
56 | ||
57 | //_____________________________________________________________________________ | |
58 | AliMpMotifMap::AliMpMotifMap() | |
59 | : TObject(), | |
60 | fMotifs(), | |
61 | fMotifTypes(), | |
62 | fMotifPositions(), | |
63 | fMotifPositions2() | |
64 | { | |
65 | /// Default constructor | |
66 | } | |
67 | ||
68 | //_____________________________________________________________________________ | |
69 | AliMpMotifMap::~AliMpMotifMap() | |
70 | { | |
71 | /// Destructor | |
72 | ||
73 | // Delete all registered motifs, motif types, motif positions | |
74 | ||
75 | #ifdef WITH_STL | |
76 | for (MotifMapIterator im=fMotifs.begin(); im != fMotifs.end(); im++) { | |
77 | delete im->second; | |
78 | } | |
79 | ||
80 | for (MotifTypeMapIterator it=fMotifTypes.begin(); | |
81 | it != fMotifTypes.end(); it++) { | |
82 | delete it->second; | |
83 | } | |
84 | ||
85 | for (MotifPositionMapIterator ip=fMotifPositions.begin(); | |
86 | ip != fMotifPositions.end(); ip++) { | |
87 | delete ip->second; | |
88 | } | |
89 | #endif | |
90 | } | |
91 | ||
92 | // | |
93 | // private methods | |
94 | // | |
95 | ||
96 | //_____________________________________________________________________________ | |
97 | void AliMpMotifMap::PrintMotif(const AliMpVMotif* motif) const | |
98 | { | |
99 | /// Print the motif. | |
100 | ||
101 | cout << motif->GetID().Data() << " " | |
102 | << motif->GetMotifType()->GetID() << " " | |
103 | << motif->Dimensions().X() << " " | |
104 | << motif->Dimensions().Y(); | |
105 | } | |
106 | ||
107 | //_____________________________________________________________________________ | |
108 | void AliMpMotifMap::PrintMotifType(const AliMpMotifType* motifType) const | |
109 | { | |
110 | /// Print the motif type. | |
111 | ||
112 | cout << motifType->GetID().Data() << " " | |
113 | << motifType->GetNofPadsX() << " " | |
114 | << motifType->GetNofPadsY() << " "; | |
115 | } | |
116 | ||
117 | //_____________________________________________________________________________ | |
118 | void AliMpMotifMap::PrintMotifPosition( | |
119 | const AliMpMotifPosition* motifPosition) const | |
120 | { | |
121 | /// Print the motif position. | |
122 | ||
123 | cout << " ID " << motifPosition->GetID() << " " | |
124 | << " Motif ID " << motifPosition->GetMotif()->GetID() << " " | |
125 | << " Pos (X,Y) = (" << motifPosition->Position().X() << "," | |
126 | << motifPosition->Position().Y() << ")"; | |
127 | } | |
128 | ||
129 | //_____________________________________________________________________________ | |
130 | void AliMpMotifMap::PrintMotifPosition2( | |
131 | const AliMpMotifPosition* motifPosition) const | |
132 | { | |
133 | /// Print the motif position. | |
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 | ||
142 | //_____________________________________________________________________________ | |
143 | void AliMpMotifMap::PrintMotifs() const | |
144 | { | |
145 | /// Print all the motifs and their motif types | |
146 | /// for all motifs in the motifs map. | |
147 | ||
148 | #ifdef WITH_STL | |
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; | |
154 | cout << "Map element " | |
155 | << setw(3) << counter++ << " " | |
156 | << id.Data() << " " ; | |
157 | PrintMotif((*i).second); | |
158 | cout << endl; | |
159 | } | |
160 | cout << endl; | |
161 | } | |
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; | |
168 | TExMapIter i = fMotifs.GetIterator(); | |
169 | Long_t key, value; | |
170 | while ( i.Next(key, value) ) { | |
171 | TString id = fMotifs.AliMpExMap::GetString(key); | |
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 | |
182 | } | |
183 | ||
184 | //_____________________________________________________________________________ | |
185 | void AliMpMotifMap::PrintMotifTypes() const | |
186 | { | |
187 | /// Print all the the motifs types and their motif dimensions | |
188 | /// for all motif types in the motif types map. | |
189 | ||
190 | #ifdef WITH_STL | |
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; | |
196 | cout << "Map element " | |
197 | << setw(3) << counter++ << " " | |
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; | |
210 | TExMapIter i = fMotifTypes.GetIterator(); | |
211 | Long_t key, value; | |
212 | while ( i.Next(key, value) ) { | |
213 | TString id = AliMpExMap::GetString(key); | |
214 | AliMpMotifType* motifType = (AliMpMotifType*)value; | |
215 | cout << "Map element " | |
216 | << setw(3) << counter++ << " " | |
217 | << id.Data() << " " ; | |
218 | PrintMotifType(motifType); | |
219 | cout << endl; | |
220 | } | |
221 | cout << endl; | |
222 | } | |
223 | #endif | |
224 | } | |
225 | ||
226 | //_____________________________________________________________________________ | |
227 | void | |
228 | AliMpMotifMap::GetAllMotifPositionsIDs(TArrayI& ecn) const | |
229 | { | |
230 | /// Fill the given array with all motif positions IDs (electronic card numbers) | |
231 | /// defined in the map | |
232 | ||
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 | ||
259 | //_____________________________________________________________________________ | |
260 | Int_t AliMpMotifMap::CalculateNofPads() const | |
261 | { | |
262 | /// Calculate total number of pads in the map | |
263 | ||
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 | ||
284 | return nofPads; | |
285 | } | |
286 | ||
287 | //_____________________________________________________________________________ | |
288 | void AliMpMotifMap::PrintMotifPositions() const | |
289 | { | |
290 | /// Print all motif positions. | |
291 | ||
292 | #ifdef WITH_STL | |
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 | ||
299 | cout << "Map element " | |
300 | << setw(3) << counter++ << " "; | |
301 | PrintMotifPosition((*i).second); | |
302 | cout << endl; | |
303 | } | |
304 | cout << endl; | |
305 | } | |
306 | #endif | |
307 | ||
308 | #ifdef WITH_ROOT | |
309 | if (fMotifPositions.GetSize()) { | |
310 | cout << "Dump of Motif Position Map - " << fMotifPositions.GetSize() << " entries:" << endl; | |
311 | Int_t counter = 0; | |
312 | TExMapIter i = fMotifPositions.GetIterator(); | |
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 | |
324 | } | |
325 | ||
326 | //_____________________________________________________________________________ | |
327 | void AliMpMotifMap::PrintMotifPositions2() const | |
328 | { | |
329 | /// Print all motif positions from the second map | |
330 | /// (by global indices) | |
331 | ||
332 | #ifdef WITH_STL | |
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 | ||
339 | cout << "Map element " | |
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; | |
352 | TExMapIter i = fMotifPositions2.GetIterator(); | |
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; | |
360 | } | |
361 | cout << endl; | |
362 | } | |
363 | #endif | |
364 | } | |
365 | ||
366 | // | |
367 | // public methods | |
368 | // | |
369 | ||
370 | //_____________________________________________________________________________ | |
371 | Bool_t AliMpMotifMap::AddMotif(AliMpVMotif* motif, Bool_t warn) | |
372 | { | |
373 | /// Add the specified motif | |
374 | /// if the motif with this ID is not yet present. | |
375 | ||
376 | AliMpVMotif* found = FindMotif(motif->GetID()); | |
377 | if (found) { | |
378 | if (warn && found == motif) | |
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 | } | |
385 | return false; | |
386 | } | |
387 | ||
388 | #ifdef WITH_STL | |
389 | fMotifs[motif->GetID()] = motif; | |
390 | #endif | |
391 | ||
392 | #ifdef WITH_ROOT | |
393 | fMotifs.Add(motif->GetID(), motif); | |
394 | #endif | |
395 | ||
396 | return true; | |
397 | } | |
398 | ||
399 | //_____________________________________________________________________________ | |
400 | Bool_t AliMpMotifMap::AddMotifType(AliMpMotifType* motifType, Bool_t warn) | |
401 | { | |
402 | /// Add the specified motif type | |
403 | /// if the motif with this ID is not yet present. | |
404 | ||
405 | AliMpMotifType* found = FindMotifType(motifType->GetID()); | |
406 | if (found) { | |
407 | if (warn && found == motifType) | |
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 | } | |
414 | return false; | |
415 | } | |
416 | ||
417 | #ifdef WITH_STL | |
418 | fMotifTypes[motifType->GetID()] = motifType; | |
419 | #endif | |
420 | ||
421 | #ifdef WITH_ROOT | |
422 | fMotifTypes.Add(motifType->GetID(), motifType); | |
423 | #endif | |
424 | ||
425 | return true; | |
426 | } | |
427 | ||
428 | //_____________________________________________________________________________ | |
429 | Bool_t AliMpMotifMap::AddMotifPosition(AliMpMotifPosition* motifPosition, Bool_t warn) | |
430 | { | |
431 | /// Add the specified motif position | |
432 | /// if this position is not yet present. | |
433 | ||
434 | AliMpMotifPosition* found = FindMotifPosition(motifPosition->GetID()); | |
435 | if (found) { | |
436 | if (warn && found == motifPosition) { | |
437 | AliWarningStream() | |
438 | << "ID: " << motifPosition->GetID() | |
439 | << " found: " << found | |
440 | << " new: " << motifPosition << endl | |
441 | << "This motif position is already in map." << endl; | |
442 | } | |
443 | ||
444 | if (warn && found != motifPosition) { | |
445 | AliWarningStream() | |
446 | << "ID: " << motifPosition->GetID() | |
447 | << " found: " << found | |
448 | << " new: " << motifPosition << endl | |
449 | << "Another motif position with the same ID is already in map." | |
450 | << endl; | |
451 | } | |
452 | ||
453 | return false; | |
454 | } | |
455 | ||
456 | #ifdef WITH_STL | |
457 | fMotifPositions[motifPosition->GetID()] = motifPosition; | |
458 | #endif | |
459 | ||
460 | #ifdef WITH_ROOT | |
461 | fMotifPositions.Add(motifPosition->GetID(), motifPosition); | |
462 | #endif | |
463 | ||
464 | return true; | |
465 | } | |
466 | ||
467 | //_____________________________________________________________________________ | |
468 | void AliMpMotifMap::FillMotifPositionMap2() | |
469 | { | |
470 | /// Fill the second map (by global indices) of motif positions. | |
471 | ||
472 | #ifdef WITH_STL | |
473 | if (fMotifPositions2.size() > 0 ) { | |
474 | AliWarningStream() << "Map has been already filled." << endl; | |
475 | return; | |
476 | } | |
477 | ||
478 | for (MotifPositionMapIterator ip=fMotifPositions.begin(); | |
479 | ip != fMotifPositions.end(); ip++) { | |
480 | ||
481 | fMotifPositions2[(*ip).second->GetLowIndicesLimit()] = (*ip).second; | |
482 | } | |
483 | #endif | |
484 | ||
485 | #ifdef WITH_ROOT | |
486 | if (fMotifPositions2.GetSize() > 0 ) { | |
487 | AliWarningStream() <<"Map has been already filled." << endl; | |
488 | return; | |
489 | } | |
490 | ||
491 | TExMapIter i = fMotifPositions.GetIterator(); | |
492 | Long_t key, value; | |
493 | while ( i.Next(key, value) ) { | |
494 | AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value; | |
495 | fMotifPositions2.Add(motifPosition->GetLowIndicesLimit(), motifPosition); | |
496 | } | |
497 | #endif | |
498 | ||
499 | } | |
500 | ||
501 | //_____________________________________________________________________________ | |
502 | void AliMpMotifMap::Print(const char* opt) const | |
503 | { | |
504 | /// Print the motifs and motif types maps. | |
505 | ||
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(); | |
514 | } | |
515 | ||
516 | //_____________________________________________________________________________ | |
517 | void AliMpMotifMap::PrintGlobalIndices(const char* fileName) const | |
518 | { | |
519 | /// Print all motif positions and their global indices. | |
520 | ||
521 | ofstream out(fileName, ios::out); | |
522 | ||
523 | #ifdef WITH_STL | |
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 | } | |
536 | #endif | |
537 | ||
538 | #ifdef WITH_ROOT | |
539 | if (fMotifPositions.GetSize()) { | |
540 | TExMapIter i = fMotifPositions.GetIterator(); | |
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 | |
552 | } | |
553 | ||
554 | //_____________________________________________________________________________ | |
555 | void AliMpMotifMap::UpdateGlobalIndices(const char* fileName) | |
556 | { | |
557 | /// Update the motif positions global indices from the file. | |
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) { | |
574 | AliDebugStream(1) | |
575 | << "Processing " | |
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 { | |
589 | AliWarningStream() | |
590 | << "Motif position " << motifPositionId << " not found" << endl; | |
591 | } | |
592 | } | |
593 | while (!in.eof()); | |
594 | } | |
595 | ||
596 | ||
597 | //_____________________________________________________________________________ | |
598 | AliMpVMotif* AliMpMotifMap::FindMotif(const TString& motifID) const | |
599 | { | |
600 | /// Find the motif with the specified ID. | |
601 | ||
602 | #ifdef WITH_STL | |
603 | MotifMapIterator i = fMotifs.find(motifID); | |
604 | if (i != fMotifs.end()) | |
605 | return (*i).second; | |
606 | else | |
607 | return 0; | |
608 | #endif | |
609 | ||
610 | #ifdef WITH_ROOT | |
611 | return (AliMpVMotif*)fMotifs.GetValue(motifID); | |
612 | #endif | |
613 | } | |
614 | ||
615 | //_____________________________________________________________________________ | |
616 | AliMpVMotif* AliMpMotifMap::FindMotif(const TString& motifID, | |
617 | const TString& motifTypeID, | |
618 | const TVector2& padDimensions ) const | |
619 | { | |
620 | /// Find 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 | ||
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 | //_____________________________________________________________________________ | |
660 | AliMpMotifType* AliMpMotifMap::FindMotifType(const TString& motifTypeID) const | |
661 | { | |
662 | /// Find the motif type with the specified motif type ID. | |
663 | ||
664 | #ifdef WITH_STL | |
665 | MotifTypeMapIterator i = fMotifTypes.find(motifTypeID); | |
666 | if (i != fMotifTypes.end()) | |
667 | return (*i).second; | |
668 | else | |
669 | return 0; | |
670 | #endif | |
671 | ||
672 | #ifdef WITH_ROOT | |
673 | return (AliMpMotifType*)fMotifTypes.GetValue(motifTypeID); | |
674 | #endif | |
675 | } | |
676 | ||
677 | //_____________________________________________________________________________ | |
678 | AliMpMotifPosition* | |
679 | AliMpMotifMap::FindMotifPosition(Int_t motifPositionID) const | |
680 | { | |
681 | /// Find the motif position with the specified motif position ID. | |
682 | ||
683 | #ifdef WITH_STL | |
684 | MotifPositionMapIterator i = fMotifPositions.find(motifPositionID); | |
685 | if (i != fMotifPositions.end()) | |
686 | return (*i).second; | |
687 | else | |
688 | return 0; | |
689 | #endif | |
690 | ||
691 | #ifdef WITH_ROOT | |
692 | return (AliMpMotifPosition*)fMotifPositions.GetValue(motifPositionID); | |
693 | #endif | |
694 | } | |
695 | ||
696 | /* | |
697 | //_____________________________________________________________________________ | |
698 | AliMpMotifPosition* | |
699 | AliMpMotifMap::FindMotifPosition(const AliMpIntPair& indices) const | |
700 | { | |
701 | /// Find the last motif position which has the global indices (low limit) | |
702 | /// less then the indices specified. | |
703 | ||
704 | #ifdef WITH_STL | |
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; | |
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 | |
733 | } | |
734 | */ |