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