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