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