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