]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSegmentationSlatN.cxx
Use only x-symmetry in global to local transformations and delegation.
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationSlatN.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.2  2000/10/09 14:06:18  morsch
19 Some type cast problems of type  (TMath::Sign((Float_t)1.,x)) corrected (P.H.)
20
21 Revision 1.1  2000/10/06 09:00:47  morsch
22 Segmentation class for chambers built out of slats.
23
24 */
25
26 #include "AliMUONSegmentationSlatN.h"
27 #include "AliMUONSegmentationSlatModuleN.h"
28 #include "TArrayI.h"
29 #include "TArrayF.h"
30 #include "TObjArray.h"
31 #include <TMath.h>
32 #include <iostream.h>
33
34 //___________________________________________
35 ClassImp(AliMUONSegmentationSlatN);
36
37
38
39 AliMUONSegmentationSlatN::AliMUONSegmentationSlatN()
40 {
41 // Default constructor
42 }
43
44
45 Float_t AliMUONSegmentationSlatN::Dpx(Int_t isec) const
46 {
47 //
48 // Returns y-pad size for given sector isec
49    return fDpx;
50 }
51
52 Float_t AliMUONSegmentationSlatN::Dpy(Int_t isec) const
53 {
54 //
55 // Returns x-pad size for given sector isec
56 // isec = 100*islat+iregion
57 //
58     Int_t islat, iregion;
59     islat    = isec/100;
60     iregion  = isec%100;
61     return Slat(islat)->Dpy(iregion);
62 }
63
64
65
66 void AliMUONSegmentationSlatN::GlobalToLocal(
67     Int_t ix, Int_t iy, Int_t &islat, Int_t &ixlocal, Int_t &iylocal)
68 {
69 //
70 // Perform local to global transformation for pad coordinates
71 //
72     Int_t iytemp = iy; 
73     Int_t index  = 0;
74     
75     iylocal = iytemp;
76     ix=TMath::Abs(ix);
77     
78 //
79 // Find slat number (index) and iylocal  
80     for (Int_t i=0; i<fNSlats; i++) {
81         if (ix <= Slat(i)->Npx()) {
82             Int_t isec=Slat(i)->Sector(ix,1);
83             iytemp-=Slat(i)->Npy()*(*fNDiv)[isec]/(*fNDiv)[1];
84         }
85         if (iytemp <= 0) break;
86         iylocal = iytemp;
87         index=i+1;
88     }
89     ixlocal=ix;
90     islat=index;
91 }
92
93 void AliMUONSegmentationSlatN::LocalToGlobal(
94     Int_t islat, Int_t ixlocal, Int_t iylocal, Int_t &ix, Int_t &iy)
95 {
96 // Local to global transformation for pad coordinates
97     
98     Int_t i;
99     iy=iylocal;
100     
101 //
102 // Find iy global by adding iy offset from slats below
103     for (i=0; i<islat; i++) {
104         if (ixlocal <= Slat(i)->Npx()) {
105             Int_t isec=Slat(i)->Sector(ixlocal,1);
106             iy+=Slat(i)->Npy()*(*fNDiv)[isec]/(*fNDiv)[1];
107         }
108     }
109 //
110 // Perform symmetry transformation
111     ix=ixlocal*fSym;
112 }
113
114
115 void AliMUONSegmentationSlatN::
116 GetPadI(Float_t x, Float_t y, Float_t z, Int_t &ix, Int_t &iy) 
117 {
118 // Returns pad coordinates for given set of space coordinates
119
120     Int_t islat, i;
121     Float_t xlocal, ylocal;
122 // Transform to local coordinates    
123     AliMUONSegmentationSlat::GlobalToLocal(x,y,z,islat,xlocal,ylocal);
124     Slat(islat)->GetPadI(xlocal, ylocal, ix, iy);
125 // add to local iy offfset from slats below  
126     for (i=0; i<islat; i++) {
127         if (ix <= Slat(i)->Npx()) {
128             Int_t isec=Slat(i)->Sector(ix,1);
129             iy+=Slat(i)->Npy()*(*fNDiv)[isec]/(*fNDiv)[1];
130         }
131     }
132 // Determine sign depending on quadrant
133     ix=ix*Int_t(TMath::Sign((Float_t)1.,x));
134 }
135
136 AliMUONSegmentationSlatModule* AliMUONSegmentationSlatN::
137 CreateSlatModule()
138 {
139     // Factory method for slat module
140     return new AliMUONSegmentationSlatModuleN();
141 }
142
143
144
145
146