- Updated for modifs in AliMpFiles
[u/mrichter/AliRoot.git] / MUON / mapping / macros / testReadSector.C
CommitLineData
66e0997c 1// $Id$
0f54a452 2// $MpId: testReadSector.C,v 1.16 2006/01/11 10:00:50 ivana Exp $
66e0997c 3//
4// Test macro for reading sector data.
5
e8c253a0 6#include <iomanip>
7
66e0997c 8void testReadSector(AliMpStationType station = kStation1,
334be4b7 9 AliMpPlaneType plane = kBendingPlane,
10 Bool_t rootInput = false)
66e0997c 11{
334be4b7 12 AliMpSector *sector = 0;
13 if (!rootInput) {
14 AliMpSectorReader r(station, plane);
15 //reader.SetVerboseLevel(1);
16 sector=r.BuildSector();
17
18 // Write sector on Root file
0f54a452 19 TString filePath = AliMpFiles::SectorFilePath(station,plane);
334be4b7 20 filePath.ReplaceAll("zones.dat", "sector.root");
66e0997c 21
334be4b7 22 TFile f(filePath.Data(), "RECREATE");
23 sector->Write();
24 f.Close();
25 }
26 else {
0f54a452 27 TString filePath = AliMpFiles::SectorFilePath(station,plane);
334be4b7 28 filePath.ReplaceAll("zones.dat", "sector.root");
29
30 TFile f(filePath.Data(), "READ");
31 sector = (AliMpSector*)f.Get("Sector");
32 }
33
66e0997c 34 cout << endl;
35
36 // Sector geometry
37 sector->PrintGeometry();
38
39 cout << endl;
40
41 // Find row test
a387ee7c 42 if (plane == kBendingPlane)
43 cout << "0th row low border " << sector->FindRow(TVector2(0., 0.))->GetID() << endl;
44 if (plane == kNonBendingPlane)
45 cout << "0th row low border " << sector->FindRow(TVector2(0., 0.215))->GetID() << endl;
0f54a452 46 cout << "in 0th row " << sector->FindRow(TVector2(0., 2.5))->GetID() << endl;
47 cout << "0th row up border " << sector->FindRow(TVector2(0., 6.72))->GetID() << endl;
48 cout << "in 4th row " << sector->FindRow(TVector2(0., 30.))->GetID() << endl;
66e0997c 49 if (plane == kBendingPlane)
0f54a452 50 cout << "12th row up border " << sector->FindRow(TVector2(0., 89.46))->GetID() << endl;
66e0997c 51 if (plane == kNonBendingPlane)
0f54a452 52 cout << "12th row up border " << sector->FindRow(TVector2(0., 84.84))->GetID() << endl;
66e0997c 53 cout << endl;
54
55 // Find motif position test
e8c253a0 56 Int_t ids[15] = { 19, 14, 9, 32, 36, 136, 187, 212, 207, 220, 1, 131, 239, 243, 250 };
57 for (Int_t i=0; i<15 ; i++) {
58 Int_t id = ids[i];
59 cout << "Motif pos " << std::setw(3) << id;
60 if (!sector->FindRowSegment(id)) {
61 cout << " not found." << endl;
62 }
63 else {
64 cout << " found in : "
65 << sector->FindRow(id)->GetID() << " row, "
66 << " motif id: "
67 << sector->FindRowSegment(id)->GetMotif(0)->GetID().Data()
68 << endl;
69 }
66e0997c 70 }
66e0997c 71 cout << endl;
72
73 // Find motif by coordinates test
74 for (Int_t i=0; i<2 ; i++) {
0f54a452 75 TVector2 pos(0.5, 18.6 - i*2.); // i=0 in motif 1001,
66e0997c 76 // i=1 outside (below) motif 1001
77 AliMpMotif* motif = sector->FindMotif(pos);
78 cout << "In the position " << pos.X() << " " << pos.Y();
79
80 if (motif)
81 cout << " found motif " << motif->GetID() << endl;
82 else
83 cout << " motif not found " << endl;
84 }
85
86 // Find special motif test
e8c253a0 87 if (plane == kNonBendingPlane) {
88
89 Int_t ids[6] = { 20, 46, 47, 74, 75, 76 };
66e0997c 90 for (Int_t i=0; i<6 ; i++) {
e8c253a0 91
92 Int_t id = ids[i];
66e0997c 93 cout << "Motif pos " << id;
94 if (!sector->FindRowSegment(id)) {
95 cout << " not found." << endl;
96 }
97 else {
98 cout << " found in : "
99 << sector->FindRow(id)->GetID() << " row, "
100 << " position : "
101 << sector->FindPosition(id).X() << " " << sector->FindPosition(id).Y()
102 << endl;
103 }
e8c253a0 104 }
105 }
66e0997c 106 cout << endl;
107
108 // Motif map
109 sector->GetMotifMap()->Print();
110
111 delete sector;
112}
113
114
115