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