Mapping test macros (D. Guez, I. Hrivnacova)
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testPlaneAreaIterator.C
1 // $Id$
2 //
3 // Test macro for iterating over the whole plane
4
5 #include <iomanip>
6
7 class AliMpVPadIterator;
8
9 void 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 plane. 
15 // ---
16
17   Int_t num=0;
18
19   TH2C* histo = new TH2C("pads", "pads", 401, -200, 200, 501, -250, 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
49 void testPlaneAreaIterator(AliMpStationType station = kStation1,
50                   AliMpPlaneType planeType = kBendingPlane, 
51                   AliMpArea area = AliMpArea(TVector2(0.,0.),TVector2(900.,900.)))
52 {
53   AliMpPlane* plane = AliMpPlane::Create(station, planeType);
54   AliMpPlaneSegmentation planeSeg(plane);
55   AliMpVPadIterator* iter = planeSeg.CreateIterator(area);
56
57   TCanvas* graph = new TCanvas("Graph");
58   graph->Divide(2);
59   graph->cd(1);
60   AliMpVPainter::CreatePainter(plane->GetFrontSector())->Draw("ZSSMP");
61   graph->cd(2);
62   AliMpVPainter::CreatePainter(plane->GetBackSector())->Draw("ZSSMP");
63   TCanvas *canv = new TCanvas("canv");
64   canv->Range(-1,-1,1,1);
65   
66   MarkPads(*iter, TMath::Abs(area.Position().X())+area.Dimensions().X(),
67                   TMath::Abs(area.Position().Y())+area.Dimensions().Y(), kTRUE);
68 }