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