]>
Commit | Line | Data |
---|---|---|
409f8c84 | 1 | #include <iostream.h> |
2 | #include <TRandom.h> | |
3 | #include <TH1.h> | |
4 | #include <TMath.h> | |
5 | #include <TString.h> | |
6 | #include <TParticle.h> | |
7 | ||
8 | ||
9 | #include "AliRun.h" | |
10 | #include "AliITS.h" | |
11 | #include "AliITShit.h" | |
12 | #include "AliITSdigit.h" | |
13 | #include "AliITSmodule.h" | |
14 | #include "AliITSMapA2.h" | |
2cc6b29a | 15 | #include "AliITSpList.h" |
409f8c84 | 16 | #include "AliITSsimulationSPDdubna.h" |
17 | #include "AliITSsegmentation.h" | |
18 | #include "AliITSresponse.h" | |
19 | ||
20 | ||
21 | ||
22 | ||
23 | ClassImp(AliITSsimulationSPDdubna) | |
24 | //////////////////////////////////////////////////////////////////////// | |
25 | // Version: 0 | |
26 | // Written by Boris Batyunya | |
27 | // December 20 1999 | |
28 | // | |
29 | // AliITSsimulationSPDdubna is the simulation of SPDs | |
2cc6b29a | 30 | //______________________________________________________________________ |
31 | ||
32 | ||
33 | AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(){ | |
34 | // constructor | |
35 | ||
36 | fResponse = 0; | |
37 | fSegmentation = 0; | |
38 | fMapA2 = 0; | |
39 | fpList = 0; | |
40 | fModule = 0; | |
41 | fEvent = 0; | |
42 | fHis = 0; | |
43 | fNoise = 0.; | |
44 | fBaseline = 0.; | |
45 | fNPixelsZ = 0; | |
46 | fNPixelsX = 0; | |
409f8c84 | 47 | } |
2cc6b29a | 48 | //______________________________________________________________________ |
49 | AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(AliITSsegmentation *seg, | |
50 | AliITSresponse *resp){ | |
51 | // standard constructor | |
409f8c84 | 52 | |
2cc6b29a | 53 | fHis = 0; |
54 | fResponse = resp; | |
55 | fSegmentation = seg; | |
56 | fModule = 0; | |
57 | fEvent = 0; | |
409f8c84 | 58 | |
2cc6b29a | 59 | fNPixelsZ=fSegmentation->Npz(); |
60 | fNPixelsX=fSegmentation->Npx(); | |
409f8c84 | 61 | |
2cc6b29a | 62 | fResponse->GetNoiseParam(fNoise,fBaseline); |
409f8c84 | 63 | |
2cc6b29a | 64 | fMapA2 = new AliITSMapA2(fSegmentation); |
409f8c84 | 65 | |
2cc6b29a | 66 | fpList = new AliITSpList(fNPixelsZ+1,fNPixelsX+1); |
409f8c84 | 67 | |
2cc6b29a | 68 | } |
69 | //______________________________________________________________________ | |
70 | AliITSsimulationSPDdubna::~AliITSsimulationSPDdubna(){ | |
71 | // destructor | |
409f8c84 | 72 | |
2cc6b29a | 73 | delete fMapA2; |
409f8c84 | 74 | |
2cc6b29a | 75 | if (fHis) { |
76 | fHis->Delete(); | |
77 | delete fHis; | |
78 | } // end if fHis | |
409f8c84 | 79 | } |
2cc6b29a | 80 | //______________________________________________________________________ |
81 | AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(const | |
82 | AliITSsimulationSPDdubna | |
83 | &source){ | |
84 | // Copy Constructor | |
85 | if(&source == this) return; | |
86 | this->fMapA2 = source.fMapA2; | |
87 | this->fNoise = source.fNoise; | |
88 | this->fBaseline = source.fBaseline; | |
89 | this->fNPixelsX = source.fNPixelsX; | |
90 | this->fNPixelsZ = source.fNPixelsZ; | |
91 | this->fHis = source.fHis; | |
92 | return; | |
93 | } | |
94 | //______________________________________________________________________ | |
95 | AliITSsimulationSPDdubna& AliITSsimulationSPDdubna::operator=(const | |
96 | AliITSsimulationSPDdubna &source){ | |
97 | // Assignment operator | |
98 | if(&source == this) return *this; | |
99 | this->fMapA2 = source.fMapA2; | |
100 | this->fNoise = source.fNoise; | |
101 | this->fBaseline = source.fBaseline; | |
102 | this->fNPixelsX = source.fNPixelsX; | |
103 | this->fNPixelsZ = source.fNPixelsZ; | |
104 | this->fHis = source.fHis; | |
105 | return *this; | |
106 | } | |
107 | //______________________________________________________________________ | |
108 | void AliITSsimulationSPDdubna::InitSimulationModule(Int_t module, Int_t event){ | |
109 | // This function creates maps to build the list of tracks for each | |
110 | // summable digit. | |
111 | // | |
112 | // Inputs: | |
113 | // Int_t module // Module number to be simulated | |
114 | // Int_t event // Event number to be simulated | |
115 | // | |
116 | // Outputs: | |
117 | // none | |
118 | // | |
119 | // Returns: | |
120 | // none | |
409f8c84 | 121 | |
2cc6b29a | 122 | fModule = module; |
123 | fEvent = event; | |
124 | fMapA2->ClearMap(); | |
125 | fpList->ClearMap(); | |
126 | } | |
127 | //_____________________________________________________________________ | |
128 | void AliITSsimulationSPDdubna::SDigitiseModule(AliITSmodule *mod, Int_t mask, | |
129 | Int_t event){ | |
130 | // This function begins the work of creating S-Digits | |
131 | // | |
132 | // Inputs: | |
133 | // AliITSmodule *mod // module | |
134 | // Int_t mask // mask to be applied to the module | |
135 | // | |
136 | // Outputs: | |
137 | // none | |
138 | // | |
139 | // Return: | |
140 | // test // test returns kTRUE if the module contained hits | |
141 | // // test returns kFALSE if it did not contain hits | |
409f8c84 | 142 | |
2cc6b29a | 143 | Int_t module = 0; |
409f8c84 | 144 | |
2cc6b29a | 145 | if(!(mod->GetNhits())) return;// if module has no hits don't create Sdigits |
146 | fModule = mod->GetIndex(); | |
147 | HitToSDigit(mod, module, mask, fpList); | |
148 | WriteSDigits(fpList); | |
149 | fMapA2->ClearMap(); | |
150 | fpList->ClearMap(); | |
409f8c84 | 151 | } |
2cc6b29a | 152 | //______________________________________________________________________ |
153 | void AliITSsimulationSPDdubna::WriteSDigits(AliITSpList *pList){ | |
154 | // This function adds each S-Digit to pList | |
155 | // | |
156 | // Inputs: | |
157 | // AliITSpList *pList | |
158 | // | |
159 | // Outputs: | |
160 | // none | |
161 | // | |
162 | // Return: | |
163 | // none | |
7d50ea21 | 164 | Int_t ix, nix, iz, niz; |
2cc6b29a | 165 | static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS"); |
166 | ||
7d50ea21 | 167 | pList->GetMaxMapIndex(niz, nix); |
168 | for(iz=0; iz<niz; iz++)for(ix=0; ix<nix; ix++){ | |
169 | if(pList->GetSignalOnly(iz,ix)>0.0){ | |
170 | aliITS->AddSumDigit(*(pList->GetpListItem(iz,ix))); | |
2cc6b29a | 171 | } // end if pList |
7d50ea21 | 172 | } // end for iz,ix |
2cc6b29a | 173 | return; |
174 | } | |
175 | //______________________________________________________________________ | |
176 | void AliITSsimulationSPDdubna::FinishSDigitiseModule(){ | |
177 | // This function calls SDigitsToDigits which creates Digits from SDigits | |
178 | // | |
179 | // Inputs: | |
180 | // none | |
181 | // | |
182 | // Outputs: | |
183 | // none | |
184 | // Return | |
185 | // none | |
409f8c84 | 186 | |
2cc6b29a | 187 | SDigitsToDigits(fModule, fpList); |
188 | return; | |
189 | } | |
190 | //______________________________________________________________________ | |
191 | void AliITSsimulationSPDdubna::SDigitsToDigits(Int_t module, | |
192 | AliITSpList *pList){ | |
193 | // This function adds electronic noise to the S-Digits and then adds them | |
194 | // to a new pList | |
195 | // | |
196 | // Inputs: | |
197 | // Int_t module // module number | |
198 | // AliITSpList *pList // pList | |
199 | // | |
200 | // Outputs: | |
201 | // pList is passed along to the functions ChargeToSignal and GetList | |
202 | // | |
203 | // Return: | |
204 | // none | |
409f8c84 | 205 | |
2cc6b29a | 206 | fModule = module; |
207 | ChargeToSignal(pList); // Charge To Signal both adds noise and | |
208 | fMapA2->ClearMap(); | |
209 | pList->ClearMap(); | |
409f8c84 | 210 | } |
2cc6b29a | 211 | //______________________________________________________________________ |
212 | void AliITSsimulationSPDdubna::DigitiseModule(AliITSmodule *mod, Int_t module, | |
213 | Int_t dummy){ | |
214 | // This function creates Digits straight from the hits and then adds | |
215 | // electronic noise to the digits before adding them to pList | |
216 | // | |
217 | // Inputs: | |
218 | // AliITSmodule *mod // module | |
219 | // Int_t module // module number Dummy. | |
220 | // Int_t dummy | |
221 | // | |
222 | // Outputs: | |
223 | // Each of the input variables is passed along to HitToSDigit | |
224 | // | |
225 | // Return: | |
226 | // none | |
409f8c84 | 227 | |
2cc6b29a | 228 | fModule = mod->GetIndex(); //This calls the module for HitToSDigit |
229 | HitToSDigit(mod,fModule, dummy, fpList); | |
230 | ChargeToSignal(fpList); | |
231 | fMapA2->ClearMap(); | |
232 | fpList->ClearMap(); | |
233 | } | |
234 | //______________________________________________________________________ | |
7d50ea21 | 235 | void AliITSsimulationSPDdubna::UpdateMapSignal(Int_t iz, Int_t ix, Int_t trk, |
2cc6b29a | 236 | Int_t ht, Int_t module, |
237 | Double_t signal, | |
238 | AliITSpList *pList){ | |
239 | // This function adds a signal to the pList from the pList class | |
240 | // | |
241 | // Inputs: | |
7d50ea21 | 242 | // Int_t iz // row number |
243 | // Int_t ix // column number | |
2cc6b29a | 244 | // Int_t trk // track number |
245 | // Int_t ht // hit number | |
246 | // Double_t signal // signal strength | |
247 | // AliITSpList *pList // pList | |
248 | // | |
249 | // Outputs: | |
250 | // All of the inputs are passed to AliITSpList::AddSignal | |
251 | // Int_t ix // row number | |
252 | // Int_t iz // column number | |
253 | // Double_t sig // signal strength | |
254 | // // These three variables are defined to preserve the | |
255 | // // assignments used in the function AliITSMapA2::AddSignal | |
256 | // | |
257 | // Return: | |
258 | // none | |
2cc6b29a | 259 | |
7d50ea21 | 260 | fMapA2->AddSignal(iz, ix, signal); |
261 | pList->AddSignal(iz,ix, trk, ht, fModule, signal); | |
2cc6b29a | 262 | } |
263 | //______________________________________________________________________ | |
7d50ea21 | 264 | void AliITSsimulationSPDdubna::UpdateMapNoise(Int_t iz, |
265 | Int_t ix, Int_t fModule, | |
2cc6b29a | 266 | Double_t sig, Float_t noise, |
267 | AliITSpList *pList){ | |
268 | // This function adds noise to data in the MapA2 as well as the pList | |
269 | // | |
270 | // Inputs: | |
7d50ea21 | 271 | // Int_t iz // row number |
272 | // Int_t ix // column number | |
2cc6b29a | 273 | // Int_t mod // module number |
274 | // Double_t sig // signal strength | |
275 | // Double_t noise // electronic noise generated by ChargeToSignal | |
276 | // AliITSpList *pList // pList | |
277 | // | |
278 | // Outputs: | |
279 | // All of the inputs are passed to AliITSMapA2::AddSignal or | |
280 | // AliITSpList::AddNoise | |
281 | // | |
282 | // Return: | |
283 | // none | |
409f8c84 | 284 | |
2cc6b29a | 285 | fMapA2->AddSignal(iz, ix, sig); |
7d50ea21 | 286 | pList->AddNoise(iz,ix, fModule, noise); |
2cc6b29a | 287 | } |
288 | //______________________________________________________________________ | |
289 | void AliITSsimulationSPDdubna::HitToDigit(AliITSmodule *mod, Int_t module, | |
290 | Int_t dummy){ | |
291 | DigitiseModule(mod, module, dummy); | |
292 | } | |
293 | //______________________________________________________________________ | |
294 | void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod, Int_t module, | |
295 | Int_t dummy, AliITSpList *pList){ | |
296 | // digitize module | |
409f8c84 | 297 | const Float_t kEnToEl = 2.778e+8; // GeV->charge in electrons |
298 | // for 3.6 eV/pair | |
299 | const Float_t kconv = 10000.; // cm -> microns | |
300 | ||
301 | Float_t spdLength = fSegmentation->Dz(); | |
302 | Float_t spdWidth = fSegmentation->Dx(); | |
338e4f06 | 303 | Float_t spdThickness = fSegmentation->Dy(); |
409f8c84 | 304 | Float_t difCoef, dum; |
305 | fResponse->DiffCoeff(difCoef,dum); | |
338e4f06 | 306 | if(spdThickness > 290) difCoef = 0.00613; |
409f8c84 | 307 | |
308 | Float_t zPix0 = 1e+6; | |
309 | Float_t xPix0 = 1e+6; | |
310 | Float_t yPrev = 1e+6; | |
311 | ||
312 | Float_t zPitch = fSegmentation->Dpz(0); | |
313 | Float_t xPitch = fSegmentation->Dpx(0); | |
314 | ||
315 | TObjArray *fHits = mod->GetHits(); | |
2cc6b29a | 316 | module = mod->GetIndex(); |
409f8c84 | 317 | Int_t nhits = fHits->GetEntriesFast(); |
318 | if (!nhits) return; | |
319 | ||
2cc6b29a | 320 | cout<<"len,wid,thickness,nx,nz,pitchx,pitchz,difcoef ="<<spdLength<<"," |
321 | <<spdWidth<<","<<spdThickness<<","<<fNPixelsX<<","<<fNPixelsZ<<"," | |
322 | <<xPitch<<","<<zPitch<<","<<difCoef<<endl; | |
323 | // Array of pointers to the label-signal list | |
409f8c84 | 324 | Int_t indexRange[4] = {0,0,0,0}; |
325 | ||
326 | // Fill detector maps with GEANT hits | |
327 | // loop over hits in the module | |
328 | static Bool_t first; | |
329 | Int_t lasttrack=-2; | |
330 | Int_t hit, iZi, jz, jx; | |
338e4f06 | 331 | Int_t idhit=-1; //! |
332 | cout<<"SPDdubna: module,nhits ="<<module<<","<<nhits<<endl; | |
409f8c84 | 333 | for (hit=0;hit<nhits;hit++) { |
334 | AliITShit *iHit = (AliITShit*) fHits->At(hit); | |
338e4f06 | 335 | //Int_t layer = iHit->GetLayer(); |
336 | Float_t yPix0 = -spdThickness/2; | |
337 | ||
338 | // work with the idtrack=entry number in the TreeH | |
339 | //Int_t idhit,idtrack; //! | |
340 | //mod->GetHitTrackAndHitIndex(hit,idtrack,idhit); //! | |
341 | //Int_t idtrack=mod->GetHitTrackIndex(hit); | |
342 | // or store straight away the particle position in the array | |
343 | // of particles : | |
409f8c84 | 344 | if(iHit->StatusEntering()) idhit=hit; |
345 | Int_t itrack = iHit->GetTrack(); | |
346 | Int_t dray = 0; | |
347 | ||
348 | if (lasttrack != itrack || hit==(nhits-1)) first = kTRUE; | |
349 | ||
338e4f06 | 350 | //Int_t parent = iHit->GetParticle()->GetFirstMother(); |
409f8c84 | 351 | Int_t partcode = iHit->GetParticle()->GetPdgCode(); |
352 | ||
2cc6b29a | 353 | // partcode (pdgCode): 11 - e-, 13 - mu-, 22 - gamma, 111 - pi0, |
354 | // 211 - pi+, 310 - K0s, 321 - K+, 2112 - n, 2212 - p, 3122 - lambda | |
409f8c84 | 355 | |
356 | Float_t pmod = iHit->GetParticle()->P(); // total momentum at the | |
357 | // vertex | |
358 | pmod *= 1000; | |
359 | ||
409f8c84 | 360 | if(partcode == 11 && pmod < 6) dray = 1; // delta ray is e- |
361 | // at p < 6 MeV/c | |
362 | ||
409f8c84 | 363 | // Get hit z and x(r*phi) cordinates for each module (detector) |
364 | // in local system. | |
365 | ||
366 | Float_t zPix = kconv*iHit->GetZL(); | |
367 | Float_t xPix = kconv*iHit->GetXL(); | |
368 | Float_t yPix = kconv*iHit->GetYL(); | |
369 | ||
370 | // Get track status | |
371 | Int_t status = iHit->GetTrackStatus(); | |
409f8c84 | 372 | |
373 | // Check boundaries | |
374 | if(zPix > spdLength/2) { | |
2cc6b29a | 375 | //cout<<"!!! SPD: z outside ="<<zPix<<endl; |
376 | zPix = spdLength/2 - 10; | |
409f8c84 | 377 | } |
378 | if(zPix < 0 && zPix < -spdLength/2) { | |
2cc6b29a | 379 | //cout<<"!!! SPD: z outside ="<<zPix<<endl; |
380 | zPix = -spdLength/2 + 10; | |
409f8c84 | 381 | } |
382 | if(xPix > spdWidth/2) { | |
2cc6b29a | 383 | //cout<<"!!! SPD: x outside ="<<xPix<<endl; |
384 | xPix = spdWidth/2 - 10; | |
409f8c84 | 385 | } |
386 | if(xPix < 0 && xPix < -spdWidth/2) { | |
2cc6b29a | 387 | //cout<<"!!! SPD: x outside ="<<xPix<<endl; |
388 | xPix = -spdWidth/2 + 10; | |
409f8c84 | 389 | } |
390 | Int_t trdown = 0; | |
391 | ||
392 | // enter Si or after event in Si | |
393 | if (status == 66 ) { | |
2cc6b29a | 394 | zPix0 = zPix; |
395 | xPix0 = xPix; | |
396 | yPrev = yPix; | |
397 | } // end if status == 66 | |
409f8c84 | 398 | |
399 | Float_t depEnergy = iHit->GetIonization(); | |
400 | // skip if the input point to Si | |
401 | ||
402 | if(depEnergy <= 0.) continue; | |
403 | ||
404 | // if track returns to the opposite direction: | |
405 | if (yPix < yPrev) { | |
406 | trdown = 1; | |
2cc6b29a | 407 | } // end if yPix < yPrev |
409f8c84 | 408 | |
409 | // take into account the holes diffusion inside the Silicon | |
410 | // the straight line between the entrance and exit points in Si is | |
411 | // divided into the several steps; the diffusion is considered | |
412 | // for each end point of step and charge | |
413 | // is distributed between the pixels through the diffusion. | |
409f8c84 | 414 | |
415 | // ---------- the diffusion in Z (beam) direction ------- | |
409f8c84 | 416 | Float_t charge = depEnergy*kEnToEl; // charge in e- |
417 | Float_t drPath = 0.; | |
418 | Float_t tang = 0.; | |
419 | Float_t sigmaDif = 0.; | |
420 | Float_t zdif = zPix - zPix0; | |
421 | Float_t xdif = xPix - xPix0; | |
422 | Float_t ydif = TMath::Abs(yPix - yPrev); | |
423 | Float_t ydif0 = TMath::Abs(yPrev - yPix0); | |
424 | ||
425 | if(ydif < 1) continue; // ydif is not zero | |
426 | ||
427 | Float_t projDif = sqrt(xdif*xdif + zdif*zdif); | |
428 | ||
429 | Int_t ndZ = (Int_t)TMath::Abs(zdif/zPitch) + 1; | |
430 | Int_t ndX = (Int_t)TMath::Abs(xdif/xPitch) + 1; | |
431 | ||
432 | // number of the steps along the track: | |
433 | Int_t nsteps = ndZ; | |
434 | if(ndX > ndZ) nsteps = ndX; | |
338e4f06 | 435 | if(nsteps < 20) nsteps = 20; // minimum number of the steps |
409f8c84 | 436 | |
437 | if (projDif < 5 ) { | |
2cc6b29a | 438 | drPath = (yPix-yPix0)*1.e-4; |
439 | drPath = TMath::Abs(drPath); // drift path in cm | |
440 | sigmaDif = difCoef*sqrt(drPath); // sigma diffusion in cm | |
441 | sigmaDif = sigmaDif*kconv; // sigma diffusion in microns | |
442 | nsteps = 1; | |
443 | } // end if projDif < 5 | |
409f8c84 | 444 | |
445 | if(projDif > 5) tang = ydif/projDif; | |
446 | Float_t dCharge = charge/nsteps; // charge in e- for one step | |
447 | Float_t dZ = zdif/nsteps; | |
448 | Float_t dX = xdif/nsteps; | |
449 | ||
2cc6b29a | 450 | for (iZi = 1; iZi <= nsteps;iZi++) { |
451 | Float_t dZn = iZi*dZ; | |
409f8c84 | 452 | Float_t dXn = iZi*dX; |
453 | Float_t zPixn = zPix0 + dZn; | |
454 | Float_t xPixn = xPix0 + dXn; | |
455 | ||
456 | if(projDif >= 5) { | |
2cc6b29a | 457 | Float_t dProjn = sqrt(dZn*dZn+dXn*dXn); |
458 | drPath = dProjn*tang*1.e-4; // drift path for iZi+1 step in cm | |
459 | if(trdown == 0) { | |
460 | drPath = TMath::Abs(drPath) + ydif0*1.e-4; | |
461 | }// end if trdow ==0 | |
462 | if(trdown == 1) { | |
463 | drPath = ydif0*1.e-4 - TMath::Abs(drPath); | |
464 | drPath = TMath::Abs(drPath); | |
465 | } // end if trdown == 1 | |
466 | sigmaDif = difCoef*sqrt(drPath); | |
467 | sigmaDif = sigmaDif*kconv; // sigma diffusion in microns | |
468 | } // end if projdif >= 5 | |
409f8c84 | 469 | |
470 | zPixn = (zPixn + spdLength/2.); | |
471 | xPixn = (xPixn + spdWidth/2.); | |
472 | Int_t nZpix, nXpix; | |
473 | fSegmentation->GetPadIxz(xPixn,zPixn,nXpix,nZpix); | |
474 | zPitch = fSegmentation->Dpz(nZpix); | |
475 | fSegmentation->GetPadTxz(xPixn,zPixn); | |
476 | // set the window for the integration | |
477 | Int_t jzmin = 1; | |
478 | Int_t jzmax = 3; | |
479 | if(nZpix == 1) jzmin =2; | |
480 | if(nZpix == fNPixelsZ) jzmax = 2; | |
481 | ||
482 | Int_t jxmin = 1; | |
483 | Int_t jxmax = 3; | |
484 | if(nXpix == 1) jxmin =2; | |
485 | if(nXpix == fNPixelsX) jxmax = 2; | |
486 | ||
487 | Float_t zpix = nZpix; | |
488 | Float_t dZright = zPitch*(zpix - zPixn); | |
489 | Float_t dZleft = zPitch - dZright; | |
490 | ||
491 | Float_t xpix = nXpix; | |
492 | Float_t dXright = xPitch*(xpix - xPixn); | |
493 | Float_t dXleft = xPitch - dXright; | |
494 | ||
495 | Float_t dZprev = 0.; | |
496 | Float_t dZnext = 0.; | |
497 | Float_t dXprev = 0.; | |
498 | Float_t dXnext = 0.; | |
499 | ||
500 | for(jz=jzmin; jz <=jzmax; jz++) { | |
501 | if(jz == 1) { | |
2cc6b29a | 502 | dZprev = -zPitch - dZleft; |
503 | dZnext = -dZleft; | |
504 | } else if(jz == 2) { | |
505 | dZprev = -dZleft; | |
506 | dZnext = dZright; | |
507 | } else if(jz == 3) { | |
508 | dZprev = dZright; | |
509 | dZnext = dZright + zPitch; | |
510 | } // end if jz | |
409f8c84 | 511 | // kz changes from 1 to the fNofPixels(270) |
512 | Int_t kz = nZpix + jz -2; | |
513 | ||
514 | Float_t zArg1 = dZprev/sigmaDif; | |
515 | Float_t zArg2 = dZnext/sigmaDif; | |
516 | Float_t zProb1 = TMath::Erfc(zArg1); | |
517 | Float_t zProb2 = TMath::Erfc(zArg2); | |
518 | Float_t dZCharge =0.5*(zProb1-zProb2)*dCharge; | |
519 | ||
520 | ||
521 | // ----------- holes diffusion in X(r*phi) direction -------- | |
522 | ||
523 | if(dZCharge > 1.) { | |
2cc6b29a | 524 | for(jx=jxmin; jx <=jxmax; jx++) { |
525 | if(jx == 1) { | |
526 | dXprev = -xPitch - dXleft; | |
527 | dXnext = -dXleft; | |
528 | } else if(jx == 2) { | |
529 | dXprev = -dXleft; | |
530 | dXnext = dXright; | |
531 | } else if(jx == 3) { | |
532 | dXprev = dXright; | |
533 | dXnext = dXright + xPitch; | |
534 | } // end if jx | |
535 | Int_t kx = nXpix + jx -2; | |
536 | Float_t xArg1 = dXprev/sigmaDif; | |
537 | Float_t xArg2 = dXnext/sigmaDif; | |
538 | Float_t xProb1 = TMath::Erfc(xArg1); | |
539 | Float_t xProb2 = TMath::Erfc(xArg2); | |
540 | Float_t dXCharge =0.5*(xProb1-xProb2)*dZCharge; | |
541 | ||
542 | if(dXCharge > 1.) { | |
543 | Int_t index = kz-1; | |
544 | if (first) { | |
545 | indexRange[0]=indexRange[1]=index; | |
546 | indexRange[2]=indexRange[3]=kx-1; | |
547 | first=kFALSE; | |
548 | } // end if first | |
549 | indexRange[0]=TMath::Min(indexRange[0],kz-1); | |
550 | indexRange[1]=TMath::Max(indexRange[1],kz-1); | |
551 | indexRange[2]=TMath::Min(indexRange[2],kx-1); | |
552 | indexRange[3]=TMath::Max(indexRange[3],kx-1); | |
553 | ||
554 | // build the list of digits for this module | |
555 | Double_t signal=fMapA2->GetSignal(index,kx-1); | |
556 | signal+=dXCharge; | |
557 | fMapA2->SetHit(index,kx-1,(double)signal); | |
558 | ||
559 | // The calling sequence for UpdateMapSignal was | |
560 | // moved into the (dx > 1 e-) loop because it | |
561 | // needs to call signal which is defined inside | |
562 | // this loop | |
2cc6b29a | 563 | fModule = module;//Defined because functions |
564 | // called by UpdateMapSignal | |
565 | // expect module to be an | |
566 | // integer | |
7d50ea21 | 567 | UpdateMapSignal(kz-1,kx-1, |
568 | mod->GetHitTrackIndex(hit), | |
569 | hit,fModule,signal,pList); | |
2cc6b29a | 570 | } // dXCharge > 1 e- |
571 | } // jx loop | |
409f8c84 | 572 | } // dZCharge > 1 e- |
573 | } // jz loop | |
574 | } // iZi loop | |
409f8c84 | 575 | if (status == 65) { // the step is inside of Si |
2cc6b29a | 576 | zPix0 = zPix; |
577 | xPix0 = xPix; | |
578 | } // end if status == 65 | |
579 | yPrev = yPix; | |
409f8c84 | 580 | } // hit loop inside the module |
409f8c84 | 581 | } |
2cc6b29a | 582 | //______________________________________________________________________ |
583 | void AliITSsimulationSPDdubna::ChargeToSignal(AliITSpList *pList){ | |
584 | // add noise and electronics, perform the zero suppression and add the | |
585 | // digit to the list | |
586 | ||
587 | AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS"); | |
588 | ||
589 | Float_t threshold = (float)fResponse->MinVal(); | |
590 | ||
591 | Int_t digits[3], tracks[3], hits[3], gi, j1; | |
592 | Float_t charges[3]; | |
593 | Float_t electronics; | |
594 | Float_t signal; | |
595 | Float_t phys; | |
596 | Double_t sig; | |
7d50ea21 | 597 | // Int_t module = 0; |
2cc6b29a | 598 | for(Int_t iz=0; iz<fNPixelsZ; iz++){ |
599 | for(Int_t ix=0; ix<fNPixelsX; ix++){ | |
600 | electronics = fBaseline + fNoise*gRandom->Gaus(); | |
7d50ea21 | 601 | signal = (float)pList->GetSignalOnly(iz,ix); |
2cc6b29a | 602 | sig = Double_t (signal); // sig will be passed along to |
603 | // UpdateMapNoise this is necessary so | |
604 | // that a signal without electronic | |
605 | // noise is passed along | |
606 | signal += electronics; | |
607 | gi =iz*fNPixelsX+ix; // global index | |
608 | if (signal > threshold) { | |
609 | digits[0]=iz; | |
610 | digits[1]=ix; | |
611 | digits[2]=1; | |
612 | for(j1=0;j1<3;j1++){ | |
7d50ea21 | 613 | if (pList->GetTrack(iz,ix,gi)) { |
2cc6b29a | 614 | //b.b. tracks[j1]=-3; |
7d50ea21 | 615 | tracks[j1] = (Int_t)(pList->GetTrack(iz,ix,j1)+j1); |
616 | hits[j1] = (Int_t)(pList->GetHit(iz,ix,j1)+j1+6); | |
2cc6b29a | 617 | }else { |
618 | tracks[j1]=-2; //noise | |
619 | hits[j1] = -1; | |
620 | } // end if pList | |
621 | charges[j1] = 0; | |
622 | } // end for j1 | |
623 | ||
624 | if(tracks[0] == tracks[1] && tracks[0] == tracks[2]) { | |
625 | tracks[1] = -3; | |
626 | hits[1] = -1; | |
627 | tracks[2] = -3; | |
628 | hits[2] = -1; | |
629 | } else if(tracks[0] == tracks[1] && tracks[0] != tracks[2]) { | |
630 | tracks[1] = -3; | |
631 | hits[1] = -1; | |
632 | } else if(tracks[0] == tracks[2] && tracks[0] != tracks[1]) { | |
633 | tracks[2] = -3; | |
634 | hits[2] = -1; | |
635 | } else if(tracks[1] == tracks[2] && tracks[0] != tracks[1]) { | |
636 | tracks[2] = -3; | |
637 | hits[2] = -1; | |
638 | } // end if | |
639 | ||
640 | phys = 0; | |
641 | ||
7d50ea21 | 642 | UpdateMapNoise(iz,ix,fModule,sig,electronics,pList); |
2cc6b29a | 643 | aliITS->AddSimDigit(0, phys, digits, tracks, hits, charges); |
644 | } // | |
645 | } // | |
646 | } // | |
409f8c84 | 647 | } |
2cc6b29a | 648 | //______________________________________________________________________ |
649 | void AliITSsimulationSPDdubna::CreateHistograms(){ | |
650 | // create 1D histograms for tests | |
651 | ||
652 | printf("SPD - create histograms\n"); | |
653 | ||
654 | fHis=new TObjArray(fNPixelsZ); | |
655 | TString spdName("spd_"); | |
656 | for (Int_t i=0;i<fNPixelsZ;i++) { | |
657 | Char_t pixelz[4]; | |
658 | sprintf(pixelz,"%d",i+1); | |
659 | spdName.Append(pixelz); | |
660 | //PH (*fHis)[i] = new TH1F(spdName.Data(),"SPD maps", | |
661 | //PH fNPixelsX,0.,(Float_t) fNPixelsX); | |
662 | fHis->AddAt(new TH1F(spdName.Data(),"SPD maps", | |
663 | fNPixelsX,0.,(Float_t) fNPixelsX), i); | |
664 | } // end for i | |
409f8c84 | 665 | } |
2cc6b29a | 666 | //______________________________________________________________________ |
667 | void AliITSsimulationSPDdubna::ResetHistograms(){ | |
409f8c84 | 668 | // |
669 | // Reset histograms for this detector | |
670 | // | |
671 | ||
672 | for ( int i=0;i<fNPixelsZ;i++ ) { | |
2cc6b29a | 673 | //PH if ((*fHis)[i]) ((TH1F*)(*fHis)[i])->Reset(); |
2682e810 | 674 | if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset(); |
2cc6b29a | 675 | } // end for i |
409f8c84 | 676 | } |