+ // none.
+ const Double_t kmictocm = 1.0e-4; // convert microns to cm.
+ TObjArray *hits = mod->GetHits();
+ Int_t nhits = hits->GetEntriesFast();
+ Int_t h,ix,iz,i;
+ Int_t idtrack;
+ Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
+ Double_t x,y,z,t,tp,st,dt=0.2,el,sig,sigx,sigz,fda;
+ AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+ AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
+ Double_t thick = 0.5*kmictocm*seg->Dy(); // Half Thickness
+ res->GetSigmaDiffusionAsymmetry(fda);
+
+ AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
+ if(nhits<=0) return;
+ for(h=0;h<nhits;h++){
+ if(AliDebugLevel()>0) {
+ AliDebug(1,Form("Hits, %d", h));
+ cout << *(mod->GetHit(h)) << endl;
+ } // end if GetDebug
+ if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
+ st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
+ if(st>0.0){
+ st = (Double_t)((Int_t)(st/kmictocm)); // number of microns
+ if(st<=1.0) st = 1.0;
+ dt = 1.0/st;
+ for(t=0.0;t<1.0;t+=dt){ // Integrate over t
+ tp = t+0.5*dt;
+ x = x0+x1*tp;
+ y = y0+y1*tp;
+ z = z0+z1*tp;
+ if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
+ el = res->GeVToCharge((Double_t)(dt*de));
+ if(GetDebug(1)){
+ if(el<=0.0) cout<<"el="<<el<<" dt="<<dt
+ <<" de="<<de<<endl;
+ } // end if GetDebug
+ sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
+ // SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
+ sigx=sig;
+ sigz=sig*fda;
+ SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
+ cout << "sigx, sigz, y "<< sigx << " " << sigz<< " " << TMath::Abs(thick + y) << endl;// ciccio
+ } // end for t
+ } else { // st == 0.0 deposit it at this point
+ x = x0;
+ y = y0;
+ z = z0;
+ if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
+ el = res->GeVToCharge((Double_t)de);
+ sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
+ // SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
+ sigx=sig;
+ sigz=sig*fda;
+ SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
+ } // end if st>0.0
+ // Coupling
+ switch (fCoupling) {
+ default:
+ break;
+ case 1: //case 3:
+ for(i=0;i<GetMap()->GetEntries();i++)
+ if(GetMap()->GetpListItem(i)==0) continue;
+ else{
+ GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
+ SetCoupling(iz,ix,idtrack,h);
+ } // end for i
+ break;
+ case 2: // case 4:
+ for(i=0;i<GetMap()->GetEntries();i++)
+ if(GetMap()->GetpListItem(i)==0) continue;
+ else{
+ GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
+ SetCouplingOld(iz,ix,idtrack,h);
+ } // end for i
+ break;
+ } // end switch
+ } // Loop over all hits h
+ if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::HitToSDigitFast(AliITSmodule *mod){
+ // Does the charge distributions using Gaussian diffusion charge charing. // Inputs:
+ // AliITSmodule *mod Pointer to this module
+ // Output:
+ // none.
+ // Return:
+ // none.
+ const Double_t kmictocm = 1.0e-4; // convert microns to cm.
+ const Int_t kn10=10;
+ const Double_t kti[kn10]={7.443716945e-3,2.166976971e-1,3.397047841e-1,
+ 4.325316833e-1,4.869532643e-1,5.130467358e-1,
+ 5.674683167e-1,6.602952159e-1,7.833023029e-1,
+ 9.255628306e-1};
+ const Double_t kwi[kn10]={1.477621124e-1,1.346333597e-1,1.095431813e-1,
+ 7.472567455e-2,3.333567215e-2,3.333567215e-2,
+ 7.472567455e-2,1.095431813e-1,1.346333597e-1,
+ 1.477621124e-1};
+ TObjArray *hits = mod->GetHits();
+ Int_t nhits = hits->GetEntriesFast();
+ Int_t h,ix,iz,i;
+ Int_t idtrack;
+ Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
+ Double_t x,y,z,t,st,el,sig,sigx,sigz,fda;
+ AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+ AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD());
+ Double_t thick = 0.5*kmictocm*seg->Dy(); // Half thickness
+ res->GetSigmaDiffusionAsymmetry(fda);
+// cout << "Half Thickness " << thick << endl; // dom
+// cout << "Diffusion asymm " << fda << endl; // dom
+
+ AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
+ if(nhits<=0) return;
+ for(h=0;h<nhits;h++){
+ if(AliDebugLevel()>0) {
+ AliDebug(1,Form("Hits, %d", h));
+ cout << *(mod->GetHit(h)) << endl;
+ } // end if GetDebug
+ if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
+ st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
+ if(st>0.0) for(i=0;i<kn10;i++){ // Integrate over t
+ t = kti[i];
+ x = x0+x1*t;
+ y = y0+y1*t;
+ z = z0+z1*t;
+ if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
+ // el = res->GeVToCharge((Double_t)(dt*de));
+ // el = 1./kn10*res->GeVToCharge((Double_t)de);
+ el = kwi[i]*res->GeVToCharge((Double_t)de);
+ if(GetDebug(1)){
+ if(el<=0.0) cout<<"el="<<el<<" kwi["<<i<<"]="<<kwi[i]
+ <<" de="<<de<<endl;
+ } // end if GetDebug
+ sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
+ sigx=sig;
+ sigz=sig*fda;
+ //SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
+ SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
+ // cout << "sigx sigz " << sigx << " " << sigz << endl; // dom
+ } // end for i // End Integrate over t
+ else { // st == 0.0 deposit it at this point
+ x = x0;
+ y = y0;
+ z = z0;
+ if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
+ el = res->GeVToCharge((Double_t)de);
+ sig = res->SigmaDiffusion1D(TMath::Abs(thick + y));
+ //SpreadCharge(x,z,ix,iz,el,sig,idtrack,h);
+ sigx=sig;
+ sigz=sig*fda;
+ SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,idtrack,h);
+ } // end if st>0.0
+ // Coupling
+ switch (fCoupling) {
+ default:
+ break;
+ case 1: // case 3:
+ for(i=0;i<GetMap()->GetEntries();i++)
+ if(GetMap()->GetpListItem(i)==0) continue;
+ else{
+ GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
+ SetCoupling(iz,ix,idtrack,h);
+ } // end for i
+ break;
+ case 2: // case 4:
+ for(i=0;i<GetMap()->GetEntries();i++)
+ if(GetMap()->GetpListItem(i)==0) continue;
+ else{
+ GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
+ SetCouplingOld(iz,ix,idtrack,h);
+ } // end for i
+ break;
+ } // end switch
+ } // Loop over all hits h
+ if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);