]>
Commit | Line | Data |
---|---|---|
1ef5468a | 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 | ||
18 | #include "AliMpManuIterator.h" | |
19 | ||
20 | #include "AliMpBusPatch.h" | |
21 | #include "AliMpDDLStore.h" | |
22 | #include "TExMap.h" | |
23 | ||
24 | /// \class AliMpManuIterator | |
25 | /// | |
26 | /// Class to loop over all manus of MUON Tracker | |
27 | /// | |
28 | /// \author Laurent Aphecetche, Subatech | |
29 | ||
30 | /// \cond CLASSIMP | |
31 | ClassImp(AliMpManuIterator) | |
32 | /// \endcond | |
33 | ||
34 | //_____________________________________________________________________________ | |
35 | AliMpManuIterator::AliMpManuIterator() | |
36 | : TObject(), | |
37 | fIterator(new TExMapIter(AliMpDDLStore::Instance()->GetBusPatchesIterator())), | |
38 | fCurrentBusPatch(0x0), | |
39 | fCurrentManuIndex(-1) | |
40 | { | |
41 | /// ctor | |
42 | Reset(); | |
43 | } | |
44 | ||
45 | //_____________________________________________________________________________ | |
46 | AliMpManuIterator::~AliMpManuIterator() | |
47 | { | |
48 | /// dtor | |
49 | delete fIterator; | |
50 | } | |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | Bool_t | |
54 | AliMpManuIterator::Next(Int_t& detElemId, Int_t& manuId) | |
55 | { | |
56 | /// Set the next (de,manu) pair and return kTRUE, or kFALSE if ended. | |
57 | ||
58 | ++fCurrentManuIndex; | |
59 | ||
60 | if ( fCurrentManuIndex < fCurrentBusPatch->GetNofManus() ) | |
61 | { | |
62 | detElemId = fCurrentBusPatch->GetDEId(); | |
63 | manuId = fCurrentBusPatch->GetManuId(fCurrentManuIndex); | |
64 | return kTRUE; | |
65 | } | |
66 | else | |
67 | { | |
68 | fCurrentBusPatch = NextBusPatch(); | |
69 | if (!fCurrentBusPatch ) | |
70 | { | |
71 | return kFALSE; | |
72 | } | |
73 | fCurrentManuIndex = -1; | |
74 | return Next(detElemId,manuId); | |
75 | } | |
76 | } | |
77 | ||
78 | //_____________________________________________________________________________ | |
79 | AliMpBusPatch* | |
80 | AliMpManuIterator::NextBusPatch() const | |
81 | { | |
82 | /// Return next bus patch | |
83 | ||
84 | Long_t key, value; | |
85 | ||
86 | Bool_t ok = fIterator->Next(key,value); | |
87 | ||
88 | if (ok) | |
89 | { | |
90 | return reinterpret_cast<AliMpBusPatch*>(value); | |
91 | } | |
92 | return 0x0; | |
93 | } | |
94 | ||
95 | //_____________________________________________________________________________ | |
96 | void | |
97 | AliMpManuIterator::Reset() | |
98 | { | |
99 | /// Rewind the iterator | |
100 | fIterator->Reset(); | |
101 | ||
102 | fCurrentBusPatch = NextBusPatch(); | |
103 | ||
104 | fCurrentManuIndex = -1; | |
105 | } |