From Laurent:
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testAnyPadIterators.C
CommitLineData
66e0997c 1// $Id$
2//
3// Test macro for reading sector, and iterate over it
4
5class AliMpVPadIterator;
6void MarkPads(AliMpVPadIterator& it,Int_t xmax,Int_t ymax,Bool_t print=kTRUE)
7{
8// This function works with pad iterator, no matter which kind of iterator
72d8f376 9// it is. So it can be used for drawing all pad of the sector (AliMpSectorPadIterator)
66e0997c 10// or all pad around a given pad (AliMpNeighboursPadIterator), as with pads
11// of a given motif type (AliMpMotifTypePadIterator)
12
13 Int_t num=0;
14
15 for (it.First(); ! it.IsDone(); it.Next()){
16 AliMpIntPair indices = it.CurrentItem().GetIndices();
17 if (print) cout<<"Iterator number "<< num++ << " at "<< indices <<endl;
18 TMarker* marker = new TMarker( (Double_t)indices.GetFirst() /xmax,
19 (Double_t)indices.GetSecond()/ymax,
20 2);
21 marker->Draw();
22 }
23}
24
25void testAnyPadIterators(AliMpStationType station = kStation1,
26 AliMpPlaneType plane = kBendingPlane,
27 Int_t i=50, Int_t j=50)
28{
29 AliMpReader r(station, plane);
30 AliMpSector* sect = r.BuildSector();
31
32 TCanvas *canv = new TCanvas("canv");
33 canv->Divide(2,2);
34 //canv_1->Divide(2);
35
36 canv->cd(1);
72d8f376 37 MarkPads(AliMpSectorPadIterator(sect), 150, 250, kFALSE);
66e0997c 38 canv->cd(2);
72d8f376 39 AliMpVMotif* motif = sect->FindMotif(TVector2(300,30));
66e0997c 40
41 if (motif) {
42 AliMpMotifType* motifType = motif->GetMotifType();
43 MarkPads(AliMpMotifTypePadIterator(motifType),15,15);
e8c253a0 44 cout<<"______________ MotifType " << motifType->GetID()
45 <<"__________________________"<<endl;
66e0997c 46 } else cout<<"No motif found at given position..."<<endl;
47
48 canv->cd(3);
49 //MarkPads(*AliMpPadIteratorPtr(AliMpSectorSegmentation(sect)->CreateIterator(AliMpIntPair(i,j)))
50 AliMpSectorSegmentation segm(sect);
51 AliMpPad pad = segm.PadByIndices(AliMpIntPair(i,j));
52 MarkPads(AliMpNeighboursPadIterator(&AliMpSectorSegmentation(sect),pad)
53 ,i+8,j+8);
54 cout<<"________________ Neighbours __________________________"<<endl;
55 canv->cd(4);
e8c253a0 56 Int_t motifPosId = 20;
57 if (plane == kNonBendingPlane) motifPosId = 19;
66e0997c 58 AliMpMotifPosition* motifPos = sect->GetMotifMap()->FindMotifPosition(motifPosId);
59 if (motifPos){
60 //MarkPads(*AliMpPadIteratorPtr(motifPos->CreateIterator()),15,15);
61 MarkPads(AliMpMotifPositionPadIterator(motifPos),15,15);
62 cout<<"_________________ MotifPosition _________________________"<<endl;
63 }
66e0997c 64}