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 Revision 1.9 2002/10/22 14:45:45 alibrary
19 Introducing Riostream.h
21 Revision 1.8 2002/10/14 14:57:08 hristov
22 Merging the VirtualMC branch to the main development branch (HEAD)
24 Revision 1.3.8.2 2002/10/14 13:14:08 hristov
25 Updating VirtualMC to v3-09-02
27 Revision 1.7 2002/09/09 17:23:28 nilsen
28 Minor changes in support of changes to AliITSdigitS?D class'.
30 Revision 1.6 2002/08/21 22:09:58 nilsen
31 Updated SPD simulation with difusion effects. ReWritten Hit to SDigits
35 #include <Riostream.h>
40 #include <TParticle.h>
44 #include "AliITShit.h"
45 #include "AliITSdigit.h"
46 #include "AliITSmodule.h"
47 #include "AliITSMapA2.h"
48 #include "AliITSpList.h"
49 #include "AliITSsimulationSPDdubna.h"
50 #include "AliITSsegmentationSPD.h"
51 #include "AliITSresponseSPDdubna.h"
55 ClassImp(AliITSsimulationSPDdubna)
56 ////////////////////////////////////////////////////////////////////////
58 // Written by Boris Batyunya
61 // AliITSsimulationSPDdubna is the simulation of SPDs
62 //______________________________________________________________________
65 AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(){
80 //______________________________________________________________________
81 AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(AliITSsegmentation *seg,
82 AliITSresponse *resp){
83 // standard constructor
84 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
92 fNPixelsZ=GetSeg()->Npz();
93 fNPixelsX=GetSeg()->Npx();
95 GetResp()->GetNoiseParam(fNoise,fBaseline);
96 GetResp()->SetDistanceOverVoltage(kmictocm*GetSeg()->Dy(),50.0);
98 // fMapA2 = new AliITSMapA2(GetSeg());
101 fpList = new AliITSpList(fNPixelsZ+1,fNPixelsX+1);
104 //______________________________________________________________________
105 AliITSsimulationSPDdubna::~AliITSsimulationSPDdubna(){
108 if(fMapA2) delete fMapA2;
115 //______________________________________________________________________
116 AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(const
117 AliITSsimulationSPDdubna
120 if(&source == this) return;
121 this->fMapA2 = source.fMapA2;
122 this->fNoise = source.fNoise;
123 this->fBaseline = source.fBaseline;
124 this->fNPixelsX = source.fNPixelsX;
125 this->fNPixelsZ = source.fNPixelsZ;
126 this->fHis = source.fHis;
129 //______________________________________________________________________
130 AliITSsimulationSPDdubna& AliITSsimulationSPDdubna::operator=(const
131 AliITSsimulationSPDdubna &source){
132 // Assignment operator
133 if(&source == this) return *this;
134 this->fMapA2 = source.fMapA2;
135 this->fNoise = source.fNoise;
136 this->fBaseline = source.fBaseline;
137 this->fNPixelsX = source.fNPixelsX;
138 this->fNPixelsZ = source.fNPixelsZ;
139 this->fHis = source.fHis;
142 //______________________________________________________________________
143 void AliITSsimulationSPDdubna::InitSimulationModule(Int_t module, Int_t event){
144 // This function creates maps to build the list of tracks for each
148 // Int_t module // Module number to be simulated
149 // Int_t event // Event number to be simulated
159 // fMapA2->ClearMap();
162 //_____________________________________________________________________
163 void AliITSsimulationSPDdubna::SDigitiseModule(AliITSmodule *mod, Int_t mask,
165 // This function begins the work of creating S-Digits
168 // AliITSmodule *mod // module
169 // Int_t mask // mask to be applied to the module
175 // test // test returns kTRUE if the module contained hits
176 // // test returns kFALSE if it did not contain hits
180 if(!(mod->GetNhits())) return;// if module has no hits don't create Sdigits
181 fModule = mod->GetIndex();
182 HitToSDigit(mod, module, mask, fpList);
183 WriteSDigits(fpList);
184 // fMapA2->ClearMap();
187 //______________________________________________________________________
188 void AliITSsimulationSPDdubna::WriteSDigits(AliITSpList *pList){
189 // This function adds each S-Digit to pList
192 // AliITSpList *pList
199 Int_t ix, nix, iz, niz;
200 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
202 pList->GetMaxMapIndex(niz, nix);
203 for(iz=0; iz<niz-1; iz++)for(ix=0; ix<nix-1; ix++){
204 if(pList->GetSignalOnly(iz+1,ix+1)>0.0){
205 aliITS->AddSumDigit(*(pList->GetpListItem(iz+1,ix+1)));
207 cout <<"SDigits " << iz << "," << ix << "," <<
208 *(pList->GetpListItem(iz+1,ix+1)) << endl;
214 //______________________________________________________________________
215 void AliITSsimulationSPDdubna::FinishSDigitiseModule(){
216 // This function calls SDigitsToDigits which creates Digits from SDigits
226 SDigitsToDigits(fModule, fpList);
229 //______________________________________________________________________
230 void AliITSsimulationSPDdubna::SDigitsToDigits(Int_t module,
232 // This function adds electronic noise to the S-Digits and then adds them
236 // Int_t module // module number
237 // AliITSpList *pList // pList
240 // pList is passed along to the functions ChargeToSignal and GetList
246 ChargeToSignal(pList); // Charge To Signal both adds noise and
247 // fMapA2->ClearMap();
250 //______________________________________________________________________
251 void AliITSsimulationSPDdubna::DigitiseModule(AliITSmodule *mod, Int_t module,
253 // This function creates Digits straight from the hits and then adds
254 // electronic noise to the digits before adding them to pList
257 // AliITSmodule *mod // module
258 // Int_t module // module number Dummy.
262 // Each of the input variables is passed along to HitToSDigit
267 fModule = mod->GetIndex(); //This calls the module for HitToSDigit
268 HitToSDigit(mod,fModule, dummy, fpList);
269 ChargeToSignal(fpList);
270 // fMapA2->ClearMap();
273 //______________________________________________________________________
274 void AliITSsimulationSPDdubna::UpdateMapSignal(Int_t iz, Int_t ix, Int_t trk,
275 Int_t ht, Int_t module,
278 // This function adds a signal to the pList from the pList class
281 // Int_t iz // row number
282 // Int_t ix // column number
283 // Int_t trk // track number
284 // Int_t ht // hit number
285 // Double_t signal // signal strength
286 // AliITSpList *pList // pList
289 // All of the inputs are passed to AliITSpList::AddSignal
290 // Int_t ix // row number
291 // Int_t iz // column number
292 // Double_t sig // signal strength
293 // // These three variables are defined to preserve the
294 // // assignments used in the function AliITSMapA2::AddSignal
299 // fMapA2->AddSignal(iz, ix, signal);
300 pList->AddSignal(iz+1,ix+1, trk, ht, fModule, signal);
302 //______________________________________________________________________
303 void AliITSsimulationSPDdubna::UpdateMapNoise(Int_t iz,
304 Int_t ix, Int_t fModule,
305 Double_t sig, Float_t noise,
307 // This function adds noise to data in the MapA2 as well as the pList
310 // Int_t iz // row number
311 // Int_t ix // column number
312 // Int_t mod // module number
313 // Double_t sig // signal strength
314 // Double_t noise // electronic noise generated by ChargeToSignal
315 // AliITSpList *pList // pList
318 // All of the inputs are passed to AliITSMapA2::AddSignal or
319 // AliITSpList::AddNoise
324 // fMapA2->AddSignal(iz, ix, noise);
325 pList->AddNoise(iz+1,ix+1, fModule, noise);
327 //______________________________________________________________________
328 void AliITSsimulationSPDdubna::HitToDigit(AliITSmodule *mod, Int_t module,
330 DigitiseModule(mod, module, dummy);
332 //______________________________________________________________________
333 void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod, Int_t module,
334 Int_t dummy,AliITSpList *pList){
335 // Does the charge distributions using Gaussian diffusion charge charing.
336 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
337 TObjArray *hits = mod->GetHits();
338 Int_t nhits = hits->GetEntriesFast();
341 Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
342 Double_t x,y,z,t,tp,st,dt=0.2,el,sig;
343 Double_t thick = kmictocm*GetSeg()->Dy();
346 for(h=0;h<nhits;h++){
348 cout << "Hits=" << h << "," << *(mod->GetHit(h)) << endl;
350 if(mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)){
351 st =TMath::Sqrt(x1*x1+y1*y1+z1*z1);
353 st = (Double_t)((Int_t)(1.0E+04*st)); // number of microns
354 if(st<=0.0) st = 1.0;
356 for(t=0;t<1.0;t+=dt){ // Integrate over t
358 el = GetResp()->GeVToCharge((Float_t)(dt*de));
360 if(el<=0.0) cout << "el="<<el<<" dt="<<dt<<" de="<<de<<endl;
365 GetSeg()->LocalToDet(x,z,ix,iz);
366 sig = GetResp()->SigmaDiffusion1D(thick + y);
367 SpreadCharge(x,y,z,ix,iz,el,sig,idtrack,
368 mod->GetHitTrackIndex(h),h,mod->GetIndex());
370 } else { // st == 0.0 deposit it at this point
371 el = GetResp()->GeVToCharge((Float_t)de);
375 GetSeg()->LocalToDet(x,z,ix,iz);
376 sig = GetResp()->SigmaDiffusion1D(thick + y);
377 SpreadCharge(x,y,z,ix,iz,el,sig,
378 idtrack,mod->GetHitTrackIndex(h),h,mod->GetIndex());
380 }} // Loop over all hits h
382 //______________________________________________________________________
383 void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod, Int_t module,
384 Int_t dummy,AliITSpList *pList){
385 // Does the charge distributions using Gaussian diffusion charge charing.
386 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
387 TObjArray *hits = mod->GetHits();
388 Int_t nhits = hits->GetEntriesFast();
391 Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
392 Double_t x,y,z,*ta,t,tp,st,dt=0.2,el,sig;
393 Double_t thick = kmictocm*GetSeg()->Dy();
396 for(h=0;h<nhits;h++){
398 cout << "Hits=" << h << "," << *(mod->GetHit(h)) << endl;
400 if(mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)){
401 st =TMath::Sqrt(x1*x1+y1*y1+z1*z1);
403 st =TMath::Sqrt(x1*x1+y1*y1+z1*z1)*(ta[i+1]-ta[i]);
404 ta = CreateFindCellEdges(x0,x1,z0,z1,n);
406 dt = TMath::Min((1.0E-4)/st,);
407 for(t=ta[i];t<ta[i+1];t+=dt){ // Integrate over t
409 el = GetResp()->GeVToCharge((Float_t)(dt*de));
411 if(el<=0.0) cout << "el="<<el<<" dt="<<dt<<" de="<<de<<endl;
416 GetSeg()->LocalToDet(x,z,ix,iz);
417 sig = GetResp()->SigmaDiffusion1D(thick + y);
418 SpreadCharge(x,y,z,ix,iz,el,sig,idtrack,
419 mod->GetHitTrackIndex(h),h,mod->GetIndex());
422 } else { // st == 0.0 deposit it at this point
423 el = GetResp()->GeVToCharge((Float_t)de);
427 GetSeg()->LocalToDet(x,z,ix,iz);
428 sig = GetResp()->SigmaDiffusion1D(thick + y);
429 SpreadCharge(x,y,z,ix,iz,el,sig,
430 idtrack,mod->GetHitTrackIndex(h),h,mod->GetIndex());
432 }} // Loop over all hits h
434 //______________________________________________________________________
435 void AliITSsimulationSPDdubna::SpreadCharge(Double_t x0,Double_t y0,
436 Double_t z0,Int_t ix0,Int_t iz0,
437 Double_t el,Double_t sig,Int_t t,
438 Int_t ti,Int_t hi,Int_t mod){
439 // Spreads the charge over neighboring cells. Assume charge is distributed
440 // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg)
441 // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig)
442 // Defined this way, the integral over all x and z is el.
443 const Int_t knx = 3,knz = 2;
444 const Double_t kRoot2 = 1.414213562; // Sqrt(2).
445 const Double_t kmictocm = 1.0e-4; // convert microns to cm.
446 Int_t ix,iz,ixs,ixe,izs,ize;
448 Double_t x1,x2,z1,z2,s,sp;
451 fpList->AddSignal(iz0+1,ix0+1,t,hi,mod,el);
454 sp = 1.0/(sig*kRoot2);
456 cout << "sig=" << sig << " sp=" << sp << endl;
458 ixs = TMath::Max(-knx+ix0,0);
459 ixe = TMath::Min(knx+ix0,GetSeg()->Npx()-1);
460 izs = TMath::Max(-knz+iz0,0);
461 ize = TMath::Min(knz+iz0,GetSeg()->Npz()-1);
462 for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
463 GetSeg()->DetToLocal(ix,iz,x,z); // pixel center
466 x2 = x1 + 0.5*kmictocm*GetSeg()->Dpx(ix); // Upper
467 x1 -= 0.5*kmictocm*GetSeg()->Dpx(ix); // Lower
468 z2 = z1 + 0.5*kmictocm*GetSeg()->Dpz(iz); // Upper
469 z1 -= 0.5*kmictocm*GetSeg()->Dpz(iz); // Lower
470 x1 -= x0; // Distance from where track traveled
471 x2 -= x0; // Distance from where track traveled
472 z1 -= z0; // Distance from where track traveled
473 z2 -= z0; // Distance from where track traveled
474 s = 0.25; // Correction based on definision of Erfc
475 s *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2);
477 cout << "el=" << el << " ix0=" << ix0 << " ix=" << ix << " x0="<< x <<
478 " iz0=" << iz0 << " iz=" << iz << " z0=" << z <<
479 " sp*x1=" << sp*x1 <<" sp*x2=" << sp*x2 << " s=" << s;
481 s *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2);
483 cout << " sp*z1=" << sp*z1 <<" sp*z2=" << sp*z2 << " s=" << s << endl;
485 fpList->AddSignal(iz+1,ix+1,t,hi,mod,s*el);
488 //______________________________________________________________________
489 Double_t *AliITSsimulationSPDdubna::CreateFindCellEdges(Double_t x0,Double_t x1,
490 Double_t z0,Double_t z1,Int_t &n){
491 // Note: This function is a potensial source for a memory leak. The memory
492 // pointed to in its return, must be deleted.
494 // Double_t x0 The starting location of the track step in x
495 // Double_t x1 The distance allong x for the track step
496 // Double_t z0 The starting location of the track step in z
497 // Double_t z1 The distance allong z for the track step
499 // Int)t &n The size of the array returned. Minimal n=2.
501 // The pointer to the array of track steps.
502 Int_t ix0,ix1,ix,iz0,iz1,iz,i;
503 Double_t x,z,lx,ux,lz,uz,a,b,c,d;
506 GetSeg()->LocalToDet(x0,z0,ix0,iz0);
507 GetSeg()->LocalToDet(x1,z1,ix1,iz1);
508 n = 2 + TMath::Abs(ix1-ix0) + TMath::Abs(iz1-iz0);
515 GetSeg()->LocalToDet(x,z,ix,iz);
516 GetSeg()->CellBoundries(ix,iz,lx,ux,lz,uz);
518 if(a<=t[i-1]) a = 1.0;
520 if(b<=t[i-1]) b = 1.0;
522 if(c<=t[i-1]) c = 1.0;
524 if(d<=t[i-1]) d = 1.0;
525 t[i] = TMath::Min(TMath::Min(TMath::Min(a,b),c),d);
526 x = x0+x1*(t[i]*1.00000001);
527 z = z0+z1*(t[i]*1.00000001);
532 //______________________________________________________________________
533 void AliITSsimulationSPDdubna::HitToSDigitOld(AliITSmodule *mod, Int_t module,
534 Int_t dummy, AliITSpList *pList){
536 const Float_t kEnToEl = 2.778e+8; // GeV->charge in electrons
538 const Float_t kconv = 10000.; // cm -> microns
540 Float_t spdLength = GetSeg()->Dz();
541 Float_t spdWidth = GetSeg()->Dx();
542 Float_t spdThickness = GetSeg()->Dy();
543 Float_t difCoef, dum;
544 GetResp()->DiffCoeff(difCoef,dum);
545 if(spdThickness > 290) difCoef = 0.00613;
547 Float_t zPix0 = 1e+6;
548 Float_t xPix0 = 1e+6;
549 Float_t yPrev = 1e+6;
551 Float_t zPitch = GetSeg()->Dpz(0);
552 Float_t xPitch = GetSeg()->Dpx(0);
554 TObjArray *fHits = mod->GetHits();
555 module = mod->GetIndex();
556 Int_t nhits = fHits->GetEntriesFast();
559 cout<<"len,wid,thickness,nx,nz,pitchx,pitchz,difcoef ="<<spdLength<<","
560 <<spdWidth<<","<<spdThickness<<","<<fNPixelsX<<","<<fNPixelsZ<<","
561 <<xPitch<<","<<zPitch<<","<<difCoef<<endl;
563 // Array of pointers to the label-signal list
564 Int_t indexRange[4] = {0,0,0,0};
566 // Fill detector maps with GEANT hits
567 // loop over hits in the module
570 Int_t hit, iZi, jz, jx;
573 cout<<"SPDdubna: module,nhits ="<<module<<","<<nhits<<endl;
575 for (hit=0;hit<nhits;hit++) {
576 AliITShit *iHit = (AliITShit*) fHits->At(hit);
578 cout << "Hits=" << hit << "," << *iHit << endl;
580 //Int_t layer = iHit->GetLayer();
581 Float_t yPix0 = -spdThickness/2;
583 // work with the idtrack=entry number in the TreeH
584 //Int_t idhit,idtrack; //!
585 //mod->GetHitTrackAndHitIndex(hit,idtrack,idhit); //!
586 //Int_t idtrack=mod->GetHitTrackIndex(hit);
587 // or store straight away the particle position in the array
589 if(iHit->StatusEntering()) idhit=hit;
590 Int_t itrack = iHit->GetTrack();
593 if (lasttrack != itrack || hit==(nhits-1)) first = kTRUE;
595 //Int_t parent = iHit->GetParticle()->GetFirstMother();
596 Int_t partcode = iHit->GetParticle()->GetPdgCode();
598 // partcode (pdgCode): 11 - e-, 13 - mu-, 22 - gamma, 111 - pi0,
599 // 211 - pi+, 310 - K0s, 321 - K+, 2112 - n, 2212 - p, 3122 - lambda
601 Float_t pmod = iHit->GetParticle()->P(); // total momentum at the
605 if(partcode == 11 && pmod < 6) dray = 1; // delta ray is e-
608 // Get hit z and x(r*phi) cordinates for each module (detector)
611 Float_t zPix = kconv*iHit->GetZL();
612 Float_t xPix = kconv*iHit->GetXL();
613 Float_t yPix = kconv*iHit->GetYL();
616 Int_t status = iHit->GetTrackStatus();
619 if(zPix > spdLength/2) {
621 cout<<"!!! SPD: z outside ="<<zPix<<endl;
623 zPix = spdLength/2 - 10;
625 if(zPix < 0 && zPix < -spdLength/2) {
627 cout<<"!!! SPD: z outside ="<<zPix<<endl;
629 zPix = -spdLength/2 + 10;
631 if(xPix > spdWidth/2) {
633 cout<<"!!! SPD: x outside ="<<xPix<<endl;
635 xPix = spdWidth/2 - 10;
637 if(xPix < 0 && xPix < -spdWidth/2) {
639 cout<<"!!! SPD: x outside ="<<xPix<<endl;
641 xPix = -spdWidth/2 + 10;
645 // enter Si or after event in Si
650 } // end if status == 66
652 Float_t depEnergy = iHit->GetIonization();
653 // skip if the input point to Si
655 if(depEnergy <= 0.) continue;
657 // if track returns to the opposite direction:
660 } // end if yPix < yPrev
662 // take into account the holes diffusion inside the Silicon
663 // the straight line between the entrance and exit points in Si is
664 // divided into the several steps; the diffusion is considered
665 // for each end point of step and charge
666 // is distributed between the pixels through the diffusion.
668 // ---------- the diffusion in Z (beam) direction -------
669 Float_t charge = depEnergy*kEnToEl; // charge in e-
672 Float_t sigmaDif = 0.;
673 Float_t zdif = zPix - zPix0;
674 Float_t xdif = xPix - xPix0;
675 Float_t ydif = TMath::Abs(yPix - yPrev);
676 Float_t ydif0 = TMath::Abs(yPrev - yPix0);
678 if(ydif < 1) continue; // ydif is not zero
680 Float_t projDif = sqrt(xdif*xdif + zdif*zdif);
682 Int_t ndZ = (Int_t)TMath::Abs(zdif/zPitch) + 1;
683 Int_t ndX = (Int_t)TMath::Abs(xdif/xPitch) + 1;
685 // number of the steps along the track:
687 if(ndX > ndZ) nsteps = ndX;
688 if(nsteps < 20) nsteps = 20; // minimum number of the steps
691 drPath = (yPix-yPix0)*1.e-4;
692 drPath = TMath::Abs(drPath); // drift path in cm
693 sigmaDif = difCoef*sqrt(drPath); // sigma diffusion in cm
694 sigmaDif = sigmaDif*kconv; // sigma diffusion in microns
696 } // end if projDif < 5
698 if(projDif > 5) tang = ydif/projDif;
699 Float_t dCharge = charge/nsteps; // charge in e- for one step
700 Float_t dZ = zdif/nsteps;
701 Float_t dX = xdif/nsteps;
703 for (iZi = 1; iZi <= nsteps;iZi++) {
704 Float_t dZn = iZi*dZ;
705 Float_t dXn = iZi*dX;
706 Float_t zPixn = zPix0 + dZn;
707 Float_t xPixn = xPix0 + dXn;
710 Float_t dProjn = sqrt(dZn*dZn+dXn*dXn);
711 drPath = dProjn*tang*1.e-4; // drift path for iZi+1 step in cm
713 drPath = TMath::Abs(drPath) + ydif0*1.e-4;
716 drPath = ydif0*1.e-4 - TMath::Abs(drPath);
717 drPath = TMath::Abs(drPath);
718 } // end if trdown == 1
719 sigmaDif = difCoef*sqrt(drPath);
720 sigmaDif = sigmaDif*kconv; // sigma diffusion in microns
721 } // end if projdif >= 5
723 zPixn = (zPixn + spdLength/2.);
724 xPixn = (xPixn + spdWidth/2.);
726 GetSeg()->GetPadIxz(xPixn,zPixn,nXpix,nZpix);
727 zPitch = GetSeg()->Dpz(nZpix);
728 GetSeg()->GetPadTxz(xPixn,zPixn);
729 // set the window for the integration
732 if(nZpix == 1) jzmin =2;
733 if(nZpix == fNPixelsZ) jzmax = 2;
737 if(nXpix == 1) jxmin =2;
738 if(nXpix == fNPixelsX) jxmax = 2;
740 Float_t zpix = nZpix;
741 Float_t dZright = zPitch*(zpix - zPixn);
742 Float_t dZleft = zPitch - dZright;
744 Float_t xpix = nXpix;
745 Float_t dXright = xPitch*(xpix - xPixn);
746 Float_t dXleft = xPitch - dXright;
753 for(jz=jzmin; jz <=jzmax; jz++) {
755 dZprev = -zPitch - dZleft;
762 dZnext = dZright + zPitch;
764 // kz changes from 1 to the fNofPixels(270)
765 Int_t kz = nZpix + jz -2;
767 Float_t zArg1 = dZprev/sigmaDif;
768 Float_t zArg2 = dZnext/sigmaDif;
769 Float_t zProb1 = TMath::Erfc(zArg1);
770 Float_t zProb2 = TMath::Erfc(zArg2);
771 Float_t dZCharge =0.5*(zProb1-zProb2)*dCharge;
774 // ----------- holes diffusion in X(r*phi) direction --------
777 for(jx=jxmin; jx <=jxmax; jx++) {
779 dXprev = -xPitch - dXleft;
786 dXnext = dXright + xPitch;
788 Int_t kx = nXpix + jx -2;
789 Float_t xArg1 = dXprev/sigmaDif;
790 Float_t xArg2 = dXnext/sigmaDif;
791 Float_t xProb1 = TMath::Erfc(xArg1);
792 Float_t xProb2 = TMath::Erfc(xArg2);
793 Float_t dXCharge =0.5*(xProb1-xProb2)*dZCharge;
797 indexRange[0]=indexRange[1]=kz-1;
798 indexRange[2]=indexRange[3]=kx-1;
801 indexRange[0]=TMath::Min(indexRange[0],kz-1);
802 indexRange[1]=TMath::Max(indexRange[1],kz-1);
803 indexRange[2]=TMath::Min(indexRange[2],kx-1);
804 indexRange[3]=TMath::Max(indexRange[3],kx-1);
806 // build the list of digits for this module
807 Double_t signal = fMapA2->GetSignal(kz-1,kx-1);
809 fMapA2->SetHit(kz-1,kx-1,(double)signal);
811 // The calling sequence for UpdateMapSignal was
812 // moved into the (dx > 1 e-) loop because it
813 // needs to call signal which is defined inside
815 fModule = module;//Defined because functions
816 // called by UpdateMapSignal
817 // expect module to be an
819 UpdateMapSignal(kz-1,kx-1,
820 // mod->GetHitTrackIndex(hit),
821 ((AliITShit*)(mod->GetHit(hit)))->GetTrack(),
822 hit,fModule,dXCharge,pList);
828 if (status == 65) { // the step is inside of Si
831 } // end if status == 65
833 } // hit loop inside the module
835 //______________________________________________________________________
836 void AliITSsimulationSPDdubna::ChargeToSignal(AliITSpList *pList){
837 // add noise and electronics, perform the zero suppression and add the
839 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
840 Float_t threshold = (float)GetResp()->MinVal();
842 // Int_t digits[3], tracks[3], hits[3];
843 // Float_t charges[3];
847 const Int_t nmaxtrk=AliITSdigitSPD::GetNTracks();
848 static AliITSdigitSPD dig;
850 for(Int_t iz=0; iz<fNPixelsZ; iz++){
851 for(Int_t ix=0; ix<fNPixelsX; ix++){
852 electronics = fBaseline + fNoise*gRandom->Gaus();
853 sig = pList->GetSignalOnly(iz+1,ix+1);
854 UpdateMapNoise(iz,ix,fModule,sig,electronics,pList);
856 // cout << sig << "+" << electronics <<">threshold=" << threshold
859 if (sig+electronics > threshold) {
863 dig.fSignalSPD = (Int_t) pList->GetSignal(iz+1,ix+1);
868 for(j=0;j<nmaxtrk;j++){
870 if (j<pList->GetNEnteries()) {
871 dig.fTracks[j] = pList->GetTrack(iz+1,ix+1,j);
872 dig.fHits[j] = pList->GetHit(iz+1,ix+1,j);
874 tracks[j] = pList->GetTrack(iz+1,ix+1,j);
875 hits[j] = pList->GetHit(iz+1,ix+1,j);
877 }else { // Default values
880 /* tracks[j] = -2; //noise
884 // charges[0] = (Float_t) pList->GetSumSignal(iz+1,ix+1);
886 if(tracks[0] == tracks[1] && tracks[0] == tracks[2]) {
891 } else if(tracks[0] == tracks[1] && tracks[0] != tracks[2]) {
894 } else if(tracks[0] == tracks[2] && tracks[0] != tracks[1]) {
897 } else if(tracks[1] == tracks[2] && tracks[0] != tracks[1]) {
904 cout << iz << "," << ix << "," <<
905 *(pList->GetpListItem(iz+1,ix+1)) << endl;
907 // aliITS->AddSimDigit(0, phys, digits, tracks, hits, charges);
908 aliITS->AddSimDigit(0,&dig);
913 //______________________________________________________________________
914 void AliITSsimulationSPDdubna::CreateHistograms(){
915 // create 1D histograms for tests
917 printf("SPD - create histograms\n");
919 fHis=new TObjArray(fNPixelsZ);
920 TString spdName("spd_");
921 for (Int_t i=0;i<fNPixelsZ;i++) {
923 sprintf(pixelz,"%d",i+1);
924 spdName.Append(pixelz);
925 //PH (*fHis)[i] = new TH1F(spdName.Data(),"SPD maps",
926 //PH fNPixelsX,0.,(Float_t) fNPixelsX);
927 fHis->AddAt(new TH1F(spdName.Data(),"SPD maps",
928 fNPixelsX,0.,(Float_t) fNPixelsX), i);
931 //______________________________________________________________________
932 void AliITSsimulationSPDdubna::ResetHistograms(){
934 // Reset histograms for this detector
937 for ( int i=0;i<fNPixelsZ;i++ ) {
938 //PH if ((*fHis)[i]) ((TH1F*)(*fHis)[i])->Reset();
939 if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset();