1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include <Riostream.h>
23 #include <TParticle.h>
27 #include "AliITShit.h"
28 #include "AliITSdigit.h"
29 #include "AliITSmodule.h"
30 #include "AliITSMapA2.h"
31 #include "AliITSpList.h"
32 #include "AliITSsimulationSPDdubna.h"
33 #include "AliITSsegmentationSPD.h"
34 #include "AliITSresponseSPDdubna.h"
38 ClassImp(AliITSsimulationSPDdubna)
39 ////////////////////////////////////////////////////////////////////////
41 // Written by Boris Batyunya
44 // AliITSsimulationSPDdubna is the simulation of SPDs
45 //______________________________________________________________________
48 AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(){
63 //______________________________________________________________________
64 AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(AliITSsegmentation *seg,
65 AliITSresponse *resp){
66 // standard constructor
67 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
75 fNPixelsZ=GetSeg()->Npz();
76 fNPixelsX=GetSeg()->Npx();
78 GetResp()->GetNoiseParam(fNoise,fBaseline);
79 GetResp()->SetDistanceOverVoltage(kmictocm*GetSeg()->Dy(),50.0);
81 // fMapA2 = new AliITSMapA2(GetSeg());
84 fpList = new AliITSpList(fNPixelsZ+1,fNPixelsX+1);
87 //______________________________________________________________________
88 AliITSsimulationSPDdubna::~AliITSsimulationSPDdubna(){
91 if(fMapA2) delete fMapA2;
98 //______________________________________________________________________
99 AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(const
100 AliITSsimulationSPDdubna
103 if(&source == this) return;
104 this->fMapA2 = source.fMapA2;
105 this->fNoise = source.fNoise;
106 this->fBaseline = source.fBaseline;
107 this->fNPixelsX = source.fNPixelsX;
108 this->fNPixelsZ = source.fNPixelsZ;
109 this->fHis = source.fHis;
112 //______________________________________________________________________
113 AliITSsimulationSPDdubna& AliITSsimulationSPDdubna::operator=(const
114 AliITSsimulationSPDdubna &source){
115 // Assignment operator
116 if(&source == this) return *this;
117 this->fMapA2 = source.fMapA2;
118 this->fNoise = source.fNoise;
119 this->fBaseline = source.fBaseline;
120 this->fNPixelsX = source.fNPixelsX;
121 this->fNPixelsZ = source.fNPixelsZ;
122 this->fHis = source.fHis;
125 //______________________________________________________________________
126 void AliITSsimulationSPDdubna::InitSimulationModule(Int_t module, Int_t event){
127 // This function creates maps to build the list of tracks for each
131 // Int_t module // Module number to be simulated
132 // Int_t event // Event number to be simulated
142 // fMapA2->ClearMap();
145 //_____________________________________________________________________
146 void AliITSsimulationSPDdubna::SDigitiseModule(AliITSmodule *mod, Int_t mask,
148 // This function begins the work of creating S-Digits
151 // AliITSmodule *mod // module
152 // Int_t mask // mask to be applied to the module
158 // test // test returns kTRUE if the module contained hits
159 // // test returns kFALSE if it did not contain hits
163 if(!(mod->GetNhits())) return;// if module has no hits don't create Sdigits
164 fModule = mod->GetIndex();
165 HitToSDigit(mod, module, mask, fpList);
166 WriteSDigits(fpList);
167 // fMapA2->ClearMap();
170 //______________________________________________________________________
171 void AliITSsimulationSPDdubna::WriteSDigits(AliITSpList *pList){
172 // This function adds each S-Digit to pList
175 // AliITSpList *pList
182 Int_t ix, nix, iz, niz;
183 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
185 pList->GetMaxMapIndex(niz, nix);
186 for(iz=0; iz<niz-1; iz++)for(ix=0; ix<nix-1; ix++){
187 if(pList->GetSignalOnly(iz+1,ix+1)>0.0){
188 aliITS->AddSumDigit(*(pList->GetpListItem(iz+1,ix+1)));
190 cout <<"SDigits " << iz << "," << ix << "," <<
191 *(pList->GetpListItem(iz+1,ix+1)) << endl;
197 //______________________________________________________________________
198 void AliITSsimulationSPDdubna::FinishSDigitiseModule(){
199 // This function calls SDigitsToDigits which creates Digits from SDigits
209 SDigitsToDigits(fModule, fpList);
212 //______________________________________________________________________
213 void AliITSsimulationSPDdubna::SDigitsToDigits(Int_t module,
215 // This function adds electronic noise to the S-Digits and then adds them
219 // Int_t module // module number
220 // AliITSpList *pList // pList
223 // pList is passed along to the functions ChargeToSignal and GetList
229 ChargeToSignal(pList); // Charge To Signal both adds noise and
230 // fMapA2->ClearMap();
233 //______________________________________________________________________
234 void AliITSsimulationSPDdubna::DigitiseModule(AliITSmodule *mod, Int_t module,
236 // This function creates Digits straight from the hits and then adds
237 // electronic noise to the digits before adding them to pList
240 // AliITSmodule *mod // module
241 // Int_t module // module number Dummy.
245 // Each of the input variables is passed along to HitToSDigit
250 fModule = mod->GetIndex(); //This calls the module for HitToSDigit
251 HitToSDigit(mod,fModule, dummy, fpList);
252 ChargeToSignal(fpList);
253 // fMapA2->ClearMap();
256 //______________________________________________________________________
257 void AliITSsimulationSPDdubna::UpdateMapSignal(Int_t iz, Int_t ix, Int_t trk,
258 Int_t ht, Int_t module,
261 // This function adds a signal to the pList from the pList class
264 // Int_t iz // row number
265 // Int_t ix // column number
266 // Int_t trk // track number
267 // Int_t ht // hit number
268 // Double_t signal // signal strength
269 // AliITSpList *pList // pList
272 // All of the inputs are passed to AliITSpList::AddSignal
273 // Int_t ix // row number
274 // Int_t iz // column number
275 // Double_t sig // signal strength
276 // // These three variables are defined to preserve the
277 // // assignments used in the function AliITSMapA2::AddSignal
282 // fMapA2->AddSignal(iz, ix, signal);
283 pList->AddSignal(iz+1,ix+1, trk, ht, fModule, signal);
285 //______________________________________________________________________
286 void AliITSsimulationSPDdubna::UpdateMapNoise(Int_t iz,
287 Int_t ix, Int_t fModule,
288 Double_t sig, Float_t noise,
290 // This function adds noise to data in the MapA2 as well as the pList
293 // Int_t iz // row number
294 // Int_t ix // column number
295 // Int_t mod // module number
296 // Double_t sig // signal strength
297 // Double_t noise // electronic noise generated by ChargeToSignal
298 // AliITSpList *pList // pList
301 // All of the inputs are passed to AliITSMapA2::AddSignal or
302 // AliITSpList::AddNoise
307 // fMapA2->AddSignal(iz, ix, noise);
308 pList->AddNoise(iz+1,ix+1, fModule, noise);
310 //______________________________________________________________________
311 void AliITSsimulationSPDdubna::HitToDigit(AliITSmodule *mod, Int_t module,
313 DigitiseModule(mod, module, dummy);
315 //______________________________________________________________________
316 void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod, Int_t module,
317 Int_t dummy,AliITSpList *pList){
318 // Does the charge distributions using Gaussian diffusion charge charing.
319 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
320 TObjArray *hits = mod->GetHits();
321 Int_t nhits = hits->GetEntriesFast();
324 Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
325 Double_t x,y,z,t,tp,st,dt=0.2,el,sig;
326 Double_t thick = kmictocm*GetSeg()->Dy();
329 for(h=0;h<nhits;h++){
331 cout << "Hits=" << h << "," << *(mod->GetHit(h)) << endl;
333 if(mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)){
334 st =TMath::Sqrt(x1*x1+y1*y1+z1*z1);
336 st = (Double_t)((Int_t)(1.0E+04*st)); // number of microns
337 if(st<=0.0) st = 1.0;
339 for(t=0;t<1.0;t+=dt){ // Integrate over t
341 el = GetResp()->GeVToCharge((Float_t)(dt*de));
343 if(el<=0.0) cout << "el="<<el<<" dt="<<dt<<" de="<<de<<endl;
348 GetSeg()->LocalToDet(x,z,ix,iz);
349 sig = GetResp()->SigmaDiffusion1D(thick + y);
350 SpreadCharge(x,y,z,ix,iz,el,sig,idtrack,
351 mod->GetHitTrackIndex(h),h,mod->GetIndex());
353 } else { // st == 0.0 deposit it at this point
354 el = GetResp()->GeVToCharge((Float_t)de);
358 GetSeg()->LocalToDet(x,z,ix,iz);
359 sig = GetResp()->SigmaDiffusion1D(thick + y);
360 SpreadCharge(x,y,z,ix,iz,el,sig,
361 idtrack,mod->GetHitTrackIndex(h),h,mod->GetIndex());
363 }} // Loop over all hits h
365 //______________________________________________________________________
366 void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod, Int_t module,
367 Int_t dummy,AliITSpList *pList){
368 // Does the charge distributions using Gaussian diffusion charge charing.
369 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
370 TObjArray *hits = mod->GetHits();
371 Int_t nhits = hits->GetEntriesFast();
374 Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
375 Double_t x,y,z,*ta,t,tp,st,dt=0.2,el,sig;
376 Double_t thick = kmictocm*GetSeg()->Dy();
379 for(h=0;h<nhits;h++){
381 cout << "Hits=" << h << "," << *(mod->GetHit(h)) << endl;
383 if(mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)){
384 st =TMath::Sqrt(x1*x1+y1*y1+z1*z1);
386 st =TMath::Sqrt(x1*x1+y1*y1+z1*z1)*(ta[i+1]-ta[i]);
387 ta = CreateFindCellEdges(x0,x1,z0,z1,n);
389 dt = TMath::Min((1.0E-4)/st,);
390 for(t=ta[i];t<ta[i+1];t+=dt){ // Integrate over t
392 el = GetResp()->GeVToCharge((Float_t)(dt*de));
394 if(el<=0.0) cout << "el="<<el<<" dt="<<dt<<" de="<<de<<endl;
399 GetSeg()->LocalToDet(x,z,ix,iz);
400 sig = GetResp()->SigmaDiffusion1D(thick + y);
401 SpreadCharge(x,y,z,ix,iz,el,sig,idtrack,
402 mod->GetHitTrackIndex(h),h,mod->GetIndex());
405 } else { // st == 0.0 deposit it at this point
406 el = GetResp()->GeVToCharge((Float_t)de);
410 GetSeg()->LocalToDet(x,z,ix,iz);
411 sig = GetResp()->SigmaDiffusion1D(thick + y);
412 SpreadCharge(x,y,z,ix,iz,el,sig,
413 idtrack,mod->GetHitTrackIndex(h),h,mod->GetIndex());
415 }} // Loop over all hits h
417 //______________________________________________________________________
418 void AliITSsimulationSPDdubna::SpreadCharge(Double_t x0,Double_t y0,
419 Double_t z0,Int_t ix0,Int_t iz0,
420 Double_t el,Double_t sig,Int_t t,
421 Int_t ti,Int_t hi,Int_t mod){
422 // Spreads the charge over neighboring cells. Assume charge is distributed
423 // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg)
424 // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig)
425 // Defined this way, the integral over all x and z is el.
426 const Int_t knx = 3,knz = 2;
427 const Double_t kRoot2 = 1.414213562; // Sqrt(2).
428 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
429 Int_t ix,iz,ixs,ixe,izs,ize;
431 Double_t x1,x2,z1,z2,s,sp;
434 fpList->AddSignal(iz0+1,ix0+1,t,hi,mod,el);
437 sp = 1.0/(sig*kRoot2);
439 cout << "sig=" << sig << " sp=" << sp << endl;
441 ixs = TMath::Max(-knx+ix0,0);
442 ixe = TMath::Min(knx+ix0,GetSeg()->Npx()-1);
443 izs = TMath::Max(-knz+iz0,0);
444 ize = TMath::Min(knz+iz0,GetSeg()->Npz()-1);
445 for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
446 GetSeg()->DetToLocal(ix,iz,x,z); // pixel center
449 x2 = x1 + 0.5*kmictocm*GetSeg()->Dpx(ix); // Upper
450 x1 -= 0.5*kmictocm*GetSeg()->Dpx(ix); // Lower
451 z2 = z1 + 0.5*kmictocm*GetSeg()->Dpz(iz); // Upper
452 z1 -= 0.5*kmictocm*GetSeg()->Dpz(iz); // Lower
453 x1 -= x0; // Distance from where track traveled
454 x2 -= x0; // Distance from where track traveled
455 z1 -= z0; // Distance from where track traveled
456 z2 -= z0; // Distance from where track traveled
457 s = 0.25; // Correction based on definision of Erfc
458 s *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2);
460 cout << "el=" << el << " ix0=" << ix0 << " ix=" << ix << " x0="<< x <<
461 " iz0=" << iz0 << " iz=" << iz << " z0=" << z <<
462 " sp*x1=" << sp*x1 <<" sp*x2=" << sp*x2 << " s=" << s;
464 s *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2);
466 cout << " sp*z1=" << sp*z1 <<" sp*z2=" << sp*z2 << " s=" << s << endl;
468 fpList->AddSignal(iz+1,ix+1,t,hi,mod,s*el);
471 //______________________________________________________________________
472 Double_t *AliITSsimulationSPDdubna::CreateFindCellEdges(Double_t x0,Double_t x1,
473 Double_t z0,Double_t z1,Int_t &n){
474 // Note: This function is a potensial source for a memory leak. The memory
475 // pointed to in its return, must be deleted.
477 // Double_t x0 The starting location of the track step in x
478 // Double_t x1 The distance allong x for the track step
479 // Double_t z0 The starting location of the track step in z
480 // Double_t z1 The distance allong z for the track step
482 // Int)t &n The size of the array returned. Minimal n=2.
484 // The pointer to the array of track steps.
485 Int_t ix0,ix1,ix,iz0,iz1,iz,i;
486 Double_t x,z,lx,ux,lz,uz,a,b,c,d;
489 GetSeg()->LocalToDet(x0,z0,ix0,iz0);
490 GetSeg()->LocalToDet(x1,z1,ix1,iz1);
491 n = 2 + TMath::Abs(ix1-ix0) + TMath::Abs(iz1-iz0);
498 GetSeg()->LocalToDet(x,z,ix,iz);
499 GetSeg()->CellBoundries(ix,iz,lx,ux,lz,uz);
501 if(a<=t[i-1]) a = 1.0;
503 if(b<=t[i-1]) b = 1.0;
505 if(c<=t[i-1]) c = 1.0;
507 if(d<=t[i-1]) d = 1.0;
508 t[i] = TMath::Min(TMath::Min(TMath::Min(a,b),c),d);
509 x = x0+x1*(t[i]*1.00000001);
510 z = z0+z1*(t[i]*1.00000001);
515 //______________________________________________________________________
516 void AliITSsimulationSPDdubna::HitToSDigitOld(AliITSmodule *mod, Int_t module,
517 Int_t dummy, AliITSpList *pList){
519 const Float_t kEnToEl = 2.778e+8; // GeV->charge in electrons
521 const Float_t kconv = 10000.; // cm -> microns
523 Float_t spdLength = GetSeg()->Dz();
524 Float_t spdWidth = GetSeg()->Dx();
525 Float_t spdThickness = GetSeg()->Dy();
526 Float_t difCoef, dum;
527 GetResp()->DiffCoeff(difCoef,dum);
528 if(spdThickness > 290) difCoef = 0.00613;
530 Float_t zPix0 = 1e+6;
531 Float_t xPix0 = 1e+6;
532 Float_t yPrev = 1e+6;
534 Float_t zPitch = GetSeg()->Dpz(0);
535 Float_t xPitch = GetSeg()->Dpx(0);
537 TObjArray *fHits = mod->GetHits();
538 module = mod->GetIndex();
539 Int_t nhits = fHits->GetEntriesFast();
542 cout<<"len,wid,thickness,nx,nz,pitchx,pitchz,difcoef ="<<spdLength<<","
543 <<spdWidth<<","<<spdThickness<<","<<fNPixelsX<<","<<fNPixelsZ<<","
544 <<xPitch<<","<<zPitch<<","<<difCoef<<endl;
546 // Array of pointers to the label-signal list
547 Int_t indexRange[4] = {0,0,0,0};
549 // Fill detector maps with GEANT hits
550 // loop over hits in the module
553 Int_t hit, iZi, jz, jx;
556 cout<<"SPDdubna: module,nhits ="<<module<<","<<nhits<<endl;
558 for (hit=0;hit<nhits;hit++) {
559 AliITShit *iHit = (AliITShit*) fHits->At(hit);
561 cout << "Hits=" << hit << "," << *iHit << endl;
563 //Int_t layer = iHit->GetLayer();
564 Float_t yPix0 = -spdThickness/2;
566 // work with the idtrack=entry number in the TreeH
567 //Int_t idhit,idtrack; //!
568 //mod->GetHitTrackAndHitIndex(hit,idtrack,idhit); //!
569 //Int_t idtrack=mod->GetHitTrackIndex(hit);
570 // or store straight away the particle position in the array
572 if(iHit->StatusEntering()) idhit=hit;
573 Int_t itrack = iHit->GetTrack();
576 if (lasttrack != itrack || hit==(nhits-1)) first = kTRUE;
578 //Int_t parent = iHit->GetParticle()->GetFirstMother();
579 Int_t partcode = iHit->GetParticle()->GetPdgCode();
581 // partcode (pdgCode): 11 - e-, 13 - mu-, 22 - gamma, 111 - pi0,
582 // 211 - pi+, 310 - K0s, 321 - K+, 2112 - n, 2212 - p, 3122 - lambda
584 Float_t pmod = iHit->GetParticle()->P(); // total momentum at the
588 if(partcode == 11 && pmod < 6) dray = 1; // delta ray is e-
591 // Get hit z and x(r*phi) cordinates for each module (detector)
594 Float_t zPix = kconv*iHit->GetZL();
595 Float_t xPix = kconv*iHit->GetXL();
596 Float_t yPix = kconv*iHit->GetYL();
599 Int_t status = iHit->GetTrackStatus();
602 if(zPix > spdLength/2) {
604 cout<<"!!! SPD: z outside ="<<zPix<<endl;
606 zPix = spdLength/2 - 10;
608 if(zPix < 0 && zPix < -spdLength/2) {
610 cout<<"!!! SPD: z outside ="<<zPix<<endl;
612 zPix = -spdLength/2 + 10;
614 if(xPix > spdWidth/2) {
616 cout<<"!!! SPD: x outside ="<<xPix<<endl;
618 xPix = spdWidth/2 - 10;
620 if(xPix < 0 && xPix < -spdWidth/2) {
622 cout<<"!!! SPD: x outside ="<<xPix<<endl;
624 xPix = -spdWidth/2 + 10;
628 // enter Si or after event in Si
633 } // end if status == 66
635 Float_t depEnergy = iHit->GetIonization();
636 // skip if the input point to Si
638 if(depEnergy <= 0.) continue;
640 // if track returns to the opposite direction:
643 } // end if yPix < yPrev
645 // take into account the holes diffusion inside the Silicon
646 // the straight line between the entrance and exit points in Si is
647 // divided into the several steps; the diffusion is considered
648 // for each end point of step and charge
649 // is distributed between the pixels through the diffusion.
651 // ---------- the diffusion in Z (beam) direction -------
652 Float_t charge = depEnergy*kEnToEl; // charge in e-
655 Float_t sigmaDif = 0.;
656 Float_t zdif = zPix - zPix0;
657 Float_t xdif = xPix - xPix0;
658 Float_t ydif = TMath::Abs(yPix - yPrev);
659 Float_t ydif0 = TMath::Abs(yPrev - yPix0);
661 if(ydif < 1) continue; // ydif is not zero
663 Float_t projDif = sqrt(xdif*xdif + zdif*zdif);
665 Int_t ndZ = (Int_t)TMath::Abs(zdif/zPitch) + 1;
666 Int_t ndX = (Int_t)TMath::Abs(xdif/xPitch) + 1;
668 // number of the steps along the track:
670 if(ndX > ndZ) nsteps = ndX;
671 if(nsteps < 20) nsteps = 20; // minimum number of the steps
674 drPath = (yPix-yPix0)*1.e-4;
675 drPath = TMath::Abs(drPath); // drift path in cm
676 sigmaDif = difCoef*sqrt(drPath); // sigma diffusion in cm
677 sigmaDif = sigmaDif*kconv; // sigma diffusion in microns
679 } // end if projDif < 5
681 if(projDif > 5) tang = ydif/projDif;
682 Float_t dCharge = charge/nsteps; // charge in e- for one step
683 Float_t dZ = zdif/nsteps;
684 Float_t dX = xdif/nsteps;
686 for (iZi = 1; iZi <= nsteps;iZi++) {
687 Float_t dZn = iZi*dZ;
688 Float_t dXn = iZi*dX;
689 Float_t zPixn = zPix0 + dZn;
690 Float_t xPixn = xPix0 + dXn;
693 Float_t dProjn = sqrt(dZn*dZn+dXn*dXn);
694 drPath = dProjn*tang*1.e-4; // drift path for iZi+1 step in cm
696 drPath = TMath::Abs(drPath) + ydif0*1.e-4;
699 drPath = ydif0*1.e-4 - TMath::Abs(drPath);
700 drPath = TMath::Abs(drPath);
701 } // end if trdown == 1
702 sigmaDif = difCoef*sqrt(drPath);
703 sigmaDif = sigmaDif*kconv; // sigma diffusion in microns
704 } // end if projdif >= 5
706 zPixn = (zPixn + spdLength/2.);
707 xPixn = (xPixn + spdWidth/2.);
709 GetSeg()->GetPadIxz(xPixn,zPixn,nXpix,nZpix);
710 zPitch = GetSeg()->Dpz(nZpix);
711 GetSeg()->GetPadTxz(xPixn,zPixn);
712 // set the window for the integration
715 if(nZpix == 1) jzmin =2;
716 if(nZpix == fNPixelsZ) jzmax = 2;
720 if(nXpix == 1) jxmin =2;
721 if(nXpix == fNPixelsX) jxmax = 2;
723 Float_t zpix = nZpix;
724 Float_t dZright = zPitch*(zpix - zPixn);
725 Float_t dZleft = zPitch - dZright;
727 Float_t xpix = nXpix;
728 Float_t dXright = xPitch*(xpix - xPixn);
729 Float_t dXleft = xPitch - dXright;
736 for(jz=jzmin; jz <=jzmax; jz++) {
738 dZprev = -zPitch - dZleft;
745 dZnext = dZright + zPitch;
747 // kz changes from 1 to the fNofPixels(270)
748 Int_t kz = nZpix + jz -2;
750 Float_t zArg1 = dZprev/sigmaDif;
751 Float_t zArg2 = dZnext/sigmaDif;
752 Float_t zProb1 = TMath::Erfc(zArg1);
753 Float_t zProb2 = TMath::Erfc(zArg2);
754 Float_t dZCharge =0.5*(zProb1-zProb2)*dCharge;
757 // ----------- holes diffusion in X(r*phi) direction --------
760 for(jx=jxmin; jx <=jxmax; jx++) {
762 dXprev = -xPitch - dXleft;
769 dXnext = dXright + xPitch;
771 Int_t kx = nXpix + jx -2;
772 Float_t xArg1 = dXprev/sigmaDif;
773 Float_t xArg2 = dXnext/sigmaDif;
774 Float_t xProb1 = TMath::Erfc(xArg1);
775 Float_t xProb2 = TMath::Erfc(xArg2);
776 Float_t dXCharge =0.5*(xProb1-xProb2)*dZCharge;
780 indexRange[0]=indexRange[1]=kz-1;
781 indexRange[2]=indexRange[3]=kx-1;
784 indexRange[0]=TMath::Min(indexRange[0],kz-1);
785 indexRange[1]=TMath::Max(indexRange[1],kz-1);
786 indexRange[2]=TMath::Min(indexRange[2],kx-1);
787 indexRange[3]=TMath::Max(indexRange[3],kx-1);
789 // build the list of digits for this module
790 Double_t signal = fMapA2->GetSignal(kz-1,kx-1);
792 fMapA2->SetHit(kz-1,kx-1,(double)signal);
794 // The calling sequence for UpdateMapSignal was
795 // moved into the (dx > 1 e-) loop because it
796 // needs to call signal which is defined inside
798 fModule = module;//Defined because functions
799 // called by UpdateMapSignal
800 // expect module to be an
802 UpdateMapSignal(kz-1,kx-1,
803 // mod->GetHitTrackIndex(hit),
804 ((AliITShit*)(mod->GetHit(hit)))->GetTrack(),
805 hit,fModule,dXCharge,pList);
811 if (status == 65) { // the step is inside of Si
814 } // end if status == 65
816 } // hit loop inside the module
818 //______________________________________________________________________
819 void AliITSsimulationSPDdubna::ChargeToSignal(AliITSpList *pList){
820 // add noise and electronics, perform the zero suppression and add the
822 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
823 Float_t threshold = (float)GetResp()->MinVal();
825 // Int_t digits[3], tracks[3], hits[3];
826 // Float_t charges[3];
830 const Int_t nmaxtrk=AliITSdigitSPD::GetNTracks();
831 static AliITSdigitSPD dig;
833 for(Int_t iz=0; iz<fNPixelsZ; iz++){
834 for(Int_t ix=0; ix<fNPixelsX; ix++){
835 electronics = fBaseline + fNoise*gRandom->Gaus();
836 sig = pList->GetSignalOnly(iz+1,ix+1);
837 UpdateMapNoise(iz,ix,fModule,sig,electronics,pList);
839 // cout << sig << "+" << electronics <<">threshold=" << threshold
842 if (sig+electronics > threshold) {
846 dig.fSignalSPD = (Int_t) pList->GetSignal(iz+1,ix+1);
851 for(j=0;j<nmaxtrk;j++){
853 if (j<pList->GetNEnteries()) {
854 dig.fTracks[j] = pList->GetTrack(iz+1,ix+1,j);
855 dig.fHits[j] = pList->GetHit(iz+1,ix+1,j);
857 tracks[j] = pList->GetTrack(iz+1,ix+1,j);
858 hits[j] = pList->GetHit(iz+1,ix+1,j);
860 }else { // Default values
863 /* tracks[j] = -2; //noise
867 // charges[0] = (Float_t) pList->GetSumSignal(iz+1,ix+1);
869 if(tracks[0] == tracks[1] && tracks[0] == tracks[2]) {
874 } else if(tracks[0] == tracks[1] && tracks[0] != tracks[2]) {
877 } else if(tracks[0] == tracks[2] && tracks[0] != tracks[1]) {
880 } else if(tracks[1] == tracks[2] && tracks[0] != tracks[1]) {
887 cout << iz << "," << ix << "," <<
888 *(pList->GetpListItem(iz+1,ix+1)) << endl;
890 // aliITS->AddSimDigit(0, phys, digits, tracks, hits, charges);
891 aliITS->AddSimDigit(0,&dig);
896 //______________________________________________________________________
897 void AliITSsimulationSPDdubna::CreateHistograms(){
898 // create 1D histograms for tests
900 printf("SPD - create histograms\n");
902 fHis=new TObjArray(fNPixelsZ);
903 TString spdName("spd_");
904 for (Int_t i=0;i<fNPixelsZ;i++) {
906 sprintf(pixelz,"%d",i+1);
907 spdName.Append(pixelz);
908 //PH (*fHis)[i] = new TH1F(spdName.Data(),"SPD maps",
909 //PH fNPixelsX,0.,(Float_t) fNPixelsX);
910 fHis->AddAt(new TH1F(spdName.Data(),"SPD maps",
911 fNPixelsX,0.,(Float_t) fNPixelsX), i);
914 //______________________________________________________________________
915 void AliITSsimulationSPDdubna::ResetHistograms(){
917 // Reset histograms for this detector
920 for ( int i=0;i<fNPixelsZ;i++ ) {
921 //PH if ((*fHis)[i]) ((TH1F*)(*fHis)[i])->Reset();
922 if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset();