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