AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpSlatPadIterator.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: AliMpSlatPadIterator.cxx,v 1.6 2006/05/24 13:58:50 ivana Exp $
18 
19 #include "AliMpSlatPadIterator.h"
20 
21 #include "AliLog.h"
22 #include "AliMpArea.h"
23 #include "AliMpPCB.h"
24 #include "AliMpSlat.h"
25 #include "AliMpPCBPadIterator.h"
26 
27 
28 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
40 
44 
45 //_____________________________________________________________________________
48 fkSlat(0),
49 fDelegates(),
50 fCurrentDelegate(0),
51 fCurrentDelegateIndex(0)
52 {
56 }
57 
58 //_____________________________________________________________________________
60  const AliMpArea& area)
62 fkSlat(slat),
63 fDelegates(),
64 fCurrentDelegate(0),
65 fCurrentDelegateIndex(0)
66 {
71  AliDebug(1,Form("this=%p ctor area=(%e,%e,%e,%e)",this,
72  area.LeftBorder(),area.DownBorder(),
73  area.RightBorder(),area.UpBorder()));
74  if (!Prepare(area))
75  {
76  AliError("Iterator invalidated by improper initialization (e.g. incorrect area given ?)");
77  }
78  fDelegates.SetOwner(kTRUE);
79 }
80 
81 //_____________________________________________________________________________
83 {
87  AliDebug(1,Form("this=%p dtor",this));
88  Invalidate();
89 }
90 
91 //_____________________________________________________________________________
94 {
98  AliDebug(4,Form("a=(%7.2f,%7.2f;%7.2f,%7.2f) b=(%7.2f,%7.2f;%7.2f,%7.2f)",
99  a.LeftBorder(),a.DownBorder(),a.RightBorder(),a.UpBorder(),
100  b.LeftBorder(),b.DownBorder(),b.RightBorder(),b.UpBorder()));
101 
102  Double_t xmin = TMath::Max(a.LeftBorder(),b.LeftBorder());
103  Double_t xmax = TMath::Min(a.RightBorder(),b.RightBorder());
104  Double_t ymin = TMath::Max(a.DownBorder(),b.DownBorder());
105  Double_t ymax = TMath::Min(a.UpBorder(),b.UpBorder());
106  AliMpArea c( (xmin+xmax)/2.0, (ymin+ymax)/2.0 ,
107  (xmax-xmin)/2.0, (ymax-ymin)/2.0 );
108 
109  AliDebug(4,Form("a intersect b = (%7.2f,%7.2f;%7.2f,%7.2f)",
110  c.LeftBorder(),c.DownBorder(),c.RightBorder(),c.UpBorder()));
111  return c;
112 }
113 
114 //_____________________________________________________________________________
115 Bool_t
117 {
121 
122  for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
123  {
124  const AliMpPCB* pcb = fkSlat->GetPCB(i);
125  AliMpArea pcbArea(pcb->Area());
126  AliMpArea zone = Intersect(pcbArea,area);
127  AliDebug(3,Form("i=%2d zone is %7.2f,%7.2f->%7.2f,%7.2f %d",i,
128  zone.LeftBorder(),zone.DownBorder(),
129  zone.RightBorder(),zone.UpBorder(),
130  zone.IsValid()));
131  if ( zone.IsValid() )
132  {
133  fDelegates.AddLast(new AliMpPCBPadIterator(fkSlat,zone));
134  }
135  }
136  AliDebug(3,Form("Number of delegates = %d",fDelegates.GetEntries()));
137 // StdoutToAliDebug(3,fDelegates.Print(););
138  return fDelegates.GetLast()>=0;
139 }
140 
141 //_____________________________________________________________________________
142 AliMpPad
144 {
148  if ( fCurrentDelegate )
149  {
150  return fCurrentDelegate->CurrentItem();
151  }
152  else
153  {
154  return AliMpPad::Invalid();
155  }
156 }
157 
158 //_____________________________________________________________________________
159 void
161 {
165  if ( fDelegates.GetLast() < 0 )
166  {
167  AliError("Iterator is not valid, as it gets no delegates at all !");
168  }
169  else
170  {
172  fCurrentDelegate = static_cast<AliMpVPadIterator*>(fDelegates.At(0));
174  }
175 }
176 
177 //_____________________________________________________________________________
178 void
180 {
184  fDelegates.Delete();
185  fCurrentDelegate = 0;
187 }
188 
189 //_____________________________________________________________________________
190 Bool_t
192 {
196  return ( !fCurrentDelegate ||
197  ( fCurrentDelegateIndex > fDelegates.GetLast() &&
198  fCurrentDelegate->IsDone() ) );
199 }
200 
201 //_____________________________________________________________________________
202 void
204 {
208  if (IsDone()) return;
209 
211 
212  if ( fCurrentDelegate->IsDone() )
213  {
214  AliDebug(3,"Moving to next delegate");
216  if ( fCurrentDelegateIndex <= fDelegates.GetLast() )
217  {
220  }
221  }
222 }
Bool_t Prepare(const AliMpArea &area)
Double_t LeftBorder() const
Definition: AliMpArea.cxx:124
void Invalidate()
Invalidate iterator (.
A PCB for station 3,4 or 5.
Definition: AliMpPCB.h:46
AliMpArea Area() const
Definition: AliMpPCB.cxx:319
A rectangle area positioned in plane..
Definition: AliMpArea.h:20
virtual Bool_t IsDone() const =0
Is iterator done.
void Next()
Set iterator to the next pad.
A slat (building block of stations 3, 4 and 5)
Definition: AliMpSlat.h:51
Iterates over slat pads within a region of constant pad size.
AliMpArea Intersect(const AliMpArea &a, const AliMpArea &b) const
static AliMpPad Invalid()
Return invalid pad.
Definition: AliMpPad.h:57
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
void First()
Set iterator to the first pad.
AliMpPCB * GetPCB(Int_t i) const
Returns the i-th PCB of this slat.
Definition: AliMpSlat.cxx:435
virtual void Next()=0
Set iterator to the next pad.
An interface for an iterator over pads.
Double_t UpBorder() const
Definition: AliMpArea.cxx:140
virtual AliMpPad CurrentItem() const =0
Return current pad.
Double_t DownBorder() const
Definition: AliMpArea.cxx:148
Int_t fCurrentDelegateIndex
current iterator index
Bool_t IsDone() const
Is iterator done.
AliMpVPadIterator * fCurrentDelegate
current iterator
TObjArray fDelegates
iterators we do use (array of AliMpVPadIterator*)
virtual void First()=0
Set iterator to the first pad.
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
const AliMpSlat * fkSlat
pointer to the slat being iterated over
AliMpPad CurrentItem() const
Return current pad.
Double_t RightBorder() const
Definition: AliMpArea.cxx:132
Int_t GetSize() const
Returns the number of PCBs of this slat.
Definition: AliMpSlat.cxx:446
Iterator for slat pads.