]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSsimulationSPD.cxx
Functions for bitio. Taken as is from The Data Compression Book
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationSPD.cxx
CommitLineData
c7a4dac0 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$
0fee5d51 18Revision 1.13 2001/11/13 11:13:24 barbera
19A protection against tracks with the same entrance and exit has been made more strict
20
0cadf298 21Revision 1.12 2001/10/04 22:44:31 nilsen
22Major changes in supppor of PreDigits (SDigits). Changes made with will make
23it easier to suppor expected changes in AliITSHit class. Added use of new
24class AliITSpList. Both SPD and SDD have added effects of Dead Channels. Both
25of these will require addtional work as data bases of detectors and the like
26are developed.
27
c7a4dac0 28*/
b0f5e3fc 29#include <iostream.h>
30#include <TRandom.h>
31#include <TH1.h>
e8189707 32#include <TMath.h>
9f033001 33#include <TString.h>
34#include <TParticle.h>
e8189707 35
b0f5e3fc 36#include "AliRun.h"
e8189707 37#include "AliITS.h"
9f033001 38#include "AliITShit.h"
39#include "AliITSdigit.h"
40#include "AliITSmodule.h"
21b825a4 41#include "AliITSMapA2.h"
c7a4dac0 42#include "AliITSpList.h"
b0f5e3fc 43#include "AliITSsimulationSPD.h"
9f033001 44#include "AliITSsegmentation.h"
45#include "AliITSresponse.h"
c7a4dac0 46#include "AliITSsegmentationSPD.h"
47#include "AliITSresponseSPD.h"
9f033001 48
e8189707 49
b0f5e3fc 50ClassImp(AliITSsimulationSPD)
51////////////////////////////////////////////////////////////////////////
52// Version: 0
21b825a4 53// Written by Rocco Caliandro
54// from a model developed with T. Virgili and R.A. Fini
55// June 15 2000
b0f5e3fc 56//
57// AliITSsimulationSPD is the simulation of SPDs
21b825a4 58//
c7a4dac0 59//______________________________________________________________________
21b825a4 60AliITSsimulationSPD::AliITSsimulationSPD(){
c7a4dac0 61 // Default constructor
62
63 fResponse = 0;
64 fSegmentation = 0;
65 fHis = 0;
66 fMapA2 = 0;
67/*
68 fThresh = 0.;
69 fSigma = 0.;
70 fCouplCol = 0.;
71 fCouplRow = 0.; */
b0f5e3fc 72}
c7a4dac0 73//______________________________________________________________________
74AliITSsimulationSPD::AliITSsimulationSPD(AliITSsegmentation *seg,
75 AliITSresponse *resp) {
76 // Standard constructor
77
78 fResponse = 0;
79 fSegmentation = 0;
80 fHis = 0;
81 fMapA2 = 0;
82/*
83 fThresh = 0.;
84 fSigma = 0.;
85 fCouplCol = 0.;
86 fCouplRow = 0.*/
87 Init((AliITSsegmentationSPD*)seg,(AliITSresponseSPD*)resp);
b0f5e3fc 88}
c7a4dac0 89//______________________________________________________________________
90void AliITSsimulationSPD::Init(AliITSsegmentationSPD *seg,
91 AliITSresponseSPD *resp) {
92 // Initilizes the variables of AliITSsimulation SPD.
93
94 fHis = 0;
95 fResponse = resp;
96 fSegmentation = seg;
97 fMapA2 = new AliITSMapA2(fSegmentation);
98/*
99 fResponse->Thresholds(fThresh,fSigma);
100 fResponse->GetNoiseParam(fCouplCol,fCouplRow);
101 fNPixelsZ = fSegmentation->Npz();
102 fNPixelsX = fSegmentation->Npx();
103*/
104}
105//______________________________________________________________________
b0f5e3fc 106AliITSsimulationSPD::~AliITSsimulationSPD() {
c7a4dac0 107 // destructor
b0f5e3fc 108
c7a4dac0 109 delete fMapA2;
b0f5e3fc 110
c7a4dac0 111 if (fHis) {
112 fHis->Delete();
113 delete fHis;
114 } // end if
b0f5e3fc 115}
c7a4dac0 116//______________________________________________________________________
b0f5e3fc 117AliITSsimulationSPD::AliITSsimulationSPD(const AliITSsimulationSPD &source){
c7a4dac0 118 // Copy Constructor
119
120 if(&source == this) return;
121
122 this->fMapA2 = source.fMapA2;
123 this->fHis = source.fHis;
124/*
125 this->fThresh = source.fThresh;
126 this->fSigma = source.fSigma;
127 this->fCouplCol = source.fCouplCol;
128 this->fCouplRow = source.fCouplRow;
129 this->fNPixelsX = source.fNPixelsX;
130 this->fNPixelsZ = source.fNPixelsZ;
131*/
132 return;
b0f5e3fc 133}
c7a4dac0 134//______________________________________________________________________
135AliITSsimulationSPD& AliITSsimulationSPD::operator=(const AliITSsimulationSPD
136 &source) {
137 // Assignment operator
138
139 if(&source == this) return *this;
140
141 this->fMapA2 = source.fMapA2;
142 this->fHis = source.fHis;
143/*
144 this->fThresh = source.fThresh;
145 this->fSigma = source.fSigma;
146 this->fCouplCol = source.fCouplCol;
147 this->fCouplRow = source.fCouplRow;
148 this->fNPixelsX = source.fNPixelsX;
149 this->fNPixelsZ = source.fNPixelsZ;
150*/
151 return *this;
152}
153//______________________________________________________________________
154void AliITSsimulationSPD::SDigitiseModule(AliITSmodule *mod, Int_t dummy0,
155 Int_t dummy1) {
156 // Sum digitize module
157 if (!(mod->GetNhits())) return; // if module has no hits then no Sdigits.
158 Int_t number = 10000;
159 Int_t *frowpixel = new Int_t[number];
160 Int_t *fcolpixel = new Int_t[number];
161 Double_t *fenepixel = new Double_t[number];
162
163 // Array of pointers to store the track index of the digits
164 // leave +1, otherwise pList crashes when col=256, row=192
165 AliITSpList *pList = new AliITSpList(GetNPixelsZ()+1,GetNPixelsX()+1);
166
167 HitsToAnalogDigits(mod,frowpixel,fcolpixel,fenepixel,pList);
168
169 WriteSDigits(pList);
170
171 // clean memory
172 delete[] frowpixel;
173 delete[] fcolpixel;
174 delete[] fenepixel;
175 fMapA2->ClearMap();
176 delete pList;
177}
178//______________________________________________________________________
179void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod, Int_t dummy0,
180 Int_t dummy1) {
181 // digitize module. Also need to digitize modules with only noise.
b0f5e3fc 182
c7a4dac0 183 Int_t number = 10000;
184 Int_t *frowpixel = new Int_t[number];
185 Int_t *fcolpixel = new Int_t[number];
186 Double_t *fenepixel = new Double_t[number];
187 Int_t module = mod->GetIndex();
b0f5e3fc 188
c7a4dac0 189 // Array of pointers to store the track index of the digits
190 // leave +1, otherwise pList crashes when col=256, row=192
191 AliITSpList *pList = new AliITSpList(GetNPixelsZ()+1,GetNPixelsX()+1);
b0f5e3fc 192
c7a4dac0 193 // noise setting
194 SetFluctuations(pList,module);
b0f5e3fc 195
c7a4dac0 196 HitsToAnalogDigits(mod,frowpixel,fcolpixel,fenepixel,pList);
21b825a4 197
c7a4dac0 198 // apply mask to SPD module
199 SetMask();
21b825a4 200
c7a4dac0 201 CreateDigit(module,pList);
b0f5e3fc 202
c7a4dac0 203 // clean memory
204 delete[] frowpixel;
205 delete[] fcolpixel;
206 delete[] fenepixel;
207 fMapA2->ClearMap();
208 delete pList;
21b825a4 209}
c7a4dac0 210//______________________________________________________________________
211void AliITSsimulationSPD::SDigitsToDigits(Int_t module,AliITSpList *pList) {
212 // sum digits to Digits.
b0f5e3fc 213
c7a4dac0 214 FillMapFrompList(pList);
b0f5e3fc 215
c7a4dac0 216 // noise setting
217 SetFluctuations(pList,module);
b0f5e3fc 218
c7a4dac0 219 // apply mask to SPD module
220 SetMask();
21b825a4 221
c7a4dac0 222 CreateDigit(module,pList);
223}
224//______________________________________________________________________
225void AliITSsimulationSPD::UpdateMapSignal(Int_t row,Int_t col,Int_t trk,
226 Int_t hit,Int_t mod,Double_t ene,
227 AliITSpList *pList) {
228 // updates the Map of signal, adding the energy (ene) released by
229 // the current track
230
231 fMapA2->AddSignal(row,col,ene);
232 pList->AddSignal(row,col,trk,hit,mod,ene);
233}
234//______________________________________________________________________
235void AliITSsimulationSPD::UpdateMapNoise(Int_t row,Int_t col,Int_t mod,
236 Double_t ene,AliITSpList *pList) {
237 // updates the Map of noise, adding the energy (ene) give my noise
21b825a4 238
c7a4dac0 239 fMapA2->AddSignal(row,col,ene);
240 pList->AddNoise(row,col,mod,ene);
241}
242//______________________________________________________________________
243void AliITSsimulationSPD::HitsToAnalogDigits(AliITSmodule *mod,
244 Int_t *frowpixel,Int_t *fcolpixel,
245 Double_t *fenepixel,
246 AliITSpList *pList) {
247 // Loops over all hits to produce Analog/floting point digits. This
248 // is also the first task in producing standard digits.
21b825a4 249
c7a4dac0 250 // loop over hits in the module
251 Int_t hitpos,nhits = mod->GetNhits();
252 for (hitpos=0;hitpos<nhits;hitpos++) {
253 HitToDigit(mod,hitpos,frowpixel,fcolpixel,fenepixel,pList);
254 }// end loop over digits
255}
256//______________________________________________________________________
257void AliITSsimulationSPD::HitToDigit(AliITSmodule *mod,Int_t hitpos,
258 Int_t *frowpixel,Int_t *fcolpixel,
259 Double_t *fenepixel,AliITSpList *pList) {
260 // Steering function to determine the digits associated to a given
261 // hit (hitpos)
262 // The digits are created by charge sharing (ChargeSharing) and by
263 // capacitive coupling (SetCoupling). At all the created digits is
264 // associated the track number of the hit (ntrack)
265 Double_t x1l=0.0,y1l=0.0,z1l=0.0,x2l=0.0,y2l=0.0,z2l=0.0;
266 Int_t r1,r2,c1,c2,row,col,npixel = 0;
267 Int_t ntrack;
268 Double_t ene=0.0,etot=0.0;
269 const Float_t kconv = 10000.; // cm -> microns
270 const Float_t kconv1= 0.277e9; // GeV -> electrons equivalent
271
272 if(!(mod->LineSegmentL(hitpos,x1l,x2l,y1l,y2l,z1l,z2l,etot,ntrack)))return;
273
274 x2l += x1l; y2l += y1l; z2l += z1l; // Convert to ending coordinate.
275 // positions shifted and converted in microns
276 x1l = x1l*kconv + fSegmentation->Dx()/2.;
277 z1l = z1l*kconv + fSegmentation->Dz()/2.;
278 // positions shifted and converted in microns
279 x2l = x2l*kconv + fSegmentation->Dx()/2.;
280 z2l = z2l*kconv + fSegmentation->Dz()/2.;
281 etot *= kconv1; // convert from GeV to electrons equivalent.
282 Int_t module = mod->GetIndex();
283
284 // to account for the effective sensitive area
285 // introduced in geometry
286 if (z1l<0 || z1l>fSegmentation->Dz()) return;
287 if (z2l<0 || z2l>fSegmentation->Dz()) return;
288 if (x1l<0 || x1l>fSegmentation->Dx()) return;
289 if (x2l<0 || x2l>fSegmentation->Dx()) return;
290
291 //Get the col and row number starting from 1
292 // the x direction is not inverted for the second layer!!!
293 fSegmentation->GetPadIxz(x1l, z1l, c1, r1);
294 fSegmentation->GetPadIxz(x2l, z2l, c2, r2);
295
296 // to account for unexpected equal entrance and
297 // exit coordinates
0fee5d51 298 if (x1l==x2l) x2l=x2l+x2l*0.1;
299 if (z1l==z2l) z2l=z2l+z2l*0.1;
c7a4dac0 300
301 if ((r1==r2) && (c1==c2)){
302 // no charge sharing
303 npixel = 1;
304 frowpixel[npixel-1] = r1;
305 fcolpixel[npixel-1] = c1;
306 fenepixel[npixel-1] = etot;
307 } else {
308 // charge sharing
309 ChargeSharing(x1l,z1l,x2l,z2l,c1,r1,c2,r2,etot,
310 npixel,frowpixel,fcolpixel,fenepixel);
311 } // end if r1==r2 && c1==c2.
312
313 for (Int_t npix=0;npix<npixel;npix++){
314 row = frowpixel[npix];
315 col = fcolpixel[npix];
316 ene = fenepixel[npix];
317 UpdateMapSignal(row,col,ntrack,hitpos,module,ene,pList);
318 // Starting capacitive coupling effect
319 SetCoupling(row,col,ntrack,hitpos,module,pList);
320 } // end for npix
321}
322//______________________________________________________________________
323void AliITSsimulationSPD::ChargeSharing(Float_t x1l,Float_t z1l,Float_t x2l,
324 Float_t z2l,Int_t c1,Int_t r1,Int_t c2,
325 Int_t r2,Float_t etot,
326 Int_t &npixel,Int_t *frowpixel,
327 Int_t *fcolpixel,Double_t *fenepixel){
328 // Take into account the geometrical charge sharing when the track
329 // crosses more than one pixel.
330 //
331 //Begin_Html
21b825a4 332 /*
c7a4dac0 333 <img src="picts/ITS/barimodel_2.gif">
334 </pre>
335 <br clear=left>
336 <font size=+2 color=red>
337 <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
338 </font>
339 <pre>
21b825a4 340 */
c7a4dac0 341 //End_Html
342 Float_t xa,za,xb,zb,dx,dz,dtot,dm,refr,refm,refc;
343 Float_t refn=0.;
344 Float_t arefm, arefr, arefn, arefc, azb, az2l, axb, ax2l;
345 Int_t dirx,dirz,rb,cb;
346 Int_t flag,flagrow,flagcol;
347 Double_t epar;
348
349 npixel = 0;
350 xa = x1l;
351 za = z1l;
352 dx = TMath::Abs(x1l-x2l);
0fee5d51 353 if (dx == 0.) dx = 0.01;
c7a4dac0 354 dz = TMath::Abs(z1l-z2l);
0fee5d51 355 if (dz == 0.) dz = 0.01;
c7a4dac0 356 dtot = TMath::Sqrt((dx*dx)+(dz*dz));
357 dm = (x2l - x1l) / (z2l - z1l);
0fee5d51 358 if (dm == 0.) dm = 0.01;
c7a4dac0 359 dirx = (Int_t) ((x2l - x1l) / dx);
360 dirz = (Int_t) ((z2l - z1l) / dz);
361
362 // calculate the x coordinate of the pixel in the next column
363 // and the z coordinate of the pixel in the next row
364 Float_t xpos, zpos;
365
366 fSegmentation->GetPadCxz(c1, r1-1, xpos, zpos);
367
368 Float_t xsize = fSegmentation->Dpx(0);
369 Float_t zsize = fSegmentation->Dpz(r1-1);
21b825a4 370
c7a4dac0 371 if (dirx == 1) refr = xpos+xsize/2.;
372 else refr = xpos-xsize/2.;
373
374 if (dirz == 1) refn = zpos+zsize/2.;
375 else refn = zpos-zsize/2.;
376
377 flag = 0;
378 flagrow = 0;
379 flagcol = 0;
380 do{
381 // calculate the x coordinate of the intersection with the pixel
382 // in the next cell in row direction
383 refm = (refn - z1l)*dm + x1l;
e8189707 384
c7a4dac0 385 // calculate the z coordinate of the intersection with the pixel
386 // in the next cell in column direction
387 refc = (refr - x1l)/dm + z1l;
388
389 arefm = refm * dirx;
390 arefr = refr * dirx;
391 arefn = refn * dirz;
392 arefc = refc * dirz;
393
394 if ((arefm < arefr) && (arefn < arefc)){
395 // the track goes in the pixel in the next cell in row direction
396 xb = refm;
397 zb = refn;
398 cb = c1;
399 rb = r1 + dirz;
400 azb = zb * dirz;
401 az2l = z2l * dirz;
402 if (rb == r2) flagrow=1;
403 if (azb > az2l) {
21b825a4 404 zb = z2l;
405 xb = x2l;
c7a4dac0 406 } // end if
407 // shift to the pixel in the next cell in row direction
408 Float_t zsizeNext = fSegmentation->Dpz(rb-1);
409 //to account for cell at the borders of the detector
410 if(zsizeNext==0) zsizeNext = zsize;
411 refn += zsizeNext*dirz;
412 }else {
413 // the track goes in the pixel in the next cell in column direction
414 xb = refr;
415 zb = refc;
416 cb = c1 + dirx;
417 rb = r1;
418 axb = xb * dirx;
419 ax2l = x2l * dirx;
420 if (cb == c2) flagcol=1;
421 if (axb > ax2l) {
21b825a4 422 zb = z2l;
423 xb = x2l;
c7a4dac0 424 } // end ifaxb > ax2l
425
426 // shift to the pixel in the next cell in column direction
427 Float_t xsizeNext = fSegmentation->Dpx(cb-1);
428 //to account for cell at the borders of the detector
429 if(xsizeNext==0) xsizeNext = xsize;
430 refr += xsizeNext*dirx;
431 } // end if (arefm < arefr) && (arefn < arefc)
432
433 //calculate the energy lost in the crossed pixel
434 epar = TMath::Sqrt((xb-xa)*(xb-xa)+(zb-za)*(zb-za));
435 epar = etot*(epar/dtot);
436
437 //store row, column and energy lost in the crossed pixel
438 frowpixel[npixel] = r1;
439 fcolpixel[npixel] = c1;
440 fenepixel[npixel] = epar;
441 npixel++;
21b825a4 442
c7a4dac0 443 // the exit point of the track is reached
444 if (epar == 0) flag = 1;
445 if ((r1 == r2) && (c1 == c2)) flag = 1;
446 if (flag!=1) {
447 r1 = rb;
448 c1 = cb;
449 xa = xb;
450 za = zb;
451 } // end if flag!=1
452 } while (flag==0);
21b825a4 453}
c7a4dac0 454//______________________________________________________________________
21b825a4 455void AliITSsimulationSPD::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
c7a4dac0 456 Int_t idhit,Int_t module,
457 AliITSpList *pList) {
458 // Take into account the coupling between adiacent pixels.
459 // The parameters probcol and probrow are the fractions of the
460 // signal in one pixel shared in the two adjacent pixels along
461 // the column and row direction, respectively.
462 //
463 //Begin_Html
464 /*
465 <img src="picts/ITS/barimodel_3.gif">
466 </pre>
467 <br clear=left>
468 <font size=+2 color=red>
469 <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
470 </font>
471 <pre>
472 */
473 //End_Html
474 Int_t j1,j2,flag=0;
475 Double_t pulse1,pulse2;
476 Float_t couplR=0.0,couplC=0.0;
477
478 GetCouplings(couplR,couplC);
479 j1 = row;
480 j2 = col;
481 pulse1 = fMapA2->GetSignal(row,col);
482 pulse2 = pulse1;
483 for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
484 do{
485 j1 += isign;
486 pulse1 *= couplR;
487 if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1<GetThreshold())){
488 pulse1 = fMapA2->GetSignal(row,col);
489 j1 = row;
490 flag = 1;
491 }else{
492 UpdateMapSignal(j1,col,ntrack,idhit,module,pulse1,pList);
493 flag = 0;
494 } // end if
495 } while(flag == 0);
496 // loop in column direction
497 do{
498 j2 += isign;
499 pulse2 *= couplC;
500 if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2<GetThreshold())){
501 pulse2 = fMapA2->GetSignal(row,col);
502 j2 = col;
503 flag = 1;
504 }else{
505 UpdateMapSignal(row,j2,ntrack,idhit,module,pulse2,pList);
506 flag = 0;
507 } // end if
508 } while(flag == 0);
509 } // for isign
21b825a4 510}
c7a4dac0 511//______________________________________________________________________
512void AliITSsimulationSPD::CreateDigit(Int_t module,AliITSpList *pList) {
513 // The pixels are fired if the energy deposited inside them is above
514 // the threshold parameter ethr. Fired pixed are interpreted as digits
515 // and stored in the file digitfilename. One also needs to write out
516 // cases when there is only noise (nhits==0).
517
518 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
519
520 Int_t digits[3];
521 Int_t tracks[3];
522 Int_t hits[3];
523 Float_t charges[3];
524 Int_t j1;
525
526 for (Int_t r=1;r<=GetNPixelsZ();r++) {
527 for (Int_t c=1;c<=GetNPixelsX();c++) {
528 // check if the deposited energy in a pixel is above the
529 // threshold
530 Float_t signal = (Float_t) fMapA2->GetSignal(r,c);
531 if ( signal > GetThreshold()) {
532 digits[0] = r-1; // digits starts from 0
533 digits[1] = c-1; // digits starts from 0
534 //digits[2] = 1;
535 digits[2] = (Int_t) signal; // the signal is stored in
536 // electrons
537 for(j1=0;j1<3;j1++){
538 tracks[j1] = pList->GetTrack(r,c,j1);
539 hits[j1] = pList->GetHit(r,c,j1);
21b825a4 540 charges[j1] = 0;
c7a4dac0 541 } // end for j1
542 Float_t phys = 0;
543 aliITS->AddSimDigit(0,phys,digits,tracks,hits,charges);
544 } // end if of threshold condition
545 } // for c
546 }// end do on pixels
21b825a4 547}
c7a4dac0 548//______________________________________________________________________
549void AliITSsimulationSPD::SetFluctuations(AliITSpList *pList,Int_t module) {
550 // Set the electronic noise and threshold non-uniformities to all the
551 // pixels in a detector.
552 // The parameter fSigma is the squared sum of the sigma due to noise
553 // and the sigma of the threshold distribution among pixels.
554 //
555 //Begin_Html
556 /*
557 <img src="picts/ITS/barimodel_1.gif">
558 </pre>
559 <br clear=left>
560 <font size=+2 color=red>
561 <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>.
562 </font>
563 <pre>
564 */
565 //End_Html
566 Float_t thr=0.0,sigm=0.0;
567 Double_t signal,sigma;
568 Int_t iz,ix;
569
570 GetThresholds(thr,sigm);
571 sigma = (Double_t) sigm;
572 for(iz=1;iz<=GetNPixelsZ();iz++){
573 for(ix=1;ix<=GetNPixelsX();ix++){
574 signal = sigma*gRandom->Gaus();
575 fMapA2->SetHit(iz,ix,signal);
576 // insert in the label-signal-hit list the pixels fired
577 // only by noise
578 pList->AddNoise(iz,ix,module,signal);
579 } // end of loop on pixels
21b825a4 580 } // end of loop on pixels
c7a4dac0 581}
582//______________________________________________________________________
583void AliITSsimulationSPD::SetMask() {
584 // Apply a mask to the SPD module. 1% of the pixel channels are
585 // masked. When the database will be ready, the masked pixels
586 // should be read from it.
587 Double_t signal;
588 Int_t iz,ix,im;
589 Float_t totMask;
590 Float_t perc = ((AliITSresponseSPD*)fResponse)->GetFractionDead();
591 // in this way we get the same set of random numbers for all runs.
592 // This is a cluge for now.
593 static TRandom *rnd = new TRandom();
594
595 totMask= perc*GetNPixelsZ()*GetNPixelsX();
596 for(im=1;im<totMask;im++){
597 do{
598 ix=(Int_t)(rnd->Rndm()*(GetNPixelsX()-1.) + 1.);
599 } while(ix<=0 || ix>GetNPixelsX());
600 do{
601 iz=(Int_t)(rnd->Rndm()*(GetNPixelsZ()-1.) + 1.);
602 } while(iz<=0 || iz>GetNPixelsZ());
603 signal = -1.;
604 fMapA2->SetHit(iz,ix,signal);
605 } // end loop on masked pixels
606}
607//______________________________________________________________________
21b825a4 608void AliITSsimulationSPD::CreateHistograms() {
c7a4dac0 609 // Create Histograms
610 Int_t i;
21b825a4 611
c7a4dac0 612 fHis=new TObjArray(GetNPixelsZ());
613 for(i=0;i<GetNPixelsZ();i++) {
614 TString spdname("spd_");
615 Char_t candnum[4];
616 sprintf(candnum,"%d",i+1);
617 spdname.Append(candnum);
618 (*fHis)[i] = new TH1F(spdname.Data(),"SPD maps",
619 GetNPixelsX(),0.,(Float_t) GetNPixelsX());
620 } // end for i
b0f5e3fc 621}
c7a4dac0 622//______________________________________________________________________
21b825a4 623void AliITSsimulationSPD::ResetHistograms() {
b0f5e3fc 624 // Reset histograms for this detector
21b825a4 625 Int_t i;
b0f5e3fc 626
c7a4dac0 627 for(i=0;i<GetNPixelsZ();i++ ) {
628 if ((*fHis)[i]) ((TH1F*)(*fHis)[i])->Reset();
629 } // end for i
630}
631//______________________________________________________________________
632void AliITSsimulationSPD::WriteSDigits(AliITSpList *pList){
633 // Fills the Summable digits Tree
634 Int_t i,ni,j,nj;
635 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
636
637 pList->GetMaxMapIndex(ni,nj);
638 for(i=0;i<ni;i++)for(j=0;j<nj;j++){
639 if(pList->GetSignalOnly(i,j)>0.0){
640 aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
641// cout << "pListSPD: " << *(pList->GetpListItem(i,j)) << endl;
642 } // end if
643 } // end for i,j
644 return;
645}
646//______________________________________________________________________
647void AliITSsimulationSPD::FillMapFrompList(AliITSpList *pList){
648 // Fills fMap2A from the pList of Summable digits
649 Int_t k,ix;
650
651 for(k=0;k<GetNPixelsZ();k++)for(ix=0;ix<GetNPixelsX();ix++)
652 fMapA2->AddSignal(k,ix,pList->GetSignal(k,ix));
653 return;
b0f5e3fc 654}