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