]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSsimulationSSD.cxx
Changes to remove Effective C++ warnings
[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>
e939a978 22#include <TRandom.h>
23
fd61217e 24#include "AliITSmodule.h"
57817f7c 25#include "AliITSMapA2.h"
c7a4dac0 26#include "AliITSpList.h"
fcf95fc7 27#include "AliITSCalibrationSSD.h"
c7a4dac0 28#include "AliITSsegmentationSSD.h"
14a74335 29//#include "AliITSdcsSSD.h"
b0f5e3fc 30#include "AliITS.h"
3a97c582 31#include "AliITShit.h"
e869281d 32#include "AliITSdigitSSD.h"
b0f5e3fc 33#include "AliRun.h"
569a17d8 34#include "AliITSgeom.h"
57817f7c 35#include "AliITSsimulationSSD.h"
84541af4 36#include "AliITSTableSSD.h"
14a74335 37//#include "AliITSresponseSSD.h"
b0f5e3fc 38
925e6570 39ClassImp(AliITSsimulationSSD)
fd61217e 40////////////////////////////////////////////////////////////////////////
8ba39da9 41// //
14a74335 42// Author: Enrico Fragiacomo //
43// enrico.fragiacomo@ts.infn.it //
44// Last revised: march 2006 //
45// //
46// AliITSsimulationSSD is the simulation of SSD. //
8ba39da9 47////////////////////////////////////////////////////////////////////////
fd61217e 48
57817f7c 49//----------------------------------------------------------------------
aacedc3e 50AliITSsimulationSSD::AliITSsimulationSSD():AliITSsimulation(),
14a74335 51 //fDCS(0),
aacedc3e 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//----------------------------------------------------------------------
8ba39da9 65AliITSsimulationSSD::AliITSsimulationSSD(AliITSDetTypeSim* dettyp):
66AliITSsimulation(dettyp),
14a74335 67//fDCS(0),
aacedc3e 68fMapA2(0),
69fIonE(0.0),
70fDifConst(),
71fDriftVel(){
3a97c582 72 // Constructor
73 // Input:
14a74335 74 // AliITSDetTypeSim Pointer to the SSD dettype to be used
3a97c582 75 // Outputs:
76 // none.
77 // Return
aacedc3e 78 // A standard constructed AliITSsimulationSSD class
3a97c582 79
aacedc3e 80 Init();
c7a4dac0 81}
82//----------------------------------------------------------------------
aacedc3e 83void AliITSsimulationSSD::Init(){
14a74335 84 // Inilizer, Inilizes all of the variable as needed in a standard place.
85 // Input:
86 // AliITSsegmentationSSD *seg Pointer to the SSD segmentation to be used
87 // AliITSCalibrationSSD *resp Pointer to the SSD responce class to be used
88 // Outputs:
89 // none.
90 // Return
91 // none.
8ba39da9 92 AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
14a74335 93
94 SetDriftVelocity(); // use default values in .h file
95 SetIonizeE(); // use default values in .h file
96 SetDiffConst(); // use default values in .h file
97 fpList = new AliITSpList(2,GetNStrips());
98 fMapA2 = new AliITSMapA2(seg);
b0f5e3fc 99}
0315d466 100//______________________________________________________________________
57817f7c 101AliITSsimulationSSD& AliITSsimulationSSD::operator=(
3a97c582 102 const AliITSsimulationSSD &s){
84541af4 103 // Operator =
104
105 if(this==&s) return *this;
106
14a74335 107 // this->fDCS = new AliITSdcsSSD(*(s.fDCS));
84541af4 108 this->fMapA2 = s.fMapA2;
109 this->fIonE = s.fIonE;
110 this->fDifConst[0] = s.fDifConst[0];
111 this->fDifConst[1] = s.fDifConst[1];
112 this->fDriftVel[0] = s.fDriftVel[0];
113 this->fDriftVel[1] = s.fDriftVel[1];
114 return *this;
b0f5e3fc 115}
57817f7c 116//______________________________________________________________________
5402d9ca 117AliITSsimulation& AliITSsimulationSSD::operator=(
d2f55a22 118 const AliITSsimulation &s){
119 // Operator =
120
121 if(this==&s) return *this;
122 Error("AliITSsimulationSSD","Not allowed to make a = with "
123 "AliITSsimulationSSD Using default creater instead");
124
125 return *this;
126}
127//______________________________________________________________________
ac74f489 128AliITSsimulationSSD::AliITSsimulationSSD(const AliITSsimulationSSD &source):
7537d03c 129 AliITSsimulation(source),
130fMapA2(source.fMapA2),
131fIonE(source.fIonE),
132fDifConst(),
133fDriftVel(){
84541af4 134 // copy constructor
7537d03c 135 fDifConst[0] = source.fDifConst[0];
136 fDifConst[1] = source.fDifConst[1];
137 fDriftVel[0] = source.fDriftVel[0];
138 fDriftVel[1] = source.fDriftVel[1];
b0f5e3fc 139}
0315d466 140//______________________________________________________________________
b0f5e3fc 141AliITSsimulationSSD::~AliITSsimulationSSD() {
84541af4 142 // destructor
143 delete fMapA2;
14a74335 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
14a74335 172 FillMapFrompList(fpList); // need to check if needed here or not????
173 SDigitToDigit(fModule,fpList);
174 fpList->ClearMap();
175 fMapA2->ClearMap();
3a97c582 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());
14a74335 181
3a97c582 182 HitsToAnalogDigits(mod,fpList);
aacedc3e 183 SDigitToDigit(GetModuleNumber(),fpList);
14a74335 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);
14a74335 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.
14a74335 202
84541af4 203 ApplyNoise(pList,module);
204 ApplyCoupling(pList,module);
14a74335 205 ApplyDeadChannels(module);
206
8ba39da9 207 ChargeToSignal(module,pList);
c7a4dac0 208}
209//______________________________________________________________________
210void AliITSsimulationSSD::HitsToAnalogDigits(AliITSmodule *mod,
84541af4 211 AliITSpList *pList){
3a97c582 212 // Loops over all hits to produce Analog/floating point digits. This
213 // is also the first task in producing standard digits.
14a74335 214 Int_t lasttrack = -2;
215 Int_t idtrack = -2;
216 Double_t x0=0.0, y0=0.0, z0=0.0;
217 Double_t x1=0.0, y1=0.0, z1=0.0;
218 Double_t de=0.0;
219 Int_t module = mod->GetIndex();
220
221 AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
222
3a97c582 223 TObjArray *hits = mod->GetHits();
224 Int_t nhits = hits->GetEntriesFast();
225 if (nhits<=0) return;
226 AliITSTableSSD * tav = new AliITSTableSSD(GetNStrips());
227 module = mod->GetIndex();
8ba39da9 228 if ( mod->GetLayer() == 6 ) seg->SetLayer(6);
229 if ( mod->GetLayer() == 5 ) seg->SetLayer(5);
3a97c582 230 for(Int_t i=0; i<nhits; i++) {
14a74335 231 // LineSegmentL returns 0 if the hit is entering
232 // If hits is exiting returns positions of entering and exiting hits
233 // Returns also energy loss
234 if(GetDebug(4)){
235 cout << i << " ";
236 cout << mod->GetHit(i)->GetXL() << " "<<mod->GetHit(i)->GetYL();
237 cout << " " << mod->GetHit(i)->GetZL();
238 cout << endl;
239 } // end if
240 if (mod->LineSegmentL(i, x0, x1, y0, y1, z0, z1, de, idtrack)) {
241 HitToDigit(module, x0, y0, z0, x1, y1, z1, de,tav);
242 if (lasttrack != idtrack || i==(nhits-1)) {
243 GetList(idtrack,i,module,pList,tav);
244 } // end if
245 lasttrack=idtrack;
246 } // end if
3a97c582 247 } // end loop over hits
248 delete tav; tav=0;
249 return;
b0f5e3fc 250}
0315d466 251//----------------------------------------------------------------------
fd61217e 252void AliITSsimulationSSD::HitToDigit(Int_t module, Double_t x0, Double_t y0,
84541af4 253 Double_t z0, Double_t x1, Double_t y1,
254 Double_t z1, Double_t de,
255 AliITSTableSSD *tav) {
14a74335 256
8ba39da9 257 // hit to digit conversion
14a74335 258
8ba39da9 259 AliITSsegmentationSSD* seg = (AliITSsegmentationSSD*)GetSegmentationModel(2);
14a74335 260 // Turns hits in SSD module into one or more digits.
261 Float_t tang[2] = {0.0,0.0};
262 seg->Angles(tang[0], tang[1]);//stereo<<->tan(stereo)~=stereo
263 Double_t x, y, z;
264 Double_t dex=0.0, dey=0.0, dez=0.0;
265 Double_t pairs; // pair generation energy per step.
266 Double_t sigma[2] = {0.,0.};// standard deviation of the diffusion gaussian
267 Double_t tdrift[2] = {0.,0.}; // time of drift
268 Double_t w;
269 Double_t inf[2], sup[2], par0[2];
270
271 // Steps in the module are determined "manually" (i.e. No Geant)
272 // NumOfSteps divide path between entering and exiting hits in steps
273 Int_t numOfSteps = NumOfSteps(x1, y1, z1, dex, dey, dez);
274 // Enery loss is equally distributed among steps
275 de = de/numOfSteps;
276 pairs = de/GetIonizeE(); // e-h pairs generated
277 for(Int_t j=0; j<numOfSteps; j++) { // stepping
278 x = x0 + (j+0.5)*dex;
279 y = y0 + (j+0.5)*dey;
280 if ( y > (seg->Dy()/2+10)*1.0E-4 ) {
281 // check if particle is within the detector
282 Warning("HitToDigit",
d35ad08f 283 "hit out of detector y0=%e,y=%e,dey=%e,j =%d module=%d, exceed=%e",
284 y0,y,dey,j,module, y-(seg->Dy()/2+10)*1.0E-4);
14a74335 285 return;
286 } // end if
287 z = z0 + (j+0.5)*dez;
288 if(GetDebug(4)) cout <<"HitToDigit "<<x<<" "<<y<<" "<<z<< " "
289 <<dex<<" "<<dey<<" "<<dez<<endl;
290 // calculate drift time
291 // y is the minimum path
292 tdrift[0] = (y+(seg->Dy()*1.0E-4)/2)/GetDriftVelocity(0);
293 tdrift[1] = ((seg->Dy()*1.0E-4)/2-y)/GetDriftVelocity(1);
294
295 for(Int_t k=0; k<2; k++) { // both sides remember: 0=Pside 1=Nside
296
297 tang[k]=TMath::Tan(tang[k]);
298
299 // w is the coord. perpendicular to the strips
300 Float_t xp=x*1.e+4,zp=z*1.e+4; // microns
301 seg->GetPadTxz(xp,zp);
302 if(k==0) w = xp; // P side strip number
303 else w = zp; // N side strip number
304
305 if((w<(-0.5)) || (w>(GetNStrips()-0.5))) {
306 // this check rejects hits in regions not covered by strips
307 // 0.5 takes into account boundaries
308 if(GetDebug(4)) cout << "x,z="<<x<<","<<z<<" w="<<w
309 <<" Nstrips="<<GetNStrips()<<endl;
310 return; // There are dead region on the SSD sensitive volume.
311 } // end if
312
313 // sigma is the standard deviation of the diffusion gaussian
314 if(tdrift[k]<0) return;
315 sigma[k] = TMath::Sqrt(2*GetDiffConst(k)*tdrift[k]);
316 sigma[k] /= (GetStripPitch()*1.0E-4); //units of Pitch
317 if(sigma[k]==0.0) {
318 Error("HitToDigit"," sigma[%d]=0",k);
319 exit(0);
320 } // end if
321
322 par0[k] = pairs;
323 // we integrate the diffusion gaussian from -3sigma to 3sigma
324 inf[k] = w - 3*sigma[k]; // 3 sigma from the gaussian average
325 sup[k] = w + 3*sigma[k]; // 3 sigma from the gaussian average
326 // IntegrateGaussian does the actual
327 // integration of diffusion gaussian
328 IntegrateGaussian(k, par0[k], w, sigma[k], inf[k], sup[k],tav);
329 } // end for loop over side (0=Pside, 1=Nside)
330 } // end stepping
b0f5e3fc 331}
14a74335 332
57817f7c 333//______________________________________________________________________
c7a4dac0 334void AliITSsimulationSSD::ApplyNoise(AliITSpList *pList,Int_t module){
14a74335 335 // Apply Noise.
336 Int_t ix;
337 Double_t signal,noise;
338 AliITSCalibrationSSD* res =(AliITSCalibrationSSD*)GetCalibrationModel(module);
339
340 // Pside
341 for(ix=0;ix<GetNStrips();ix++){ // loop over strips
342
343 // noise is gaussian
569a17d8 344 noise = (Double_t) gRandom->Gaus(0,res->GetNoiseP().At(ix));
14a74335 345
346 // need to calibrate noise
347 // NOTE. noise from the calibration database comes uncalibrated,
348 // it needs to be calibrated in order to be added
349 // to the signal. It will be decalibrated later on together with the noise
569a17d8 350 noise *= (Double_t) res->GetGainP(ix);
14a74335 351
352 // noise comes in ADC channels from the calibration database
353 // It needs to be converted back to electronVolts
354 noise /= res->GetDEvToADC(1.);
355
356 // Finally, noise is added to the signal
357 signal = noise + fMapA2->GetSignal(0,ix);//get signal from map
358 fMapA2->SetHit(0,ix,signal); // give back signal to map
359 if(signal>0.0) pList->AddNoise(0,ix,module,noise);
360 } // loop over strip
361
362 // Nside
363 for(ix=0;ix<GetNStrips();ix++){ // loop over strips
569a17d8 364 noise = (Double_t) gRandom->Gaus(0,res->GetNoiseN().At(ix));// give noise to signal
365 noise *= (Double_t) res->GetGainN(ix);
14a74335 366 noise /= res->GetDEvToADC(1.);
367 signal = noise + fMapA2->GetSignal(1,ix);//get signal from map
368 fMapA2->SetHit(1,ix,signal); // give back signal to map
369 if(signal>0.0) pList->AddNoise(1,ix,module,noise);
370 } // loop over strip
371
b0f5e3fc 372}
0315d466 373//______________________________________________________________________
c7a4dac0 374void AliITSsimulationSSD::ApplyCoupling(AliITSpList *pList,Int_t module) {
14a74335 375 // Apply the effect of electronic coupling between channels
376 Int_t ix;
377 Double_t signal=0;
378 AliITSCalibrationSSD* res =(AliITSCalibrationSSD*)GetCalibrationModel(module);
379
380 Double_t *contrLeft = new Double_t[GetNStrips()];
381 Double_t *contrRight = new Double_t[GetNStrips()];
382
383 // P side coupling
384 for(ix=0;ix<GetNStrips();ix++){
385 if(ix>0) contrLeft[ix] = fMapA2->GetSignal(0,ix-1)*res->GetCouplingPL();
386 else contrLeft[ix] = 0.0;
387 if(ix<(GetNStrips()-1)) contrRight[ix] = fMapA2->GetSignal(0,ix+1)*res->GetCouplingPR();
388 else contrRight[ix] = 0.0;
389 } // loop over strips
390
391 for(ix=0;ix<GetNStrips();ix++){
392 signal = contrLeft[ix] + contrRight[ix] - res->GetCouplingPL() * fMapA2->GetSignal(0,ix)
393 - res->GetCouplingPR() * fMapA2->GetSignal(0,ix);
394 fMapA2->AddSignal(0,ix,signal);
395 if(signal>0.0) pList->AddNoise(0,ix,module,signal);
396 } // loop over strips
397
398 // N side coupling
399 for(ix=0;ix<GetNStrips();ix++){
400 if(ix>0) contrLeft[ix] = fMapA2->GetSignal(1,ix-1)*res->GetCouplingNL();
401 else contrLeft[ix] = 0.0;
402 if(ix<(GetNStrips()-1)) contrRight[ix] = fMapA2->GetSignal(1,ix+1)*res->GetCouplingNR();
403 else contrRight[ix] = 0.0;
404 } // loop over strips
405
406 for(ix=0;ix<GetNStrips();ix++){
407 signal = contrLeft[ix] + contrRight[ix] - res->GetCouplingNL() * fMapA2->GetSignal(0,ix)
408 - res->GetCouplingNR() * fMapA2->GetSignal(0,ix);
409 fMapA2->AddSignal(1,ix,signal);
410 if(signal>0.0) pList->AddNoise(1,ix,module,signal);
411 } // loop over strips
412
413
414 delete [] contrLeft;
415 delete [] contrRight;
b0f5e3fc 416}
14a74335 417
418//______________________________________________________________________
419void AliITSsimulationSSD::ApplyDeadChannels(Int_t module) {
420 // Kill dead channels setting gain to zero
421
422 Int_t deadentries;
423
424 AliITSCalibrationSSD* res = (AliITSCalibrationSSD*)GetCalibrationModel(module);
425
426 deadentries = res->GetDeadPChannelsList().GetSize();
427 //cout<<module<<" "<<deadentries<<endl;
428 for(Int_t i=0; i<deadentries; i++) {
429 res->AddGainP(res->GetDeadPChannelsList().At(i),0.0);
430 }
431
432 deadentries = res->GetDeadNChannelsList().GetSize();
433 for(Int_t i=0; i<deadentries; i++) {
434 res->AddGainN(res->GetDeadNChannelsList().At(i),0.0);
435 }
436
437}
438
0315d466 439//______________________________________________________________________
fd61217e 440Float_t AliITSsimulationSSD::F(Float_t av, Float_t x, Float_t s) {
aacedc3e 441 // Computes the integral of a gaussian using Error Function
442 Float_t sqrt2 = TMath::Sqrt(2.0);
443 Float_t sigm2 = sqrt2*s;
444 Float_t integral;
fd61217e 445
aacedc3e 446 integral = 0.5 * TMath::Erf( (x - av) / sigm2);
447 return integral;
0315d466 448}
449//______________________________________________________________________
fd61217e 450void AliITSsimulationSSD::IntegrateGaussian(Int_t k,Double_t par, Double_t w,
84541af4 451 Double_t sigma,
452 Double_t inf, Double_t sup,
453 AliITSTableSSD *tav) {
aacedc3e 454 // integrate the diffusion gaussian
455 // remind: inf and sup are w-3sigma and w+3sigma
456 // we could define them here instead of passing them
457 // this way we are free to introduce asimmetry
458
459 Double_t a=0.0, b=0.0;
460 Double_t dXCharge1 = 0.0, dXCharge2 = 0.0;
461 // dXCharge1 and 2 are the charge to two neighbouring strips
462 // Watch that we only involve at least two strips
463 // Numbers greater than 2 of strips in a cluster depend on
464 // geometry of the track and delta rays, not charge diffusion!
465
466 Double_t strip = TMath::Floor(w); // closest strip on the left
467
468 if ( TMath::Abs((strip - w)) < 0.5) {
469 // gaussian mean is closer to strip on the left
470 a = inf; // integration starting point
471 if((strip+0.5)<=sup) {
472 // this means that the tail of the gaussian goes beyond
473 // the middle point between strips ---> part of the signal
474 // is given to the strip on the right
475 b = strip + 0.5; // integration stopping point
476 dXCharge1 = F( w, b, sigma) - F(w, a, sigma);
477 dXCharge2 = F( w, sup, sigma) - F(w ,b, sigma);
478 }else {
479 // this means that all the charge is given to the strip on the left
480 b = sup;
481 dXCharge1 = 0.9973; // gaussian integral at 3 sigmas
482 dXCharge2 = 0.0;
483 } // end if
484 dXCharge1 = par * dXCharge1;// normalize by mean of number of carriers
485 dXCharge2 = par * dXCharge2;
486
487 // for the time being, signal is the charge
488 // in ChargeToSignal signal is converted in ADC channel
489 fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
490 tav->Add(k,(Int_t)strip);
491 if(((Int_t) strip) < (GetNStrips()-1)) {
492 // strip doesn't have to be the last (remind: last=GetNStrips()-1)
493 // otherwise part of the charge is lost
494 fMapA2->AddSignal(k,((Int_t)strip+1),dXCharge2);
495 tav->Add(k,((Int_t)(strip+1)));
496 } // end if
497 }else{
498 // gaussian mean is closer to strip on the right
499 strip++; // move to strip on the rigth
500 b = sup; // now you know where to stop integrating
501 if((strip-0.5)>=inf) {
502 // tail of diffusion gaussian on the left goes left of
503 // middle point between strips
504 a = strip - 0.5; // integration starting point
505 dXCharge1 = F(w, b, sigma) - F(w, a, sigma);
506 dXCharge2 = F(w, a, sigma) - F(w, inf, sigma);
507 }else {
508 a = inf;
509 dXCharge1 = 0.9973; // gaussian integral at 3 sigmas
510 dXCharge2 = 0.0;
511 } // end if
512 dXCharge1 = par * dXCharge1; // normalize by means of carriers
513 dXCharge2 = par * dXCharge2;
514 // for the time being, signal is the charge
515 // in ChargeToSignal signal is converted in ADC channel
516 fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
517 tav->Add(k,(Int_t)strip);
518 if(((Int_t) strip) > 0) {
519 // strip doesn't have to be the first
520 // otherwise part of the charge is lost
521 fMapA2->AddSignal(k,((Int_t)strip-1),dXCharge2);
522 tav->Add(k,((Int_t)(strip-1)));
523 } // end if
524 } // end if
b0f5e3fc 525}
0315d466 526//______________________________________________________________________
fd61217e 527Int_t AliITSsimulationSSD::NumOfSteps(Double_t x, Double_t y, Double_t z,
aacedc3e 528 Double_t &dex,Double_t &dey,
529 Double_t &dez){
530 // number of steps
531 // it also returns steps for each coord
532 //AliITSsegmentationSSD *seg = new AliITSsegmentationSSD();
533
534 Double_t step = 25E-4;
535 //step = (Double_t) seg->GetStepSize(); // step size (cm)
536 Int_t numOfSteps = (Int_t) (TMath::Sqrt(x*x+y*y+z*z)/step);
537
538 if (numOfSteps < 1) numOfSteps = 1; // one step, at least
14a74335 539 //numOfSteps=1;
aacedc3e 540
541 // we could condition the stepping depending on the incident angle
542 // of the track
543 dex = x/numOfSteps;
544 dey = y/numOfSteps;
545 dez = z/numOfSteps;
546
547 return numOfSteps;
fd61217e 548}
0315d466 549//----------------------------------------------------------------------
c7a4dac0 550void AliITSsimulationSSD::GetList(Int_t label,Int_t hit,Int_t mod,
84541af4 551 AliITSpList *pList,AliITSTableSSD *tav) {
aacedc3e 552 // loop over nonzero digits
553 Int_t ix,i;
554 Double_t signal=0.;
555
556 for(Int_t k=0; k<2; k++) {
84541af4 557 ix=tav->Use(k);
aacedc3e 558 while(ix>-1){
559 signal = fMapA2->GetSignal(k,ix);
560 if(signal==0.0) {
561 ix=tav->Use(k);
562 continue;
563 } // end if signal==0.0
564 // check the signal magnitude
565 for(i=0;i<pList->GetNSignals(k,ix);i++){
566 signal -= pList->GetTSignal(k,ix,i);
567 } // end for i
568 // compare the new signal with already existing list
569 if(signal>0)pList->AddSignal(k,ix,label,hit,mod,signal);
570 ix=tav->Use(k);
571 } // end of loop on strips
572 } // end of loop on P/N side
573 tav->Clear();
fd61217e 574}
0315d466 575//----------------------------------------------------------------------
8ba39da9 576void AliITSsimulationSSD::ChargeToSignal(Int_t module,AliITSpList *pList) {
aacedc3e 577 // charge to signal
578 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
579 Float_t threshold = 0.;
580 Int_t size = AliITSdigitSSD::GetNTracks();
581 Int_t * digits = new Int_t[size];
582 Int_t * tracks = new Int_t[size];
583 Int_t * hits = new Int_t[size];
584 Int_t j1;
585 Float_t charges[3] = {0.0,0.0,0.0};
586 Float_t signal;
fcf95fc7 587 AliITSCalibrationSSD* res =(AliITSCalibrationSSD*)GetCalibrationModel(module);
aacedc3e 588
589 for(Int_t k=0;k<2;k++){ // both sides (0=Pside, 1=Nside)
14a74335 590 for(Int_t ix=0;ix<GetNStrips();ix++){ // loop over strips
591
592 // if strip is dead -> gain=0
593 if( ((k==0)&&(res->GetGainP(ix)==0)) || ((k==1)&&(res->GetGainN(ix)==0))) continue;
594
3a4139a2 595 signal = fMapA2->GetSignal(k,ix);
14a74335 596 // signal has to be uncalibrated
597 // In real life, gains are supposed to be calculated from calibration runs,
598 // stored in the calibration DB and used in the reconstruction
599 // (see AliITSClusterFinderSSD.cxx)
600 if(k==0) signal /= res->GetGainP(ix);
601 else signal /= res->GetGainN(ix);
602
603 // signal is converted in unit of ADC
3a4139a2 604 signal = res->GetDEvToADC(signal);
14a74335 605 if(signal>4096.) signal = 4096.;//if exceeding, accumulate last one
606
607 // threshold for zero suppression is set on the basis of the noise
608 // A good value is 3*sigma_noise
609 if(k==0) threshold = res->GetNoiseP().At(ix);
610 else threshold = res->GetNoiseN().At(ix);
611 threshold *= res->GetZSThreshold(); // threshold at 3 sigma noise
612 if(signal < threshold) continue;
613
614 digits[0] = k;
615 digits[1] = ix;
616 digits[2] = TMath::Nint(signal);
617 for(j1=0;j1<size;j1++)if(j1<pList->GetNEntries()){
618 // only three in digit.
619 tracks[j1] = pList->GetTrack(k,ix,j1);
620 hits[j1] = pList->GetHit(k,ix,j1);
621 }else{
622 tracks[j1] = -3;
623 hits[j1] = -1;
624 } // end for j1
625 // finally add digit
626 aliITS->AddSimDigit(2,0,digits,tracks,hits,charges);
627 } // end for ix
aacedc3e 628 } // end for k
629 delete [] digits;
630 delete [] tracks;
631 delete [] hits;
c7a4dac0 632}
633//______________________________________________________________________
634void AliITSsimulationSSD::WriteSDigits(AliITSpList *pList){
aacedc3e 635 // Fills the Summable digits Tree
636 Int_t i,ni,j,nj;
637 static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
638
639 pList->GetMaxMapIndex(ni,nj);
640 for(i=0;i<ni;i++)for(j=0;j<nj;j++){
641 if(pList->GetSignalOnly(i,j)>0.0){
642 aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
643 if(GetDebug(4)) cout << "pListSSD: "<<*(pList->GetpListItem(i,j))
644 << endl;
645 } // end if
646 } // end for i,j
84541af4 647 return;
c7a4dac0 648}
649//______________________________________________________________________
650void AliITSsimulationSSD::FillMapFrompList(AliITSpList *pList){
aacedc3e 651 // Fills fMap2A from the pList of Summable digits
652 Int_t k,ix;
c7a4dac0 653
aacedc3e 654 for(k=0;k<2;k++)for(ix=0;ix<GetNStrips();ix++)
655 fMapA2->AddSignal(k,ix,pList->GetSignal(k,ix));
656 return;
b0f5e3fc 657}
57817f7c 658//______________________________________________________________________
659void AliITSsimulationSSD::Print(ostream *os){
aacedc3e 660 //Standard output format for this class
661
662 //AliITSsimulation::Print(os);
663 *os << fIonE <<",";
664 *os << fDifConst[0] <<","<< fDifConst[1] <<",";
665 *os << fDriftVel[0] <<","<< fDriftVel[1];
666 //*os <<","; fDCS->Print(os);
667 //*os <<","; fMapA2->Print(os);
57817f7c 668}
669//______________________________________________________________________
670void AliITSsimulationSSD::Read(istream *is){
aacedc3e 671 // Standard output streaming function.
672
673 //AliITSsimulation::Read(is);
674 *is >> fIonE;
675 *is >> fDifConst[0] >> fDifConst[1];
676 *is >> fDriftVel[0] >> fDriftVel[1];
677 //fDCS->Read(is);
678 //fMapA2->Read(is);
57817f7c 679}
680//______________________________________________________________________
681ostream &operator<<(ostream &os,AliITSsimulationSSD &source){
aacedc3e 682 // Standard output streaming function.
57817f7c 683
aacedc3e 684 source.Print(&os);
685 return os;
57817f7c 686}
687//______________________________________________________________________
688istream &operator>>(istream &os,AliITSsimulationSSD &source){
aacedc3e 689 // Standard output streaming function.
57817f7c 690
aacedc3e 691 source.Read(&os);
692 return os;
57817f7c 693}
c7a4dac0 694//______________________________________________________________________
84541af4 695
696
697
698
699