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