]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/scripts/ShowCoordinates.C
Bringing CMakeLists under svn maintenance
[u/mrichter/AliRoot.git] / FMD / scripts / ShowCoordinates.C
1 /**
2  * A script to dump the physical coordinates as given by the
3  * geometry. 
4  * 
5  */
6 #include <iomanip>
7
8 /** 
9  * Get the physical coordinates of a strip 
10  * 
11  * @param det Detector
12  * @param rng Ring
13  * @param sec Sector
14  * @param str Strip
15  */
16 void
17 PhysicalCoordinates(UShort_t det, Char_t rng, UShort_t sec, UShort_t str)
18 {
19   Double_t x, y, z;
20   AliFMDGeometry::Instance()->Detector2XYZ(det, rng, sec, str, x, y, z);
21   Double_t phi   = TMath::ATan2(y, x);
22   Double_t r     = TMath::Sqrt(x * x + y * y);
23   Double_t theta = TMath::ATan2(r, z);
24   if (theta < 0) theta += TMath::Pi();
25   Double_t eta   = -TMath::Log(TMath::Tan(theta / 2));
26   Double_t deg   = 180. / TMath::Pi();
27   
28   std::cout << det << rng << "[" 
29             << std::setw(2) << sec << "," 
30             << std::setw(3) << str << "] | "
31             << std::setw(9) << x << "," 
32             << std::setw(9) << y << "," 
33             << std::setw(9) << z << " | " 
34             << std::setw(9) << phi * deg << "," 
35             << std::setw(9) << theta * deg << "," 
36             << std::setw(9) << eta << std::endl;
37 }
38
39 /** 
40  * Show coordinates of all strips 
41  * 
42  */
43 void
44 ShowCoordinates()
45 {
46   AliFMDGeometry::Instance()->Init();
47   AliFMDGeometry::Instance()->InitTransformations();
48   std::cout << std::setw(1+1+1+2+1+3+1) << "Detector" << " | " 
49             << std::setw(9+1+9+1+9) << "Cartisian Coords" << " | " 
50             << std::setw(9+1+9+1+9) << "phi,theta,eta" << "\n"
51             << std::setfill('-') 
52             << std::setw(1+1+1+2+1+3+1+1+1)  << "+"
53             << std::setw(1+9+1+9+1+9+1+1)  << "+"
54             << std::setw(1+9+1+9+1+9+1+1)  << "+" 
55             << std::setfill(' ') << std::endl;
56   for (UShort_t d = 1; d <= 3; d++) {
57     UShort_t nrng = (d == 1 ? 1 : 2);
58     for (UShort_t ir = 0; ir < nrng; ir++) { 
59       Char_t r = (ir == 0 ? 'I' : 'O');
60       UShort_t nsec = (r == 'I' ?  20 :  40);
61       UShort_t nstr = 1; // (r == 'I' ? 512 : 256);
62       for (UShort_t s = 0; s < nsec; s++) { 
63         for (UShort_t t = 0; t < nstr; t++) {
64           PhysicalCoordinates(d, r, s, t);
65         }
66       }
67     }
68   }
69 }
70 //
71 // EOF
72 //