]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSsimulationSSD.cxx
One instance of AliITSresponse per sensor - AliITSresponse objects read/stored from...
[u/mrichter/AliRoot.git] / ITS / AliITSsimulationSSD.cxx
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 /* $Id$ */
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <Riostream.h>
21 #include <TObjArray.h>
22 #include "AliITSmodule.h"
23 #include "AliITSMapA2.h"
24 #include "AliITSpList.h"
25 #include "AliITSresponseSSD.h"
26 #include "AliITSsegmentationSSD.h"
27 #include "AliITSdcsSSD.h"
28 #include "AliITS.h"
29 #include "AliITShit.h"
30 #include "AliITSdigitSSD.h"
31 #include "AliRun.h"
32 #include "AliITSgeom.h"
33 #include "AliITSsimulationSSD.h"
34 #include "AliITSTableSSD.h"
35
36 ClassImp(AliITSsimulationSSD)
37 ////////////////////////////////////////////////////////////////////////
38 // Version: 0                                                         //
39 // Written by Enrico Fragiacomo                                       //
40 // July 2000                                                          // 
41 //                                                                    //
42 // AliITSsimulationSSD is the simulation of SSDs.                     //
43 ////////////////////////////////////////////////////////////////////////
44
45 //----------------------------------------------------------------------
46 AliITSsimulationSSD::AliITSsimulationSSD():AliITSsimulation(),
47 fDCS(0),
48 fMapA2(0),
49 fIonE(0.0),
50 fDifConst(),
51 fDriftVel(){
52     //default Constructor
53     //Inputs:
54     // none.
55     // Outputs:
56     // none.
57     // Return:
58     //  A default construction AliITSsimulationSSD class
59 }
60 //----------------------------------------------------------------------
61 AliITSsimulationSSD::AliITSsimulationSSD(AliITSDetTypeSim* dettyp):
62 AliITSsimulation(dettyp),
63 fDCS(0),
64 fMapA2(0),
65 fIonE(0.0),
66 fDifConst(),
67 fDriftVel(){
68     // Constructor 
69     // Input:
70     //   AliITSsegmentationSSD *seg  Pointer to the SSD segmentation to be used
71     //   AliITSresponseSSD   *resp Pointer to the SSD responce class to be used
72     // Outputs:
73     //   none.
74     // Return
75     //   A standard constructed AliITSsimulationSSD class
76
77     Init();
78 }
79 //----------------------------------------------------------------------
80 void AliITSsimulationSSD::Init(){
81     // Inilizer, Inilizes all of the variable as needed in a standard place.
82     // Input:
83     //   AliITSsegmentationSSD *seg  Pointer to the SSD segmentation to be used
84     //   AliITSresponseSSD   *resp Pointer to the SSD responce class to be used
85     // Outputs:
86     //   none.
87     // Return
88     //   none.
89   AliITSresponseSSD* res =(AliITSresponseSSD*)GetResponseModel(fDetType->GetITSgeom()->GetStartSSD());
90   AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
91     Double_t noise[2] = {0.,0.};
92     res->GetNoiseParam(noise[0],noise[1]); // retrieves noise parameters
93     fDCS = new AliITSdcsSSD(seg,res); 
94
95     SetDriftVelocity(); // use default values in .h file
96     SetIonizeE();       // use default values in .h file
97     SetDiffConst();     // use default values in .h file
98     fpList           = new AliITSpList(2,GetNStrips());
99     fMapA2           = new AliITSMapA2(seg);
100 }
101 //______________________________________________________________________
102 AliITSsimulationSSD& AliITSsimulationSSD::operator=(
103                                          const AliITSsimulationSSD &s){
104   // Operator =
105
106   if(this==&s) return *this;
107
108   this->fDCS         = new AliITSdcsSSD(*(s.fDCS));
109   this->fMapA2       = s.fMapA2;
110   this->fIonE        = s.fIonE;
111   this->fDifConst[0] = s.fDifConst[0];
112   this->fDifConst[1] = s.fDifConst[1];
113   this->fDriftVel[0] = s.fDriftVel[0];
114   this->fDriftVel[1] = s.fDriftVel[1];
115   return *this;
116 }
117 //______________________________________________________________________
118 AliITSsimulation& AliITSsimulationSSD::operator=(
119                                          const AliITSsimulation &s){
120   // Operator =
121
122   if(this==&s) return *this;
123   Error("AliITSsimulationSSD","Not allowed to make a = with "
124         "AliITSsimulationSSD Using default creater instead");
125   
126   return *this;
127 }
128 //______________________________________________________________________
129 AliITSsimulationSSD::AliITSsimulationSSD(const AliITSsimulationSSD &source):
130     AliITSsimulation(source){
131   // copy constructor
132
133   *this = source;
134 }
135 //______________________________________________________________________
136 AliITSsimulationSSD::~AliITSsimulationSSD() {
137   // destructor
138   delete fMapA2;
139   delete fDCS;
140 }
141 //______________________________________________________________________
142 void AliITSsimulationSSD::InitSimulationModule(Int_t module,Int_t event){
143     // Creates maps to build the list of tracks for each sumable digit
144     // Inputs:
145     //   Int_t module    // Module number to be simulated
146     //   Int_t event     // Event number to be simulated
147     // Outputs:
148     //   none.
149     // Return
150     //    none.
151
152     SetModuleNumber(module);
153     SetEventNumber(event);
154     fMapA2->ClearMap();
155     fpList->ClearMap();
156 }
157 //______________________________________________________________________
158 void AliITSsimulationSSD::FinishSDigitiseModule(){
159     // Does the Sdigits to Digits work
160     // Inputs:
161     //   none.
162     // Outputs:
163     //   none.
164     // Return:
165     //   none.
166
167     FillMapFrompList(fpList);  // need to check if needed here or not????
168     SDigitToDigit(fModule,fpList);
169     fpList->ClearMap();
170     fMapA2->ClearMap();
171 }
172 //______________________________________________________________________
173 void AliITSsimulationSSD::DigitiseModule(AliITSmodule *mod,Int_t,Int_t) {
174   // Digitizes hits for one SSD module
175   SetModuleNumber(mod->GetIndex());
176
177   HitsToAnalogDigits(mod,fpList);
178   SDigitToDigit(GetModuleNumber(),fpList);
179
180   fpList->ClearMap();
181   fMapA2->ClearMap();
182 }
183 //______________________________________________________________________
184 void AliITSsimulationSSD::SDigitiseModule(AliITSmodule *mod,Int_t,Int_t) {
185   // Produces Summable/Analog digits and writes them to the SDigit tree. 
186
187     HitsToAnalogDigits(mod,fpList);
188
189     WriteSDigits(fpList);
190
191     fpList->ClearMap();
192     fMapA2->ClearMap();
193 }
194 //______________________________________________________________________
195 void AliITSsimulationSSD::SDigitToDigit(Int_t module,AliITSpList *pList){
196   // Takes the pList and finishes the digitization.
197
198   ApplyNoise(pList,module);
199   ApplyCoupling(pList,module);
200
201   ChargeToSignal(module,pList);
202 }
203 //______________________________________________________________________
204 void AliITSsimulationSSD::HitsToAnalogDigits(AliITSmodule *mod,
205                                              AliITSpList *pList){
206     // Loops over all hits to produce Analog/floating point digits. This
207     // is also the first task in producing standard digits.
208     Int_t lasttrack     = -2;
209     Int_t idtrack       = -2;
210     Double_t x0=0.0, y0=0.0, z0=0.0;
211     Double_t x1=0.0, y1=0.0, z1=0.0;
212     Double_t de=0.0;
213     Int_t module = mod->GetIndex();
214
215     AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
216
217     TObjArray *hits = mod->GetHits();
218     Int_t nhits     = hits->GetEntriesFast();
219     if (nhits<=0) return;
220     AliITSTableSSD * tav = new AliITSTableSSD(GetNStrips());
221     module = mod->GetIndex();
222     if ( mod->GetLayer() == 6 ) seg->SetLayer(6);
223     if ( mod->GetLayer() == 5 ) seg->SetLayer(5);
224     for(Int_t i=0; i<nhits; i++) {    
225         // LineSegmentL returns 0 if the hit is entering
226         // If hits is exiting returns positions of entering and exiting hits
227         // Returns also energy loss
228         if(GetDebug(4)){
229             cout << i << " ";
230             cout << mod->GetHit(i)->GetXL() << " "<<mod->GetHit(i)->GetYL();
231             cout << " " << mod->GetHit(i)->GetZL();
232             cout << endl;
233         } // end if
234         if (mod->LineSegmentL(i, x0, x1, y0, y1, z0, z1, de, idtrack)) {
235             HitToDigit(module, x0, y0, z0, x1, y1, z1, de,tav);
236             if (lasttrack != idtrack || i==(nhits-1)) {
237                 GetList(idtrack,i,module,pList,tav);
238             } // end if
239             lasttrack=idtrack;
240         } // end if
241     }  // end loop over hits
242     delete tav; tav=0;
243     return;
244 }
245 //----------------------------------------------------------------------
246 void AliITSsimulationSSD::HitToDigit(Int_t module, Double_t x0, Double_t y0, 
247                                      Double_t z0, Double_t x1, Double_t y1, 
248                                      Double_t z1, Double_t de,
249                                      AliITSTableSSD *tav) {
250
251   // hit to digit conversion
252
253   AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
254     // Turns hits in SSD module into one or more digits.
255     Float_t tang[2] = {0.0,0.0};
256     seg->Angles(tang[0], tang[1]);//stereo<<->tan(stereo)~=stereo
257     Double_t x, y, z;
258     Double_t dex=0.0, dey=0.0, dez=0.0; 
259     Double_t pairs; // pair generation energy per step.
260     Double_t sigma[2] = {0.,0.};// standard deviation of the diffusion gaussian
261     Double_t tdrift[2] = {0.,0.}; // time of drift
262     Double_t w;
263     Double_t inf[2], sup[2], par0[2];                 
264
265     // Steps in the module are determined "manually" (i.e. No Geant)
266     // NumOfSteps divide path between entering and exiting hits in steps 
267     Int_t numOfSteps = NumOfSteps(x1, y1, z1, dex, dey, dez);
268     // Enery loss is equally distributed among steps
269     de    = de/numOfSteps;
270     pairs = de/GetIonizeE(); // e-h pairs generated
271     for(Int_t j=0; j<numOfSteps; j++) {     // stepping
272         x = x0 + (j+0.5)*dex;
273         y = y0 + (j+0.5)*dey;
274         if ( y > (seg->Dy()/2+10)*1.0E-4 ) {
275             // check if particle is within the detector
276             Warning("HitToDigit",
277                     "hit out of detector y0=%e,y=%e,dey=%e,j =%e module=%d",
278                     y0,y,dey,j,module);
279             return;
280         } // end if
281         z = z0 + (j+0.5)*dez;
282         if(GetDebug(4)) cout <<"HitToDigit "<<x<<" "<<y<<" "<<z<< " "
283                             <<dex<<" "<<dey<<" "<<dez<<endl;
284         // calculate drift time
285         // y is the minimum path
286         tdrift[0] = (y+(seg->Dy()*1.0E-4)/2)/GetDriftVelocity(0);
287         tdrift[1] = ((seg->Dy()*1.0E-4)/2-y)/GetDriftVelocity(1);
288
289         for(Int_t k=0; k<2; k++) {   // both sides    remember: 0=Pside 1=Nside
290
291             tang[k]=TMath::Tan(tang[k]);
292
293             // w is the coord. perpendicular to the strips
294             /*
295               if(k==0) {
296               w = (x+(GetSegmentation()->Dx()*1.0E-4)/2) -
297                     (z+(GetSegmentation()->Dz()*1.0E-4)/2)*tang[k]; 
298               }else{
299               w = (x+(GetSegmentation()->Dx()*1.0E-4)/2) + 
300                     (z-(GetSegmentation()->Dz()*1.0E-4)/2)*tang[k];
301               } // end if
302               w /= (GetStripPitch()*1.0E-4); //w is converted in units of pitch
303             */
304             { // replacement block for the above.
305                 Float_t xp=x*1.e+4,zp=z*1.e+4; // microns
306                 seg->GetPadTxz(xp,zp);
307                 if(k==0) w = xp; // P side strip number
308                 else w = zp; // N side strip number
309             } // end test block
310
311             if((w<(-0.5)) || (w>(GetNStrips()-0.5))) {
312                 // this check rejects hits in regions not covered by strips
313                 // 0.5 takes into account boundaries 
314                 if(GetDebug(4)) cout << "x,z="<<x<<","<<z<<" w="<<w
315                                     <<" Nstrips="<<GetNStrips()<<endl;
316                 return; // There are dead region on the SSD sensitive volume.
317             } // end if
318
319             // sigma is the standard deviation of the diffusion gaussian
320             if(tdrift[k]<0) return;
321             sigma[k] = TMath::Sqrt(2*GetDiffConst(k)*tdrift[k]);
322             sigma[k] /= (GetStripPitch()*1.0E-4);  //units of Pitch
323             if(sigma[k]==0.0) {         
324                 Error("HitToDigit"," sigma[%d]=0",k);
325                 exit(0);
326             } // end if
327
328             par0[k] = pairs;
329             // we integrate the diffusion gaussian from -3sigma to 3sigma 
330             inf[k] = w - 3*sigma[k]; // 3 sigma from the gaussian average  
331             sup[k] = w + 3*sigma[k]; // 3 sigma from the gaussian average
332             // IntegrateGaussian does the actual
333             // integration of diffusion gaussian
334             IntegrateGaussian(k, par0[k], w, sigma[k], inf[k], sup[k],tav);
335         }  // end for loop over side (0=Pside, 1=Nside)      
336     } // end stepping
337 }
338 //______________________________________________________________________
339 void AliITSsimulationSSD::ApplyNoise(AliITSpList *pList,Int_t module){
340     // Apply Noise.
341     Int_t    k,ix;
342     Double_t signal,noise;
343     Double_t noiseP[2] = {0.,0.};
344     Double_t a,b;
345     AliITSresponseSSD* res =(AliITSresponseSSD*)GetResponseModel(module);
346     res->GetNoiseParam(a,b); // retrieves noise parameters
347     noiseP[0] = a; noiseP[1] = b;
348     for(k=0;k<2;k++){                    // both sides (0=Pside, 1=Nside)
349         for(ix=0;ix<GetNStrips();ix++){      // loop over strips
350             noise  = gRandom->Gaus(0,noiseP[k]);// get noise to signal
351             signal = noise + fMapA2->GetSignal(k,ix);//get signal from map
352             if(signal<0.) signal=0.0;           // in case noise is negative...
353             fMapA2->SetHit(k,ix,signal); // give back signal to map
354             if(signal>0.0) pList->AddNoise(k,ix,module,noise);
355         } // loop over strip 
356     } // loop over k (P or N side)
357 }
358 //______________________________________________________________________
359 void AliITSsimulationSSD::ApplyCoupling(AliITSpList *pList,Int_t module) {
360     // Apply the effect of electronic coupling between channels
361     Int_t ix;
362     Double_t signalLeft=0, signalRight=0,signal=0;
363
364     for(ix=0;ix<GetNStrips();ix++){
365         // P side coupling
366         if(ix>0.)signalLeft = fMapA2->GetSignal(0,ix-1)*fDCS->GetCouplingPL();
367         else signalLeft = 0.0;
368         if(ix<(GetNStrips()-1)) signalRight = fMapA2->GetSignal(0,ix+1)*
369                                     fDCS->GetCouplingPR();
370         else signalRight = 0.0;
371         signal = signalLeft + signalRight;
372         fMapA2->AddSignal(0,ix,signal);
373         if(signal>0.0) pList->AddNoise(0,ix,module,signal);
374
375         signalLeft = signalRight = signal = 0.0;
376         // N side coupling
377         if(ix>0.) signalLeft = fMapA2->GetSignal(1,ix-1)*fDCS->GetCouplingNL();
378         else signalLeft = 0.0;
379         if(ix<(GetNStrips()-1)) signalRight = fMapA2->GetSignal(1,ix+1)*
380                                     fDCS->GetCouplingNR();
381         else signalRight = 0.0;
382         signal = signalLeft + signalRight;
383         fMapA2->AddSignal(1,ix,signal);
384         if(signal>0.0) pList->AddNoise(1,ix,module,signal);
385     } // loop over strips 
386 }
387 //______________________________________________________________________
388 Float_t AliITSsimulationSSD::F(Float_t av, Float_t x, Float_t s) {
389     // Computes the integral of a gaussian using Error Function
390     Float_t sqrt2 = TMath::Sqrt(2.0);
391     Float_t sigm2 = sqrt2*s;
392     Float_t integral;
393
394     integral = 0.5 * TMath::Erf( (x - av) / sigm2);
395     return integral;
396 }
397 //______________________________________________________________________
398 void AliITSsimulationSSD::IntegrateGaussian(Int_t k,Double_t par, Double_t w,
399                                             Double_t sigma, 
400                                             Double_t inf, Double_t sup,
401                                             AliITSTableSSD *tav) {
402     // integrate the diffusion gaussian
403     // remind: inf and sup are w-3sigma and w+3sigma
404     //         we could define them here instead of passing them
405     //         this way we are free to introduce asimmetry
406
407     Double_t a=0.0, b=0.0;
408     Double_t dXCharge1 = 0.0, dXCharge2 = 0.0;
409     // dXCharge1 and 2 are the charge to two neighbouring strips
410     // Watch that we only involve at least two strips
411     // Numbers greater than 2 of strips in a cluster depend on
412     //  geometry of the track and delta rays, not charge diffusion!   
413
414     Double_t strip = TMath::Floor(w);         // closest strip on the left
415
416     if ( TMath::Abs((strip - w)) < 0.5) { 
417         // gaussian mean is closer to strip on the left
418         a = inf;                         // integration starting point
419         if((strip+0.5)<=sup) {
420             // this means that the tail of the gaussian goes beyond
421             // the middle point between strips ---> part of the signal
422             // is given to the strip on the right
423             b = strip + 0.5;               // integration stopping point
424             dXCharge1 = F( w, b, sigma) - F(w, a, sigma);
425             dXCharge2 = F( w, sup, sigma) - F(w ,b, sigma); 
426         }else { 
427             // this means that all the charge is given to the strip on the left
428             b = sup;
429             dXCharge1 = 0.9973;   // gaussian integral at 3 sigmas
430             dXCharge2 = 0.0;
431         } // end if
432         dXCharge1 = par * dXCharge1;// normalize by mean of number of carriers
433         dXCharge2 = par * dXCharge2;
434
435         // for the time being, signal is the charge
436         // in ChargeToSignal signal is converted in ADC channel
437         fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
438         tav->Add(k,(Int_t)strip);
439         if(((Int_t) strip) < (GetNStrips()-1)) {
440             // strip doesn't have to be the last (remind: last=GetNStrips()-1)
441             // otherwise part of the charge is lost
442             fMapA2->AddSignal(k,((Int_t)strip+1),dXCharge2);
443             tav->Add(k,((Int_t)(strip+1)));
444         } // end if
445     }else{
446         // gaussian mean is closer to strip on the right
447         strip++;     // move to strip on the rigth
448         b = sup;     // now you know where to stop integrating
449         if((strip-0.5)>=inf) { 
450             // tail of diffusion gaussian on the left goes left of
451             // middle point between strips
452             a = strip - 0.5;        // integration starting point
453             dXCharge1 = F(w, b, sigma) - F(w, a, sigma);
454             dXCharge2 = F(w, a, sigma) - F(w, inf, sigma);
455         }else {
456             a = inf;
457             dXCharge1 = 0.9973;   // gaussian integral at 3 sigmas
458             dXCharge2 = 0.0;
459         } // end if
460         dXCharge1 = par * dXCharge1;    // normalize by means of carriers
461         dXCharge2 = par * dXCharge2;
462         // for the time being, signal is the charge
463         // in ChargeToSignal signal is converted in ADC channel
464         fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
465         tav->Add(k,(Int_t)strip);
466         if(((Int_t) strip) > 0) {
467             // strip doesn't have to be the first
468             // otherwise part of the charge is lost
469             fMapA2->AddSignal(k,((Int_t)strip-1),dXCharge2);
470             tav->Add(k,((Int_t)(strip-1)));
471         } // end if
472     } // end if
473 }
474 //______________________________________________________________________
475 Int_t AliITSsimulationSSD::NumOfSteps(Double_t x, Double_t y, Double_t z,
476                                       Double_t &dex,Double_t &dey,
477                                       Double_t &dez){
478     // number of steps
479     // it also returns steps for each coord
480     //AliITSsegmentationSSD *seg = new AliITSsegmentationSSD();
481
482     Double_t step = 25E-4;
483     //step = (Double_t) seg->GetStepSize();  // step size (cm)
484     Int_t numOfSteps = (Int_t) (TMath::Sqrt(x*x+y*y+z*z)/step); 
485
486     if (numOfSteps < 1) numOfSteps = 1;       // one step, at least
487
488     // we could condition the stepping depending on the incident angle
489     // of the track
490     dex = x/numOfSteps;
491     dey = y/numOfSteps;
492     dez = z/numOfSteps;
493     
494     return numOfSteps;
495 }
496 //----------------------------------------------------------------------
497 void AliITSsimulationSSD::GetList(Int_t label,Int_t hit,Int_t mod,
498                                   AliITSpList *pList,AliITSTableSSD *tav) {
499     // loop over nonzero digits
500     Int_t ix,i;
501     Double_t signal=0.;
502
503     for(Int_t k=0; k<2; k++) {
504         ix=tav->Use(k);
505         while(ix>-1){
506             signal = fMapA2->GetSignal(k,ix);
507             if(signal==0.0) {
508                 ix=tav->Use(k);
509                 continue;
510             } // end if signal==0.0
511             // check the signal magnitude
512             for(i=0;i<pList->GetNSignals(k,ix);i++){
513                 signal -= pList->GetTSignal(k,ix,i);
514             } // end for i
515             //  compare the new signal with already existing list
516             if(signal>0)pList->AddSignal(k,ix,label,hit,mod,signal);
517             ix=tav->Use(k);
518         } // end of loop on strips
519     } // end of loop on P/N side
520     tav->Clear();
521 }
522 //----------------------------------------------------------------------
523 void AliITSsimulationSSD::ChargeToSignal(Int_t module,AliITSpList *pList) {
524     // charge to signal
525     static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
526     Float_t threshold = 0.;
527     Int_t size = AliITSdigitSSD::GetNTracks();
528     Int_t * digits = new Int_t[size];
529     Int_t * tracks = new Int_t[size];
530     Int_t * hits = new Int_t[size];
531     Int_t j1;
532     Float_t charges[3] = {0.0,0.0,0.0};
533     Float_t signal;
534     Double_t noise[2] = {0.,0.};
535     AliITSresponseSSD* res =(AliITSresponseSSD*)GetResponseModel(module);
536     res->GetNoiseParam(noise[0],noise[1]);
537
538     for(Int_t k=0;k<2;k++){         // both sides (0=Pside, 1=Nside)
539         // Threshold for zero-suppression
540         // It can be defined in AliITSresponseSSD
541         //             threshold = (Float_t)GetResp()->MinVal(k);
542         // I prefer to think adjusting the threshold "manually", looking
543         // at the scope, and considering noise standard deviation
544         threshold = 4.0*noise[k]; // 4 times noise is a choice
545         for(Int_t ix=0;ix<GetNStrips();ix++){     // loop over strips
546             if(fMapA2->GetSignal(k,ix) <= threshold)continue;
547             // convert to ADC signal
548             signal = res->DEvToADC(
549                 fMapA2->GetSignal(k,ix));
550             if(signal>1024.) signal = 1024.;//if exceeding, accumulate last one
551             digits[0] = k;
552             digits[1] = ix;
553             digits[2] = (Int_t) signal;
554             for(j1=0;j1<size;j1++)if(j1<pList->GetNEnteries()){
555                 // only three in digit.
556                 tracks[j1]  = pList->GetTrack(k,ix,j1);
557                 hits[j1]    = pList->GetHit(k,ix,j1);
558             }else{
559                 tracks[j1]  = -3;
560                 hits[j1]    = -1;
561             } // end for j1
562             // finally add digit
563             aliITS->AddSimDigit(2,0,digits,tracks,hits,charges);
564         } // end for ix
565     } // end for k
566     delete [] digits;
567     delete [] tracks;
568     delete [] hits;
569 }
570 //______________________________________________________________________
571 void AliITSsimulationSSD::WriteSDigits(AliITSpList *pList){
572     // Fills the Summable digits Tree
573     Int_t i,ni,j,nj;
574     static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
575
576     pList->GetMaxMapIndex(ni,nj);
577     for(i=0;i<ni;i++)for(j=0;j<nj;j++){
578         if(pList->GetSignalOnly(i,j)>0.0){
579             aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
580             if(GetDebug(4)) cout << "pListSSD: "<<*(pList->GetpListItem(i,j))
581                                 << endl;
582         } // end if
583     } // end for i,j
584   return;
585 }
586 //______________________________________________________________________
587 void AliITSsimulationSSD::FillMapFrompList(AliITSpList *pList){
588     // Fills fMap2A from the pList of Summable digits
589     Int_t k,ix;
590
591     for(k=0;k<2;k++)for(ix=0;ix<GetNStrips();ix++) 
592         fMapA2->AddSignal(k,ix,pList->GetSignal(k,ix));
593     return;
594 }
595 //______________________________________________________________________
596 void AliITSsimulationSSD::Print(ostream *os){
597     //Standard output format for this class
598
599     //AliITSsimulation::Print(os);
600     *os << fIonE <<",";
601     *os << fDifConst[0] <<","<< fDifConst[1] <<",";
602     *os << fDriftVel[0] <<","<< fDriftVel[1];
603     //*os <<","; fDCS->Print(os);
604     //*os <<","; fMapA2->Print(os);
605 }
606 //______________________________________________________________________
607 void AliITSsimulationSSD::Read(istream *is){
608     // Standard output streaming function.
609
610     //AliITSsimulation::Read(is);
611     *is >> fIonE;
612     *is >> fDifConst[0] >> fDifConst[1];
613     *is >> fDriftVel[0] >> fDriftVel[1];
614     //fDCS->Read(is);
615     //fMapA2->Read(is);
616 }
617 //______________________________________________________________________
618 ostream &operator<<(ostream &os,AliITSsimulationSSD &source){
619     // Standard output streaming function.
620
621     source.Print(&os);
622     return os;
623 }
624 //______________________________________________________________________
625 istream &operator>>(istream &os,AliITSsimulationSSD &source){
626     // Standard output streaming function.
627
628     source.Read(&os);
629     return os;
630 }
631 //______________________________________________________________________
632
633
634
635
636