f74211b0 |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * |
4 | * Author: The ALICE Off-line Project. * |
5 | * Contributors are mentioned in the code where appropriate. * |
6 | * * |
7 | * Permission to use, copy, modify and distribute this software and its * |
8 | * documentation strictly for non-commercial purposes is hereby granted * |
9 | * without fee, provided that the above copyright notice appears in all * |
10 | * copies and that both the copyright notice and this permission notice * |
11 | * appear in the supporting documentation. The authors make no claims * |
12 | * about the suitability of this software for any purpose. It is * |
13 | * provided "as is" without express or implied warranty. * |
14 | **************************************************************************/ |
15 | |
12e7c97c |
16 | /* |
17 | $Id$ |
18 | */ |
fcf95fc7 |
19 | |
4ae5bbc4 |
20 | #include <Riostream.h> |
409f8c84 |
21 | #include <TH1.h> |
22 | #include <TMath.h> |
409f8c84 |
23 | #include <TParticle.h> |
f77f13c8 |
24 | #include <TRandom.h> |
25 | #include <TString.h> |
409f8c84 |
26 | #include "AliITS.h" |
f77f13c8 |
27 | #include "AliITSMapA2.h" |
e869281d |
28 | #include "AliITSdigitSPD.h" |
8ba39da9 |
29 | #include "AliITSgeom.h" |
f77f13c8 |
30 | #include "AliITShit.h" |
409f8c84 |
31 | #include "AliITSmodule.h" |
2cc6b29a |
32 | #include "AliITSpList.h" |
fcf95fc7 |
33 | #include "AliITSCalibrationSPD.h" |
f77f13c8 |
34 | #include "AliITSsegmentationSPD.h" |
35 | #include "AliITSsimulationSPDdubna.h" |
36 | #include "AliLog.h" |
37 | #include "AliRun.h" |
409f8c84 |
38 | |
f74211b0 |
39 | //#define DEBUG |
409f8c84 |
40 | |
41 | ClassImp(AliITSsimulationSPDdubna) |
42 | //////////////////////////////////////////////////////////////////////// |
12e7c97c |
43 | // Version: 1 |
44 | // Modified by Bjorn S. Nilsen |
409f8c84 |
45 | // Version: 0 |
46 | // Written by Boris Batyunya |
47 | // December 20 1999 |
48 | // |
12e7c97c |
49 | // AliITSsimulationSPDdubna is to do the simulation of SPDs. |
2cc6b29a |
50 | //______________________________________________________________________ |
aacedc3e |
51 | AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(): |
52 | AliITSsimulation(), |
53 | fHis(0), |
54 | fSPDname(), |
55 | fCoupling(0){ |
12e7c97c |
56 | // Default constructor. |
57 | // Inputs: |
58 | // none. |
59 | // Outputs: |
60 | // none. |
61 | // Return: |
62 | // A default constructed AliITSsimulationSPDdubna class. |
2cc6b29a |
63 | |
f77f13c8 |
64 | AliDebug(1,Form("Calling degault constructor")); |
409f8c84 |
65 | } |
2cc6b29a |
66 | //______________________________________________________________________ |
8ba39da9 |
67 | AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(AliITSDetTypeSim *dettyp, Int_t cup): |
68 | AliITSsimulation(dettyp), |
aacedc3e |
69 | fHis(0), |
70 | fSPDname(), |
71 | fCoupling(cup){ |
2cc6b29a |
72 | // standard constructor |
12e7c97c |
73 | // Inputs: |
74 | // AliITSsegmentation *seg A pointer to the segmentation class |
75 | // to be used for this simulation |
fcf95fc7 |
76 | // AliITSCalibration *resp A pointer to the responce class to |
12e7c97c |
77 | // be used for this simulation |
aacedc3e |
78 | // Int_t cup The type of coupling to be used |
79 | // =1 uses SetCoupling, =2 uses SetCouplingOld |
80 | // With diffusion tured off |
81 | // =3 uses SetCoupling, =4 uses SetCouplingOld |
82 | // with diffusion on other, no coupling. |
12e7c97c |
83 | // Outputs: |
84 | // none. |
85 | // Return: |
86 | // A default constructed AliITSsimulationSPDdubna class. |
409f8c84 |
87 | |
f77f13c8 |
88 | AliDebug(1, |
8ba39da9 |
89 | Form("Calling degault constructor cup=%d",cup)); |
aacedc3e |
90 | if(cup==1||cup==2){ // For the moment, remove defusion if Coupling is |
91 | // set. |
fcf95fc7 |
92 | AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD()); |
8ba39da9 |
93 | res->SetTemperature(0.0); |
94 | res->SetDistanceOverVoltage(0.0); |
aacedc3e |
95 | } // end if |
96 | Init(); |
12e7c97c |
97 | } |
98 | //______________________________________________________________________ |
aacedc3e |
99 | void AliITSsimulationSPDdubna::Init(){ |
12e7c97c |
100 | // Initilization |
101 | // Inputs: |
aacedc3e |
102 | // none. |
12e7c97c |
103 | // Outputs: |
104 | // none. |
105 | // Return: |
106 | // none. |
107 | const Double_t kmictocm = 1.0e-4; // convert microns to cm. |
409f8c84 |
108 | |
12e7c97c |
109 | SetModuleNumber(0); |
110 | SetEventNumber(0); |
111 | SetMap(new AliITSpList(GetNPixelsZ(),GetNPixelsX())); |
fcf95fc7 |
112 | AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD()); |
8ba39da9 |
113 | AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0); |
114 | res->SetDistanceOverVoltage(kmictocm*seg->Dy(),50.0); |
2cc6b29a |
115 | } |
116 | //______________________________________________________________________ |
117 | AliITSsimulationSPDdubna::~AliITSsimulationSPDdubna(){ |
118 | // destructor |
12e7c97c |
119 | // Inputs: |
120 | // none. |
121 | // Outputs: |
122 | // none. |
123 | // Return: |
124 | // none. |
409f8c84 |
125 | |
2cc6b29a |
126 | if (fHis) { |
aacedc3e |
127 | fHis->Delete(); |
128 | delete fHis; |
2cc6b29a |
129 | } // end if fHis |
409f8c84 |
130 | } |
2cc6b29a |
131 | //______________________________________________________________________ |
132 | AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(const |
133 | AliITSsimulationSPDdubna |
12e7c97c |
134 | &s) : AliITSsimulation(s){ |
135 | // Copy Constructor |
136 | // Inputs: |
137 | // AliITSsimulationSPDdubna &s The original class for which |
138 | // this class is a copy of |
139 | // Outputs: |
140 | // none. |
141 | // Return: |
142 | |
143 | *this = s; |
2cc6b29a |
144 | return; |
145 | } |
146 | //______________________________________________________________________ |
147 | AliITSsimulationSPDdubna& AliITSsimulationSPDdubna::operator=(const |
12e7c97c |
148 | AliITSsimulationSPDdubna &s){ |
2cc6b29a |
149 | // Assignment operator |
12e7c97c |
150 | // Inputs: |
151 | // AliITSsimulationSPDdubna &s The original class for which |
152 | // this class is a copy of |
153 | // Outputs: |
154 | // none. |
155 | // Return: |
156 | |
157 | if(&s == this) return *this; |
aacedc3e |
158 | this->fHis = s.fHis; |
159 | fCoupling = s.fCoupling; |
160 | fSPDname = s.fSPDname; |
2cc6b29a |
161 | return *this; |
162 | } |
163 | //______________________________________________________________________ |
5402d9ca |
164 | AliITSsimulation& AliITSsimulationSPDdubna::operator=(const |
d2f55a22 |
165 | AliITSsimulation &s){ |
166 | // Assignment operator |
167 | // Inputs: |
168 | // AliITSsimulationSPDdubna &s The original class for which |
169 | // this class is a copy of |
170 | // Outputs: |
171 | // none. |
172 | // Return: |
173 | |
174 | if(&s == this) return *this; |
175 | Error("AliITSsimulationSPDdubna","Not allowed to make a = with " |
176 | "AliITSsimulationSPDdubna","Using default creater instead"); |
177 | |
178 | return *this; |
179 | } |
180 | //______________________________________________________________________ |
2cc6b29a |
181 | void AliITSsimulationSPDdubna::InitSimulationModule(Int_t module, Int_t event){ |
182 | // This function creates maps to build the list of tracks for each |
12e7c97c |
183 | // summable digit. Inputs defined by base class. |
2cc6b29a |
184 | // Inputs: |
185 | // Int_t module // Module number to be simulated |
186 | // Int_t event // Event number to be simulated |
2cc6b29a |
187 | // Outputs: |
188 | // none |
2cc6b29a |
189 | // Returns: |
190 | // none |
409f8c84 |
191 | |
f77f13c8 |
192 | AliDebug(1,Form("(module=%d,event=%d)",module,event)); |
12e7c97c |
193 | SetModuleNumber(module); |
194 | SetEventNumber(event); |
195 | ClearMap(); |
2cc6b29a |
196 | } |
197 | //_____________________________________________________________________ |
aacedc3e |
198 | void AliITSsimulationSPDdubna::SDigitiseModule(AliITSmodule *mod,Int_t, |
199 | Int_t event){ |
12e7c97c |
200 | // This function begins the work of creating S-Digits. Inputs defined |
201 | // by base class. |
2cc6b29a |
202 | // Inputs: |
203 | // AliITSmodule *mod // module |
aacedc3e |
204 | // Int_t // not used |
205 | // Int_t event // Event number |
2cc6b29a |
206 | // Outputs: |
207 | // none |
2cc6b29a |
208 | // Return: |
209 | // test // test returns kTRUE if the module contained hits |
210 | // // test returns kFALSE if it did not contain hits |
409f8c84 |
211 | |
f77f13c8 |
212 | AliDebug(1,Form("(mod=%p, ,event=%d)",mod,event)); |
aacedc3e |
213 | if(!(mod->GetNhits())){ |
f77f13c8 |
214 | AliDebug(1,Form("In event %d module %d there are %d hits returning.", |
215 | event, mod->GetIndex(),mod->GetNhits())); |
aacedc3e |
216 | return;// if module has no hits don't create Sdigits |
217 | } // end if |
12e7c97c |
218 | SetModuleNumber(mod->GetIndex()); |
219 | SetEventNumber(event); |
220 | HitToSDigit(mod); |
221 | WriteSDigits(); |
222 | ClearMap(); |
409f8c84 |
223 | } |
2cc6b29a |
224 | //______________________________________________________________________ |
12e7c97c |
225 | void AliITSsimulationSPDdubna::WriteSDigits(){ |
2cc6b29a |
226 | // This function adds each S-Digit to pList |
2cc6b29a |
227 | // Inputs: |
12e7c97c |
228 | // none. |
2cc6b29a |
229 | // Outputs: |
12e7c97c |
230 | // none. |
2cc6b29a |
231 | // Return: |
232 | // none |
7d50ea21 |
233 | Int_t ix, nix, iz, niz; |
2cc6b29a |
234 | static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS"); |
235 | |
f77f13c8 |
236 | AliDebug(1,Form("Writing SDigits for module %d",GetModuleNumber())); |
12e7c97c |
237 | GetMap()->GetMaxMapIndex(niz, nix); |
238 | for(iz=0; iz<niz; iz++)for(ix=0; ix<nix; ix++){ |
aacedc3e |
239 | if(GetMap()->GetSignalOnly(iz,ix)>0.0){ |
240 | aliITS->AddSumDigit(*(GetMap()->GetpListItem(iz,ix))); |
f77f13c8 |
241 | if(AliDebugLevel()>0) { |
242 | AliDebug(1,Form("%d, %d",iz,ix)); |
243 | cout << *(GetMap()->GetpListItem(iz,ix)) << endl; |
aacedc3e |
244 | } // end if GetDebug |
245 | } // end if GetMap()->GetSignalOnly(iz,ix)>0.0 |
7d50ea21 |
246 | } // end for iz,ix |
2cc6b29a |
247 | return; |
248 | } |
249 | //______________________________________________________________________ |
250 | void AliITSsimulationSPDdubna::FinishSDigitiseModule(){ |
251 | // This function calls SDigitsToDigits which creates Digits from SDigits |
2cc6b29a |
252 | // Inputs: |
253 | // none |
2cc6b29a |
254 | // Outputs: |
255 | // none |
256 | // Return |
257 | // none |
409f8c84 |
258 | |
f77f13c8 |
259 | AliDebug(1,"()"); |
aacedc3e |
260 | pListToDigits(); // Charge To Signal both adds noise and |
12e7c97c |
261 | ClearMap(); |
aacedc3e |
262 | return; |
409f8c84 |
263 | } |
2cc6b29a |
264 | //______________________________________________________________________ |
aacedc3e |
265 | void AliITSsimulationSPDdubna::DigitiseModule(AliITSmodule *mod,Int_t, |
266 | Int_t){ |
2cc6b29a |
267 | // This function creates Digits straight from the hits and then adds |
268 | // electronic noise to the digits before adding them to pList |
12e7c97c |
269 | // Each of the input variables is passed along to HitToSDigit |
2cc6b29a |
270 | // Inputs: |
12e7c97c |
271 | // AliITSmodule *mod module |
aacedc3e |
272 | // Int_t Dummy. |
273 | // Int_t Dummy |
2cc6b29a |
274 | // Outputs: |
12e7c97c |
275 | // none. |
2cc6b29a |
276 | // Return: |
12e7c97c |
277 | // none. |
409f8c84 |
278 | |
f77f13c8 |
279 | AliDebug(1,Form("(mod=%p,,)",mod)); |
12e7c97c |
280 | HitToSDigit(mod); |
aacedc3e |
281 | pListToDigits(); |
12e7c97c |
282 | ClearMap(); |
2cc6b29a |
283 | } |
284 | //______________________________________________________________________ |
12e7c97c |
285 | void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod){ |
f74211b0 |
286 | // Does the charge distributions using Gaussian diffusion charge charing. |
12e7c97c |
287 | // Inputs: |
288 | // AliITSmodule *mod Pointer to this module |
289 | // Output: |
290 | // none. |
291 | // Return: |
292 | // none. |
f74211b0 |
293 | const Double_t kmictocm = 1.0e-4; // convert microns to cm. |
294 | TObjArray *hits = mod->GetHits(); |
295 | Int_t nhits = hits->GetEntriesFast(); |
aacedc3e |
296 | Int_t h,ix,iz,i; |
f74211b0 |
297 | Int_t idtrack; |
298 | Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0; |
299 | Double_t x,y,z,t,tp,st,dt=0.2,el,sig; |
8ba39da9 |
300 | AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0); |
fcf95fc7 |
301 | AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD()); |
8ba39da9 |
302 | Double_t thick = kmictocm*seg->Dy(); |
f74211b0 |
303 | |
f77f13c8 |
304 | AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling)); |
f74211b0 |
305 | if(nhits<=0) return; |
306 | for(h=0;h<nhits;h++){ |
f77f13c8 |
307 | if(AliDebugLevel()>0) { |
308 | AliDebug(1,Form("Hits, %d", h)); |
309 | cout << *(mod->GetHit(h)) << endl; |
310 | } // end if GetDebug |
aacedc3e |
311 | if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue; |
312 | st = TMath::Sqrt(x1*x1+y1*y1+z1*z1); |
313 | if(st>0.0){ |
c789ee28 |
314 | st = (Double_t)((Int_t)(st/kmictocm)); // number of microns |
315 | if(st<=1.0) st = 1.0; |
aacedc3e |
316 | dt = 1.0/st; |
317 | for(t=0.0;t<1.0;t+=dt){ // Integrate over t |
318 | tp = t+0.5*dt; |
319 | x = x0+x1*tp; |
320 | y = y0+y1*tp; |
321 | z = z0+z1*tp; |
8ba39da9 |
322 | if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside |
323 | el = res->GeVToCharge((Double_t)(dt*de)); |
aacedc3e |
324 | if(GetDebug(1)){ |
325 | if(el<=0.0) cout<<"el="<<el<<" dt="<<dt |
326 | <<" de="<<de<<endl; |
327 | } // end if GetDebug |
8ba39da9 |
328 | sig = res->SigmaDiffusion1D(thick + y); |
aacedc3e |
329 | SpreadCharge(x,z,ix,iz,el,sig,idtrack,h); |
330 | } // end for t |
331 | } else { // st == 0.0 deposit it at this point |
332 | x = x0; |
333 | y = y0; |
334 | z = z0; |
8ba39da9 |
335 | if(!(seg->LocalToDet(x,z,ix,iz))) continue; // outside |
336 | el = res->GeVToCharge((Double_t)de); |
337 | sig = res->SigmaDiffusion1D(thick + y); |
aacedc3e |
338 | SpreadCharge(x,z,ix,iz,el,sig,idtrack,h); |
339 | } // end if st>0.0 |
340 | // Coupling |
341 | switch (fCoupling) { |
342 | default: |
343 | break; |
344 | case 1: case 3: |
345 | // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz) |
346 | for(i=0;i<GetMap()->GetEntries();i++) |
347 | if(GetMap()->GetpListItem(i)==0) continue; |
348 | else{ |
349 | GetMap()->GetMapIndex( |
350 | GetMap()->GetpListItem(i)->GetIndex(),iz,ix); |
351 | SetCoupling(iz,ix,idtrack,h); |
352 | } // end for i |
353 | break; |
354 | case 2: case 4: |
355 | // x is column and z is row (see AliITSsegmentationSPD::GetPadIxz) |
356 | for(i=0;i<GetMap()->GetEntries();i++) |
357 | if(GetMap()->GetpListItem(i)==0) continue; |
358 | else{ |
359 | GetMap()->GetMapIndex( |
360 | GetMap()->GetpListItem(i)->GetIndex(),iz,ix); |
361 | SetCouplingOld(iz,ix,idtrack,h); |
362 | } // end for i |
363 | break; |
364 | } // end switch |
12e7c97c |
365 | } // Loop over all hits h |
aacedc3e |
366 | if(GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling); |
12e7c97c |
367 | } |
f74211b0 |
368 | //______________________________________________________________________ |
12e7c97c |
369 | void AliITSsimulationSPDdubna::SpreadCharge(Double_t x0,Double_t z0, |
370 | Int_t ix0,Int_t iz0, |
f74211b0 |
371 | Double_t el,Double_t sig,Int_t t, |
12e7c97c |
372 | Int_t hi){ |
f74211b0 |
373 | // Spreads the charge over neighboring cells. Assume charge is distributed |
374 | // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg) |
375 | // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig) |
376 | // Defined this way, the integral over all x and z is el. |
12e7c97c |
377 | // Inputs: |
378 | // Double_t x0 x position of point where charge is liberated |
379 | // Double_t y0 y position of point where charge is liberated |
380 | // Double_t z0 z position of point where charge is liberated |
381 | // Int_t ix0 row of cell corresponding to point x0 |
382 | // Int_t iz0 columb of cell corresponding to point z0 |
383 | // Double_t el number of electrons liberated in this step |
384 | // Double_t sig Sigma difusion for this step (y0 dependent) |
385 | // Int_t t track number |
386 | // Int_t ti hit track index number |
387 | // Int_t hi hit "hit" index number |
388 | // Outputs: |
389 | // none. |
390 | // Return: |
391 | // none. |
f74211b0 |
392 | const Int_t knx = 3,knz = 2; |
393 | const Double_t kRoot2 = 1.414213562; // Sqrt(2). |
394 | const Double_t kmictocm = 1.0e-4; // convert microns to cm. |
395 | Int_t ix,iz,ixs,ixe,izs,ize; |
396 | Float_t x,z; |
397 | Double_t x1,x2,z1,z2,s,sp; |
8ba39da9 |
398 | AliITSsegmentationSPD* seg = (AliITSsegmentationSPD*)GetSegmentationModel(0); |
399 | |
f74211b0 |
400 | |
aacedc3e |
401 | if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e," |
402 | "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sig,t,hi); |
403 | if(sig<=0.0) { // if sig<=0 No diffusion to simulate. |
404 | GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el); |
405 | if(GetDebug(2)){ |
406 | cout << "sig<=0.0=" << sig << endl; |
407 | } // end if GetDebug |
408 | return; |
f74211b0 |
409 | } // end if |
410 | sp = 1.0/(sig*kRoot2); |
aacedc3e |
411 | if(GetDebug(2)){ |
412 | cout << "sig=" << sig << " sp=" << sp << endl; |
413 | } // end if GetDebug |
f74211b0 |
414 | ixs = TMath::Max(-knx+ix0,0); |
8ba39da9 |
415 | ixe = TMath::Min(knx+ix0,seg->Npx()-1); |
f74211b0 |
416 | izs = TMath::Max(-knz+iz0,0); |
8ba39da9 |
417 | ize = TMath::Min(knz+iz0,seg->Npz()-1); |
f74211b0 |
418 | for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){ |
8ba39da9 |
419 | seg->DetToLocal(ix,iz,x,z); // pixel center |
aacedc3e |
420 | x1 = x; |
421 | z1 = z; |
8ba39da9 |
422 | x2 = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper |
423 | x1 -= 0.5*kmictocm*seg->Dpx(ix); // Lower |
424 | z2 = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper |
425 | z1 -= 0.5*kmictocm*seg->Dpz(iz); // Lower |
aacedc3e |
426 | x1 -= x0; // Distance from where track traveled |
427 | x2 -= x0; // Distance from where track traveled |
428 | z1 -= z0; // Distance from where track traveled |
429 | z2 -= z0; // Distance from where track traveled |
430 | s = 0.25; // Correction based on definision of Erfc |
431 | s *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2); |
432 | if(GetDebug(3)){ |
433 | cout <<"el="<<el<<" ix0="<<ix0<<" ix="<<ix<<" x0="<<x<< |
434 | " iz0="<<iz0<<" iz="<<iz<<" z0="<<z<< |
435 | " sp*x1="<<sp*x1<<" sp*x2="<<sp*x2<<" s="<<s; |
436 | } // end if GetDebug |
437 | s *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2); |
438 | if(GetDebug(3)){ |
439 | cout<<" sp*z1="<<sp*z1<<" sp*z2="<<sp*z2<<" s="<<s<< endl; |
440 | } // end if GetDebug |
441 | GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el); |
f74211b0 |
442 | } // end for ix, iz |
443 | } |
444 | //______________________________________________________________________ |
aacedc3e |
445 | void AliITSsimulationSPDdubna::pListToDigits(){ |
2cc6b29a |
446 | // add noise and electronics, perform the zero suppression and add the |
447 | // digit to the list |
12e7c97c |
448 | // Inputs: |
449 | // none. |
450 | // Outputs: |
451 | // none. |
452 | // Return: |
453 | // none. |
f74211b0 |
454 | static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS"); |
12e7c97c |
455 | Int_t j,ix,iz; |
aacedc3e |
456 | Double_t electronics; |
2cc6b29a |
457 | Double_t sig; |
ee86d557 |
458 | const Int_t nmaxtrk=AliITSdigitSPD::GetNTracks(); |
f74211b0 |
459 | static AliITSdigitSPD dig; |
fcf95fc7 |
460 | AliITSCalibrationSPD* res = (AliITSCalibrationSPD*)GetCalibrationModel(fDetType->GetITSgeom()->GetStartSPD()); |
aacedc3e |
461 | if(GetDebug(1)) Info("pListToDigits","()"); |
12e7c97c |
462 | for(iz=0; iz<GetNPixelsZ(); iz++) for(ix=0; ix<GetNPixelsX(); ix++){ |
aacedc3e |
463 | // Apply Noise/Dead channals and the like |
8ba39da9 |
464 | if(res->IsPixelDead(GetModuleNumber(),ix,iz)) continue; |
465 | electronics = res->ApplyBaselineAndNoise(); |
aacedc3e |
466 | UpdateMapNoise(ix,iz,electronics); |
467 | // |
468 | // Apply Threshold and write Digits. |
469 | sig = GetMap()->GetSignalOnly(iz,ix); |
470 | FillHistograms(ix,iz,sig+electronics); |
471 | if(GetDebug(3)){ |
472 | cout<<sig<<"+"<<electronics<<">threshold("<<ix<<","<<iz |
3600eb30 |
473 | <<")="<<GetThreshold() <<endl; |
aacedc3e |
474 | } // end if GetDebug |
3600eb30 |
475 | if (sig+electronics <= GetThreshold()) continue; |
aacedc3e |
476 | dig.SetCoord1(iz); |
477 | dig.SetCoord2(ix); |
478 | dig.SetSignal(1); |
479 | dig.SetSignalSPD((Int_t) GetMap()->GetSignal(iz,ix)); |
480 | for(j=0;j<nmaxtrk;j++){ |
9881a682 |
481 | if (j<GetMap()->GetNEntries()) { |
aacedc3e |
482 | dig.SetTrack(j,GetMap()->GetTrack(iz,ix,j)); |
483 | dig.SetHit(j,GetMap()->GetHit(iz,ix,j)); |
484 | }else { // Default values |
485 | dig.SetTrack(j,-3); |
486 | dig.SetHit(j,-1); |
487 | } // end if GetMap() |
488 | } // end for j |
489 | if(GetDebug(3)){ |
490 | cout<<iz<<","<<ix<<","<<*(GetMap()->GetpListItem(iz,ix))<<endl; |
491 | } // end if GetDebug |
492 | aliITS->AddSimDigit(0,&dig); |
12e7c97c |
493 | } // for ix/iz |
409f8c84 |
494 | } |
2cc6b29a |
495 | //______________________________________________________________________ |
496 | void AliITSsimulationSPDdubna::CreateHistograms(){ |
497 | // create 1D histograms for tests |
12e7c97c |
498 | // Inputs: |
499 | // none. |
500 | // Outputs: |
501 | // none. |
502 | // Return: |
503 | // none. |
2cc6b29a |
504 | |
aacedc3e |
505 | if(GetDebug(1)) Info("CreateHistograms","create histograms"); |
2cc6b29a |
506 | |
aacedc3e |
507 | fHis = new TObjArray(GetNPixelsZ()); |
508 | TString fSPDname("spd_"); |
509 | for(Int_t i=0;i<GetNPixelsZ();i++) { |
510 | Char_t pixelz[4]; |
511 | sprintf(pixelz,"%d",i); |
512 | fSPDname.Append(pixelz); |
513 | fHis->AddAt(new TH1F(fSPDname.Data(),"SPD maps", |
514 | GetNPixelsX(),0.,(Double_t)GetNPixelsX()),i); |
2cc6b29a |
515 | } // end for i |
409f8c84 |
516 | } |
2cc6b29a |
517 | //______________________________________________________________________ |
aacedc3e |
518 | void AliITSsimulationSPDdubna::FillHistograms(Int_t ix,Int_t iz,Double_t v){ |
519 | // Fill the histogram |
520 | // Inputs: |
521 | // none. |
522 | // Outputs: |
523 | // none. |
524 | // Return: |
525 | // none. |
526 | |
527 | if(!GetHistArray()) return; // Only fill if setup. |
528 | if(GetDebug(2)) Info("FillHistograms","fill histograms"); |
529 | GetHistogram(iz)->Fill(ix,v); |
530 | } |
531 | //______________________________________________________________________ |
2cc6b29a |
532 | void AliITSsimulationSPDdubna::ResetHistograms(){ |
409f8c84 |
533 | // Reset histograms for this detector |
12e7c97c |
534 | // Inputs: |
535 | // none. |
536 | // Outputs: |
537 | // none. |
538 | // Return: |
539 | // none. |
409f8c84 |
540 | |
aacedc3e |
541 | if(!GetHistArray()) return; // Only fill if setup. |
542 | if(GetDebug(2)) Info("FillHistograms","fill histograms"); |
12e7c97c |
543 | for ( int i=0;i<GetNPixelsZ();i++ ) { |
aacedc3e |
544 | if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset(); |
2cc6b29a |
545 | } // end for i |
409f8c84 |
546 | } |
12e7c97c |
547 | |
548 | //______________________________________________________________________ |
549 | void AliITSsimulationSPDdubna::SetCoupling(Int_t row, Int_t col, Int_t ntrack, |
550 | Int_t idhit) { |
551 | // Take into account the coupling between adiacent pixels. |
552 | // The parameters probcol and probrow are the probability of the |
553 | // signal in one pixel shared in the two adjacent pixels along |
554 | // the column and row direction, respectively. |
aacedc3e |
555 | // Note pList is goten via GetMap() and module is not need any more. |
556 | // Otherwise it is identical to that coded by Tiziano Virgili (BSN). |
12e7c97c |
557 | //Begin_Html |
558 | /* |
559 | <img src="picts/ITS/barimodel_3.gif"> |
560 | </pre> |
561 | <br clear=left> |
562 | <font size=+2 color=red> |
563 | <a href="mailto:tiziano.virgili@cern.ch"></a>. |
564 | </font> |
565 | <pre> |
566 | */ |
567 | //End_Html |
568 | // Inputs: |
569 | // Int_t row z cell index |
570 | // Int_t col x cell index |
571 | // Int_t ntrack track incex number |
572 | // Int_t idhit hit index number |
12e7c97c |
573 | // Outputs: |
574 | // none. |
575 | // Return: |
576 | // none. |
577 | Int_t j1,j2,flag=0; |
578 | Double_t pulse1,pulse2; |
aacedc3e |
579 | Double_t couplR=0.0,couplC=0.0; |
12e7c97c |
580 | Double_t xr=0.; |
12e7c97c |
581 | |
582 | GetCouplings(couplR,couplC); |
aacedc3e |
583 | if(GetDebug(3)) Info("SetCoupling","(row=%d,col=%d,ntrack=%d,idhit=%d) " |
584 | "Calling SetCoupling couplR=%e couplC=%e", |
585 | row,col,ntrack,idhit,couplR,couplC); |
12e7c97c |
586 | j1 = row; |
587 | j2 = col; |
aacedc3e |
588 | pulse1 = GetMap()->GetSignalOnly(row,col); |
12e7c97c |
589 | pulse2 = pulse1; |
590 | for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction |
aacedc3e |
591 | do{ |
592 | j1 += isign; |
593 | // pulse1 *= couplR; |
594 | xr = gRandom->Rndm(); |
3600eb30 |
595 | //if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){ |
aacedc3e |
596 | if ((j1<0) || (j1>GetNPixelsZ()-1) || (xr>couplR)){ |
597 | j1 = row; |
598 | flag = 1; |
599 | }else{ |
600 | UpdateMapSignal(col,j1,ntrack,idhit,pulse1); |
601 | // flag = 0; |
602 | flag = 1; // only first next!! |
603 | } // end if |
604 | } while(flag == 0); |
605 | // loop in column direction |
606 | do{ |
607 | j2 += isign; |
608 | // pulse2 *= couplC; |
609 | xr = gRandom->Rndm(); |
3600eb30 |
610 | //if((j2<0)||j2>(GetNPixelsX()-1)||pulse2<GetThreshold()){ |
aacedc3e |
611 | if ((j2<0) || (j2>GetNPixelsX()-1) || (xr>couplC)){ |
612 | j2 = col; |
613 | flag = 1; |
614 | }else{ |
615 | UpdateMapSignal(j2,row,ntrack,idhit,pulse2); |
616 | // flag = 0; |
617 | flag = 1; // only first next!! |
618 | } // end if |
619 | } while(flag == 0); |
12e7c97c |
620 | } // for isign |
621 | } |
622 | //______________________________________________________________________ |
623 | void AliITSsimulationSPDdubna::SetCouplingOld(Int_t row, Int_t col, |
624 | Int_t ntrack,Int_t idhit) { |
625 | // Take into account the coupling between adiacent pixels. |
626 | // The parameters probcol and probrow are the fractions of the |
627 | // signal in one pixel shared in the two adjacent pixels along |
628 | // the column and row direction, respectively. |
629 | //Begin_Html |
630 | /* |
631 | <img src="picts/ITS/barimodel_3.gif"> |
632 | </pre> |
633 | <br clear=left> |
634 | <font size=+2 color=red> |
635 | <a href="mailto:Rocco.Caliandro@ba.infn.it"></a>. |
636 | </font> |
637 | <pre> |
638 | */ |
639 | //End_Html |
640 | // Inputs: |
641 | // Int_t row z cell index |
642 | // Int_t col x cell index |
643 | // Int_t ntrack track incex number |
644 | // Int_t idhit hit index number |
645 | // Int_t module module number |
646 | // Outputs: |
647 | // none. |
648 | // Return: |
649 | // none. |
650 | Int_t j1,j2,flag=0; |
651 | Double_t pulse1,pulse2; |
aacedc3e |
652 | Double_t couplR=0.0,couplC=0.0; |
12e7c97c |
653 | |
654 | GetCouplings(couplR,couplC); |
aacedc3e |
655 | if(GetDebug(3)) Info("SetCouplingOld","(row=%d,col=%d,ntrack=%d,idhit=%d) " |
656 | "Calling SetCoupling couplR=%e couplC=%e", |
657 | row,col,ntrack,idhit,couplR,couplC); |
12e7c97c |
658 | j1 = row; |
659 | j2 = col; |
aacedc3e |
660 | pulse1 = GetMap()->GetSignalOnly(row,col); |
12e7c97c |
661 | pulse2 = pulse1; |
662 | for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction |
aacedc3e |
663 | do{ |
664 | j1 += isign; |
665 | pulse1 *= couplR; |
3600eb30 |
666 | if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1<GetThreshold())){ |
aacedc3e |
667 | pulse1 = GetMap()->GetSignalOnly(row,col); |
668 | j1 = row; |
669 | flag = 1; |
670 | }else{ |
671 | UpdateMapSignal(col,j1,ntrack,idhit,pulse1); |
672 | flag = 0; |
673 | } // end if |
674 | } while(flag == 0); |
675 | // loop in column direction |
676 | do{ |
677 | j2 += isign; |
678 | pulse2 *= couplC; |
3600eb30 |
679 | if((j2<0)||(j2>(GetNPixelsX()-1))||(pulse2<GetThreshold())){ |
aacedc3e |
680 | pulse2 = GetMap()->GetSignalOnly(row,col); |
681 | j2 = col; |
682 | flag = 1; |
683 | }else{ |
684 | UpdateMapSignal(j2,row,ntrack,idhit,pulse2); |
685 | flag = 0; |
686 | } // end if |
687 | } while(flag == 0); |
12e7c97c |
688 | } // for isign |
689 | } |