#include "AliMpSlatPadIterator.h"
#include "AliLog.h"
#include "AliMpArea.h"
#include "AliMpPCB.h"
#include "AliMpSlat.h"
#include "AliMpPCBPadIterator.h"
ClassImp(AliMpSlatPadIterator)
AliMpSlatPadIterator::AliMpSlatPadIterator()
: AliMpVPadIterator(),
fkSlat(0),
fDelegates(),
fCurrentDelegate(0),
fCurrentDelegateIndex(0)
{
}
AliMpSlatPadIterator::AliMpSlatPadIterator(const AliMpSlat* slat,
const AliMpArea& area)
: AliMpVPadIterator(),
fkSlat(slat),
fDelegates(),
fCurrentDelegate(0),
fCurrentDelegateIndex(0)
{
AliDebug(1,Form("this=%p ctor area=(%e,%e,%e,%e)",this,
area.LeftBorder(),area.DownBorder(),
area.RightBorder(),area.UpBorder()));
if (!Prepare(area))
{
AliError("Iterator invalidated by improper initialization (e.g. incorrect area given ?)");
}
fDelegates.SetOwner(kTRUE);
}
AliMpSlatPadIterator::~AliMpSlatPadIterator()
{
AliDebug(1,Form("this=%p dtor",this));
Invalidate();
}
AliMpArea
AliMpSlatPadIterator::Intersect(const AliMpArea& a, const AliMpArea& b) const
{
AliDebug(4,Form("a=(%7.2f,%7.2f;%7.2f,%7.2f) b=(%7.2f,%7.2f;%7.2f,%7.2f)",
a.LeftBorder(),a.DownBorder(),a.RightBorder(),a.UpBorder(),
b.LeftBorder(),b.DownBorder(),b.RightBorder(),b.UpBorder()));
Double_t xmin = TMath::Max(a.LeftBorder(),b.LeftBorder());
Double_t xmax = TMath::Min(a.RightBorder(),b.RightBorder());
Double_t ymin = TMath::Max(a.DownBorder(),b.DownBorder());
Double_t ymax = TMath::Min(a.UpBorder(),b.UpBorder());
AliMpArea c( (xmin+xmax)/2.0, (ymin+ymax)/2.0 ,
(xmax-xmin)/2.0, (ymax-ymin)/2.0 );
AliDebug(4,Form("a intersect b = (%7.2f,%7.2f;%7.2f,%7.2f)",
c.LeftBorder(),c.DownBorder(),c.RightBorder(),c.UpBorder()));
return c;
}
Bool_t
AliMpSlatPadIterator::Prepare(const AliMpArea& area)
{
for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
{
const AliMpPCB* pcb = fkSlat->GetPCB(i);
AliMpArea pcbArea(pcb->Area());
AliMpArea zone = Intersect(pcbArea,area);
AliDebug(3,Form("i=%2d zone is %7.2f,%7.2f->%7.2f,%7.2f %d",i,
zone.LeftBorder(),zone.DownBorder(),
zone.RightBorder(),zone.UpBorder(),
zone.IsValid()));
if ( zone.IsValid() )
{
fDelegates.AddLast(new AliMpPCBPadIterator(fkSlat,zone));
}
}
AliDebug(3,Form("Number of delegates = %d",fDelegates.GetEntries()));
return fDelegates.GetLast()>=0;
}
AliMpPad
AliMpSlatPadIterator::CurrentItem() const
{
if ( fCurrentDelegate )
{
return fCurrentDelegate->CurrentItem();
}
else
{
return AliMpPad::Invalid();
}
}
void
AliMpSlatPadIterator::First()
{
if ( fDelegates.GetLast() < 0 )
{
AliError("Iterator is not valid, as it gets no delegates at all !");
}
else
{
fCurrentDelegateIndex = 0;
fCurrentDelegate = static_cast<AliMpVPadIterator*>(fDelegates.At(0));
fCurrentDelegate->First();
}
}
void
AliMpSlatPadIterator::Invalidate()
{
fDelegates.Delete();
fCurrentDelegate = 0;
fCurrentDelegateIndex = 0;
}
Bool_t
AliMpSlatPadIterator::IsDone() const
{
return ( !fCurrentDelegate ||
( fCurrentDelegateIndex > fDelegates.GetLast() &&
fCurrentDelegate->IsDone() ) );
}
void
AliMpSlatPadIterator::Next()
{
if (IsDone()) return;
fCurrentDelegate->Next();
if ( fCurrentDelegate->IsDone() )
{
AliDebug(3,"Moving to next delegate");
++fCurrentDelegateIndex;
if ( fCurrentDelegateIndex <= fDelegates.GetLast() )
{
fCurrentDelegate = static_cast<AliMpVPadIterator*>(fDelegates.At(fCurrentDelegateIndex));
fCurrentDelegate->First();
}
}
}
AliMpSlatPadIterator.cxx:1 AliMpSlatPadIterator.cxx:2 AliMpSlatPadIterator.cxx:3 AliMpSlatPadIterator.cxx:4 AliMpSlatPadIterator.cxx:5 AliMpSlatPadIterator.cxx:6 AliMpSlatPadIterator.cxx:7 AliMpSlatPadIterator.cxx:8 AliMpSlatPadIterator.cxx:9 AliMpSlatPadIterator.cxx:10 AliMpSlatPadIterator.cxx:11 AliMpSlatPadIterator.cxx:12 AliMpSlatPadIterator.cxx:13 AliMpSlatPadIterator.cxx:14 AliMpSlatPadIterator.cxx:15 AliMpSlatPadIterator.cxx:16 AliMpSlatPadIterator.cxx:17 AliMpSlatPadIterator.cxx:18 AliMpSlatPadIterator.cxx:19 AliMpSlatPadIterator.cxx:20 AliMpSlatPadIterator.cxx:21 AliMpSlatPadIterator.cxx:22 AliMpSlatPadIterator.cxx:23 AliMpSlatPadIterator.cxx:24 AliMpSlatPadIterator.cxx:25 AliMpSlatPadIterator.cxx:26 AliMpSlatPadIterator.cxx:27 AliMpSlatPadIterator.cxx:28 AliMpSlatPadIterator.cxx:29 AliMpSlatPadIterator.cxx:30 AliMpSlatPadIterator.cxx:31 AliMpSlatPadIterator.cxx:32 AliMpSlatPadIterator.cxx:33 AliMpSlatPadIterator.cxx:34 AliMpSlatPadIterator.cxx:35 AliMpSlatPadIterator.cxx:36 AliMpSlatPadIterator.cxx:37 AliMpSlatPadIterator.cxx:38 AliMpSlatPadIterator.cxx:39 AliMpSlatPadIterator.cxx:40 AliMpSlatPadIterator.cxx:41 AliMpSlatPadIterator.cxx:42 AliMpSlatPadIterator.cxx:43 AliMpSlatPadIterator.cxx:44 AliMpSlatPadIterator.cxx:45 AliMpSlatPadIterator.cxx:46 AliMpSlatPadIterator.cxx:47 AliMpSlatPadIterator.cxx:48 AliMpSlatPadIterator.cxx:49 AliMpSlatPadIterator.cxx:50 AliMpSlatPadIterator.cxx:51 AliMpSlatPadIterator.cxx:52 AliMpSlatPadIterator.cxx:53 AliMpSlatPadIterator.cxx:54 AliMpSlatPadIterator.cxx:55 AliMpSlatPadIterator.cxx:56 AliMpSlatPadIterator.cxx:57 AliMpSlatPadIterator.cxx:58 AliMpSlatPadIterator.cxx:59 AliMpSlatPadIterator.cxx:60 AliMpSlatPadIterator.cxx:61 AliMpSlatPadIterator.cxx:62 AliMpSlatPadIterator.cxx:63 AliMpSlatPadIterator.cxx:64 AliMpSlatPadIterator.cxx:65 AliMpSlatPadIterator.cxx:66 AliMpSlatPadIterator.cxx:67 AliMpSlatPadIterator.cxx:68 AliMpSlatPadIterator.cxx:69 AliMpSlatPadIterator.cxx:70 AliMpSlatPadIterator.cxx:71 AliMpSlatPadIterator.cxx:72 AliMpSlatPadIterator.cxx:73 AliMpSlatPadIterator.cxx:74 AliMpSlatPadIterator.cxx:75 AliMpSlatPadIterator.cxx:76 AliMpSlatPadIterator.cxx:77 AliMpSlatPadIterator.cxx:78 AliMpSlatPadIterator.cxx:79 AliMpSlatPadIterator.cxx:80 AliMpSlatPadIterator.cxx:81 AliMpSlatPadIterator.cxx:82 AliMpSlatPadIterator.cxx:83 AliMpSlatPadIterator.cxx:84 AliMpSlatPadIterator.cxx:85 AliMpSlatPadIterator.cxx:86 AliMpSlatPadIterator.cxx:87 AliMpSlatPadIterator.cxx:88 AliMpSlatPadIterator.cxx:89 AliMpSlatPadIterator.cxx:90 AliMpSlatPadIterator.cxx:91 AliMpSlatPadIterator.cxx:92 AliMpSlatPadIterator.cxx:93 AliMpSlatPadIterator.cxx:94 AliMpSlatPadIterator.cxx:95 AliMpSlatPadIterator.cxx:96 AliMpSlatPadIterator.cxx:97 AliMpSlatPadIterator.cxx:98 AliMpSlatPadIterator.cxx:99 AliMpSlatPadIterator.cxx:100 AliMpSlatPadIterator.cxx:101 AliMpSlatPadIterator.cxx:102 AliMpSlatPadIterator.cxx:103 AliMpSlatPadIterator.cxx:104 AliMpSlatPadIterator.cxx:105 AliMpSlatPadIterator.cxx:106 AliMpSlatPadIterator.cxx:107 AliMpSlatPadIterator.cxx:108 AliMpSlatPadIterator.cxx:109 AliMpSlatPadIterator.cxx:110 AliMpSlatPadIterator.cxx:111 AliMpSlatPadIterator.cxx:112 AliMpSlatPadIterator.cxx:113 AliMpSlatPadIterator.cxx:114 AliMpSlatPadIterator.cxx:115 AliMpSlatPadIterator.cxx:116 AliMpSlatPadIterator.cxx:117 AliMpSlatPadIterator.cxx:118 AliMpSlatPadIterator.cxx:119 AliMpSlatPadIterator.cxx:120 AliMpSlatPadIterator.cxx:121 AliMpSlatPadIterator.cxx:122 AliMpSlatPadIterator.cxx:123 AliMpSlatPadIterator.cxx:124 AliMpSlatPadIterator.cxx:125 AliMpSlatPadIterator.cxx:126 AliMpSlatPadIterator.cxx:127 AliMpSlatPadIterator.cxx:128 AliMpSlatPadIterator.cxx:129 AliMpSlatPadIterator.cxx:130 AliMpSlatPadIterator.cxx:131 AliMpSlatPadIterator.cxx:132 AliMpSlatPadIterator.cxx:133 AliMpSlatPadIterator.cxx:134 AliMpSlatPadIterator.cxx:135 AliMpSlatPadIterator.cxx:136 AliMpSlatPadIterator.cxx:137 AliMpSlatPadIterator.cxx:138 AliMpSlatPadIterator.cxx:139 AliMpSlatPadIterator.cxx:140 AliMpSlatPadIterator.cxx:141 AliMpSlatPadIterator.cxx:142 AliMpSlatPadIterator.cxx:143 AliMpSlatPadIterator.cxx:144 AliMpSlatPadIterator.cxx:145 AliMpSlatPadIterator.cxx:146 AliMpSlatPadIterator.cxx:147 AliMpSlatPadIterator.cxx:148 AliMpSlatPadIterator.cxx:149 AliMpSlatPadIterator.cxx:150 AliMpSlatPadIterator.cxx:151 AliMpSlatPadIterator.cxx:152 AliMpSlatPadIterator.cxx:153 AliMpSlatPadIterator.cxx:154 AliMpSlatPadIterator.cxx:155 AliMpSlatPadIterator.cxx:156 AliMpSlatPadIterator.cxx:157 AliMpSlatPadIterator.cxx:158 AliMpSlatPadIterator.cxx:159 AliMpSlatPadIterator.cxx:160 AliMpSlatPadIterator.cxx:161 AliMpSlatPadIterator.cxx:162 AliMpSlatPadIterator.cxx:163 AliMpSlatPadIterator.cxx:164 AliMpSlatPadIterator.cxx:165 AliMpSlatPadIterator.cxx:166 AliMpSlatPadIterator.cxx:167 AliMpSlatPadIterator.cxx:168 AliMpSlatPadIterator.cxx:169 AliMpSlatPadIterator.cxx:170 AliMpSlatPadIterator.cxx:171 AliMpSlatPadIterator.cxx:172 AliMpSlatPadIterator.cxx:173 AliMpSlatPadIterator.cxx:174 AliMpSlatPadIterator.cxx:175 AliMpSlatPadIterator.cxx:176 AliMpSlatPadIterator.cxx:177 AliMpSlatPadIterator.cxx:178 AliMpSlatPadIterator.cxx:179 AliMpSlatPadIterator.cxx:180 AliMpSlatPadIterator.cxx:181 AliMpSlatPadIterator.cxx:182 AliMpSlatPadIterator.cxx:183 AliMpSlatPadIterator.cxx:184 AliMpSlatPadIterator.cxx:185 AliMpSlatPadIterator.cxx:186 AliMpSlatPadIterator.cxx:187 AliMpSlatPadIterator.cxx:188 AliMpSlatPadIterator.cxx:189 AliMpSlatPadIterator.cxx:190 AliMpSlatPadIterator.cxx:191 AliMpSlatPadIterator.cxx:192 AliMpSlatPadIterator.cxx:193 AliMpSlatPadIterator.cxx:194 AliMpSlatPadIterator.cxx:195 AliMpSlatPadIterator.cxx:196 AliMpSlatPadIterator.cxx:197 AliMpSlatPadIterator.cxx:198 AliMpSlatPadIterator.cxx:199 AliMpSlatPadIterator.cxx:200 AliMpSlatPadIterator.cxx:201 AliMpSlatPadIterator.cxx:202 AliMpSlatPadIterator.cxx:203 AliMpSlatPadIterator.cxx:204 AliMpSlatPadIterator.cxx:205 AliMpSlatPadIterator.cxx:206 AliMpSlatPadIterator.cxx:207 AliMpSlatPadIterator.cxx:208 AliMpSlatPadIterator.cxx:209 AliMpSlatPadIterator.cxx:210 AliMpSlatPadIterator.cxx:211 AliMpSlatPadIterator.cxx:212 AliMpSlatPadIterator.cxx:213 AliMpSlatPadIterator.cxx:214 AliMpSlatPadIterator.cxx:215 AliMpSlatPadIterator.cxx:216 AliMpSlatPadIterator.cxx:217 AliMpSlatPadIterator.cxx:218 AliMpSlatPadIterator.cxx:219 AliMpSlatPadIterator.cxx:220 AliMpSlatPadIterator.cxx:221 AliMpSlatPadIterator.cxx:222