]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/macros/testSt12AllIndices.C
In Mapping/macros:
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testSt12AllIndices.C
1 // $Id$
2 // $MpId: testAllIndices.C,v 1.7 2005/08/24 08:53:27 ivana Exp $
3 //
4 // Test macro for testing which pad is seen as "existing" by AliMpSector.
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 "AliMpSectorReader.h"
15 #include "AliMpSectorSegmentation.h" 
16 #include "AliMpVPainter.h" 
17 #include "AliMpRow.h"
18 #include "AliMpVRowSegment.h"
19 #include "AliMpMotifMap.h"
20 #include "AliMpMotifPosition.h"
21 #include "AliMpMotifType.h"
22
23 #include <Riostream.h>
24 #include <TCanvas.h>
25 #include <TString.h>
26 #include <TH2.h>
27
28 #endif
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 testAllIndices(AliMq::Station12Type station, AliMp::PlaneType plane) 
42 {
43   AliMpDataProcessor mp;
44   AliMpDataMap* dataMap = mp.CreateDataMap("data");
45   AliMpDataStreams dataStreams(dataMap);
46
47   AliMpSectorReader r(dataStreams, station, plane);
48
49   AliMpSector *sector=r.BuildSector();
50   AliMpSectorSegmentation segmentation(sector);
51   AliMpVPainter* painter = AliMpVPainter::CreatePainter(sector);
52
53   TCanvas* c1 = CreateTCanvas("view ", 
54                               "MSectorPainter::Draw() output (view per pad) ", 
55                               station, plane);
56   painter->Draw("ZSSMP");
57   c1->Update();
58
59   Int_t maxPadIndexX = segmentation.MaxPadIndexX();
60   Int_t maxPadIndexY = segmentation.MaxPadIndexY();
61   
62   // Define histogram limits
63   Int_t nx = (maxPadIndexX/10 + 1)*10;
64   Int_t ny = (maxPadIndexY/10 + 1)*10;
65   TH2C* histo  = new TH2C("histo","Existing pads", 
66                           nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
67
68   Int_t nx2 = 95/2;
69   Int_t ny2 = 95/2;
70   if (station == AliMq::kStation2) {
71     nx2 = 120/2;
72     ny2 = 120/2;
73   }
74   TH2F* histo2 = new TH2F("histo2","Existing positions",
75                           nx2, 0, nx2*2, ny2, 0, ny2*2);
76
77   // Define canvas
78   TCanvas* c2 = CreateTCanvas("c2 ", "Only existing pads are filled ", station, plane);
79   TCanvas* c3 = CreateTCanvas("c3 ", "Positions ", station, plane);
80   
81   for ( Int_t irow=0; irow<sector->GetNofRows(); irow++ ) {
82     AliMpRow* row = sector->GetRow(irow);
83     
84     for ( Int_t  iseg=0; iseg<row->GetNofRowSegments(); iseg++ ) {
85       AliMpVRowSegment* seg = row->GetRowSegment(iseg);
86       
87       for ( Int_t imot=0; imot<seg->GetNofMotifs(); imot++) {
88         AliMpMotifPosition* motifPos 
89          = sector->GetMotifMap()->FindMotifPosition(seg->GetMotifPositionId(imot));
90          
91         for ( Int_t gassNum=0; gassNum<64; gassNum++ ) {
92           if (motifPos->GetMotif()->GetMotifType()->FindConnectionByGassiNum(gassNum)){
93           
94             AliMpPad pad = segmentation.PadByLocation(AliMpIntPair(motifPos->GetID(),gassNum));
95             if (pad != AliMpPad::Invalid()) {
96               histo->Fill(pad.GetIndices().GetFirst(),
97                           pad.GetIndices().GetSecond());
98               histo2->Fill(pad.Position().X(),
99                            pad.Position().Y());
100             }
101           }
102         }
103       }
104     }
105   }
106   c2->cd();
107   histo->Draw("col");
108   c3->cd();
109   histo2->Draw("box");
110 }
111
112 void testSt12AllIndices()
113 {
114   AliMq::Station12Type  station[2] = { AliMq::kStation1, AliMq::kStation2 }; 
115   AliMp::PlaneType      plane[2]   = { AliMp::kBendingPlane, AliMp::kNonBendingPlane };
116   
117   for ( Int_t is = 0; is < 2; is++ ) {
118     for ( Int_t ip = 0; ip < 2; ip++ ) {
119     
120       cout << "Running testAllIndices for " 
121            << AliMq::Station12TypeName(station[is]) << "  "
122            << AliMp::PlaneTypeName(plane[ip])  << " ... " << endl;
123        
124       testAllIndices(station[is], plane[ip]);
125     
126       cout << "... end running " << endl << endl;
127     }  
128   }   
129 }  
130