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