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