]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSmoduleSSD.cxx
Correct syntax accepted by g++ but not standard for static members, remove minor...
[u/mrichter/AliRoot.git] / ITS / AliITSmoduleSSD.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  1999/09/29 09:24:20  fca
19 Introduction of the Copyright and cvs Log
20
21 */
22
23
24 #include "AliITSmoduleSSD.h"
25
26     //Technical parameters of detector
27 const Float_t   AliITSmoduleSSD::kStereo = 0.0175;  //Stereo Angle 17.5 mrad
28 const Float_t   AliITSmoduleSSD::kTan = 0.0175;  
29 const Int_t     AliITSmoduleSSD::kNStrips = 768;    //Number of strips on each side
30 const Float_t   AliITSmoduleSSD::kPitch = 0.095;    //Distance strip - strip (mm)
31 const Float_t   AliITSmoduleSSD::kX = 72.96;        //X size (mm)
32 const Float_t   AliITSmoduleSSD::kY = 0.3;          //Y size (mm)
33 const Float_t   AliITSmoduleSSD::kZ = 40;           //Thickness (mm)
34     
35     // <------------------------------
36   
37     //______________________________________________________________
38     //  
39     // Parameters for simulation
40     //______________________________________________________________
41       
42 const Float_t   AliITSmoduleSSD::kSigmaP = 0.003;     //Gaussian sigm
43 const Float_t   AliITSmoduleSSD::kSigmaN = 0.002;
44 const Int_t     AliITSmoduleSSD::kSteps  = 10;        //Number of steps 
45 const Int_t     AliITSmoduleSSD::kTresholdP = 1500;    
46 const Int_t     AliITSmoduleSSD::kTresholdN = 2500; 
47    
48
49
50 ClassImp(AliITSmoduleSSD)
51
52 //____________________________________________________________________
53 //
54 //  Constructor
55 //____________________________________________________________________
56 //                                     
57
58
59 AliITSmoduleSSD::AliITSmoduleSSD() {
60     
61
62     //Invalid Strips parameters
63     
64     fInvalidP = new TArrayS(0);
65     fInvalidN = new TArrayS(0);
66     
67     fNInvalidP = 0;
68     fNInvalidN = 0;
69     
70     
71     //DCS parameters
72     
73     fGainP = 83;
74     fGainN = 83;   
75     fSNRatioP = 600;
76     fSNRatioP = 500;
77     
78     fCouplingPR = 0.021;
79     fCouplingPL = 0.026;
80     fCouplingNR = 0.013;
81     fCouplingNL = 0.010;
82
83 }
84
85 AliITSmoduleSSD::AliITSmoduleSSD(Int_t index) {
86                                 
87     fIndex = index;     
88     
89     //Invalid Strips parameters
90     
91     fInvalidP = new TArrayS(0);
92     fInvalidN = new TArrayS(0);
93     
94     fNInvalidP = 0;
95     fNInvalidN = 0;
96     
97     
98     //DCS parameters
99     
100     fGainP = 83;
101     fGainN = 83;   
102     fSNRatioP = 600;
103     fSNRatioP = 500;
104     
105     fCouplingPR = 0.021;
106     fCouplingPL = 0.026;
107     fCouplingNR = 0.013;
108     fCouplingNL = 0.010;        
109 }
110
111 AliITSmoduleSSD::~AliITSmoduleSSD() {
112    
113     if (!fInvalidP) delete fInvalidP;
114     if (!fInvalidN) delete fInvalidN;                           
115 }
116
117
118 //____________________________________________________________________
119 //
120 //  Inalid strips menagement
121 //____________________________________________________________________
122 //                           
123
124
125
126 void AliITSmoduleSSD::SetInvalidP(Int_t strip, Bool_t b) {
127     
128     Bool_t already = kFALSE;
129     Int_t i;
130     
131     for (i=0; i<fNInvalidP; i++) {
132         if ((*fInvalidP)[i] == strip) {
133            already = kTRUE;
134            break;
135         }
136     }
137     
138     if (!already && b) {
139        (*fInvalidP)[fNInvalidP++] = strip;
140     } 
141 }
142
143 void AliITSmoduleSSD::SetInvalidMC(Float_t m, Float_t s) {
144
145     fNInvalid = m;
146     fISigma = s;
147     SetInvalidMC();
148 }
149
150 void AliITSmoduleSSD::SetInvalidMC() {
151
152     Int_t m = (Int_t)gRandom->Gaus(fNInvalid, fISigma);
153     
154     for(int i=0; i<m; i++) {
155        SetInvalidP((Int_t)(gRandom->Rndm()*kNStrips), kTRUE);
156     }
157     
158 }
159
160 Bool_t AliITSmoduleSSD::IsValidP(Int_t n) {
161     
162     for(Int_t i=0; i<fNInvalidP; i++) 
163        if ((*fInvalidP)[i] == n) return kFALSE;
164     return kTRUE;    
165 }
166
167 Bool_t AliITSmoduleSSD::IsValidN(Int_t n) {
168     
169     for(Int_t i=0; i<fNInvalidN; i++) 
170        if ((*fInvalidN)[i] == n) return kFALSE;
171     return kTRUE;    
172 }
173
174
175 //____________________________________________________________________
176 //
177 //  Add digit
178 //____________________________________________________________________
179 // 
180
181 /*********************************************************************
182
183 * AddDigits 
184 * sets paramerers: layer, ladder detector
185 * scan tracks wich produced this digit
186 * creates new SSD DIGTS
187 * call ITS to add digit to its Array
188 * set index frm ITS in its own array
189 *
190 * S.Radomski 17.09.1999
191 *
192 *********************************************************************/
193
194 void AliITSmoduleSSD::AddDigit(Int_t strNo, Int_t s, Bool_t p) {
195  
196     Int_t tracks[3];
197     Int_t digits[4];
198     AliITSdigit *t = (AliITSdigit*) (new AliITSdigitSSD(tracks, digits, 
199                                                         strNo, s, p));
200     
201     fIdigits->AddAt(((AliITS *)fITS)->AddDigit(t), fNdigits++);
202 }
203
204
205 //____________________________________________________________________
206 //
207 //  Hits to digits
208 //____________________________________________________________________
209 //                          
210
211
212
213 void AliITSmoduleSSD::HitToDigit() {
214
215     Int_t i;                           //for iteration
216     fP = new TArrayI(768);
217     fN = new TArrayI(768); 
218     
219     fPtrack1 = new TArrayI(768);
220     fPtrack2 = new TArrayI(768);
221     fPtrack3 = new TArrayI(768);
222     
223     fNtrack1 = new TArrayI(768);
224     fNtrack2 = new TArrayI(768);
225     fNtrack3 = new TArrayI(768);
226     
227     for(i=0; i<kNStrips; i++) {
228        (*fN)[i] = 0;
229        (*fP)[i] = 0;
230     } // end for i
231      
232     for(i=0; i<fNhitsM; i++) HitToDigit(i);
233
234     ApplyCoupling();    
235     ApplyNoise();
236         
237     for(i=0; i<fNInvalidP; i++) (*fP)[(*fInvalidP)[i]] = -20;
238     for(i=0; i<fNInvalidN; i++) (*fN)[(*fInvalidN)[i]] = -20;
239     
240     for(i=0; i<kNStrips; i++) 
241        if ((*fP)[i]>kTresholdP) AddDigit(i+1, (*fP)[i], kTRUE);
242     
243     for(i=0; i<kNStrips; i++)
244        if ((*fN)[i]>kTresholdN) AddDigit(i+1, (*fN)[i], kFALSE);
245        
246     delete fN;
247     delete fP;
248     
249     delete fPtrack1;
250     delete fPtrack2;
251     delete fPtrack3;
252     
253     delete fPtrack1;
254     delete fPtrack2;
255     delete fPtrack3;
256  
257 }
258
259
260
261 void AliITSmoduleSSD::HitToDigit(Int_t hitNo) {
262     
263     Int_t stripP, stripN, i;
264     Float_t dsP, dsN;
265     Float_t sP, sN;
266     Float_t EP, EN;
267     AliITShit *hit = (AliITShit*)((*fHitsM)[hitNo]);
268     Float_t dZ = kZ/kSteps*1000, l;
269
270     if(hit->GetIonization()==0.0) return;
271
272     Float_t x =  hit->GetXG();
273     Float_t y =  hit->GetYG();
274
275     Float_t dx = 0.0; //TMath::Tan(hit->fTheta)*kZ/kSteps;
276     Float_t dy = 0.0; //TMath::Tan(hit->fPhi)*kZ/kSteps;
277     l = sqrt(dZ*dZ + dx*dx *1000000);
278     
279     x -= (kSteps/2 -1) * dx;
280     y -= (kSteps/2 -1) * dy;
281     
282     for (i=1; i<kSteps; i++) {
283     
284         stripP = GetStripP(x, y);
285         dsP = Get2StripP(x, y);
286         
287         stripN = GetStripN(x, y);
288         dsN = Get2StripN(x, y);
289         
290         EP = gRandom->Landau(fGainP*l, l*10);
291         EN = gRandom->Landau(fGainN*l, l*10);
292         
293         sP = kSigmaP * sqrt(i);
294         sN = kSigmaN * sqrt(kSteps-i);
295
296         sP = (i<3 && dsP>0.3 && dsP<0.7)? 0.02 : sP;
297         sN = (i>7 && dsN>0.3 && dsN<0.7)? 0.02 : sN;         
298
299         sP = (i==3 && dsP>0.4 && dsP<0.6)? 0.015 : sP;
300         sN = (i==7 && dsN>0.4 && dsN<0.6)? 0.015 : sN;        
301         
302         
303         (*fP)[stripP-1]+=(Int_t)(EP*(F(-0.5-dsP,sP)-F(-1.5-dsP,sP)));  
304         (*fP)[stripP]  +=(Int_t)(EP*(F(0.5-dsP,sP)-F(-0.5-dsP,sP)));
305         (*fP)[stripP+1]+=(Int_t)(EP*(F(1.5-dsP,sP)-F(0.5-dsP,sP)));
306         (*fP)[stripP+2]+=(Int_t)(EP*(F(2.5-dsP,sP)-F(1.5-dsP,sP))); 
307         
308         (*fN)[stripN-1]+=(Int_t)(EN*(F(-0.5-dsN,sN)-F(-1.5-dsN,sN)));
309         (*fN)[stripN]  +=(Int_t)(EN*(F(0.5-dsN,sN)-F(-0.5-dsN,sN)));
310         (*fN)[stripN+1]+=(Int_t)(EN*(F(1.5-dsN,sN)-F(0.5-dsN,sN)));
311         (*fN)[stripN+2]+=(Int_t)(EN*(F(2.5-dsN,sN)-F(1.5-dsN,sN))); 
312         
313         x += dx; 
314         y += dy; 
315     }
316 }
317
318
319 //____________________________________________________________________
320 //
321 //  Private Methods for Simulation
322 //____________________________________________________________________
323 //                           
324
325
326
327 void AliITSmoduleSSD::ApplyNoise() {
328     
329     for(Int_t i = 0; i<kNStrips; i++) {
330         (*fP)[i] += (Int_t)gRandom->Gaus(0,fSNRatioP);
331         (*fN)[i] += (Int_t)gRandom->Gaus(0,fSNRatioN);
332     }
333 }
334
335 void AliITSmoduleSSD::ApplyCoupling() {
336     
337     for(Int_t i = 1; i<kNStrips-1; i++) {
338         (*fP)[i] += (Int_t)((*fP)[i-1]*fCouplingPL + (*fP)[i+1]*fCouplingPR);
339         (*fN)[i] += (Int_t)((*fN)[i-1]*fCouplingNL + (*fN)[i+1]*fCouplingNR);
340     }
341 }
342
343
344 //____________________________________________________________________
345 //
346 //  Private methods for geometry
347 //____________________________________________________________________
348 //                           
349
350
351
352 Int_t AliITSmoduleSSD::GetStripP(Float_t x, Float_t y) {
353     
354     Float_t  X = x - y*kTan;
355     Int_t strip = (Int_t)(X/kPitch);
356     strip = (strip<0)? -1: strip;
357     strip = (strip>kNStrips)? -1: strip;
358     return strip;
359 }
360
361 Int_t AliITSmoduleSSD::GetStripN(Float_t x, Float_t y) {
362     
363     Float_t  X = x - kTan*(kY - y);
364     Int_t strip = (Int_t)(X/kPitch);
365     strip = (strip<0)? -1: strip;
366     strip = (strip>kNStrips)? -1: strip;
367     return strip;
368
369 }
370
371 Float_t AliITSmoduleSSD::Get2StripP(Float_t x, Float_t y) {
372     
373     Int_t n = GetStripP(x,y);
374     return (x - y*kTan) / kPitch - n;
375 }
376
377 Float_t AliITSmoduleSSD::Get2StripN(Float_t x, Float_t y) {
378     
379     Int_t n = GetStripN(x,y);
380     return (x - kTan*(kY - y)) / kPitch - n;
381 }
382
383
384 Bool_t AliITSmoduleSSD::GetCrossing (Float_t &P, Float_t &N) {   
385
386     P *= kPitch;
387     N *= kPitch; 
388     
389     P = (kY * kTan + N + P)/2.0;         // x coordinate
390     N = kY - (P-N)/kTan;                 // y coordinate
391     
392     if (N<0 || N>kY) return kFALSE;
393     if (P<0 || P>kX) return kFALSE;
394     return kTRUE;   
395 }
396
397 //____________________________________________________________________
398
399
400