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