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