Added Bool_t rootInput argument; if set to true, the sector
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testSectorAreaIterator.C
1 // $Id$
2 // $MpId: testSectorAreaIterator.C,v 1.4 2005/09/26 16:05:25 ivana Exp $
3 //
4 // Test macro for iterating over the whole sector
5
6 #include <iomanip>
7
8 class AliMpVPadIterator;
9
10 void 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
50 void testSectorAreaIterator(AliMpStationType station = kStation1,
51                             AliMpPlaneType plane = kBendingPlane,
52                             Bool_t rootInput = false)
53 {
54   AliMpSector *sector = 0;
55   if (!rootInput) {
56     AliMpSectorReader r(station, plane);
57     sector=r.BuildSector();
58   }
59   else  {
60     TString filePath = AliMpFiles::Instance()->SectorFilePath(station,plane);
61     filePath.ReplaceAll("zones.dat", "sector.root"); 
62
63     TFile f(filePath.Data(), "READ");
64     sector = (AliMpSector*)f.Get("Sector");
65   }  
66
67   AliMpSectorSegmentation segmentation(sector);
68
69   AliMpArea area;
70   if ( station == kStation1 )
71     area = AliMpArea(TVector2(450.,450.),TVector2(450.,450.));
72   else   
73     area = AliMpArea(TVector2(600.,600.),TVector2(600.,600.));
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 }