]>
Commit | Line | Data |
---|---|---|
b0f5e3fc | 1 | #include <iostream.h> |
2 | #include <TRandom.h> | |
3 | #include <TH1.h> | |
e8189707 | 4 | #include <TMath.h> |
9f033001 | 5 | #include <TString.h> |
6 | #include <TParticle.h> | |
e8189707 | 7 | |
b0f5e3fc | 8 | |
9 | #include "AliRun.h" | |
e8189707 | 10 | #include "AliITS.h" |
9f033001 | 11 | #include "AliITShit.h" |
12 | #include "AliITSdigit.h" | |
13 | #include "AliITSmodule.h" | |
21b825a4 | 14 | #include "AliITSMapA2.h" |
b0f5e3fc | 15 | #include "AliITSsimulationSPD.h" |
9f033001 | 16 | #include "AliITSsegmentation.h" |
17 | #include "AliITSresponse.h" | |
18 | ||
e8189707 | 19 | |
b0f5e3fc | 20 | ClassImp(AliITSsimulationSPD) |
21 | //////////////////////////////////////////////////////////////////////// | |
22 | // Version: 0 | |
21b825a4 | 23 | // Written by Rocco Caliandro |
24 | // from a model developed with T. Virgili and R.A. Fini | |
25 | // June 15 2000 | |
b0f5e3fc | 26 | // |
27 | // AliITSsimulationSPD is the simulation of SPDs | |
21b825a4 | 28 | // |
b0f5e3fc | 29 | //________________________________________________________________________ |
30 | ||
21b825a4 | 31 | AliITSsimulationSPD::AliITSsimulationSPD(){ |
b0f5e3fc | 32 | // constructor |
21b825a4 | 33 | fResponse = 0; |
b0f5e3fc | 34 | fSegmentation = 0; |
21b825a4 | 35 | fHis = 0; |
36 | fThresh = 0.; | |
37 | fSigma = 0.; | |
38 | fCouplCol = 0.; | |
39 | fCouplRow = 0.; | |
b0f5e3fc | 40 | } |
41 | //_____________________________________________________________________________ | |
42 | ||
43 | AliITSsimulationSPD::AliITSsimulationSPD(AliITSsegmentation *seg, AliITSresponse *resp) { | |
21b825a4 | 44 | // constructor |
b0f5e3fc | 45 | fResponse = resp; |
46 | fSegmentation = seg; | |
47 | ||
21b825a4 | 48 | fResponse->Thresholds(fThresh,fSigma); |
49 | fResponse->GetNoiseParam(fCouplCol,fCouplRow); | |
50 | ||
b0f5e3fc | 51 | fMapA2 = new AliITSMapA2(fSegmentation); |
21b825a4 | 52 | |
53 | // | |
b0f5e3fc | 54 | fNPixelsZ=fSegmentation->Npz(); |
55 | fNPixelsX=fSegmentation->Npx(); | |
21b825a4 | 56 | fHis=0; |
b0f5e3fc | 57 | } |
58 | ||
59 | //_____________________________________________________________________________ | |
60 | ||
61 | AliITSsimulationSPD::~AliITSsimulationSPD() { | |
62 | // destructor | |
63 | ||
64 | delete fMapA2; | |
65 | ||
66 | if (fHis) { | |
67 | fHis->Delete(); | |
68 | delete fHis; | |
69 | } | |
70 | } | |
71 | ||
72 | //__________________________________________________________________________ | |
73 | AliITSsimulationSPD::AliITSsimulationSPD(const AliITSsimulationSPD &source){ | |
74 | // Copy Constructor | |
75 | if(&source == this) return; | |
76 | this->fMapA2 = source.fMapA2; | |
21b825a4 | 77 | this->fThresh = source.fThresh; |
78 | this->fSigma = source.fSigma; | |
79 | this->fCouplCol = source.fCouplCol; | |
80 | this->fCouplRow = source.fCouplRow; | |
b0f5e3fc | 81 | this->fNPixelsX = source.fNPixelsX; |
82 | this->fNPixelsZ = source.fNPixelsZ; | |
83 | this->fHis = source.fHis; | |
84 | return; | |
85 | } | |
86 | ||
87 | //_________________________________________________________________________ | |
88 | AliITSsimulationSPD& | |
89 | AliITSsimulationSPD::operator=(const AliITSsimulationSPD &source) { | |
90 | // Assignment operator | |
91 | if(&source == this) return *this; | |
92 | this->fMapA2 = source.fMapA2; | |
21b825a4 | 93 | this->fThresh = source.fThresh; |
94 | this->fSigma = source.fSigma; | |
95 | this->fCouplCol = source.fCouplCol; | |
96 | this->fCouplRow = source.fCouplRow; | |
b0f5e3fc | 97 | this->fNPixelsX = source.fNPixelsX; |
98 | this->fNPixelsZ = source.fNPixelsZ; | |
99 | this->fHis = source.fHis; | |
100 | return *this; | |
101 | } | |
102 | //_____________________________________________________________________________ | |
103 | ||
21b825a4 | 104 | void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod, Int_t module, |
105 | Int_t dummy) { | |
b0f5e3fc | 106 | // digitize module |
e8189707 | 107 | |
b0f5e3fc | 108 | |
21b825a4 | 109 | TObjArray *fHits = mod->GetHits(); |
110 | Int_t nhits = fHits->GetEntriesFast(); | |
111 | if (!nhits) return; | |
b0f5e3fc | 112 | |
b0f5e3fc | 113 | |
21b825a4 | 114 | //printf("Module %d (%d hits) \n",module+1,nhits); |
b0f5e3fc | 115 | |
b0f5e3fc | 116 | |
21b825a4 | 117 | Int_t number=10000; |
118 | Int_t *frowpixel = new Int_t[number]; | |
119 | Int_t *fcolpixel = new Int_t[number]; | |
120 | Double_t *fenepixel = new Double_t[number]; | |
e8189707 | 121 | |
21b825a4 | 122 | // Array of pointers to store the track index of the digits |
123 | // leave +1, otherwise pList crashes when col=256, row=192 | |
124 | Int_t maxNdigits = fNPixelsX*fNPixelsZ+fNPixelsX+1; | |
125 | Float_t **pList = new Float_t* [maxNdigits]; | |
126 | memset(pList,0,sizeof(Float_t*)*maxNdigits); | |
127 | ||
128 | ||
129 | // noise setting | |
130 | SetFluctuations(pList); | |
b0f5e3fc | 131 | |
b0f5e3fc | 132 | |
b0f5e3fc | 133 | |
21b825a4 | 134 | // loop over hits in the module |
135 | Int_t hitpos; | |
136 | for (hitpos=0;hitpos<nhits;hitpos++) { | |
137 | HitToDigit(mod,hitpos,module,frowpixel,fcolpixel,fenepixel,pList); | |
138 | }// end loop over digits | |
139 | ||
140 | CreateDigit(nhits,module,pList); | |
141 | ||
142 | // clean memory | |
143 | delete[] frowpixel; | |
144 | delete[] fcolpixel; | |
145 | delete[] fenepixel; | |
146 | fMapA2->ClearMap(); | |
147 | delete [] pList; | |
b0f5e3fc | 148 | |
21b825a4 | 149 | } |
150 | //_____________________________________________________________________________ | |
b0f5e3fc | 151 | |
21b825a4 | 152 | void AliITSsimulationSPD::UpdateMap( Int_t row, Int_t col, Double_t ene) { |
153 | // | |
154 | // updates the Map of signal, adding the energy (ene) released by the current track | |
155 | // | |
156 | Double_t signal; | |
157 | signal = fMapA2->GetSignal(row,col); | |
158 | signal += ene; | |
159 | fMapA2->SetHit(row,col,signal); | |
160 | ||
161 | } | |
162 | //_____________________________________________________________________________ | |
163 | void AliITSsimulationSPD::HitToDigit(AliITSmodule *mod, Int_t hitpos, Int_t module, | |
164 | Int_t *frowpixel, Int_t *fcolpixel, | |
165 | Double_t *fenepixel, Float_t **pList) { | |
166 | // | |
167 | // Steering function to determine the digits associated to a given hit (hitpos) | |
168 | // The digits are created by charge sharing (ChargeSharing) and by | |
169 | // capacitive coupling (SetCoupling). At all the created digits is associated | |
170 | // the track number of the hit (ntrack) | |
171 | // | |
b0f5e3fc | 172 | |
b0f5e3fc | 173 | |
21b825a4 | 174 | static Float_t x1l,y1l,z1l; |
175 | Float_t x2l,y2l,z2l,etot; | |
176 | Int_t layer,r1,r2,c1,c2,row,col,npixel = 0; | |
177 | Int_t ntrack,idhit; | |
178 | Double_t ene; | |
179 | const Float_t kconv = 10000.; // cm -> microns | |
180 | const Float_t kconv1= 0.277e9; // GeV -> electrons equivalent | |
181 | ||
182 | TObjArray *fHits = mod->GetHits(); | |
183 | AliITShit *hit = (AliITShit*) fHits->At(hitpos); | |
184 | layer = hit->GetLayer(); | |
185 | etot=kconv1*hit->GetIonization(); | |
186 | ntrack=hit->GetTrack(); | |
187 | idhit=mod->GetHitHitIndex(hitpos); | |
188 | ||
189 | ||
190 | /* | |
191 | printf("\n layer,etot,ntrack,status %d %f %d %d\n",layer,etot,ntrack,hit->GetTrackStatus()); //debug | |
192 | Int_t idtrack; //debug | |
193 | mod->GetHitTrackAndHitIndex(hitpos,idtrack,idhit); | |
194 | printf("idtrack,idhit %d %d\n",idtrack,idhit); //debug | |
195 | printf("(Dx, Dz)=(%f, %f)\n",fSegmentation->Dx(),fSegmentation->Dz()); //debug | |
196 | */ | |
197 | ||
e8189707 | 198 | |
b0f5e3fc | 199 | |
21b825a4 | 200 | if (hit->GetTrackStatus()==66) { |
201 | hit->GetPositionL(x1l,y1l,z1l); | |
202 | // positions shifted and converted in microns | |
203 | x1l = x1l*kconv + fSegmentation->Dx()/2.; | |
204 | z1l = z1l*kconv + fSegmentation->Dz()/2.; | |
205 | //printf("(x1l, z2l)=(%f, %f)\n",x1l,z1l); //debug | |
206 | } | |
207 | else { | |
208 | hit->GetPositionL(x2l,y2l,z2l); | |
209 | // positions shifted and converted in microns | |
210 | x2l = x2l*kconv + fSegmentation->Dx()/2.; | |
211 | z2l = z2l*kconv + fSegmentation->Dz()/2.; | |
212 | //printf("(x2l, z2l)=(%f, %f)\n",x2l,z2l); //debug | |
213 | ||
214 | ||
215 | ||
216 | // to account for the effective sensitive area | |
217 | // introduced in geometry | |
218 | if (z1l<0 || z1l>fSegmentation->Dz()) return; | |
219 | if (z2l<0 || z2l>fSegmentation->Dz()) return; | |
220 | if (x1l<0 || x1l>fSegmentation->Dx()) return; | |
221 | if (x2l<0 || x2l>fSegmentation->Dx()) return; | |
222 | ||
223 | //Get the col and row number starting from 1 | |
224 | // the x direction is not inverted for the second layer!!! | |
225 | fSegmentation->GetPadIxz(x1l, z1l, c1, r1); | |
226 | fSegmentation->GetPadIxz(x2l, z2l, c2, r2); | |
227 | ||
228 | //printf("(c1, r1)=(%d, %d) (c2, r2)=(%d, %d)\n",c1,r1,c2,r2); //debug | |
229 | ||
230 | // to account for unexpected equal entrance and | |
231 | // exit coordinates | |
232 | if (x1l==x2l) x2l=x2l+x2l*0.000001; | |
233 | if (z1l==z2l) z2l=z2l+z2l*0.000001; | |
234 | ||
235 | ||
236 | if ((r1==r2) && (c1==c2)) | |
237 | { | |
238 | // no charge sharing | |
239 | npixel = 1; | |
240 | frowpixel[npixel-1] = r1; | |
241 | fcolpixel[npixel-1] = c1; | |
242 | fenepixel[npixel-1] = etot; | |
243 | } | |
244 | else { | |
245 | // charge sharing | |
246 | ChargeSharing(x1l,z1l,x2l,z2l,c1,r1,c2,r2,etot, | |
247 | npixel,frowpixel,fcolpixel,fenepixel); | |
248 | ||
249 | } | |
250 | ||
251 | ||
252 | for (Int_t npix=0;npix<npixel;npix++) | |
253 | { | |
254 | row = frowpixel[npix]; | |
255 | col = fcolpixel[npix]; | |
256 | ene = fenepixel[npix]; | |
257 | UpdateMap(row,col,ene); | |
258 | GetList(ntrack,idhit,pList,row,col); | |
259 | // Starting capacitive coupling effect | |
260 | SetCoupling(row,col,ntrack,idhit,pList); | |
261 | } | |
262 | x1l=x2l; | |
263 | y1l=y2l; | |
264 | z1l=z2l; | |
265 | } | |
266 | } | |
b0f5e3fc | 267 | |
21b825a4 | 268 | //_________________________________________________________________________ |
a3e16987 | 269 | |
21b825a4 | 270 | void AliITSsimulationSPD::ChargeSharing(Float_t x1l,Float_t z1l,Float_t x2l, |
271 | Float_t z2l,Int_t c1,Int_t r1,Int_t c2, | |
272 | Int_t r2,Float_t etot, | |
273 | Int_t &npixel,Int_t *frowpixel, | |
274 | Int_t *fcolpixel,Double_t *fenepixel){ | |
275 | // | |
276 | // Take into account the geometrical charge sharing when the track | |
277 | // crosses more than one pixel. | |
278 | // | |
279 | //Begin_Html | |
280 | /* | |
281 | <img src="picts/ITS/barimodel_2.gif"> | |
282 | </pre> | |
283 | <br clear=left> | |
284 | <font size=+2 color=red> | |
285 | <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>. | |
286 | </font> | |
287 | <pre> | |
288 | */ | |
289 | //End_Html | |
290 | ||
291 | ||
292 | Float_t xa,za,xb,zb,dx,dz,dtot,dm,refr,refm,refc; | |
293 | Float_t refn=0.; | |
294 | Float_t arefm, arefr, arefn, arefc, azb, az2l, axb, ax2l; | |
295 | Int_t dirx,dirz,rb,cb; | |
296 | ||
297 | ||
298 | Int_t flag,flagrow,flagcol; | |
299 | ||
300 | Double_t epar; | |
e8189707 | 301 | |
a3e16987 | 302 | |
21b825a4 | 303 | npixel = 0; |
304 | xa = x1l; | |
305 | za = z1l; | |
306 | dx = TMath::Abs(x1l-x2l); | |
307 | dz = TMath::Abs(z1l-z2l); | |
308 | dtot = TMath::Sqrt((dx*dx)+(dz*dz)); | |
309 | dm = (x2l - x1l) / (z2l - z1l); | |
b0f5e3fc | 310 | |
21b825a4 | 311 | dirx = (Int_t) ((x2l - x1l) / dx); |
312 | dirz = (Int_t) ((z2l - z1l) / dz); | |
313 | ||
314 | ||
315 | // calculate the x coordinate of the pixel in the next column | |
316 | // and the z coordinate of the pixel in the next row | |
b0f5e3fc | 317 | |
21b825a4 | 318 | Float_t xpos, zpos; |
b0f5e3fc | 319 | |
21b825a4 | 320 | fSegmentation->GetPadCxz(c1, r1-1, xpos, zpos); |
b0f5e3fc | 321 | |
21b825a4 | 322 | Float_t xsize = fSegmentation->Dpx(0); |
323 | Float_t zsize = fSegmentation->Dpz(r1-1); | |
b0f5e3fc | 324 | |
21b825a4 | 325 | if (dirx == 1) refr = xpos+xsize/2.; |
326 | else refr = xpos-xsize/2.; | |
b0f5e3fc | 327 | |
21b825a4 | 328 | if (dirz == 1) refn = zpos+zsize/2.; |
329 | else refn = zpos-zsize/2.; | |
b0f5e3fc | 330 | |
21b825a4 | 331 | |
332 | flag = 0; | |
333 | flagrow = 0; | |
334 | flagcol = 0; | |
335 | do | |
336 | { | |
337 | ||
338 | // calculate the x coordinate of the intersection with the pixel | |
339 | // in the next cell in row direction | |
340 | ||
341 | refm = (refn - z1l)*dm + x1l; | |
342 | ||
343 | // calculate the z coordinate of the intersection with the pixel | |
344 | // in the next cell in column direction | |
345 | ||
346 | refc = (refr - x1l)/dm + z1l; | |
347 | ||
348 | ||
349 | arefm = refm * dirx; | |
350 | arefr = refr * dirx; | |
351 | arefn = refn * dirz; | |
352 | arefc = refc * dirz; | |
353 | ||
354 | ||
355 | if ((arefm < arefr) && (arefn < arefc)){ | |
356 | ||
357 | // the track goes in the pixel in the next cell in row direction | |
358 | xb = refm; | |
359 | zb = refn; | |
360 | cb = c1; | |
361 | rb = r1 + dirz; | |
362 | azb = zb * dirz; | |
363 | az2l = z2l * dirz; | |
364 | if (rb == r2) flagrow=1; | |
365 | if (azb > az2l) { | |
366 | zb = z2l; | |
367 | xb = x2l; | |
368 | } | |
369 | ||
370 | // shift to the pixel in the next cell in row direction | |
371 | Float_t zsizeNext = fSegmentation->Dpz(rb-1); | |
372 | //to account for cell at the borders of the detector | |
373 | if(zsizeNext==0) zsizeNext = zsize; | |
374 | ||
375 | refn += zsizeNext*dirz; | |
b0f5e3fc | 376 | |
21b825a4 | 377 | } |
378 | else { | |
379 | ||
380 | // the track goes in the pixel in the next cell in column direction | |
381 | xb = refr; | |
382 | zb = refc; | |
383 | cb = c1 + dirx; | |
384 | rb = r1; | |
385 | axb = xb * dirx; | |
386 | ax2l = x2l * dirx; | |
387 | if (cb == c2) flagcol=1; | |
388 | if (axb > ax2l) { | |
389 | zb = z2l; | |
390 | xb = x2l; | |
391 | } | |
392 | ||
393 | // shift to the pixel in the next cell in column direction | |
394 | Float_t xsizeNext = fSegmentation->Dpx(cb-1); | |
395 | //to account for cell at the borders of the detector | |
396 | if(xsizeNext==0) xsizeNext = xsize; | |
397 | ||
398 | refr += xsizeNext*dirx; | |
399 | ||
400 | } | |
401 | ||
402 | //calculate the energy lost in the crossed pixel | |
403 | epar = TMath::Sqrt((xb-xa)*(xb-xa)+(zb-za)*(zb-za)); | |
404 | epar = etot*(epar/dtot); | |
405 | ||
406 | //store row, column and energy lost in the crossed pixel | |
407 | frowpixel[npixel] = r1; | |
408 | fcolpixel[npixel] = c1; | |
409 | fenepixel[npixel] = epar; | |
410 | npixel++; | |
411 | ||
412 | // the exit point of the track is reached | |
413 | if (epar == 0) flag = 1; | |
414 | if ((r1 == r2) && (c1 == c2)) flag = 1; | |
415 | if (flag!=1) { | |
416 | r1 = rb; | |
417 | c1 = cb; | |
418 | xa = xb; | |
419 | za = zb; | |
420 | } | |
421 | ||
422 | } while (flag==0); | |
b0f5e3fc | 423 | |
21b825a4 | 424 | } |
425 | //___________________________________________________________________________ | |
426 | void AliITSsimulationSPD::SetCoupling(Int_t row, Int_t col, Int_t ntrack, | |
427 | Int_t idhit, Float_t **pList) { | |
428 | // | |
429 | // Take into account the coupling between adiacent pixels. | |
430 | // The parameters probcol and probrow are the fractions of the | |
431 | // signal in one pixel shared in the two adjacent pixels along | |
432 | // the column and row direction, respectively. | |
433 | // | |
434 | //Begin_Html | |
435 | /* | |
436 | <img src="picts/ITS/barimodel_3.gif"> | |
437 | </pre> | |
438 | <br clear=left> | |
439 | <font size=+2 color=red> | |
440 | <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>. | |
441 | </font> | |
442 | <pre> | |
443 | */ | |
444 | //End_Html | |
445 | ||
446 | ||
447 | Int_t j1,j2,flag=0; | |
448 | Double_t pulse1,pulse2; | |
449 | ||
450 | ||
451 | j1 = row; | |
452 | j2 = col; | |
453 | ||
454 | pulse1 = fMapA2->GetSignal(row,col); | |
455 | pulse2 = pulse1; | |
456 | ||
457 | for (Int_t isign=-1;isign<=1;isign+=2) | |
458 | { | |
459 | ||
460 | // loop in row direction | |
461 | ||
462 | do | |
463 | { | |
464 | j1 += isign; | |
465 | pulse1 *= fCouplRow; | |
466 | ||
467 | if ((j1 < 0) || (j1 > fNPixelsZ-1) || (pulse1 < fThresh)) | |
468 | { | |
469 | pulse1 = fMapA2->GetSignal(row,col); | |
470 | j1 = row; | |
471 | flag = 1; | |
472 | } | |
473 | else{ | |
474 | UpdateMap(j1,col,pulse1); | |
475 | GetList(ntrack,idhit,pList,j1,col); | |
476 | flag = 0; | |
477 | } | |
478 | ||
479 | } while(flag == 0); | |
480 | ||
481 | ||
482 | // loop in column direction | |
483 | ||
484 | do | |
485 | { | |
486 | j2 += isign; | |
487 | pulse2 *= fCouplCol; | |
488 | ||
489 | if ((j2 < 0) || (j2 > (fNPixelsX-1)) || (pulse2 < fThresh)) | |
490 | { | |
491 | pulse2 = fMapA2->GetSignal(row,col); | |
492 | j2 = col; | |
493 | flag = 1; | |
494 | } | |
495 | else{ | |
496 | UpdateMap(row,j2,pulse2); | |
497 | GetList(ntrack,idhit,pList,row,j2); | |
498 | flag = 0; | |
499 | } | |
500 | ||
501 | } while(flag == 0); | |
502 | ||
503 | } | |
b0f5e3fc | 504 | |
21b825a4 | 505 | } |
506 | //___________________________________________________________________________ | |
507 | void AliITSsimulationSPD::CreateDigit(Int_t nhits, Int_t module, Float_t | |
508 | **pList) { | |
509 | // | |
510 | // The pixels are fired if the energy deposited inside them is above | |
511 | // the threshold parameter ethr. Fired pixed are interpreted as digits | |
512 | // and stored in the file digitfilename. | |
513 | // | |
514 | ||
515 | AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS"); | |
516 | ||
517 | ||
518 | Int_t digits[3]; | |
519 | Int_t tracks[3]; | |
520 | Int_t hits[3]; | |
521 | Float_t charges[3]; | |
522 | Int_t gi,j1; | |
523 | ||
524 | if (nhits > 0) { | |
525 | ||
526 | for (Int_t r=1;r<=fNPixelsZ;r++) { | |
527 | for (Int_t c=1;c<=fNPixelsX;c++) { | |
528 | ||
529 | // check if the deposited energy in a pixel is above the threshold | |
530 | Float_t signal = (Float_t) fMapA2->GetSignal(r,c); | |
531 | gi =r*fNPixelsX+c; // global index | |
532 | if ( signal > fThresh) { | |
533 | digits[0] = r-1; // digits starts from 0 | |
534 | digits[1] = c-1; // digits starts from 0 | |
535 | //digits[2] = 1; | |
536 | digits[2] = (Int_t) signal; // the signal is stored in electrons | |
537 | for(j1=0;j1<3;j1++){ | |
538 | tracks[j1] = (Int_t)(*(pList[gi]+j1)); | |
539 | hits[j1] = (Int_t)(*(pList[gi]+j1+6)); | |
540 | charges[j1] = 0; | |
541 | } | |
542 | /* debug | |
543 | printf("digits %d %d %d\n",digits[0],digits[1],digits[2]); //debug | |
544 | printf("tracks %d %d %d\n",tracks[0],tracks[1],tracks[2]); //debug | |
545 | printf("hits %d %d %d\n",hits[0],hits[1],hits[2]); //debug | |
546 | */ | |
547 | Float_t phys = 0; | |
548 | aliITS->AddSimDigit(0,phys,digits,tracks,hits,charges); | |
549 | }//endif of threshold condition | |
550 | if(pList[gi]) delete [] pList[gi]; | |
551 | } | |
552 | }// enddo on pixels | |
553 | } | |
554 | ||
555 | } | |
556 | //_____________________________________________________________________________ | |
b0f5e3fc | 557 | |
21b825a4 | 558 | void AliITSsimulationSPD::GetList(Int_t label,Int_t idhit, Float_t **pList, |
559 | Int_t row, Int_t col) { | |
560 | // loop over nonzero digits | |
b0f5e3fc | 561 | |
21b825a4 | 562 | Int_t ix = col; |
563 | Int_t iz = row; | |
564 | Int_t globalIndex; | |
565 | Float_t signal; | |
566 | Float_t highest,middle,lowest; | |
e8189707 | 567 | |
21b825a4 | 568 | |
569 | signal=fMapA2->GetSignal(iz,ix); | |
b0f5e3fc | 570 | |
e8189707 | 571 | |
21b825a4 | 572 | globalIndex = iz*fNPixelsX+ix; // globalIndex starts from 1 |
b0f5e3fc | 573 | |
574 | ||
21b825a4 | 575 | if(!pList[globalIndex]) |
576 | { | |
577 | // | |
578 | // Create new list (9 elements - 3 signals and 3 tracks + 3 hits) | |
579 | // | |
b0f5e3fc | 580 | |
21b825a4 | 581 | pList[globalIndex] = new Float_t [9]; |
b0f5e3fc | 582 | |
b0f5e3fc | 583 | |
21b825a4 | 584 | // set list to -3 |
585 | *(pList[globalIndex]) = -3.; | |
586 | *(pList[globalIndex]+1) = -3.; | |
587 | *(pList[globalIndex]+2) = -3.; | |
588 | *(pList[globalIndex]+3) = 0.; | |
589 | *(pList[globalIndex]+4) = 0.; | |
590 | *(pList[globalIndex]+5) = 0.; | |
591 | *(pList[globalIndex]+6) = -1.; | |
592 | *(pList[globalIndex]+7) = -1.; | |
593 | *(pList[globalIndex]+8) = -1.; | |
b0f5e3fc | 594 | |
21b825a4 | 595 | *pList[globalIndex] = (float)label; |
596 | *(pList[globalIndex]+3) = signal; | |
597 | *(pList[globalIndex]+6) = (float)idhit; | |
b0f5e3fc | 598 | } |
21b825a4 | 599 | else{ |
b0f5e3fc | 600 | |
b0f5e3fc | 601 | |
21b825a4 | 602 | // check the signal magnitude |
603 | highest = *(pList[globalIndex]+3); | |
604 | middle = *(pList[globalIndex]+4); | |
605 | lowest = *(pList[globalIndex]+5); | |
b0f5e3fc | 606 | |
b0f5e3fc | 607 | |
21b825a4 | 608 | signal -= (highest+middle+lowest); |
e8189707 | 609 | |
b0f5e3fc | 610 | |
21b825a4 | 611 | // |
612 | // compare the new signal with already existing list | |
613 | // | |
614 | if(signal<lowest) return; // neglect this track | |
615 | ||
616 | if (signal>highest) | |
617 | { | |
618 | *(pList[globalIndex]+8) = *(pList[globalIndex]+7); | |
619 | *(pList[globalIndex]+7) = *(pList[globalIndex]+6); | |
620 | *(pList[globalIndex]+6) = idhit; | |
621 | *(pList[globalIndex]+5) = middle; | |
622 | *(pList[globalIndex]+4) = highest; | |
623 | *(pList[globalIndex]+3) = signal; | |
624 | *(pList[globalIndex]+2) = *(pList[globalIndex]+1); | |
625 | *(pList[globalIndex]+1) = *pList[globalIndex]; | |
626 | *(pList[globalIndex]) = label; | |
627 | } | |
628 | else if (signal>middle) | |
629 | { | |
630 | *(pList[globalIndex]+8) = *(pList[globalIndex]+7); | |
631 | *(pList[globalIndex]+7) = idhit; | |
632 | *(pList[globalIndex]+5) = middle; | |
633 | *(pList[globalIndex]+4) = signal; | |
634 | *(pList[globalIndex]+2) = *(pList[globalIndex]+1); | |
635 | *(pList[globalIndex]+1) = label; | |
636 | } | |
637 | else | |
638 | { | |
639 | *(pList[globalIndex]+8) = idhit; | |
640 | *(pList[globalIndex]+5) = signal; | |
641 | *(pList[globalIndex]+2) = label; | |
642 | } | |
643 | } | |
644 | } | |
645 | //_________________________________________________________________________ | |
646 | void AliITSsimulationSPD::SetFluctuations(Float_t **pList) { | |
647 | // | |
648 | // Set the electronic noise and threshold non-uniformities to all the | |
649 | // pixels in a detector. | |
650 | // The parameter fSigma is the squared sum of the sigma due to noise | |
651 | // and the sigma of the threshold distribution among pixels. | |
652 | // | |
653 | //Begin_Html | |
654 | /* | |
655 | <img src="picts/ITS/barimodel_1.gif"> | |
656 | </pre> | |
657 | <br clear=left> | |
658 | <font size=+2 color=red> | |
659 | <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>. | |
660 | </font> | |
661 | <pre> | |
662 | */ | |
663 | //End_Html | |
664 | ||
665 | ||
666 | Double_t signal; | |
667 | ||
668 | Int_t iz,ix; | |
669 | for(iz=1;iz<=fNPixelsZ;iz++){ | |
670 | for(ix=1;ix<=fNPixelsX;ix++){ | |
671 | signal = fSigma*gRandom->Gaus(); | |
672 | fMapA2->SetHit(iz,ix,signal); | |
673 | ||
674 | // insert in the label-signal-hit list the pixels fired only by noise | |
675 | if ( signal > fThresh) { | |
676 | Int_t globalIndex = iz*fNPixelsX+ix; | |
677 | pList[globalIndex] = new Float_t [9]; | |
678 | *(pList[globalIndex]) = -2.; | |
679 | *(pList[globalIndex]+1) = -2.; | |
680 | *(pList[globalIndex]+2) = -2.; | |
681 | *(pList[globalIndex]+3) = signal; | |
682 | *(pList[globalIndex]+4) = 0.; | |
683 | *(pList[globalIndex]+5) = 0.; | |
684 | *(pList[globalIndex]+6) = -1.; | |
685 | *(pList[globalIndex]+7) = -1.; | |
686 | *(pList[globalIndex]+8) = -1.; | |
687 | } | |
688 | } // end of loop on pixels | |
689 | } // end of loop on pixels | |
690 | ||
691 | } | |
692 | //____________________________________________ | |
693 | ||
694 | void AliITSsimulationSPD::CreateHistograms() { | |
695 | // CreateHistograms | |
696 | ||
697 | Int_t i; | |
9f033001 | 698 | fHis=new TObjArray(fNPixelsZ); |
21b825a4 | 699 | for(i=0;i<fNPixelsZ;i++) { |
700 | TString spdname("spd_"); | |
701 | Char_t candnum[4]; | |
702 | sprintf(candnum,"%d",i+1); | |
703 | spdname.Append(candnum); | |
704 | (*fHis)[i] = new TH1F(spdname.Data(),"SPD maps", | |
b0f5e3fc | 705 | fNPixelsX,0.,(Float_t) fNPixelsX); |
b0f5e3fc | 706 | } |
21b825a4 | 707 | |
b0f5e3fc | 708 | } |
709 | ||
710 | //____________________________________________ | |
711 | ||
21b825a4 | 712 | void AliITSsimulationSPD::ResetHistograms() { |
b0f5e3fc | 713 | // |
714 | // Reset histograms for this detector | |
715 | // | |
21b825a4 | 716 | Int_t i; |
717 | for(i=0;i<fNPixelsZ;i++ ) { | |
b0f5e3fc | 718 | if ((*fHis)[i]) ((TH1F*)(*fHis)[i])->Reset(); |
719 | } | |
720 | ||
721 | } |