]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONmapping/AliMpDEIterator.cxx
Fixes for object target dependencies
[u/mrichter/AliRoot.git] / MUON / MUONmapping / AliMpDEIterator.cxx
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: AliMpDEIterator.cxx,v 1.6 2006/05/24 13:58:34 ivana Exp $
18 // Category: management
19
20 //-----------------------------------------------------------------------------
21 // Class AliMpDEIterator
22 // ------------------------
23 // The iterator over valid detection elements
24 // Author: Ivana Hrivnacova, IPN Orsay
25 //-----------------------------------------------------------------------------
26
27 #include "AliMpDEIterator.h"
28
29 #include "AliMpExMapIterator.h"
30 #include "AliMpDEStore.h"
31 #include "AliMpDetElement.h"
32 #include "AliMpDEManager.h"
33 #include "AliMpFiles.h"
34
35 #include "AliLog.h"
36
37 #include <Riostream.h>
38 #include <TSystem.h>
39
40 using std::endl;
41 /// \cond CLASSIMP
42 ClassImp(AliMpDEIterator)
43 /// \endcond
44
45 //______________________________________________________________________________
46 AliMpDEIterator::AliMpDEIterator()
47 : TObject(),
48   fCurrentDE(0x0),
49   fIterator(AliMpDEStore::Instance()->fDetElements.CreateIterator()),
50   fChamberId(-1)
51 {  
52 /// Standard and default constructor
53 }
54
55 //______________________________________________________________________________
56
57 AliMpDEIterator::~AliMpDEIterator()
58 {
59 /// Destructor
60
61   delete fIterator;
62 }
63
64 //
65 // public methods
66 //
67
68 //______________________________________________________________________________
69 void AliMpDEIterator::First()
70 {
71 /// Set iterator to the first DE Id defined 
72
73   fIterator->Reset();
74   fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
75   fChamberId = -1;
76 }  
77
78 //______________________________________________________________________________
79 void AliMpDEIterator::First(Int_t chamberId)
80 {
81 /// Reset the iterator, so that it points to the first DE
82  
83   if ( ! AliMpDEManager::IsValidChamberId(chamberId) ) {
84     AliErrorStream() << "Invalid chamber Id " << chamberId << endl;
85     fIterator->Reset();
86     fChamberId = -1;    
87     fCurrentDE = 0x0;
88     return;
89   }    
90
91   fIterator->Reset();
92   fChamberId = -1;
93   while ( fChamberId != chamberId ) 
94   {
95     fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
96     if (!fCurrentDE) return;
97     fChamberId = AliMpDEManager::GetChamberId(CurrentDEId());
98   }
99 }
100
101 //______________________________________________________________________________
102 void AliMpDEIterator::Next()
103 {
104 /// Increment iterator to next DE
105
106   if ( fChamberId < 0 ) 
107   {
108     fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
109   }
110   else
111   {
112     fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
113     
114     while ( fCurrentDE && (AliMpDEManager::GetChamberId(fCurrentDE->GetId()) != fChamberId) )
115     {
116       fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
117       if (!fCurrentDE) return;
118     }
119   }
120 }
121
122 //______________________________________________________________________________
123 Bool_t AliMpDEIterator::IsDone() const
124 {
125 /// Is the iterator in the end?
126
127   return ( fCurrentDE == 0x0 );
128 }   
129
130 //______________________________________________________________________________
131 AliMpDetElement* AliMpDEIterator::CurrentDE() const
132 {
133 /// Current DE Id
134
135   return fCurrentDE;
136 }
137     
138 //______________________________________________________________________________
139 Int_t 
140 AliMpDEIterator::CurrentDEId() const
141 {
142 /// Current DE Id
143
144   if ( fCurrentDE )
145   {
146     return fCurrentDE->GetId();
147   }
148   else {   
149     AliErrorStream()
150       << "Not in valid position - returning invalid DE." << endl;
151     return 0;
152   }  
153 }
154