+//______________________________________________________________________
+void AliITSsimulationSSD::ApplyCoupling(AliITSpList *pList,Int_t module) {
+ // Apply the effect of electronic coupling between channels
+ Int_t ix;
+ Double_t signalLeft=0, signalRight=0,signal=0;
+
+ for(ix=0;ix<GetNStrips();ix++){
+ // P side coupling
+ if(ix>0.)signalLeft = fMapA2->GetSignal(0,ix-1)*fDCS->GetCouplingPL();
+ else signalLeft = 0.0;
+ if(ix<(GetNStrips()-1)) signalRight = fMapA2->GetSignal(0,ix+1)*
+ fDCS->GetCouplingPR();
+ else signalRight = 0.0;
+ signal = signalLeft + signalRight;
+ fMapA2->AddSignal(0,ix,signal);
+ if(signal>0.0) pList->AddNoise(0,ix,module,signal);
+
+ signalLeft = signalRight = signal = 0.0;
+ // N side coupling
+ if(ix>0.) signalLeft = fMapA2->GetSignal(1,ix-1)*fDCS->GetCouplingNL();
+ else signalLeft = 0.0;
+ if(ix<(GetNStrips()-1)) signalRight = fMapA2->GetSignal(1,ix+1)*
+ fDCS->GetCouplingNR();
+ else signalRight = 0.0;
+ signal = signalLeft + signalRight;
+ fMapA2->AddSignal(1,ix,signal);
+ if(signal>0.0) pList->AddNoise(1,ix,module,signal);
+ } // loop over strips
+}
+//______________________________________________________________________
+Float_t AliITSsimulationSSD::F(Float_t av, Float_t x, Float_t s) {
+ // Computes the integral of a gaussian using Error Function
+ Float_t sqrt2 = TMath::Sqrt(2.0);
+ Float_t sigm2 = sqrt2*s;
+ Float_t integral;
+
+ integral = 0.5 * TMath::Erf( (x - av) / sigm2);
+ return integral;
+}
+//______________________________________________________________________
+void AliITSsimulationSSD::IntegrateGaussian(Int_t k,Double_t par, Double_t w,
+ Double_t sigma,
+ Double_t inf, Double_t sup,
+ AliITSTableSSD *tav) {
+ // integrate the diffusion gaussian
+ // remind: inf and sup are w-3sigma and w+3sigma
+ // we could define them here instead of passing them
+ // this way we are free to introduce asimmetry
+
+ Double_t a=0.0, b=0.0;
+ Double_t dXCharge1 = 0.0, dXCharge2 = 0.0;
+ // dXCharge1 and 2 are the charge to two neighbouring strips
+ // Watch that we only involve at least two strips
+ // Numbers greater than 2 of strips in a cluster depend on
+ // geometry of the track and delta rays, not charge diffusion!
+
+ Double_t strip = TMath::Floor(w); // closest strip on the left
+
+ if ( TMath::Abs((strip - w)) < 0.5) {
+ // gaussian mean is closer to strip on the left
+ a = inf; // integration starting point
+ if((strip+0.5)<=sup) {
+ // this means that the tail of the gaussian goes beyond
+ // the middle point between strips ---> part of the signal
+ // is given to the strip on the right
+ b = strip + 0.5; // integration stopping point
+ dXCharge1 = F( w, b, sigma) - F(w, a, sigma);
+ dXCharge2 = F( w, sup, sigma) - F(w ,b, sigma);
+ }else {
+ // this means that all the charge is given to the strip on the left
+ b = sup;
+ dXCharge1 = 0.9973; // gaussian integral at 3 sigmas
+ dXCharge2 = 0.0;
+ } // end if
+ dXCharge1 = par * dXCharge1;// normalize by mean of number of carriers
+ dXCharge2 = par * dXCharge2;
+
+ // for the time being, signal is the charge
+ // in ChargeToSignal signal is converted in ADC channel
+ fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
+ tav->Add(k,(Int_t)strip);
+ if(((Int_t) strip) < (GetNStrips()-1)) {
+ // strip doesn't have to be the last (remind: last=GetNStrips()-1)
+ // otherwise part of the charge is lost
+ fMapA2->AddSignal(k,((Int_t)strip+1),dXCharge2);
+ tav->Add(k,((Int_t)(strip+1)));
+ } // end if
+ }else{
+ // gaussian mean is closer to strip on the right
+ strip++; // move to strip on the rigth
+ b = sup; // now you know where to stop integrating
+ if((strip-0.5)>=inf) {
+ // tail of diffusion gaussian on the left goes left of
+ // middle point between strips
+ a = strip - 0.5; // integration starting point
+ dXCharge1 = F(w, b, sigma) - F(w, a, sigma);
+ dXCharge2 = F(w, a, sigma) - F(w, inf, sigma);
+ }else {
+ a = inf;
+ dXCharge1 = 0.9973; // gaussian integral at 3 sigmas
+ dXCharge2 = 0.0;
+ } // end if
+ dXCharge1 = par * dXCharge1; // normalize by means of carriers
+ dXCharge2 = par * dXCharge2;
+ // for the time being, signal is the charge
+ // in ChargeToSignal signal is converted in ADC channel
+ fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
+ tav->Add(k,(Int_t)strip);
+ if(((Int_t) strip) > 0) {
+ // strip doesn't have to be the first
+ // otherwise part of the charge is lost
+ fMapA2->AddSignal(k,((Int_t)strip-1),dXCharge2);
+ tav->Add(k,((Int_t)(strip-1)));
+ } // end if
+ } // end if