]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/macros/testSt12SectorAreaIterator.C
In Mapping/macros:
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testSt12SectorAreaIterator.C
1 // $Id$
2 // $MpId: testSectorAreaIterator.C,v 1.5 2005/10/28 15:37:12 ivana Exp $
3 //
4 // Test macro for iterating over the whole sector
5
6 #if !defined(__CINT__) || defined(__MAKECINT__)
7
8 #include "AliMpStation12Type.h"
9 #include "AliMpPlaneType.h"
10 #include "AliMpDataProcessor.h"
11 #include "AliMpDataMap.h"
12 #include "AliMpDataStreams.h"
13 #include "AliMpSector.h"
14 #include "AliMpSectorSegmentation.h"
15 #include "AliMpSectorReader.h"
16 #include "AliMpArea.h"
17 #include "AliMpVPadIterator.h"
18 #include "AliMpVPainter.h"
19
20 #include <Riostream.h>
21 #include <TCanvas.h>
22 #include <TMarker.h>
23 #include <TH2.h>
24 #include <TStopwatch.h>
25
26 #endif
27
28 class AliMpVPadIterator;
29
30 void MarkPads(AliMpVPadIterator& it, Double_t xmax, Double_t ymax, 
31               Bool_t print = kTRUE)
32 {
33 // Marks pads according their position.
34 // Fills histogram with pad indices.
35 // Measures time that takes processing of full quadrant 
36 // ---
37
38   Int_t num=0;
39
40   TH2C* histo = new TH2C("pads", "pads", 201, 0, 200, 251, 0, 250); 
41
42   TStopwatch timer;
43   timer.Start();  
44
45   for (it.First(); ! it.IsDone(); it.Next()){
46    
47     if (print) cout << endl 
48                     << setw(5) << ++num 
49                     << " " << it.CurrentItem() << endl;   
50     
51     // mark pads positions
52     TVector2 posi = it.CurrentItem().Position();
53     TMarker* marker = new TMarker( posi.X()/xmax, posi.Y()/ymax, 2);
54     marker->Draw();
55
56     // fill pads indices in the histogram
57     histo->Fill(it.CurrentItem().GetIndices().GetFirst(),
58                 it.CurrentItem().GetIndices().GetSecond());             
59   }
60   
61   TCanvas *canv2 = new TCanvas("canv2");
62   canv2->cd();
63   //histo->SetMinimum(1.5);
64   histo->Draw("box");
65
66   timer.Stop();
67   //timer.Print();
68 }
69
70 void testSectorAreaIterator(AliMq::Station12Type station, AliMp::PlaneType plane)
71 {
72   AliMpDataProcessor mp;
73   AliMpDataMap* dataMap = mp.CreateDataMap("data");
74   AliMpDataStreams dataStreams(dataMap);
75
76   AliMpSectorReader r(dataStreams, station, plane);
77   AliMpSector* sector = r.BuildSector();
78   AliMpSectorSegmentation segmentation(sector);
79
80   AliMpArea area;
81   if ( station == AliMq::kStation1 )
82     area = AliMpArea(TVector2(45.,45.),TVector2(45.,45.));
83   else   
84     area = AliMpArea(TVector2(60.,60.),TVector2(60.,60.));
85   AliMpVPadIterator* iter = segmentation.CreateIterator(area);
86
87   new TCanvas("Graph");
88   AliMpVPainter::CreatePainter(sector)->Draw("ZSSMP");
89
90   TCanvas* canv = new TCanvas("canv");
91   canv->Range(-1,-1,1,1);
92   MarkPads(*iter, TMath::Abs(area.Position().X())+area.Dimensions().X(),
93                   TMath::Abs(area.Position().Y())+area.Dimensions().Y(), kTRUE);
94 }
95      
96 void testSectorAreaIterator()
97 {
98   AliMq::Station12Type  station[2] = { AliMq::kStation1, AliMq::kStation2 }; 
99   AliMp::PlaneType      plane[2]   = { AliMp::kBendingPlane, AliMp::kNonBendingPlane };
100   
101   for ( Int_t is = 0; is < 2; is++ ) {
102     for ( Int_t ip = 0; ip < 2; ip++ ) {
103     
104       cout << "Running testSectorAreaIterator for " 
105            << AliMq::Station12TypeName(station[is]) << "  "
106            << AliMp::PlaneTypeName(plane[ip])  << " ... " << endl;
107        
108       testSectorAreaIterator(station[is], plane[ip]);
109     
110       cout << "... end running " << endl << endl;
111     }  
112   }   
113 }  
114