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