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