Replacement for testPlaneAreaIterator.C macro
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testSectorAreaIterator.C
CommitLineData
d8afa711 1// $Id$
2//
3// Test macro for iterating over the whole plane
4
5#include <iomanip>
6
7class AliMpVPadIterator;
8
9void MarkPads(AliMpVPadIterator& it, Double_t xmax, Double_t ymax,
10 Bool_t print = kTRUE)
11{
12// Marks pads according their position.
13// Fills histogram with pad indices.
14// Measures time that takes processing of full quadrant
15// ---
16
17 Int_t num=0;
18
19 TH2C* histo = new TH2C("pads", "pads", 201, 0, 200, 251, 0, 250);
20
21 TStopwatch timer;
22 timer.Start();
23
24 for (it.First(); ! it.IsDone(); it.Next()){
25
26 if (print) cout << endl
27 << setw(5) << ++num
28 << " " << it.CurrentItem() << endl;
29
30 // mark pads positions
31 TVector2 posi = it.CurrentItem().Position();
32 TMarker* marker = new TMarker( posi.X()/xmax, posi.Y()/ymax, 2);
33 marker->Draw();
34
35 // fill pads indices in the histogram
36 histo->Fill(it.CurrentItem().GetIndices().GetFirst(),
37 it.CurrentItem().GetIndices().GetSecond());
38 }
39
40 TCanvas *canv2 = new TCanvas("canv2");
41 canv2->cd();
42 //histo->SetMinimum(1.5);
43 histo->Draw("box");
44
45 timer.Stop();
46 //timer.Print();
47}
48
49void testSectorAreaIterator(AliMpStationType station = kStation1,
50 AliMpPlaneType planeType = kBendingPlane)
51{
52 AliMpReader reader(station, planeType);
53 AliMpSector* sector = reader.BuildSector();
54 AliMpSectorSegmentation segmentation(sector);
55
56 AliMpArea area;
57 if ( station == kStation1 )
58 area = AliMpArea(TVector2(450.,450.),TVector2(450.,450.));
59 else
60 area = AliMpArea(TVector2(600.,600.),TVector2(600.,600.));
61 AliMpVPadIterator* iter = segmentation.CreateIterator(area);
62
63 TCanvas* graph = new TCanvas("Graph");
64 AliMpVPainter::CreatePainter(sector)->Draw("ZSSMP");
65
66 TCanvas *canv = new TCanvas("canv");
67 canv->Range(-1,-1,1,1);
68 MarkPads(*iter, TMath::Abs(area.Position().X())+area.Dimensions().X(),
69 TMath::Abs(area.Position().Y())+area.Dimensions().Y(), kTRUE);
70}