]>
Commit | Line | Data |
---|---|---|
f74211b0 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
b9d0a01d | 18 | Revision 1.3.8.2 2002/10/14 13:14:08 hristov |
19 | Updating VirtualMC to v3-09-02 | |
20 | ||
21 | Revision 1.7 2002/09/09 17:23:28 nilsen | |
22 | Minor changes in support of changes to AliITSdigitS?D class'. | |
23 | ||
ee86d557 | 24 | Revision 1.6 2002/08/21 22:09:58 nilsen |
25 | Updated SPD simulation with difusion effects. ReWritten Hit to SDigits | |
26 | code. | |
27 | ||
f74211b0 | 28 | */ |
409f8c84 | 29 | #include <iostream.h> |
30 | #include <TRandom.h> | |
31 | #include <TH1.h> | |
32 | #include <TMath.h> | |
33 | #include <TString.h> | |
34 | #include <TParticle.h> | |
35 | ||
409f8c84 | 36 | #include "AliRun.h" |
37 | #include "AliITS.h" | |
38 | #include "AliITShit.h" | |
39 | #include "AliITSdigit.h" | |
40 | #include "AliITSmodule.h" | |
41 | #include "AliITSMapA2.h" | |
2cc6b29a | 42 | #include "AliITSpList.h" |
409f8c84 | 43 | #include "AliITSsimulationSPDdubna.h" |
f74211b0 | 44 | #include "AliITSsegmentationSPD.h" |
45 | #include "AliITSresponseSPDdubna.h" | |
409f8c84 | 46 | |
f74211b0 | 47 | //#define DEBUG |
409f8c84 | 48 | |
49 | ClassImp(AliITSsimulationSPDdubna) | |
50 | //////////////////////////////////////////////////////////////////////// | |
51 | // Version: 0 | |
52 | // Written by Boris Batyunya | |
53 | // December 20 1999 | |
54 | // | |
55 | // AliITSsimulationSPDdubna is the simulation of SPDs | |
2cc6b29a | 56 | //______________________________________________________________________ |
57 | ||
58 | ||
59 | AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(){ | |
60 | // constructor | |
61 | ||
62 | fResponse = 0; | |
63 | fSegmentation = 0; | |
64 | fMapA2 = 0; | |
65 | fpList = 0; | |
66 | fModule = 0; | |
67 | fEvent = 0; | |
68 | fHis = 0; | |
69 | fNoise = 0.; | |
70 | fBaseline = 0.; | |
71 | fNPixelsZ = 0; | |
72 | fNPixelsX = 0; | |
409f8c84 | 73 | } |
2cc6b29a | 74 | //______________________________________________________________________ |
75 | AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(AliITSsegmentation *seg, | |
76 | AliITSresponse *resp){ | |
77 | // standard constructor | |
f74211b0 | 78 | const Double_t kmictocm = 1.0e-4; // convert microns to cm. |
409f8c84 | 79 | |
2cc6b29a | 80 | fHis = 0; |
81 | fResponse = resp; | |
82 | fSegmentation = seg; | |
83 | fModule = 0; | |
84 | fEvent = 0; | |
409f8c84 | 85 | |
2cc6b29a | 86 | fNPixelsZ=fSegmentation->Npz(); |
87 | fNPixelsX=fSegmentation->Npx(); | |
409f8c84 | 88 | |
2cc6b29a | 89 | fResponse->GetNoiseParam(fNoise,fBaseline); |
f74211b0 | 90 | fResponse->SetDistanceOverVoltage(kmictocm*fSegmentation->Dy(),50.0); |
409f8c84 | 91 | |
f74211b0 | 92 | // fMapA2 = new AliITSMapA2(fSegmentation); |
93 | fMapA2 = 0; | |
409f8c84 | 94 | |
2cc6b29a | 95 | fpList = new AliITSpList(fNPixelsZ+1,fNPixelsX+1); |
409f8c84 | 96 | |
2cc6b29a | 97 | } |
98 | //______________________________________________________________________ | |
99 | AliITSsimulationSPDdubna::~AliITSsimulationSPDdubna(){ | |
100 | // destructor | |
409f8c84 | 101 | |
f74211b0 | 102 | if(fMapA2) delete fMapA2; |
409f8c84 | 103 | |
2cc6b29a | 104 | if (fHis) { |
105 | fHis->Delete(); | |
106 | delete fHis; | |
107 | } // end if fHis | |
409f8c84 | 108 | } |
2cc6b29a | 109 | //______________________________________________________________________ |
110 | AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(const | |
111 | AliITSsimulationSPDdubna | |
112 | &source){ | |
113 | // Copy Constructor | |
114 | if(&source == this) return; | |
115 | this->fMapA2 = source.fMapA2; | |
116 | this->fNoise = source.fNoise; | |
117 | this->fBaseline = source.fBaseline; | |
118 | this->fNPixelsX = source.fNPixelsX; | |
119 | this->fNPixelsZ = source.fNPixelsZ; | |
120 | this->fHis = source.fHis; | |
121 | return; | |
122 | } | |
123 | //______________________________________________________________________ | |
124 | AliITSsimulationSPDdubna& AliITSsimulationSPDdubna::operator=(const | |
125 | AliITSsimulationSPDdubna &source){ | |
126 | // Assignment operator | |
127 | if(&source == this) return *this; | |
128 | this->fMapA2 = source.fMapA2; | |
129 | this->fNoise = source.fNoise; | |
130 | this->fBaseline = source.fBaseline; | |
131 | this->fNPixelsX = source.fNPixelsX; | |
132 | this->fNPixelsZ = source.fNPixelsZ; | |
133 | this->fHis = source.fHis; | |
134 | return *this; | |
135 | } | |
136 | //______________________________________________________________________ | |
137 | void AliITSsimulationSPDdubna::InitSimulationModule(Int_t module, Int_t event){ | |
138 | // This function creates maps to build the list of tracks for each | |
139 | // summable digit. | |
140 | // | |
141 | // Inputs: | |
142 | // Int_t module // Module number to be simulated | |
143 | // Int_t event // Event number to be simulated | |
144 | // | |
145 | // Outputs: | |
146 | // none | |
147 | // | |
148 | // Returns: | |
149 | // none | |
409f8c84 | 150 | |
2cc6b29a | 151 | fModule = module; |
152 | fEvent = event; | |
f74211b0 | 153 | // fMapA2->ClearMap(); |
2cc6b29a | 154 | fpList->ClearMap(); |
155 | } | |
156 | //_____________________________________________________________________ | |
157 | void AliITSsimulationSPDdubna::SDigitiseModule(AliITSmodule *mod, Int_t mask, | |
158 | Int_t event){ | |
159 | // This function begins the work of creating S-Digits | |
160 | // | |
161 | // Inputs: | |
162 | // AliITSmodule *mod // module | |
163 | // Int_t mask // mask to be applied to the module | |
164 | // | |
165 | // Outputs: | |
166 | // none | |
167 | // | |
168 | // Return: | |
169 | // test // test returns kTRUE if the module contained hits | |
170 | // // test returns kFALSE if it did not contain hits | |
409f8c84 | 171 | |
2cc6b29a | 172 | Int_t module = 0; |
409f8c84 | 173 | |
2cc6b29a | 174 | if(!(mod->GetNhits())) return;// if module has no hits don't create Sdigits |
175 | fModule = mod->GetIndex(); | |
176 | HitToSDigit(mod, module, mask, fpList); | |
177 | WriteSDigits(fpList); | |
f74211b0 | 178 | // fMapA2->ClearMap(); |
2cc6b29a | 179 | fpList->ClearMap(); |
409f8c84 | 180 | } |
2cc6b29a | 181 | //______________________________________________________________________ |
182 | void AliITSsimulationSPDdubna::WriteSDigits(AliITSpList *pList){ | |
183 | // This function adds each S-Digit to pList | |
184 | // | |
185 | // Inputs: | |
186 | // AliITSpList *pList | |
187 | // | |
188 | // Outputs: | |
189 | // none | |
190 | // | |
191 | // Return: | |
192 | // none | |
7d50ea21 | 193 | Int_t ix, nix, iz, niz; |
2cc6b29a | 194 | static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS"); |
195 | ||
7d50ea21 | 196 | pList->GetMaxMapIndex(niz, nix); |
197 | for(iz=0; iz<niz; iz++)for(ix=0; ix<nix; ix++){ | |
198 | if(pList->GetSignalOnly(iz,ix)>0.0){ | |
199 | aliITS->AddSumDigit(*(pList->GetpListItem(iz,ix))); | |
f74211b0 | 200 | #ifdef DEBUG |
201 | cout <<"SDigits " << iz << "," << ix << "," << | |
202 | *(pList->GetpListItem(iz,ix)) << endl; | |
203 | #endif | |
2cc6b29a | 204 | } // end if pList |
7d50ea21 | 205 | } // end for iz,ix |
2cc6b29a | 206 | return; |
207 | } | |
208 | //______________________________________________________________________ | |
209 | void AliITSsimulationSPDdubna::FinishSDigitiseModule(){ | |
210 | // This function calls SDigitsToDigits which creates Digits from SDigits | |
211 | // | |
212 | // Inputs: | |
213 | // none | |
214 | // | |
215 | // Outputs: | |
216 | // none | |
217 | // Return | |
218 | // none | |
409f8c84 | 219 | |
2cc6b29a | 220 | SDigitsToDigits(fModule, fpList); |
221 | return; | |
222 | } | |
223 | //______________________________________________________________________ | |
224 | void AliITSsimulationSPDdubna::SDigitsToDigits(Int_t module, | |
225 | AliITSpList *pList){ | |
226 | // This function adds electronic noise to the S-Digits and then adds them | |
227 | // to a new pList | |
228 | // | |
229 | // Inputs: | |
230 | // Int_t module // module number | |
231 | // AliITSpList *pList // pList | |
232 | // | |
233 | // Outputs: | |
234 | // pList is passed along to the functions ChargeToSignal and GetList | |
235 | // | |
236 | // Return: | |
237 | // none | |
409f8c84 | 238 | |
2cc6b29a | 239 | fModule = module; |
240 | ChargeToSignal(pList); // Charge To Signal both adds noise and | |
f74211b0 | 241 | // fMapA2->ClearMap(); |
2cc6b29a | 242 | pList->ClearMap(); |
409f8c84 | 243 | } |
2cc6b29a | 244 | //______________________________________________________________________ |
245 | void AliITSsimulationSPDdubna::DigitiseModule(AliITSmodule *mod, Int_t module, | |
246 | Int_t dummy){ | |
247 | // This function creates Digits straight from the hits and then adds | |
248 | // electronic noise to the digits before adding them to pList | |
249 | // | |
250 | // Inputs: | |
251 | // AliITSmodule *mod // module | |
252 | // Int_t module // module number Dummy. | |
253 | // Int_t dummy | |
254 | // | |
255 | // Outputs: | |
256 | // Each of the input variables is passed along to HitToSDigit | |
257 | // | |
258 | // Return: | |
259 | // none | |
409f8c84 | 260 | |
2cc6b29a | 261 | fModule = mod->GetIndex(); //This calls the module for HitToSDigit |
262 | HitToSDigit(mod,fModule, dummy, fpList); | |
263 | ChargeToSignal(fpList); | |
f74211b0 | 264 | // fMapA2->ClearMap(); |
2cc6b29a | 265 | fpList->ClearMap(); |
266 | } | |
267 | //______________________________________________________________________ | |
7d50ea21 | 268 | void AliITSsimulationSPDdubna::UpdateMapSignal(Int_t iz, Int_t ix, Int_t trk, |
2cc6b29a | 269 | Int_t ht, Int_t module, |
270 | Double_t signal, | |
271 | AliITSpList *pList){ | |
272 | // This function adds a signal to the pList from the pList class | |
273 | // | |
274 | // Inputs: | |
7d50ea21 | 275 | // Int_t iz // row number |
276 | // Int_t ix // column number | |
2cc6b29a | 277 | // Int_t trk // track number |
278 | // Int_t ht // hit number | |
279 | // Double_t signal // signal strength | |
280 | // AliITSpList *pList // pList | |
281 | // | |
282 | // Outputs: | |
283 | // All of the inputs are passed to AliITSpList::AddSignal | |
284 | // Int_t ix // row number | |
285 | // Int_t iz // column number | |
286 | // Double_t sig // signal strength | |
287 | // // These three variables are defined to preserve the | |
288 | // // assignments used in the function AliITSMapA2::AddSignal | |
289 | // | |
290 | // Return: | |
291 | // none | |
2cc6b29a | 292 | |
f74211b0 | 293 | // fMapA2->AddSignal(iz, ix, signal); |
7d50ea21 | 294 | pList->AddSignal(iz,ix, trk, ht, fModule, signal); |
2cc6b29a | 295 | } |
296 | //______________________________________________________________________ | |
7d50ea21 | 297 | void AliITSsimulationSPDdubna::UpdateMapNoise(Int_t iz, |
298 | Int_t ix, Int_t fModule, | |
2cc6b29a | 299 | Double_t sig, Float_t noise, |
300 | AliITSpList *pList){ | |
301 | // This function adds noise to data in the MapA2 as well as the pList | |
302 | // | |
303 | // Inputs: | |
7d50ea21 | 304 | // Int_t iz // row number |
305 | // Int_t ix // column number | |
2cc6b29a | 306 | // Int_t mod // module number |
307 | // Double_t sig // signal strength | |
308 | // Double_t noise // electronic noise generated by ChargeToSignal | |
309 | // AliITSpList *pList // pList | |
310 | // | |
311 | // Outputs: | |
312 | // All of the inputs are passed to AliITSMapA2::AddSignal or | |
313 | // AliITSpList::AddNoise | |
314 | // | |
315 | // Return: | |
316 | // none | |
409f8c84 | 317 | |
f74211b0 | 318 | // fMapA2->AddSignal(iz, ix, noise); |
7d50ea21 | 319 | pList->AddNoise(iz,ix, fModule, noise); |
2cc6b29a | 320 | } |
321 | //______________________________________________________________________ | |
322 | void AliITSsimulationSPDdubna::HitToDigit(AliITSmodule *mod, Int_t module, | |
323 | Int_t dummy){ | |
324 | DigitiseModule(mod, module, dummy); | |
325 | } | |
326 | //______________________________________________________________________ | |
327 | void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod, Int_t module, | |
f74211b0 | 328 | Int_t dummy,AliITSpList *pList){ |
329 | // Does the charge distributions using Gaussian diffusion charge charing. | |
330 | const Double_t kmictocm = 1.0e-4; // convert microns to cm. | |
331 | TObjArray *hits = mod->GetHits(); | |
332 | Int_t nhits = hits->GetEntriesFast(); | |
333 | Int_t h,ix,iz; | |
334 | Int_t idtrack; | |
335 | Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0; | |
336 | Double_t x,y,z,t,tp,st,dt=0.2,el,sig; | |
337 | Double_t thick = kmictocm*GetSeg()->Dy(); | |
338 | ||
339 | if(nhits<=0) return; | |
340 | for(h=0;h<nhits;h++){ | |
341 | #ifdef DEBUG | |
342 | cout << "Hits=" << h << "," << *(mod->GetHit(h)) << endl; | |
343 | #endif | |
344 | if(mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)){ | |
345 | st =TMath::Sqrt(x1*x1+y1*y1+z1*z1); | |
346 | if(st>0.0) for(t=0;t<1.0;t+=dt){ // Integrate over t | |
347 | tp = t+0.5*dt; | |
348 | el = GetResp()->GeVToCharge((Float_t)(dt*de)); | |
349 | #ifdef DEBUG | |
350 | if(el<=0.0) cout << "el="<<el<<" dt="<<dt<<" de="<<de<<endl; | |
351 | #endif | |
352 | x = x0+x1*tp; | |
353 | y = y0+y1*tp; | |
354 | z = z0+z1*tp; | |
355 | GetSeg()->LocalToDet(x,z,ix,iz); | |
356 | sig = GetResp()->SigmaDiffusion1D(thick + y); | |
357 | SpreadCharge(x,y,z,ix,iz,el,sig, | |
358 | idtrack,mod->GetHitTrackIndex(h),h,mod->GetIndex()); | |
359 | } else { // st == 0.0 deposit it at this point | |
360 | el = GetResp()->GeVToCharge((Float_t)de); | |
361 | x = x0; | |
362 | y = y0; | |
363 | z = z0; | |
364 | GetSeg()->LocalToDet(x,z,ix,iz); | |
365 | sig = GetResp()->SigmaDiffusion1D(thick + y); | |
366 | SpreadCharge(x,y,z,ix,iz,el,sig, | |
367 | idtrack,mod->GetHitTrackIndex(h),h,mod->GetIndex()); | |
368 | } // end if st>0.0 | |
369 | }} // Loop over all hits h | |
370 | } | |
371 | //______________________________________________________________________ | |
372 | void AliITSsimulationSPDdubna::SpreadCharge(Double_t x0,Double_t y0, | |
373 | Double_t z0,Int_t ix0,Int_t iz0, | |
374 | Double_t el,Double_t sig,Int_t t, | |
375 | Int_t ti,Int_t hi,Int_t mod){ | |
376 | // Spreads the charge over neighboring cells. Assume charge is distributed | |
377 | // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg) | |
378 | // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig) | |
379 | // Defined this way, the integral over all x and z is el. | |
380 | const Int_t knx = 3,knz = 2; | |
381 | const Double_t kRoot2 = 1.414213562; // Sqrt(2). | |
382 | const Double_t kmictocm = 1.0e-4; // convert microns to cm. | |
383 | Int_t ix,iz,ixs,ixe,izs,ize; | |
384 | Float_t x,z; | |
385 | Double_t x1,x2,z1,z2,s,sp; | |
386 | ||
387 | if(sig<=0.0) { | |
388 | fpList->AddSignal(iz0,ix0,t,hi,mod,el); | |
389 | return; | |
390 | } // end if | |
391 | sp = 1.0/(sig*kRoot2); | |
392 | #ifdef DEBUG | |
393 | cout << "sig=" << sig << " sp=" << sp << endl; | |
394 | #endif | |
395 | ixs = TMath::Max(-knx+ix0,0); | |
396 | ixe = TMath::Min(knx+ix0,GetSeg()->Npx()-1); | |
397 | izs = TMath::Max(-knz+iz0,0); | |
398 | ize = TMath::Min(knz+iz0,GetSeg()->Npz()-1); | |
399 | for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){ | |
400 | GetSeg()->DetToLocal(ix,iz,x,z); // pixel center | |
401 | x1 = x; | |
402 | z1 = z; | |
403 | x2 = x1 + 0.5*kmictocm*GetSeg()->Dpx(ix); // Upper | |
404 | x1 -= 0.5*kmictocm*GetSeg()->Dpx(ix); // Lower | |
405 | z2 = z1 + 0.5*kmictocm*GetSeg()->Dpz(iz); // Upper | |
406 | z1 -= 0.5*kmictocm*GetSeg()->Dpz(iz); // Lower | |
407 | x1 -= x0; // Distance from where track traveled | |
408 | x2 -= x0; // Distance from where track traveled | |
409 | z1 -= z0; // Distance from where track traveled | |
410 | z2 -= z0; // Distance from where track traveled | |
411 | s = 0.25; // Correction based on definision of Erfc | |
412 | s *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2); | |
413 | #ifdef DEBUG | |
414 | cout << "el=" << el << " ix0=" << ix0 << " ix=" << ix << " x0="<< x << | |
415 | " iz0=" << iz0 << " iz=" << iz << " z0=" << z << | |
416 | " sp*x1=" << sp*x1 <<" sp*x2=" << sp*x2 << " s=" << s; | |
417 | #endif | |
418 | s *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2); | |
419 | #ifdef DEBUG | |
420 | cout << " sp*z1=" << sp*z1 <<" sp*z2=" << sp*z2 << " s=" << s << endl; | |
421 | #endif | |
422 | fpList->AddSignal(iz,ix,t,hi,mod,s*el); | |
423 | } // end for ix, iz | |
424 | } | |
425 | //______________________________________________________________________ | |
426 | void AliITSsimulationSPDdubna::HitToSDigitOld(AliITSmodule *mod, Int_t module, | |
2cc6b29a | 427 | Int_t dummy, AliITSpList *pList){ |
428 | // digitize module | |
409f8c84 | 429 | const Float_t kEnToEl = 2.778e+8; // GeV->charge in electrons |
430 | // for 3.6 eV/pair | |
431 | const Float_t kconv = 10000.; // cm -> microns | |
432 | ||
433 | Float_t spdLength = fSegmentation->Dz(); | |
434 | Float_t spdWidth = fSegmentation->Dx(); | |
338e4f06 | 435 | Float_t spdThickness = fSegmentation->Dy(); |
409f8c84 | 436 | Float_t difCoef, dum; |
437 | fResponse->DiffCoeff(difCoef,dum); | |
338e4f06 | 438 | if(spdThickness > 290) difCoef = 0.00613; |
409f8c84 | 439 | |
440 | Float_t zPix0 = 1e+6; | |
441 | Float_t xPix0 = 1e+6; | |
442 | Float_t yPrev = 1e+6; | |
443 | ||
444 | Float_t zPitch = fSegmentation->Dpz(0); | |
445 | Float_t xPitch = fSegmentation->Dpx(0); | |
446 | ||
447 | TObjArray *fHits = mod->GetHits(); | |
2cc6b29a | 448 | module = mod->GetIndex(); |
409f8c84 | 449 | Int_t nhits = fHits->GetEntriesFast(); |
450 | if (!nhits) return; | |
f74211b0 | 451 | #ifdef DEBUG |
2cc6b29a | 452 | cout<<"len,wid,thickness,nx,nz,pitchx,pitchz,difcoef ="<<spdLength<<"," |
453 | <<spdWidth<<","<<spdThickness<<","<<fNPixelsX<<","<<fNPixelsZ<<"," | |
454 | <<xPitch<<","<<zPitch<<","<<difCoef<<endl; | |
f74211b0 | 455 | #endif |
2cc6b29a | 456 | // Array of pointers to the label-signal list |
409f8c84 | 457 | Int_t indexRange[4] = {0,0,0,0}; |
458 | ||
459 | // Fill detector maps with GEANT hits | |
460 | // loop over hits in the module | |
461 | static Bool_t first; | |
462 | Int_t lasttrack=-2; | |
463 | Int_t hit, iZi, jz, jx; | |
338e4f06 | 464 | Int_t idhit=-1; //! |
f74211b0 | 465 | #ifdef DEBUG |
338e4f06 | 466 | cout<<"SPDdubna: module,nhits ="<<module<<","<<nhits<<endl; |
f74211b0 | 467 | #endif |
409f8c84 | 468 | for (hit=0;hit<nhits;hit++) { |
469 | AliITShit *iHit = (AliITShit*) fHits->At(hit); | |
f74211b0 | 470 | #ifdef DEBUG |
471 | cout << "Hits=" << hit << "," << *iHit << endl; | |
472 | #endif | |
338e4f06 | 473 | //Int_t layer = iHit->GetLayer(); |
474 | Float_t yPix0 = -spdThickness/2; | |
475 | ||
476 | // work with the idtrack=entry number in the TreeH | |
477 | //Int_t idhit,idtrack; //! | |
478 | //mod->GetHitTrackAndHitIndex(hit,idtrack,idhit); //! | |
479 | //Int_t idtrack=mod->GetHitTrackIndex(hit); | |
480 | // or store straight away the particle position in the array | |
481 | // of particles : | |
409f8c84 | 482 | if(iHit->StatusEntering()) idhit=hit; |
483 | Int_t itrack = iHit->GetTrack(); | |
484 | Int_t dray = 0; | |
485 | ||
486 | if (lasttrack != itrack || hit==(nhits-1)) first = kTRUE; | |
487 | ||
338e4f06 | 488 | //Int_t parent = iHit->GetParticle()->GetFirstMother(); |
409f8c84 | 489 | Int_t partcode = iHit->GetParticle()->GetPdgCode(); |
490 | ||
2cc6b29a | 491 | // partcode (pdgCode): 11 - e-, 13 - mu-, 22 - gamma, 111 - pi0, |
492 | // 211 - pi+, 310 - K0s, 321 - K+, 2112 - n, 2212 - p, 3122 - lambda | |
409f8c84 | 493 | |
494 | Float_t pmod = iHit->GetParticle()->P(); // total momentum at the | |
495 | // vertex | |
496 | pmod *= 1000; | |
497 | ||
409f8c84 | 498 | if(partcode == 11 && pmod < 6) dray = 1; // delta ray is e- |
499 | // at p < 6 MeV/c | |
500 | ||
409f8c84 | 501 | // Get hit z and x(r*phi) cordinates for each module (detector) |
502 | // in local system. | |
503 | ||
504 | Float_t zPix = kconv*iHit->GetZL(); | |
505 | Float_t xPix = kconv*iHit->GetXL(); | |
506 | Float_t yPix = kconv*iHit->GetYL(); | |
507 | ||
508 | // Get track status | |
509 | Int_t status = iHit->GetTrackStatus(); | |
409f8c84 | 510 | |
511 | // Check boundaries | |
512 | if(zPix > spdLength/2) { | |
f74211b0 | 513 | #ifdef DEBUG |
514 | cout<<"!!! SPD: z outside ="<<zPix<<endl; | |
515 | #endif | |
2cc6b29a | 516 | zPix = spdLength/2 - 10; |
409f8c84 | 517 | } |
518 | if(zPix < 0 && zPix < -spdLength/2) { | |
f74211b0 | 519 | #ifdef DEBUG |
520 | cout<<"!!! SPD: z outside ="<<zPix<<endl; | |
521 | #endif | |
2cc6b29a | 522 | zPix = -spdLength/2 + 10; |
409f8c84 | 523 | } |
524 | if(xPix > spdWidth/2) { | |
f74211b0 | 525 | #ifdef DEBUG |
526 | cout<<"!!! SPD: x outside ="<<xPix<<endl; | |
527 | #endif | |
2cc6b29a | 528 | xPix = spdWidth/2 - 10; |
409f8c84 | 529 | } |
530 | if(xPix < 0 && xPix < -spdWidth/2) { | |
f74211b0 | 531 | #ifdef DEBUG |
532 | cout<<"!!! SPD: x outside ="<<xPix<<endl; | |
533 | #endif | |
2cc6b29a | 534 | xPix = -spdWidth/2 + 10; |
409f8c84 | 535 | } |
536 | Int_t trdown = 0; | |
537 | ||
538 | // enter Si or after event in Si | |
539 | if (status == 66 ) { | |
2cc6b29a | 540 | zPix0 = zPix; |
541 | xPix0 = xPix; | |
542 | yPrev = yPix; | |
543 | } // end if status == 66 | |
409f8c84 | 544 | |
545 | Float_t depEnergy = iHit->GetIonization(); | |
546 | // skip if the input point to Si | |
547 | ||
548 | if(depEnergy <= 0.) continue; | |
549 | ||
550 | // if track returns to the opposite direction: | |
551 | if (yPix < yPrev) { | |
552 | trdown = 1; | |
2cc6b29a | 553 | } // end if yPix < yPrev |
409f8c84 | 554 | |
555 | // take into account the holes diffusion inside the Silicon | |
556 | // the straight line between the entrance and exit points in Si is | |
557 | // divided into the several steps; the diffusion is considered | |
558 | // for each end point of step and charge | |
559 | // is distributed between the pixels through the diffusion. | |
409f8c84 | 560 | |
561 | // ---------- the diffusion in Z (beam) direction ------- | |
409f8c84 | 562 | Float_t charge = depEnergy*kEnToEl; // charge in e- |
563 | Float_t drPath = 0.; | |
564 | Float_t tang = 0.; | |
565 | Float_t sigmaDif = 0.; | |
566 | Float_t zdif = zPix - zPix0; | |
567 | Float_t xdif = xPix - xPix0; | |
568 | Float_t ydif = TMath::Abs(yPix - yPrev); | |
569 | Float_t ydif0 = TMath::Abs(yPrev - yPix0); | |
570 | ||
571 | if(ydif < 1) continue; // ydif is not zero | |
572 | ||
573 | Float_t projDif = sqrt(xdif*xdif + zdif*zdif); | |
574 | ||
575 | Int_t ndZ = (Int_t)TMath::Abs(zdif/zPitch) + 1; | |
576 | Int_t ndX = (Int_t)TMath::Abs(xdif/xPitch) + 1; | |
577 | ||
578 | // number of the steps along the track: | |
579 | Int_t nsteps = ndZ; | |
580 | if(ndX > ndZ) nsteps = ndX; | |
338e4f06 | 581 | if(nsteps < 20) nsteps = 20; // minimum number of the steps |
409f8c84 | 582 | |
583 | if (projDif < 5 ) { | |
2cc6b29a | 584 | drPath = (yPix-yPix0)*1.e-4; |
585 | drPath = TMath::Abs(drPath); // drift path in cm | |
586 | sigmaDif = difCoef*sqrt(drPath); // sigma diffusion in cm | |
587 | sigmaDif = sigmaDif*kconv; // sigma diffusion in microns | |
588 | nsteps = 1; | |
589 | } // end if projDif < 5 | |
409f8c84 | 590 | |
591 | if(projDif > 5) tang = ydif/projDif; | |
592 | Float_t dCharge = charge/nsteps; // charge in e- for one step | |
593 | Float_t dZ = zdif/nsteps; | |
594 | Float_t dX = xdif/nsteps; | |
595 | ||
2cc6b29a | 596 | for (iZi = 1; iZi <= nsteps;iZi++) { |
597 | Float_t dZn = iZi*dZ; | |
409f8c84 | 598 | Float_t dXn = iZi*dX; |
599 | Float_t zPixn = zPix0 + dZn; | |
600 | Float_t xPixn = xPix0 + dXn; | |
601 | ||
602 | if(projDif >= 5) { | |
2cc6b29a | 603 | Float_t dProjn = sqrt(dZn*dZn+dXn*dXn); |
604 | drPath = dProjn*tang*1.e-4; // drift path for iZi+1 step in cm | |
605 | if(trdown == 0) { | |
606 | drPath = TMath::Abs(drPath) + ydif0*1.e-4; | |
607 | }// end if trdow ==0 | |
608 | if(trdown == 1) { | |
609 | drPath = ydif0*1.e-4 - TMath::Abs(drPath); | |
610 | drPath = TMath::Abs(drPath); | |
611 | } // end if trdown == 1 | |
612 | sigmaDif = difCoef*sqrt(drPath); | |
613 | sigmaDif = sigmaDif*kconv; // sigma diffusion in microns | |
614 | } // end if projdif >= 5 | |
409f8c84 | 615 | |
616 | zPixn = (zPixn + spdLength/2.); | |
617 | xPixn = (xPixn + spdWidth/2.); | |
618 | Int_t nZpix, nXpix; | |
619 | fSegmentation->GetPadIxz(xPixn,zPixn,nXpix,nZpix); | |
620 | zPitch = fSegmentation->Dpz(nZpix); | |
621 | fSegmentation->GetPadTxz(xPixn,zPixn); | |
622 | // set the window for the integration | |
623 | Int_t jzmin = 1; | |
624 | Int_t jzmax = 3; | |
625 | if(nZpix == 1) jzmin =2; | |
626 | if(nZpix == fNPixelsZ) jzmax = 2; | |
627 | ||
628 | Int_t jxmin = 1; | |
629 | Int_t jxmax = 3; | |
630 | if(nXpix == 1) jxmin =2; | |
631 | if(nXpix == fNPixelsX) jxmax = 2; | |
632 | ||
633 | Float_t zpix = nZpix; | |
634 | Float_t dZright = zPitch*(zpix - zPixn); | |
635 | Float_t dZleft = zPitch - dZright; | |
636 | ||
637 | Float_t xpix = nXpix; | |
638 | Float_t dXright = xPitch*(xpix - xPixn); | |
639 | Float_t dXleft = xPitch - dXright; | |
640 | ||
641 | Float_t dZprev = 0.; | |
642 | Float_t dZnext = 0.; | |
643 | Float_t dXprev = 0.; | |
644 | Float_t dXnext = 0.; | |
645 | ||
646 | for(jz=jzmin; jz <=jzmax; jz++) { | |
647 | if(jz == 1) { | |
2cc6b29a | 648 | dZprev = -zPitch - dZleft; |
649 | dZnext = -dZleft; | |
650 | } else if(jz == 2) { | |
651 | dZprev = -dZleft; | |
652 | dZnext = dZright; | |
653 | } else if(jz == 3) { | |
654 | dZprev = dZright; | |
655 | dZnext = dZright + zPitch; | |
656 | } // end if jz | |
409f8c84 | 657 | // kz changes from 1 to the fNofPixels(270) |
658 | Int_t kz = nZpix + jz -2; | |
659 | ||
660 | Float_t zArg1 = dZprev/sigmaDif; | |
661 | Float_t zArg2 = dZnext/sigmaDif; | |
662 | Float_t zProb1 = TMath::Erfc(zArg1); | |
663 | Float_t zProb2 = TMath::Erfc(zArg2); | |
664 | Float_t dZCharge =0.5*(zProb1-zProb2)*dCharge; | |
665 | ||
666 | ||
667 | // ----------- holes diffusion in X(r*phi) direction -------- | |
668 | ||
669 | if(dZCharge > 1.) { | |
2cc6b29a | 670 | for(jx=jxmin; jx <=jxmax; jx++) { |
671 | if(jx == 1) { | |
672 | dXprev = -xPitch - dXleft; | |
673 | dXnext = -dXleft; | |
674 | } else if(jx == 2) { | |
675 | dXprev = -dXleft; | |
676 | dXnext = dXright; | |
677 | } else if(jx == 3) { | |
678 | dXprev = dXright; | |
679 | dXnext = dXright + xPitch; | |
680 | } // end if jx | |
681 | Int_t kx = nXpix + jx -2; | |
682 | Float_t xArg1 = dXprev/sigmaDif; | |
683 | Float_t xArg2 = dXnext/sigmaDif; | |
684 | Float_t xProb1 = TMath::Erfc(xArg1); | |
685 | Float_t xProb2 = TMath::Erfc(xArg2); | |
686 | Float_t dXCharge =0.5*(xProb1-xProb2)*dZCharge; | |
687 | ||
688 | if(dXCharge > 1.) { | |
2cc6b29a | 689 | if (first) { |
f74211b0 | 690 | indexRange[0]=indexRange[1]=kz-1; |
2cc6b29a | 691 | indexRange[2]=indexRange[3]=kx-1; |
692 | first=kFALSE; | |
693 | } // end if first | |
694 | indexRange[0]=TMath::Min(indexRange[0],kz-1); | |
695 | indexRange[1]=TMath::Max(indexRange[1],kz-1); | |
696 | indexRange[2]=TMath::Min(indexRange[2],kx-1); | |
697 | indexRange[3]=TMath::Max(indexRange[3],kx-1); | |
f74211b0 | 698 | /* |
2cc6b29a | 699 | // build the list of digits for this module |
f74211b0 | 700 | Double_t signal = fMapA2->GetSignal(kz-1,kx-1); |
2cc6b29a | 701 | signal+=dXCharge; |
f74211b0 | 702 | fMapA2->SetHit(kz-1,kx-1,(double)signal); |
703 | */ | |
2cc6b29a | 704 | // The calling sequence for UpdateMapSignal was |
705 | // moved into the (dx > 1 e-) loop because it | |
706 | // needs to call signal which is defined inside | |
707 | // this loop | |
2cc6b29a | 708 | fModule = module;//Defined because functions |
709 | // called by UpdateMapSignal | |
710 | // expect module to be an | |
711 | // integer | |
7d50ea21 | 712 | UpdateMapSignal(kz-1,kx-1, |
ee86d557 | 713 | // mod->GetHitTrackIndex(hit), |
714 | ((AliITShit*)(mod->GetHit(hit)))->GetTrack(), | |
f74211b0 | 715 | hit,fModule,dXCharge,pList); |
2cc6b29a | 716 | } // dXCharge > 1 e- |
717 | } // jx loop | |
409f8c84 | 718 | } // dZCharge > 1 e- |
719 | } // jz loop | |
720 | } // iZi loop | |
409f8c84 | 721 | if (status == 65) { // the step is inside of Si |
2cc6b29a | 722 | zPix0 = zPix; |
723 | xPix0 = xPix; | |
724 | } // end if status == 65 | |
725 | yPrev = yPix; | |
409f8c84 | 726 | } // hit loop inside the module |
409f8c84 | 727 | } |
2cc6b29a | 728 | //______________________________________________________________________ |
729 | void AliITSsimulationSPDdubna::ChargeToSignal(AliITSpList *pList){ | |
730 | // add noise and electronics, perform the zero suppression and add the | |
731 | // digit to the list | |
f74211b0 | 732 | static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS"); |
2cc6b29a | 733 | Float_t threshold = (float)fResponse->MinVal(); |
f74211b0 | 734 | Int_t j; |
735 | // Int_t digits[3], tracks[3], hits[3]; | |
736 | // Float_t charges[3]; | |
2cc6b29a | 737 | Float_t electronics; |
f74211b0 | 738 | // Float_t phys; |
2cc6b29a | 739 | Double_t sig; |
ee86d557 | 740 | const Int_t nmaxtrk=AliITSdigitSPD::GetNTracks(); |
f74211b0 | 741 | static AliITSdigitSPD dig; |
742 | ||
2cc6b29a | 743 | for(Int_t iz=0; iz<fNPixelsZ; iz++){ |
744 | for(Int_t ix=0; ix<fNPixelsX; ix++){ | |
745 | electronics = fBaseline + fNoise*gRandom->Gaus(); | |
f74211b0 | 746 | sig = pList->GetSignalOnly(iz,ix); |
747 | UpdateMapNoise(iz,ix,fModule,sig,electronics,pList); | |
748 | #ifdef DEBUG | |
749 | // cout << sig << "+" << electronics <<">threshold=" << threshold | |
750 | // << endl; | |
751 | #endif | |
752 | if (sig+electronics > threshold) { | |
753 | dig.fCoord1 = iz; | |
754 | dig.fCoord2 = ix; | |
755 | dig.fSignal = 1; | |
756 | dig.fSignalSPD = (Int_t) pList->GetSignal(iz,ix); | |
757 | /* | |
758 | digits[0] = iz; | |
759 | digits[1] = ix; | |
760 | digits[2] = 1; */ | |
761 | for(j=0;j<nmaxtrk;j++){ | |
762 | // charges[j] = 0.0; | |
ee86d557 | 763 | if (j<pList->GetNEnteries()) { |
f74211b0 | 764 | dig.fTracks[j] = pList->GetTrack(iz,ix,j); |
765 | dig.fHits[j] = pList->GetHit(iz,ix,j); | |
766 | /* | |
767 | tracks[j] = pList->GetTrack(iz,ix,j); | |
768 | hits[j] = pList->GetHit(iz,ix,j); | |
769 | */ | |
770 | }else { // Default values | |
ee86d557 | 771 | dig.fTracks[j] = -3; |
772 | dig.fHits[j] = -1; | |
f74211b0 | 773 | /* tracks[j] = -2; //noise |
774 | hits[j] = -1; */ | |
2cc6b29a | 775 | } // end if pList |
f74211b0 | 776 | } // end for j |
777 | // charges[0] = (Float_t) pList->GetSumSignal(iz,ix); | |
778 | /* | |
2cc6b29a | 779 | if(tracks[0] == tracks[1] && tracks[0] == tracks[2]) { |
780 | tracks[1] = -3; | |
781 | hits[1] = -1; | |
782 | tracks[2] = -3; | |
783 | hits[2] = -1; | |
784 | } else if(tracks[0] == tracks[1] && tracks[0] != tracks[2]) { | |
785 | tracks[1] = -3; | |
786 | hits[1] = -1; | |
787 | } else if(tracks[0] == tracks[2] && tracks[0] != tracks[1]) { | |
788 | tracks[2] = -3; | |
789 | hits[2] = -1; | |
790 | } else if(tracks[1] == tracks[2] && tracks[0] != tracks[1]) { | |
791 | tracks[2] = -3; | |
792 | hits[2] = -1; | |
793 | } // end if | |
f74211b0 | 794 | */ |
795 | // phys = 0.0; | |
796 | #ifdef DEBUG | |
797 | cout << iz << "," << ix << "," << | |
798 | *(pList->GetpListItem(iz,ix)) << endl; | |
799 | #endif | |
800 | // aliITS->AddSimDigit(0, phys, digits, tracks, hits, charges); | |
801 | aliITS->AddSimDigit(0,&dig); | |
2cc6b29a | 802 | } // |
803 | } // | |
804 | } // | |
409f8c84 | 805 | } |
2cc6b29a | 806 | //______________________________________________________________________ |
807 | void AliITSsimulationSPDdubna::CreateHistograms(){ | |
808 | // create 1D histograms for tests | |
809 | ||
810 | printf("SPD - create histograms\n"); | |
811 | ||
812 | fHis=new TObjArray(fNPixelsZ); | |
813 | TString spdName("spd_"); | |
814 | for (Int_t i=0;i<fNPixelsZ;i++) { | |
815 | Char_t pixelz[4]; | |
816 | sprintf(pixelz,"%d",i+1); | |
817 | spdName.Append(pixelz); | |
818 | //PH (*fHis)[i] = new TH1F(spdName.Data(),"SPD maps", | |
819 | //PH fNPixelsX,0.,(Float_t) fNPixelsX); | |
820 | fHis->AddAt(new TH1F(spdName.Data(),"SPD maps", | |
821 | fNPixelsX,0.,(Float_t) fNPixelsX), i); | |
822 | } // end for i | |
409f8c84 | 823 | } |
2cc6b29a | 824 | //______________________________________________________________________ |
825 | void AliITSsimulationSPDdubna::ResetHistograms(){ | |
409f8c84 | 826 | // |
827 | // Reset histograms for this detector | |
828 | // | |
829 | ||
830 | for ( int i=0;i<fNPixelsZ;i++ ) { | |
2cc6b29a | 831 | //PH if ((*fHis)[i]) ((TH1F*)(*fHis)[i])->Reset(); |
2682e810 | 832 | if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset(); |
2cc6b29a | 833 | } // end for i |
409f8c84 | 834 | } |