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