Mapping test macros (D. Guez, I. Hrivnacova)
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testAllIndices.C
1 // $Id$
2 //
3 // Test macro for testing which pad is seen as "existing" by AliMpSector.
4
5 void testAllIndices() 
6 {
7   if (!gInterpreter->IsLoaded("mlibs.C")){ 
8     gROOT->LoadMacro("mlibs.C");
9     gInterpreter->ProcessLine("mlibs()");
10   }  
11
12   AliMpReader r(kStation1, kNonBendingPlane);
13
14   AliMpSector *sector=r.BuildSector();
15   AliMpVPainter* painter = AliMpVPainter::CreatePainter(sector);
16
17   TCanvas* c1 = new TCanvas("view",
18                             "MSectorPainter::Draw() output (view per pad)");
19   painter->Draw("ZSSMP");
20   c1->Update();
21
22   TH2C* histo = new TH2C("histo","Existing pads",90,-0.5,89.5,
23                                                  230,-0.5,229.5);
24   TH2F* histo2 = new TH2F("histo2","Existing positions",950/2,0,950,
25                                                         950/2,0,950);
26   TCanvas* c2 = new TCanvas("c2","Only existing pads are filled");
27   TCanvas* c3 = new TCanvas("c3","Positions");
28
29   AliMpSectorSegmentation segmentation(sector);
30   
31   
32   for (Int_t irow=0;irow<sector->GetNofRows();irow++){
33     AliMpRow* row = sector->GetRow(irow);
34     
35     for (Int_t  iseg=0;iseg<row->GetNofRowSegments();iseg++){
36       AliMpVRowSegment* seg = row->GetRowSegment(iseg);
37       
38       for (Int_t imot=0;imot<seg->GetNofMotifs();imot++){
39         AliMpMotifPosition* motifPos 
40          = sector->GetMotifMap()->FindMotifPosition(seg->GetMotifPositionId(imot));
41          
42         for (Int_t gassNum=0;gassNum<64;gassNum++){
43           if (motifPos->GetMotif()->GetMotifType()->FindConnectionByGassiNum(gassNum)){
44           
45             AliMpPad pad = segmentation.PadByLocation(AliMpIntPair(motifPos->GetID(),gassNum));
46             if (pad != AliMpPad::Invalid()) {
47               histo->Fill (pad.GetIndices().GetFirst(),
48                           pad.GetIndices().GetSecond());
49               histo2->Fill(pad.Position().X(),
50                            pad.Position().Y());
51             }
52           }
53         }
54       }
55     }
56   }
57   c2->cd();
58   histo->Draw("col");
59   c3->cd();
60   histo2->Draw("box");
61 }