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