Bug fix after sect renamed to sector
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testNeighboursPadIterator.C
1 // $Id$
2 // $MpId: testNeighboursPadIterator.C,v 1.10 2005/10/28 15:36:08 ivana Exp $
3 //
4 // Test macro for reading  sector, and iterate over it
5
6 void testNeighboursPadIterator(AliMpStationType station = kStation1,
7                                AliMpPlaneType plane = kBendingPlane, 
8                                Bool_t rootInput = false,
9                                Int_t i=50, Int_t j=50)
10 {
11   AliMpSector *sector = 0;
12   if (!rootInput) {
13     AliMpSectorReader r(station, plane);
14     sector=r.BuildSector();
15   }
16   else  {
17     TString filePath = AliMpFiles::SectorFilePath(station,plane);
18     filePath.ReplaceAll("zones.dat", "sector.root"); 
19
20     TFile f(filePath.Data(), "READ");
21     sector = (AliMpSector*)f.Get("Sector");
22   }  
23
24   AliMpSectorSegmentation segm(sector);  
25   
26   TCanvas *can = new TCanvas("canv");
27
28   const Double_t xmax=75;
29   const Double_t ymax=120;
30   
31   Int_t num=0;
32
33   AliMpPad pad = segm.PadByIndices(AliMpIntPair(i,j));
34   AliMpNeighboursPadIterator it = AliMpNeighboursPadIterator(&segm, pad,kFALSE);
35   
36   for (it.First(); ! it.IsDone(); it.Next()) {
37     AliMpIntPair indices = it.CurrentItem().GetIndices();
38     cout<<"Iterator number "<< num++ << " at "<< indices <<endl;
39     TMarker* marker = new TMarker( (Double_t)indices.GetFirst() /xmax,
40                                    (Double_t)indices.GetSecond()/ymax,
41                                    2);
42     marker->Draw();
43   }
44   
45   AliMpVPadIterator* iter2
46     = segm.CreateIterator(AliMpArea(pad.Position(),2.*pad.Dimensions()*1.1));
47
48   Int_t i=0;
49   for( iter2->First(); !iter2->IsDone() && i<10; iter2->Next()) {
50     Int_t ix = iter2->CurrentItem().GetIndices().GetFirst();
51     Int_t iy = iter2->CurrentItem().GetIndices().GetSecond();
52     cout<<"Iterator number "<< i << " at "<< iter2->CurrentItem().GetIndices() <<endl;
53     i++;
54   }
55   
56   delete iter2;
57   delete sector;
58 }