Code from MUON-dev joined
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationTrigger.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.1.2.1  2000/06/09 21:47:24  morsch
19 Code from AliMUONSegResTrigger.cxx
20
21 */
22
23 /*
24 old Log:
25 AliMUONSegResTrigger.cxx,v $
26 Revision 1.1.2.3  2000/04/26 12:32:39  morsch
27 Mods by P. Crochet:
28 - adapted to the new Trigger chamber geometry
29 - method SetZScale removed
30
31 Revision 1.1.2.2  2000/02/21 16:13:33  morsch
32 Full cluster simulation activated by uncommenting corresponding lines in IntXY()
33
34 Revision 1.1.2.1  2000/02/17 14:32:40  morsch
35 Draft version from P. Crochet
36
37 */
38
39 #include "AliMUONSegmentationTrigger.h"
40 #include <TMath.h>
41 #include <TRandom.h>
42 #include <TArc.h>
43 #include "AliMUONChamber.h"
44 #include <iostream.h>
45  
46 ClassImp(AliMUONSegmentationTrigger)
47
48 void AliMUONSegmentationTrigger::Init(AliMUONChamber* Chamber)
49 {
50   // initialize Module geometry
51   cout << "Initialize Trigger Chamber Module Geometry " << "\n";    
52
53   Float_t zPos=Chamber->Z();
54   Float_t z1Pos=1603.5;
55   fZscale = zPos/z1Pos;
56
57   static Int_t nModule=126;
58   fgNmodule = nModule; 
59 // conv : line-column (line : from top to bottom, column : from left to right)
60   static Int_t num[126]=
61   {11,12,13,14,15,16,17,         // right side of the chamber
62    21,22,23,24,25,26,27,
63    31,32,33,34,35,36,37,
64    41,42,43,44,45,46,47,
65    51,52,53,54,55,56,57,
66    61,62,63,64,65,66,67,
67    71,72,73,74,75,76,77,
68    81,82,83,84,85,86,87,
69    91,92,93,94,95,96,97,   
70    -11,-12,-13,-14,-15,-16,-17,     // left side of the chamber
71    -21,-22,-23,-24,-25,-26,-27,
72    -31,-32,-33,-34,-35,-36,-37,
73    -41,-42,-43,-44,-45,-46,-47,
74    -51,-52,-53,-54,-55,-56,-57,
75    -61,-62,-63,-64,-65,-66,-67,
76    -71,-72,-73,-74,-75,-76,-77,
77    -81,-82,-83,-84,-85,-86,-87,
78    -91,-92,-93,-94,-95,-96,-97};
79   fgNum     = num; 
80
81   static Int_t nStripX[126]=
82   {16,16,16,16,16,16,16,  // right side of the chamber 
83    32,32,32,32,32,32,16,
84    32,32,32,32,32,32,16,
85    48,64,64,32,32,32,16,
86    0,64,64,32,32,32,16,
87    48,64,64,32,32,32,16,
88    32,32,32,32,32,32,16,
89    32,32,32,32,32,32,16,
90    16,16,16,16,16,16,16,  // left side of the chamber
91    16,16,16,16,16,16,16,
92    32,32,32,32,32,32,16,
93    32,32,32,32,32,32,16,
94    48,64,64,32,32,32,16,
95    0,64,64,32,32,32,16,
96    48,64,64,32,32,32,16,
97    32,32,32,32,32,32,16,
98    32,32,32,32,32,32,16,
99    16,16,16,16,16,16,16};
100   fgNstripx = nStripX;
101   
102   static Int_t nStripY[126]=
103   { 8, 8, 8, 8, 8, 8,16,  // right side of the chamber
104     8, 8, 8, 8, 8, 8,16,
105     16,16,16,16,16, 8,16,
106     16,16,16,16,16, 8,16,
107     0, 8,16,16,16, 8,16,
108     16,16,16,16,16, 8,16,
109     16,16,16,16,16, 8,16,
110     8, 8, 8, 8, 8, 8,16,
111     8, 8, 8, 8, 8, 8,16,  // left side of the chamber
112     8, 8, 8, 8, 8, 8,16,  // right side of the chamber
113     8, 8, 8, 8, 8, 8,16,
114     16,16,16,16,16, 8,16,
115     16,16,16,16,16, 8,16,
116     0, 8,16,16,16, 8,16,
117     16,16,16,16,16, 8,16,
118     16,16,16,16,16, 8,16,
119     8, 8, 8, 8, 8, 8,16,
120     8, 8, 8, 8, 8, 8,16};
121   fgNstripy = nStripY;
122   
123   static Float_t xCmin[126]=
124   {0.,34.,68.,102.,136.,170.,204., // right
125    0.,34.,68.,102.,136.,170.,204.,
126    0.,34.,68.,102.,136.,170.,204.,
127    0.,34.,68.,102.,136.,170.,204.,
128    0.,51.,68.,102.,136.,170.,204.,
129    0.,34.,68.,102.,136.,170.,204.,
130    0.,34.,68.,102.,136.,170.,204.,
131    0.,34.,68.,102.,136.,170.,204.,
132    0.,34.,68.,102.,136.,170.,204.,
133    -34.,-68.,-102.,-136.,-170.,-204.,-272., //left
134    -34.,-68.,-102.,-136.,-170.,-204.,-272.,
135    -34.,-68.,-102.,-136.,-170.,-204.,-272.,
136    -34.,-68.,-102.,-136.,-170.,-204.,-272.,
137    0.,-68.,-102.,-136.,-170.,-204.,-272.,
138    -34.,-68.,-102.,-136.,-170.,-204.,-272.,
139    -34.,-68.,-102.,-136.,-170.,-204.,-272.,
140    -34.,-68.,-102.,-136.,-170.,-204.,-272.,
141    -34.,-68.,-102.,-136.,-170.,-204.,-272.};
142   fgXcmin   = xCmin;
143   
144   static Float_t xCmax[126]=
145   {34.,68.,102.,136.,170.,204.,272., //right
146    34.,68.,102.,136.,170.,204.,272.,
147    34.,68.,102.,136.,170.,204.,272.,
148    34.,68.,102.,136.,170.,204.,272.,
149    0.,68.,102.,136.,170.,204.,272.,
150    34.,68.,102.,136.,170.,204.,272.,
151    34.,68.,102.,136.,170.,204.,272.,
152    34.,68.,102.,136.,170.,204.,272.,
153    34.,68.,102.,136.,170.,204.,272., 
154    0.,-34.,-68.,-102.,-136.,-170.,-204., // left
155    0.,-34.,-68.,-102.,-136.,-170.,-204.,
156    0.,-34.,-68.,-102.,-136.,-170.,-204.,
157    0.,-34.,-68.,-102.,-136.,-170.,-204.,
158    0.,-51.,-68.,-102.,-136.,-170.,-204.,
159    0.,-34.,-68.,-102.,-136.,-170.,-204.,
160    0.,-34.,-68.,-102.,-136.,-170.,-204.,
161    0.,-34.,-68.,-102.,-136.,-170.,-204.,
162    0.,-34.,-68.,-102.,-136.,-170.,-204.};
163   fgXcmax   = xCmax;
164
165   static Float_t yCmin[126];
166   static Float_t yCmax[126];
167   Float_t y1Cmin[126];
168   Float_t y1Cmax[126];
169
170   Float_t dz=7.2;
171   Float_t z1PosPlus=z1Pos+dz/2.;
172   Float_t z1PosMinus=z1Pos-dz/2.;
173
174   Float_t z1pm=z1PosPlus/z1PosMinus;
175   Float_t z1mp=z1PosMinus/z1PosPlus;
176
177   cout << " fZscale = " << fZscale << "\n";
178
179 // calculate yCmin and yCmax 
180   for (Int_t i=62; i>=0; i--) {
181     Int_t j=ModuleNumber(-num[i]);  // i == right, j == left 
182     if (Int_t(num[i]/10)==5) {  // start with middle chamber
183       if (num[i]==51) {         // special case (empty module)
184         yCmin[i]=yCmax[i]=yCmin[j]=yCmax[j]=0.;
185       } else {
186         y1Cmin[i]=y1Cmin[j]=-34;
187         y1Cmax[i]=y1Cmax[j]=34;
188         yCmin[i]=yCmin[j]=-34.;
189         yCmax[i]=yCmax[j]=34.;
190       }
191     } else if (Int_t(num[i]/10)==4) { // up
192       if (num[i]!=41) {       
193         y1Cmin[i]=y1Cmax[i+7]*z1pm;
194         y1Cmax[i]=y1Cmin[i]+68.;
195         yCmin[i]=y1Cmin[i];
196         yCmax[i]=yCmin[i]+68.;
197
198         y1Cmin[j]=y1Cmax[j+7]*z1mp;
199         y1Cmax[j]=y1Cmin[j]+68.;
200         yCmin[j]=y1Cmin[j];
201         yCmax[j]=yCmin[j]+68.;
202       } else { 
203         y1Cmin[i]=y1Cmin[ModuleNumber(42)]+17;
204         y1Cmax[i]=y1Cmin[i]+51.;
205         yCmin[i]=y1Cmin[i];
206         yCmax[i]=yCmin[i]+51.;
207
208         y1Cmin[j]=y1Cmin[ModuleNumber(-42)]+17;
209         y1Cmax[j]=y1Cmin[j]+51.;
210         yCmin[j]=y1Cmin[j];
211         yCmax[j]=yCmin[j]+51.;
212       }
213     } else if (Int_t(num[i]/10)==3) { 
214       y1Cmin[i]=y1Cmax[i+7]*z1mp;
215       y1Cmax[i]=y1Cmin[i]+68.;
216       yCmin[i]=y1Cmin[i];
217       yCmax[i]=yCmin[i]+68.;
218
219       y1Cmin[j]=y1Cmax[j+7]*z1pm;
220       y1Cmax[j]=y1Cmin[j]+68.;
221       yCmin[j]=y1Cmin[j];
222       yCmax[j]=yCmin[j]+68.;
223     } else if (Int_t(num[i]/10)==2) {
224       y1Cmin[i]=y1Cmax[i+7]*z1pm;
225       y1Cmax[i]=y1Cmin[i]+68.;
226       yCmin[i]=y1Cmin[i];
227       yCmax[i]=yCmin[i]+68.;
228
229       y1Cmin[j]=y1Cmax[j+7]*z1mp;
230       y1Cmax[j]=y1Cmin[j]+68.;
231       yCmin[j]=y1Cmin[j];
232       yCmax[j]=yCmin[j]+68.;
233     } else if (Int_t(num[i]/10)==1) {
234       y1Cmin[i]=y1Cmax[i+7]*z1mp;
235       y1Cmax[i]=y1Cmin[i]+68.;
236       yCmin[i]=y1Cmin[i];
237       yCmax[i]=yCmin[i]+68.;
238
239       y1Cmin[j]=y1Cmax[j+7]*z1pm;
240       y1Cmax[j]=y1Cmin[j]+68.;
241       yCmin[j]=y1Cmin[j];
242       yCmax[j]=yCmin[j]+68.;
243     }
244   }
245
246   for (Int_t i=0; i<63; i++) {      // second loop (fill lower part)
247     Int_t j=ModuleNumber(-num[i]);  // i == right, j == left 
248     if (TMath::Abs(Int_t(num[i]/10))==6) { 
249       yCmin[i]=-yCmax[i-14];
250       yCmax[i]=-yCmin[i-14];
251       yCmin[j]=-yCmax[j-14];
252       yCmax[j]=-yCmin[j-14];
253     } else if (TMath::Abs(Int_t(num[i]/10))==7) { 
254       yCmin[i]=-yCmax[i-28];
255       yCmax[i]=-yCmin[i-28];
256       yCmin[j]=-yCmax[j-28];
257       yCmax[j]=-yCmin[j-28];
258     } else if (TMath::Abs(Int_t(num[i]/10))==8) { 
259       yCmin[i]=-yCmax[i-42];
260       yCmax[i]=-yCmin[i-42];
261       yCmin[j]=-yCmax[j-42];
262       yCmax[j]=-yCmin[j-42];
263     } else if (TMath::Abs(Int_t(num[i]/10))==9) { 
264       yCmin[i]=-yCmax[i-56];
265       yCmax[i]=-yCmin[i-56];
266       yCmin[j]=-yCmax[j-56];
267       yCmax[j]=-yCmin[j-56];
268     } 
269   }
270
271   fgYcmin   = yCmin;
272   fgYcmax   = yCmax;
273   
274   fNpx=124;
275   fNpy=64;  
276
277   cout << "---------------------------------------------------- \n";   
278
279 }
280
281 //------------------------------------------------------------------
282 Int_t AliMUONSegmentationTrigger::ModuleNumber(Int_t imodule){
283 // returns module number (from 0 to 126) corresponding to module imodule
284   Int_t imod=0;
285   for (Int_t i=0; i<fgNmodule; i++) {
286     if (fgNum[i]==imodule) { 
287       imod=i;
288       break;
289     }
290   }
291   return imod;
292 }
293
294 //------------------------------------------------------------------
295 Float_t AliMUONSegmentationTrigger::StripSizeX(Int_t imodule){
296 // Returns x-strip size for given module imodule
297
298   Int_t absimodule=TMath::Abs(imodule); 
299   Int_t moduleNum=ModuleNumber(imodule);
300   if (fgNum[absimodule]==51) {
301     return 0; 
302   } else {
303     return TMath::Abs((fgYcmax[moduleNum]-fgYcmin[moduleNum])/
304                       fgNstripx[moduleNum]);
305   }
306 }
307
308 //------------------------------------------------------------------
309 Float_t AliMUONSegmentationTrigger::StripSizeY(Int_t imodule){
310 // Returns y-strip size for given module imodule
311         
312   Int_t absimodule=TMath::Abs(imodule); 
313   Int_t moduleNum=ModuleNumber(imodule);
314   if (fgNum[absimodule]==51) {
315     return 0;
316   } else {
317     return TMath::Abs((fgXcmax[moduleNum]-fgXcmin[moduleNum])/
318                       fgNstripy[moduleNum]);
319   }
320 }
321
322 //------------------------------------------------------------------   
323 void AliMUONSegmentationTrigger::SetHit(Float_t xhit, Float_t yhit)
324 {
325     // Sets virtual hit position, needed for evaluating pad response 
326     // outside the tracking program 
327     
328   fxhit=xhit;
329   fyhit=yhit;
330 }