AliRoot Core  d69033e (d69033e)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpDEIterator.cxx
Go to the documentation of this file.
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;
44 
45 //______________________________________________________________________________
47 : TObject(),
48  fCurrentDE(0x0),
49  fIterator(AliMpDEStore::Instance()->fDetElements.CreateIterator()),
50  fChamberId(-1)
51 {
53 }
54 
55 //______________________________________________________________________________
56 
58 {
60 
61  delete fIterator;
62 }
63 
64 //
65 // public methods
66 //
67 
68 //______________________________________________________________________________
70 {
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 {
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;
98  }
99 }
100 
101 //______________________________________________________________________________
103 {
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 
115  {
116  fCurrentDE = static_cast<AliMpDetElement*>(fIterator->Next());
117  if (!fCurrentDE) return;
118  }
119  }
120 }
121 
122 //______________________________________________________________________________
124 {
126 
127  return ( fCurrentDE == 0x0 );
128 }
129 
130 //______________________________________________________________________________
132 {
134 
135  return fCurrentDE;
136 }
137 
138 //______________________________________________________________________________
139 Int_t
141 {
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 
The iterator over detection elements.
The container class for detection element objects.
Definition: AliMpDEStore.h:29
Bool_t IsDone() const
AliMpDetElement * CurrentDE() const
AliMpDetElement * fCurrentDE
current element in iteration
Int_t CurrentDEId() const
The class defines the electronics properties of detection element.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
TIterator * fIterator
iterator
static Int_t GetChamberId(Int_t detElemId, Bool_t warn=true)
static Bool_t IsValidChamberId(Int_t chamberId, Bool_t warn=false)
Int_t fChamberId
The iterated chamber.
virtual ~AliMpDEIterator()
Int_t GetId() const
Return Id.