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