]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/macros/testSt12SectorAreaIterator.C
Patch for the pointer to AOD event
[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 TCanvas* CreateTCanvas(const TString& name, const TString& title,
31                        AliMq::Station12Type station, AliMp::PlaneType plane)
32 {
33   TString newName(name);
34   TString newTitle(title);
35   TString unique = AliMq::Station12TypeName(station) + AliMp::PlaneTypeName(plane);
36   newName += unique;
37   newTitle += unique;
38   return new TCanvas(newName.Data(), newTitle.Data());
39 }                     
40
41 void MarkPads(AliMpVPadIterator& it, Double_t xmax, Double_t ymax, 
42               AliMq::Station12Type station, AliMp::PlaneType plane,
43               Bool_t print = kTRUE)
44 {
45 // Marks pads according their position.
46 // Fills histogram with pad indices.
47 // Measures time that takes processing of full quadrant 
48 // ---
49
50   Int_t num=0;
51
52   TH2C* histo = new TH2C("pads", "pads", 201, 0, 200, 251, 0, 250); 
53
54   TStopwatch timer;
55   timer.Start();  
56
57   for (it.First(); ! it.IsDone(); it.Next()){
58    
59     if (print) cout << endl 
60                     << setw(5) << ++num 
61                     << " " << it.CurrentItem() << endl;   
62     
63     // mark pads positions
64     Double_t posix = it.CurrentItem().GetPositionX();
65     Double_t posiy = it.CurrentItem().GetPositionY();
66     TMarker* marker = new TMarker( posix/xmax, posiy/ymax, 2);
67     marker->Draw();
68
69     // fill pads indices in the histogram
70     histo->Fill(it.CurrentItem().GetIx(), it.CurrentItem().GetIy());            
71   }
72   
73   TCanvas* canv2 = CreateTCanvas("canv2 ", " ", station, plane);
74   canv2->cd();
75   //histo->SetMinimum(1.5);
76   histo->Draw("box");
77
78   timer.Stop();
79   //timer.Print();
80 }
81
82 void testSectorAreaIterator(AliMq::Station12Type station, AliMp::PlaneType plane)
83 {
84   AliMpDataProcessor mp;
85   AliMpDataMap* dataMap = mp.CreateDataMap("data");
86   AliMpDataStreams dataStreams(dataMap);
87
88   AliMpSectorReader r(dataStreams, station, plane);
89   AliMpSector* sector = r.BuildSector();
90   AliMpSectorSegmentation segmentation(sector);
91
92   AliMpArea area;
93   if ( station == AliMq::kStation1 )
94     area = AliMpArea(45.,45.,45.,45.);
95   else   
96     area = AliMpArea(60.,60.,60.,60.);
97   AliMpVPadIterator* iter = segmentation.CreateIterator(area);
98
99   CreateTCanvas("Graph ", " ", station, plane);
100   AliMpVPainter::CreatePainter(sector)->Draw("ZSSMP");
101
102   TCanvas* canv = CreateTCanvas("canv ", " ", station, plane);
103   canv->Range(-1,-1,1,1);
104   MarkPads(*iter, TMath::Abs(area.GetPositionX())+area.GetDimensionX(),
105                   TMath::Abs(area.GetPositionY())+area.GetDimensionY(), 
106                   station, plane, kTRUE);
107 }
108      
109 void testSt12SectorAreaIterator()
110 {
111   AliMq::Station12Type  station[2] = { AliMq::kStation1, AliMq::kStation2 }; 
112   AliMp::PlaneType      plane[2]   = { AliMp::kBendingPlane, AliMp::kNonBendingPlane };
113   
114   for ( Int_t is = 0; is < 2; is++ ) {
115     for ( Int_t ip = 0; ip < 2; ip++ ) {
116     
117       cout << "Running testSectorAreaIterator for " 
118            << AliMq::Station12TypeName(station[is]) << "  "
119            << AliMp::PlaneTypeName(plane[ip])  << " ... " << endl;
120        
121       testSectorAreaIterator(station[is], plane[ip]);
122     
123       cout << "... end running " << endl << endl;
124     }  
125   }   
126 }  
127