]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/macros/testSt12ExistingPads.C
Patch for the pointer to AOD event
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testSt12ExistingPads.C
1 // $Id$
2 // $MpId: testExistingPads.C,v 1.12 2005/10/28 15:36:07 ivana Exp $
3 //
4 // Test macro for testing which pad is seen as "existing" by 
5 // by AliMpSectorSegmentation and AliMpFastSegmentation
6 // To run macro:
7 // root [0] .L testExistingPads.C+
8 // root [1] testExistingPads();
9
10 #if !defined(__CINT__) || defined(__MAKECINT__)
11
12 #include "AliMpStation12Type.h"
13 #include "AliMpPlaneType.h"
14 #include "AliMpDataProcessor.h"
15 #include "AliMpDataMap.h"
16 #include "AliMpDataStreams.h"
17 #include "AliMpSector.h"
18 #include "AliMpSectorReader.h"
19 #include "AliMpSectorSegmentation.h"
20 #include "AliMpFastSegmentation.h"
21 #include "AliMpArea.h"
22 #include "AliMpVPadIterator.h"
23 #include "AliMpVPainter.h"
24
25 #include <Riostream.h>
26 #include <TCanvas.h>
27 #include <TH2.h>
28
29 #endif
30
31 TCanvas* CreateTCanvas(const TString& name, const TString& title,
32                        AliMq::Station12Type station, AliMp::PlaneType plane)
33 {
34   TString newName(name);
35   TString newTitle(title);
36   TString unique = AliMq::Station12TypeName(station) + AliMp::PlaneTypeName(plane);
37   newName += unique;
38   newTitle += unique;
39   return new TCanvas(newName.Data(), newTitle.Data());
40 }                     
41
42 void testExistingPads(AliMq::Station12Type station,AliMp::PlaneType plane)
43 {
44   AliMpDataProcessor mp;
45   AliMpDataMap* dataMap = mp.CreateDataMap("data");
46   AliMpDataStreams dataStreams(dataMap);
47
48   AliMpSectorReader r(dataStreams, station, plane);
49   AliMpSector* sector = r.BuildSector();
50   AliMpSectorSegmentation* segmentation = new AliMpSectorSegmentation(sector);
51   AliMpVPainter* painter = AliMpVPainter::CreatePainter(sector);
52
53   TCanvas* c1 = CreateTCanvas("view ",
54                             "AliMpSectorPainter::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   TCanvas* c2 = CreateTCanvas("c2 ","Only existing pads are filled ",
69                               station, plane);
70
71   for (Int_t i=0; i<maxPadIndexX+1;i++){
72     for (Int_t j=0;j<maxPadIndexY+1;++j){
73
74       if ( segmentation->HasPadByIndices(i,j) ) histo->Fill(i,j);
75     }
76   }
77
78   c2->cd();
79   histo->Draw("box");
80
81   // the same plot with fast segmentation
82   TH2C* histo2 = new TH2C("histo2","Existing pads2", 
83                           nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
84
85   TCanvas* c3 = CreateTCanvas("c3 ","Only existing pads are filled ",
86                               station, plane);
87
88   AliMpFastSegmentation* fast = new AliMpFastSegmentation(segmentation);
89   for (Int_t i=0; i<maxPadIndexX+1;i++){
90     for (Int_t j=0;j<maxPadIndexY+1;++j){
91
92       if ( fast->HasPadByIndices(i,j) ) histo2->Fill(i,j);
93     }
94   }
95
96   c3->cd();
97   histo2->Draw("box");
98   
99   delete fast;
100 }
101
102 void testSt12ExistingPads()
103 {
104   AliMq::Station12Type  station[2] = { AliMq::kStation1, AliMq::kStation2 }; 
105   AliMp::PlaneType      plane[2]   = { AliMp::kBendingPlane, AliMp::kNonBendingPlane };
106   
107   for ( Int_t is = 0; is < 2; is++ ) {
108     for ( Int_t ip = 0; ip < 2; ip++ ) {
109     
110       cout << "Running testExistingPads for " 
111            << AliMq::Station12TypeName(station[is]) << "  "
112            << AliMp::PlaneTypeName(plane[ip])  << " ... " << endl;
113        
114       testExistingPads(station[is], plane[ip]);
115     
116       cout << "... end running " << endl << endl;
117     }  
118   }   
119 }