]>
Commit | Line | Data |
---|---|---|
b0f5e3fc | 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 | **************************************************************************/ | |
5c5273c2 | 15 | |
88cb7938 | 16 | /* $Id$ */ |
b0f5e3fc | 17 | |
4ae5bbc4 | 18 | #include <Riostream.h> |
b0f5e3fc | 19 | #include <stdlib.h> |
20 | #include <stdio.h> | |
29e923a3 | 21 | #include <cstring> |
1ca7869b | 22 | |
ece86d9a | 23 | #include <TCanvas.h> |
24 | #include <TF1.h> | |
1ca7869b | 25 | #include <TH1.h> |
26 | #include <TFile.h> | |
e939a978 | 27 | #include <TRandom.h> |
a1e17193 | 28 | #include <TROOT.h> |
e8189707 | 29 | #include "AliITS.h" |
e8189707 | 30 | #include "AliITSMapA2.h" |
e8189707 | 31 | #include "AliITSRawData.h" |
f77f13c8 | 32 | #include "AliITSdigitSPD.h" |
33 | #include "AliITSetfSDD.h" | |
f77f13c8 | 34 | #include "AliITSmodule.h" |
35 | #include "AliITSpList.h" | |
fcf95fc7 | 36 | #include "AliITSCalibrationSDD.h" |
f77f13c8 | 37 | #include "AliITSsegmentationSDD.h" |
1ca7869b | 38 | #include "AliITSsimulationSDD.h" |
f77f13c8 | 39 | #include "AliLog.h" |
40 | #include "AliRun.h" | |
b0f5e3fc | 41 | |
b0f5e3fc | 42 | ClassImp(AliITSsimulationSDD) |
43 | //////////////////////////////////////////////////////////////////////// | |
8ba39da9 | 44 | // Version: 0 // |
45 | // Written by Piergiorgio Cerello // | |
46 | // November 23 1999 // | |
47 | // // | |
48 | // AliITSsimulationSDD is the simulation of SDDs. // | |
49 | //////////////////////////////////////////////////////////////////////// | |
50 | ||
8a33ae9e | 51 | //______________________________________________________________________ |
aacedc3e | 52 | AliITSsimulationSDD::AliITSsimulationSDD(): |
53 | AliITSsimulation(), | |
54 | fITS(0), | |
55 | fHitMap2(0), | |
56 | fHitSigMap2(0), | |
57 | fHitNoiMap2(0), | |
aacedc3e | 58 | fElectronics(0), |
59 | fInZR(0), | |
60 | fInZI(0), | |
61 | fOutZR(0), | |
62 | fOutZI(0), | |
63 | fAnodeFire(0), | |
64 | fHis(0), | |
aacedc3e | 65 | fFlag(kFALSE), |
aacedc3e | 66 | fCrosstalkFlag(kFALSE), |
67 | fDoFFT(1), | |
68 | fNofMaps(0), | |
69 | fMaxNofSamples(0), | |
70 | fScaleSize(0){ | |
71 | // Default constructor | |
72 | SetScaleFourier(); | |
73 | SetPerpendTracksFlag(); | |
74 | SetCrosstalkFlag(); | |
75 | SetDoFFT(); | |
b0f5e3fc | 76 | } |
8a33ae9e | 77 | //______________________________________________________________________ |
7537d03c | 78 | AliITSsimulationSDD::AliITSsimulationSDD(const AliITSsimulationSDD &source) : |
79 | AliITSsimulation(source), | |
80 | fITS(source.fITS), | |
81 | fHitMap2(source.fHitMap2), | |
82 | fHitSigMap2(source.fHitSigMap2), | |
83 | fHitNoiMap2(source.fHitNoiMap2), | |
7537d03c | 84 | fElectronics(source.fElectronics), |
85 | fInZR(source.fInZR), | |
86 | fInZI(source.fInZI), | |
87 | fOutZR(source.fOutZR), | |
88 | fOutZI(source.fOutZI), | |
89 | fAnodeFire(source.fAnodeFire), | |
90 | fHis(source.fHis), | |
7537d03c | 91 | fFlag(source.fFlag), |
7537d03c | 92 | fCrosstalkFlag(source.fCrosstalkFlag), |
93 | fDoFFT(source.fDoFFT), | |
94 | fNofMaps(source.fNofMaps), | |
95 | fMaxNofSamples(source.fMaxNofSamples), | |
96 | fScaleSize(source.fScaleSize){ | |
aacedc3e | 97 | // Copy constructor to satify Coding roules only. |
8a33ae9e | 98 | |
b0f5e3fc | 99 | } |
8a33ae9e | 100 | //______________________________________________________________________ |
d2f55a22 | 101 | AliITSsimulationSDD& AliITSsimulationSDD::operator=(const AliITSsimulationSDD &src){ |
102 | // Assignment operator to satify Coding roules only. | |
103 | ||
104 | if(this==&src) return *this; | |
105 | Error("AliITSsimulationSDD","Not allowed to make a = with " | |
106 | "AliITSsimulationSDD Using default creater instead"); | |
107 | return *this ; | |
108 | } | |
85f5e9c2 | 109 | /* |
d2f55a22 | 110 | //______________________________________________________________________ |
5402d9ca | 111 | AliITSsimulation& AliITSsimulationSDD::operator=(const AliITSsimulation &src){ |
aacedc3e | 112 | // Assignment operator to satify Coding roules only. |
8a33ae9e | 113 | |
aacedc3e | 114 | if(this==&src) return *this; |
115 | Error("AliITSsimulationSSD","Not allowed to make a = with " | |
116 | "AliITSsimulationSDD Using default creater instead"); | |
117 | return *this ; | |
b0f5e3fc | 118 | } |
85f5e9c2 | 119 | */ |
8a33ae9e | 120 | //______________________________________________________________________ |
8ba39da9 | 121 | AliITSsimulationSDD::AliITSsimulationSDD(AliITSDetTypeSim* dettyp): |
122 | AliITSsimulation(dettyp), | |
aacedc3e | 123 | fITS(0), |
124 | fHitMap2(0), | |
125 | fHitSigMap2(0), | |
126 | fHitNoiMap2(0), | |
aacedc3e | 127 | fElectronics(0), |
128 | fInZR(0), | |
129 | fInZI(0), | |
130 | fOutZR(0), | |
131 | fOutZI(0), | |
132 | fAnodeFire(0), | |
133 | fHis(0), | |
aacedc3e | 134 | fFlag(kFALSE), |
aacedc3e | 135 | fCrosstalkFlag(kFALSE), |
136 | fDoFFT(1), | |
137 | fNofMaps(0), | |
138 | fMaxNofSamples(0), | |
139 | fScaleSize(0){ | |
f45f6658 | 140 | // Default Constructor |
141 | Init(); | |
c7a4dac0 | 142 | } |
143 | //______________________________________________________________________ | |
aacedc3e | 144 | void AliITSsimulationSDD::Init(){ |
145 | // Standard Constructor | |
146 | ||
147 | SetScaleFourier(); | |
148 | SetPerpendTracksFlag(); | |
149 | SetCrosstalkFlag(); | |
150 | SetDoFFT(); | |
aacedc3e | 151 | |
8ba39da9 | 152 | AliITSsegmentationSDD* seg = (AliITSsegmentationSDD*)GetSegmentationModel(1); |
153 | ||
cd2a0045 | 154 | AliITSSimuParam* simpar = fDetType->GetSimuParam(); |
8ba39da9 | 155 | fpList = new AliITSpList( seg->Npz(), |
156 | fScaleSize*seg->Npx() ); | |
157 | fHitSigMap2 = new AliITSMapA2(seg,fScaleSize,1); | |
158 | fHitNoiMap2 = new AliITSMapA2(seg,fScaleSize,1); | |
aacedc3e | 159 | fHitMap2 = fHitSigMap2; |
160 | ||
8ba39da9 | 161 | fNofMaps = seg->Npz(); |
162 | fMaxNofSamples = seg->Npx(); | |
aacedc3e | 163 | fAnodeFire = new Bool_t [fNofMaps]; |
43217ad9 | 164 | |
8ba39da9 | 165 | Float_t sddWidth = seg->Dz(); |
f6b6d58e | 166 | Float_t anodePitch = seg->Dpz(0); |
167 | Double_t timeStep = (Double_t)seg->Dpx(0); | |
aacedc3e | 168 | |
169 | if(anodePitch*(fNofMaps/2) > sddWidth) { | |
170 | Warning("AliITSsimulationSDD", | |
171 | "Too many anodes %d or too big pitch %f \n", | |
172 | fNofMaps/2,anodePitch); | |
173 | } // end if | |
b0f5e3fc | 174 | |
b0f5e3fc | 175 | |
aacedc3e | 176 | fElectronics = new AliITSetfSDD(timeStep/fScaleSize, |
cd2a0045 | 177 | simpar->GetSDDElectronics()); |
b0f5e3fc | 178 | |
aacedc3e | 179 | |
aacedc3e | 180 | fITS = (AliITS*)gAlice->GetModule("ITS"); |
20f3f947 | 181 | |
aacedc3e | 182 | fInZR = new Double_t [fScaleSize*fMaxNofSamples]; |
183 | fInZI = new Double_t [fScaleSize*fMaxNofSamples]; | |
184 | fOutZR = new Double_t [fScaleSize*fMaxNofSamples]; | |
185 | fOutZI = new Double_t [fScaleSize*fMaxNofSamples]; | |
b0f5e3fc | 186 | } |
8a33ae9e | 187 | //______________________________________________________________________ |
b0f5e3fc | 188 | AliITSsimulationSDD::~AliITSsimulationSDD() { |
aacedc3e | 189 | // destructor |
190 | ||
191 | // delete fpList; | |
192 | delete fHitSigMap2; | |
193 | delete fHitNoiMap2; | |
aacedc3e | 194 | delete fElectronics; |
195 | ||
196 | fITS = 0; | |
197 | ||
198 | if (fHis) { | |
199 | fHis->Delete(); | |
200 | delete fHis; | |
201 | } // end if fHis | |
aacedc3e | 202 | if(fInZR) delete [] fInZR; |
203 | if(fInZI) delete [] fInZI; | |
204 | if(fOutZR) delete [] fOutZR; | |
205 | if(fOutZI) delete [] fOutZI; | |
206 | if(fAnodeFire) delete [] fAnodeFire; | |
b0f5e3fc | 207 | } |
8a33ae9e | 208 | //______________________________________________________________________ |
50d05d7b | 209 | void AliITSsimulationSDD::InitSimulationModule( Int_t module, Int_t event ) { |
aacedc3e | 210 | // create maps to build the lists of tracks for each summable digit |
211 | fModule = module; | |
212 | fEvent = event; | |
213 | ClearMaps(); | |
214 | memset(fAnodeFire,0,sizeof(Bool_t)*fNofMaps); | |
50d05d7b | 215 | } |
216 | //______________________________________________________________________ | |
217 | void AliITSsimulationSDD::ClearMaps() { | |
aacedc3e | 218 | // clear maps |
219 | fpList->ClearMap(); | |
220 | fHitSigMap2->ClearMap(); | |
221 | fHitNoiMap2->ClearMap(); | |
50d05d7b | 222 | } |
20f3f947 | 223 | //______________________________________________________________________ |
224 | void AliITSsimulationSDD::FastFourierTransform(Double_t *real, | |
225 | Double_t *imag,Int_t direction) { | |
226 | // Do a Fast Fourier Transform | |
227 | ||
228 | Int_t samples = fElectronics->GetSamples(); | |
229 | Int_t l = (Int_t) ((log((Float_t) samples)/log(2.))+0.5); | |
230 | Int_t m1 = samples; | |
231 | Int_t m = samples/2; | |
232 | Int_t m2 = samples/m1; | |
233 | Int_t i,j,k; | |
234 | for(i=1; i<=l; i++) { | |
235 | for(j=0; j<samples; j += m1) { | |
236 | Int_t p = 0; | |
237 | for(k=j; k<= j+m-1; k++) { | |
238 | Double_t wsr = fElectronics->GetWeightReal(p); | |
239 | Double_t wsi = fElectronics->GetWeightImag(p); | |
240 | if(direction == -1) wsi = -wsi; | |
241 | Double_t xr = *(real+k+m); | |
242 | Double_t xi = *(imag+k+m); | |
243 | *(real+k+m) = wsr*(*(real+k)-xr) - wsi*(*(imag+k)-xi); | |
244 | *(imag+k+m) = wsr*(*(imag+k)-xi) + wsi*(*(real+k)-xr); | |
245 | *(real+k) += xr; | |
246 | *(imag+k) += xi; | |
247 | p += m2; | |
248 | } // end for k | |
249 | } // end for j | |
250 | m1 = m; | |
251 | m /= 2; | |
252 | m2 += m2; | |
253 | } // end for i | |
254 | ||
255 | for(j=0; j<samples; j++) { | |
256 | Int_t j1 = j; | |
257 | Int_t p = 0; | |
258 | Int_t i1; | |
259 | for(i1=1; i1<=l; i1++) { | |
260 | Int_t j2 = j1; | |
261 | j1 /= 2; | |
262 | p = p + p + j2 - j1 - j1; | |
263 | } // end for i1 | |
264 | if(p >= j) { | |
265 | Double_t xr = *(real+j); | |
266 | Double_t xi = *(imag+j); | |
267 | *(real+j) = *(real+p); | |
268 | *(imag+j) = *(imag+p); | |
269 | *(real+p) = xr; | |
270 | *(imag+p) = xi; | |
271 | } // end if p>=j | |
272 | } // end for j | |
273 | if(direction == -1) { | |
274 | for(i=0; i<samples; i++) { | |
275 | *(real+i) /= samples; | |
276 | *(imag+i) /= samples; | |
277 | } // end for i | |
278 | } // end if direction == -1 | |
279 | return; | |
280 | } | |
281 | ||
50d05d7b | 282 | //______________________________________________________________________ |
aacedc3e | 283 | void AliITSsimulationSDD::SDigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev){ |
284 | // digitize module using the "slow" detector simulator creating | |
285 | // summable digits. | |
286 | ||
287 | TObjArray *fHits = mod->GetHits(); | |
288 | Int_t nhits = fHits->GetEntriesFast(); | |
289 | if( !nhits ) return; | |
290 | ||
291 | InitSimulationModule( md, ev ); | |
5683bd96 | 292 | HitsToAnalogDigits( mod ); // fills fHitMap2 which is = fHitSigmap2 |
293 | ChargeToSignal( fModule,kFALSE,kTRUE ); // - Process signal adding gain without adding noise | |
aacedc3e | 294 | fHitMap2 = fHitNoiMap2; // - Swap to noise map |
5683bd96 | 295 | ChargeToSignal( fModule,kTRUE,kFALSE ); // - Process only noise |
aacedc3e | 296 | fHitMap2 = fHitSigMap2; // - Return to signal map |
297 | WriteSDigits(); | |
298 | ClearMaps(); | |
50d05d7b | 299 | } |
300 | //______________________________________________________________________ | |
aacedc3e | 301 | Bool_t AliITSsimulationSDD::AddSDigitsToModule(TClonesArray *pItemArray, |
302 | Int_t mask ) { | |
303 | // Add Summable digits to module maps. | |
cd2a0045 | 304 | AliITSSimuParam* simpar = fDetType->GetSimuParam(); |
aacedc3e | 305 | Int_t nItems = pItemArray->GetEntries(); |
cd2a0045 | 306 | Double_t maxadc = simpar->GetSDDMaxAdc(); |
aacedc3e | 307 | Bool_t sig = kFALSE; |
48058160 | 308 | |
aacedc3e | 309 | // cout << "Adding "<< nItems <<" SDigits to module " << fModule << endl; |
310 | for( Int_t i=0; i<nItems; i++ ) { | |
311 | AliITSpListItem * pItem = (AliITSpListItem *)(pItemArray->At( i )); | |
312 | if( pItem->GetModule() != fModule ) { | |
313 | Error( "AliITSsimulationSDD","Error reading, SDigits module " | |
314 | "%d != current module %d: exit", | |
315 | pItem->GetModule(), fModule ); | |
316 | return sig; | |
317 | } // end if | |
318 | ||
319 | if(pItem->GetSignal()>0.0 ) sig = kTRUE; | |
43217ad9 | 320 | |
aacedc3e | 321 | fpList->AddItemTo( mask, pItem ); // Add SignalAfterElect + noise |
322 | AliITSpListItem * pItem2 = fpList->GetpListItem( pItem->GetIndex() ); | |
323 | Double_t sigAE = pItem2->GetSignalAfterElect(); | |
324 | if( sigAE >= maxadc ) sigAE = maxadc-1; // avoid overflow signal | |
325 | Int_t ia; | |
326 | Int_t it; | |
327 | fpList->GetMapIndex( pItem->GetIndex(), ia, it ); | |
328 | fHitMap2->SetHit( ia, it, sigAE ); | |
329 | fAnodeFire[ia] = kTRUE; | |
330 | } | |
331 | return sig; | |
48058160 | 332 | } |
50d05d7b | 333 | //______________________________________________________________________ |
334 | void AliITSsimulationSDD::FinishSDigitiseModule() { | |
aacedc3e | 335 | // digitize module using the "slow" detector simulator from |
336 | // the sum of summable digits. | |
337 | FinishDigits() ; | |
338 | ClearMaps(); | |
c7a4dac0 | 339 | } |
340 | //______________________________________________________________________ | |
b0f5e3fc | 341 | void AliITSsimulationSDD::DigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev){ |
aacedc3e | 342 | // create maps to build the lists of tracks for each digit |
b0f5e3fc | 343 | |
aacedc3e | 344 | TObjArray *fHits = mod->GetHits(); |
345 | Int_t nhits = fHits->GetEntriesFast(); | |
8a33ae9e | 346 | |
aacedc3e | 347 | InitSimulationModule( md, ev ); |
20f3f947 | 348 | if( !nhits ) return; |
48058160 | 349 | |
aacedc3e | 350 | HitsToAnalogDigits( mod ); |
5683bd96 | 351 | ChargeToSignal( fModule,kTRUE,kTRUE ); // process signal + noise |
aacedc3e | 352 | |
353 | for( Int_t i=0; i<fNofMaps; i++ ) { | |
354 | for( Int_t j=0; j<fMaxNofSamples; j++ ) { | |
355 | Int_t jdx = j*fScaleSize; | |
356 | Int_t index = fpList->GetHitIndex( i, j ); | |
357 | AliITSpListItem pItemTmp2( fModule, index, 0. ); | |
358 | // put the fScaleSize analog digits in only one | |
359 | for( Int_t ik=0; ik<fScaleSize; ik++ ) { | |
360 | AliITSpListItem *pItemTmp = fpList->GetpListItem( i, jdx+ik ); | |
361 | if( pItemTmp == 0 ) continue; | |
362 | pItemTmp2.Add( pItemTmp ); | |
363 | } | |
364 | fpList->DeleteHit( i, j ); | |
365 | fpList->AddItemTo( 0, &pItemTmp2 ); | |
366 | } | |
48058160 | 367 | } |
aacedc3e | 368 | FinishDigits(); |
369 | ClearMaps(); | |
c7a4dac0 | 370 | } |
371 | //______________________________________________________________________ | |
50d05d7b | 372 | void AliITSsimulationSDD::FinishDigits() { |
aacedc3e | 373 | // introduce the electronics effects and do zero-suppression if required |
8a33ae9e | 374 | |
8ba39da9 | 375 | if( fCrosstalkFlag ) ApplyCrosstalk(fModule); |
50d05d7b | 376 | |
f45f6658 | 377 | AliITSCalibrationSDD* res = (AliITSCalibrationSDD*)GetCalibrationModel(fModule); |
253e68a0 | 378 | Bool_t isZeroSupp = res->GetZeroSupp(); |
379 | if (isZeroSupp) Compress2D(); | |
20f3f947 | 380 | else StoreAllDigits(); |
c7a4dac0 | 381 | } |
382 | //______________________________________________________________________ | |
50d05d7b | 383 | void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) { |
aacedc3e | 384 | // create maps to build the lists of tracks for each digit |
8ba39da9 | 385 | AliITSsegmentationSDD* seg = (AliITSsegmentationSDD*)GetSegmentationModel(1); |
f45f6658 | 386 | AliITSCalibrationSDD* res = (AliITSCalibrationSDD*)GetCalibrationModel(fModule); |
cd2a0045 | 387 | AliITSSimuParam* simpar = fDetType->GetSimuParam(); |
388 | ||
8ba39da9 | 389 | TObjArray *hits = mod->GetHits(); |
aacedc3e | 390 | Int_t nhits = hits->GetEntriesFast(); |
8ba39da9 | 391 | |
aacedc3e | 392 | // Int_t arg[6] = {0,0,0,0,0,0}; |
d35ad08f | 393 | Int_t nofAnodes = fNofMaps/2; |
394 | Double_t sddLength = seg->Dx(); | |
395 | Double_t sddWidth = seg->Dz(); | |
f6b6d58e | 396 | Double_t anodePitch = seg->Dpz(0); |
397 | Double_t timeStep = seg->Dpx(0); | |
4952f440 | 398 | Double_t driftSpeed ; // drift velocity (anode dependent) |
cd2a0045 | 399 | Double_t norm = simpar->GetSDDMaxAdc()/simpar->GetSDDDynamicRange(); // maxadc/topValue; |
400 | Double_t cHloss = simpar->GetSDDChargeLoss(); | |
401 | Float_t dfCoeff, s1; | |
402 | simpar->GetSDDDiffCoeff(dfCoeff,s1); // Signal 2d Shape | |
403 | Double_t eVpairs = simpar->GetGeVToCharge()*1.0E9; // 3.6 eV by def. | |
404 | Double_t nsigma = simpar->GetNSigmaIntegration(); // | |
405 | Int_t nlookups = simpar->GetGausNLookUp(); // | |
406 | Float_t jitter = simpar->GetSDDJitterError(); // | |
407 | ||
aacedc3e | 408 | // Piergiorgio's part (apart for few variables which I made float |
409 | // when i thought that can be done | |
410 | // Fill detector maps with GEANT hits | |
411 | // loop over hits in the module | |
412 | ||
413 | const Float_t kconv = 1.0e+6; // GeV->KeV | |
d35ad08f | 414 | Int_t itrack = 0; |
d35ad08f | 415 | Int_t iWing; // which detector wing/side. |
d35ad08f | 416 | Int_t ii,kk,ka,kt; // loop indexs |
417 | Int_t ia,it,index; // sub-pixel integration indexies | |
418 | Int_t iAnode; // anode number. | |
419 | Int_t timeSample; // time buckett. | |
420 | Int_t anodeWindow; // anode direction charge integration width | |
421 | Int_t timeWindow; // time direction charge integration width | |
422 | Int_t jamin,jamax; // anode charge integration window | |
423 | Int_t jtmin,jtmax; // time charge integration window | |
424 | Int_t ndiv; // Anode window division factor. | |
425 | Int_t nsplit; // the number of splits in anode and time windows==1. | |
426 | Int_t nOfSplits; // number of times track length is split into | |
427 | Float_t nOfSplitsF; // Floating point version of nOfSplits. | |
428 | Float_t kkF; // Floating point version of loop index kk. | |
429 | Double_t pathInSDD; // Track length in SDD. | |
430 | Double_t drPath; // average position of track in detector. in microns | |
431 | Double_t drTime; // Drift time | |
432 | Double_t nmul; // drift time window multiplication factor. | |
433 | Double_t avDrft; // x position of path length segment in cm. | |
434 | Double_t avAnode; // Anode for path length segment in Anode number (float) | |
f6b6d58e | 435 | Double_t zAnode; // Floating point anode number. |
d35ad08f | 436 | Double_t driftPath; // avDrft in microns. |
437 | Double_t width; // width of signal at anodes. | |
aacedc3e | 438 | Double_t depEnergy; // Energy deposited in this GEANT step. |
439 | Double_t xL[3],dxL[3]; // local hit coordinates and diff. | |
d35ad08f | 440 | Double_t sigA; // sigma of signal at anode. |
441 | Double_t sigT; // sigma in time/drift direction for track segment | |
442 | Double_t aStep,aConst; // sub-pixel size and offset anode | |
443 | Double_t tStep,tConst; // sub-pixel size and offset time | |
444 | Double_t amplitude; // signal amplitude for track segment in nanoAmpere | |
445 | Double_t chargeloss; // charge loss for track segment. | |
446 | Double_t anodeAmplitude; // signal amplitude in anode direction | |
447 | Double_t aExpo; // exponent of Gaussian anode direction | |
448 | Double_t timeAmplitude; // signal amplitude in time direction | |
449 | Double_t tExpo; // exponent of Gaussian time direction | |
aacedc3e | 450 | // Double_t tof; // Time of flight in ns of this step. |
451 | ||
452 | for(ii=0; ii<nhits; ii++) { | |
f6b6d58e | 453 | if(!mod->LineSegmentL(ii,xL[0],dxL[0],xL[1],dxL[1],xL[2],dxL[2], |
aacedc3e | 454 | depEnergy,itrack)) continue; |
f6b6d58e | 455 | Float_t xloc=xL[0]; |
456 | if(xloc>0) iWing=0; // left side, carlos channel 0 | |
457 | else iWing=1; // right side | |
458 | ||
459 | Float_t zloc=xL[2]+0.5*dxL[2]; | |
460 | zAnode=seg->GetAnodeFromLocal(xloc,zloc); // anode number in the range 0.-511. | |
461 | driftSpeed = res->GetDriftSpeedAtAnode(zAnode); | |
462 | if(timeStep*fMaxNofSamples < sddLength/driftSpeed) { | |
463 | AliWarning("Time Interval > Allowed Time Interval\n"); | |
464 | } | |
465 | depEnergy *= kconv; | |
aacedc3e | 466 | |
f6b6d58e | 467 | // scale path to simulate a perpendicular track |
468 | // continue if the particle did not lose energy | |
469 | // passing through detector | |
470 | if (!depEnergy) { | |
471 | AliDebug(1, | |
472 | Form("fTrack = %d hit=%d module=%d This particle has passed without losing energy!", | |
473 | itrack,ii,mod->GetIndex())); | |
474 | continue; | |
475 | } // end if !depEnergy | |
476 | ||
477 | xL[0] += 0.0001*gRandom->Gaus( 0, jitter ); // | |
478 | pathInSDD = TMath::Sqrt(dxL[0]*dxL[0]+dxL[1]*dxL[1]+dxL[2]*dxL[2]); | |
479 | ||
480 | if (fFlag && pathInSDD) { depEnergy *= (0.03/pathInSDD); } | |
481 | drPath = TMath::Abs(10000.*(dxL[0]+2.*xL[0])*0.5); | |
482 | drPath = sddLength-drPath; | |
483 | if(drPath < 0) { | |
484 | AliDebug(1, // this should be fixed at geometry level | |
485 | Form("negative drift path drPath=%e sddLength=%e dxL[0]=%e xL[0]=%e", | |
f77f13c8 | 486 | drPath,sddLength,dxL[0],xL[0])); |
f6b6d58e | 487 | continue; |
488 | } // end if drPath < 0 | |
aacedc3e | 489 | |
490 | // Compute number of segments to brake step path into | |
f6b6d58e | 491 | drTime = drPath/driftSpeed; // Drift Time |
492 | sigA = TMath::Sqrt(2.*dfCoeff*drTime+s1*s1);// Sigma along the anodes | |
493 | // calcuate the number of time the path length should be split into. | |
494 | nOfSplits = (Int_t) (1. + 10000.*pathInSDD/sigA); | |
495 | if(fFlag) nOfSplits = 1; | |
496 | ||
497 | // loop over path segments, init. some variables. | |
498 | depEnergy /= nOfSplits; | |
499 | nOfSplitsF = (Float_t) nOfSplits; | |
500 | Float_t theAverage=0.,theSteps=0.; | |
501 | for(kk=0;kk<nOfSplits;kk++) { // loop over path segments | |
502 | kkF = (Float_t) kk + 0.5; | |
503 | avDrft = xL[0]+dxL[0]*kkF/nOfSplitsF; | |
504 | avAnode = xL[2]+dxL[2]*kkF/nOfSplitsF; | |
505 | theSteps+=1.; | |
506 | theAverage+=avAnode; | |
507 | zAnode = seg->GetAnodeFromLocal(avDrft,avAnode); | |
508 | driftSpeed = res->GetDriftSpeedAtAnode(zAnode); | |
509 | driftPath = TMath::Abs(10000.*avDrft); | |
510 | driftPath = sddLength-driftPath; | |
511 | if(driftPath < 0) { | |
512 | AliDebug(1, // this should be fixed at geometry level | |
513 | Form("negative drift path driftPath=%e sddLength=%e avDrft=%e dxL[0]=%e xL[0]=%e", | |
514 | driftPath,sddLength,avDrft,dxL[0],xL[0])); | |
515 | continue; | |
516 | } // end if driftPath < 0 | |
517 | drTime = driftPath/driftSpeed; // drift time for segment. | |
518 | timeSample = (Int_t) (fScaleSize*drTime/timeStep + 1); // time bin in range 1-256 !!! | |
519 | if(timeSample > fScaleSize*fMaxNofSamples) { | |
520 | AliWarning(Form("Wrong Time Sample: %e",timeSample)); | |
521 | continue; | |
522 | } // end if timeSample > fScaleSize*fMaxNoofSamples | |
523 | ||
524 | if(zAnode>nofAnodes) zAnode-=nofAnodes; // to have the anode number between 0. and 256. | |
525 | if(zAnode*anodePitch > sddWidth || zAnode*anodePitch < 0.) | |
526 | AliWarning(Form("Exceeding sddWidth=%e Z = %e",sddWidth,zAnode*anodePitch)); | |
527 | iAnode = (Int_t) (1.+zAnode); // iAnode in range 1-256 !!!! | |
528 | if(iAnode < 1 || iAnode > nofAnodes) { | |
529 | AliWarning(Form("Wrong iAnode: 1<%d>%d (xanode=%e)",iAnode,nofAnodes, zAnode)); | |
530 | continue; | |
531 | } // end if iAnode < 1 || iAnode > nofAnodes | |
532 | ||
533 | // store straight away the particle position in the array | |
534 | // of particles and take idhit=ii only when part is entering (this | |
535 | // requires FillModules() in the macro for analysis) : | |
536 | ||
537 | // Sigma along the anodes for track segment. | |
538 | sigA = TMath::Sqrt(2.*dfCoeff*drTime+s1*s1); | |
539 | sigT = sigA/driftSpeed; | |
540 | // Peak amplitude in nanoAmpere | |
541 | amplitude = fScaleSize*160.*depEnergy/ | |
542 | (timeStep*eVpairs*2.*acos(-1.)*sigT*sigA); | |
543 | amplitude *= timeStep/25.; // WARNING!!!!! Amplitude scaling to | |
544 | // account for clock variations | |
545 | // (reference value: 40 MHz) | |
546 | chargeloss = 1.-cHloss*driftPath/1000.; | |
547 | amplitude *= chargeloss; | |
548 | width = 2.*nsigma/(nlookups-1); | |
549 | // Spread the charge | |
550 | // Pixel index | |
551 | ndiv = 2; | |
552 | nmul = 3.; | |
553 | if(drTime > 1200.) { | |
554 | ndiv = 4; | |
555 | nmul = 1.5; | |
556 | } // end if drTime > 1200. | |
557 | // Sub-pixel index | |
558 | nsplit = 4; // hard-wired //nsplit=4;nsplit = (nsplit+1)/2*2; | |
559 | // Sub-pixel size see computation of aExpo and tExpo. | |
560 | aStep = anodePitch/(nsplit*fScaleSize*sigA); | |
561 | aConst = zAnode*anodePitch/sigA; | |
562 | tStep = timeStep/(nsplit*fScaleSize*sigT); | |
563 | tConst = drTime/sigT; | |
564 | // Define SDD window corresponding to the hit | |
565 | anodeWindow = (Int_t)(fScaleSize*nsigma*sigA/anodePitch+1); | |
566 | timeWindow = (Int_t) (fScaleSize*nsigma*sigT/timeStep+1.); | |
567 | jamin = (iAnode - anodeWindow/ndiv - 2)*fScaleSize*nsplit +1; | |
568 | jamax = (iAnode + anodeWindow/ndiv + 1)*fScaleSize*nsplit; | |
569 | if(jamin <= 0) jamin = 1; | |
570 | if(jamax > fScaleSize*nofAnodes*nsplit) | |
571 | jamax = fScaleSize*nofAnodes*nsplit; | |
572 | // jtmin and jtmax are Hard-wired | |
573 | jtmin = (Int_t)(timeSample-timeWindow*nmul-1)*nsplit+1; | |
574 | jtmax = (Int_t)(timeSample+timeWindow*nmul)*nsplit; | |
575 | if(jtmin <= 0) jtmin = 1; | |
576 | if(jtmax > fScaleSize*fMaxNofSamples*nsplit) | |
577 | jtmax = fScaleSize*fMaxNofSamples*nsplit; | |
578 | // Spread the charge in the anode-time window | |
579 | for(ka=jamin; ka <=jamax; ka++) { | |
580 | ia = (ka-1)/(fScaleSize*nsplit) + 1; | |
581 | if(ia <= 0) { | |
582 | Warning("HitsToAnalogDigits","ia < 1: "); | |
583 | continue; | |
584 | } // end if | |
585 | if(ia > nofAnodes) ia = nofAnodes; | |
586 | aExpo = (aStep*(ka-0.5)-aConst); | |
587 | if(TMath::Abs(aExpo) > nsigma) anodeAmplitude = 0.; | |
588 | else { | |
589 | Int_t theBin = (Int_t) ((aExpo+nsigma)/width+0.5); | |
cd2a0045 | 590 | anodeAmplitude = amplitude*simpar->GetGausLookUp(theBin); |
f6b6d58e | 591 | } // end if TMath::Abs(aEspo) > nsigma |
592 | // index starts from 0 | |
593 | index = iWing*nofAnodes+ia-1; | |
594 | if(anodeAmplitude){ | |
595 | for(kt=jtmin; kt<=jtmax; kt++) { | |
596 | it = (kt-1)/nsplit+1; // it starts from 1 | |
597 | if(it<=0){ | |
598 | Warning("HitsToAnalogDigits","it < 1:"); | |
599 | continue; | |
600 | } // end if | |
601 | if(it>fScaleSize*fMaxNofSamples) | |
602 | it = fScaleSize*fMaxNofSamples; | |
603 | tExpo = (tStep*(kt-0.5)-tConst); | |
604 | if(TMath::Abs(tExpo) > nsigma) timeAmplitude = 0.; | |
605 | else { | |
606 | Int_t theBin = (Int_t) ((tExpo+nsigma)/width+0.5); | |
cd2a0045 | 607 | timeAmplitude = anodeAmplitude*simpar->GetGausLookUp(theBin); |
f6b6d58e | 608 | } // end if TMath::Abs(tExpo) > nsigma |
609 | // build the list of Sdigits for this module | |
610 | // arg[0] = index; | |
611 | // arg[1] = it; | |
612 | // arg[2] = itrack; // track number | |
613 | // arg[3] = ii-1; // hit number. | |
614 | timeAmplitude *= norm; | |
615 | timeAmplitude *= 10; | |
616 | // ListOfFiredCells(arg,timeAmplitude,alst,padr); | |
617 | Double_t charge = timeAmplitude; | |
618 | charge += fHitMap2->GetSignal(index,it-1); | |
619 | fHitMap2->SetHit(index, it-1, charge); | |
620 | fpList->AddSignal(index,it-1,itrack,ii-1, | |
621 | mod->GetIndex(),timeAmplitude); | |
622 | fAnodeFire[index] = kTRUE; | |
623 | } // end loop over time in window | |
624 | } // end if anodeAmplitude | |
625 | } // loop over anodes in window | |
626 | } // end loop over "sub-hits" | |
aacedc3e | 627 | } // end loop over hits |
b0f5e3fc | 628 | } |
aacedc3e | 629 | |
b0f5e3fc | 630 | //____________________________________________ |
83ec5e27 | 631 | void AliITSsimulationSDD::AddDigit( Int_t i, Int_t j, Int_t signalc, Int_t signale) { |
20f3f947 | 632 | // Adds a Digit. |
633 | Int_t size = AliITSdigit::GetNTracks(); | |
634 | ||
635 | Int_t digits[3]; | |
636 | Int_t * tracks = new Int_t[size]; | |
637 | Int_t * hits = new Int_t[size]; | |
638 | Float_t phys; | |
639 | Float_t * charges = new Float_t[size]; | |
640 | ||
641 | digits[0] = i; | |
642 | digits[1] = j; | |
83ec5e27 | 643 | digits[2] = signalc; |
20f3f947 | 644 | |
645 | AliITSpListItem *pItem = fpList->GetpListItem( i, j ); | |
646 | if( pItem == 0 ) { | |
647 | phys = 0.0; | |
648 | for( Int_t l=0; l<size; l++ ) { | |
649 | tracks[l] = 0; | |
650 | hits[l] = 0; | |
651 | charges[l] = 0.0; | |
50d05d7b | 652 | } |
20f3f947 | 653 | } else { |
654 | Int_t idtrack = pItem->GetTrack( 0 ); | |
655 | if( idtrack >= 0 ) phys = pItem->GetSignal(); | |
656 | else phys = 0.0; | |
657 | ||
658 | for( Int_t l=0; l<size; l++ ) if(l<pItem->GetMaxKept()) { | |
659 | tracks[l] = pItem->GetTrack( l ); | |
660 | hits[l] = pItem->GetHit( l ); | |
661 | charges[l] = pItem->GetSignal( l ); | |
662 | }else{ | |
663 | tracks[l] = -3; | |
664 | hits[l] = -1; | |
665 | charges[l] = 0.0; | |
666 | }// end for if | |
667 | } | |
50d05d7b | 668 | |
83ec5e27 | 669 | fITS->AddSimDigit( 1, phys, digits, tracks, hits, charges, signale ); |
20f3f947 | 670 | delete [] tracks; |
671 | delete [] hits; | |
672 | delete [] charges; | |
aacedc3e | 673 | } |
8a33ae9e | 674 | //______________________________________________________________________ |
5683bd96 | 675 | void AliITSsimulationSDD::ChargeToSignal(Int_t mod,Bool_t bAddNoise, Bool_t bAddGain) { |
676 | // add baseline, noise, gain, electronics and ADC saturation effects | |
677 | // apply dead channels | |
678 | ||
5683bd96 | 679 | AliITSCalibrationSDD* res = (AliITSCalibrationSDD*)GetCalibrationModel(mod); |
5683bd96 | 680 | Double_t baseline=0; |
681 | Double_t noise=0; | |
682 | Double_t gain=0; | |
683 | Float_t contrib=0; | |
684 | Int_t i,k,kk; | |
cd2a0045 | 685 | AliITSSimuParam* simpar = fDetType->GetSimuParam(); |
686 | Float_t maxadc = simpar->GetSDDMaxAdc(); | |
5683bd96 | 687 | |
688 | for (i=0;i<fNofMaps;i++) { | |
689 | if( !fAnodeFire[i] ) continue; | |
690 | baseline = res->GetBaseline(i); | |
691 | noise = res->GetNoise(i); | |
692 | gain = res->GetChannelGain(i); | |
eefec958 | 693 | if(res->IsBad()) gain=0.; |
13a2b50d | 694 | if( res->IsChipBad(res->GetChip(i)) )gain=0.; |
5683bd96 | 695 | for(k=0; k<fScaleSize*fMaxNofSamples; k++) { |
696 | fInZR[k] = fHitMap2->GetSignal(i,k); | |
697 | if(bAddGain) fInZR[k]*=gain; | |
698 | if( bAddNoise ) { | |
699 | contrib = (baseline + noise*gRandom->Gaus()); | |
700 | fInZR[k] += contrib; | |
701 | } | |
702 | fInZI[k] = 0.; | |
703 | } // end for k | |
aacedc3e | 704 | if(!fDoFFT) { |
5683bd96 | 705 | for(k=0; k<fMaxNofSamples; k++) { |
706 | Double_t newcont = 0.; | |
707 | Double_t maxcont = 0.; | |
708 | for(kk=0;kk<fScaleSize;kk++) { | |
709 | newcont = fInZR[fScaleSize*k+kk]; | |
710 | if(newcont > maxcont) maxcont = newcont; | |
711 | } // end for kk | |
712 | newcont = maxcont; | |
713 | if (newcont >= maxadc) newcont = maxadc -1; | |
714 | if(newcont >= baseline){ | |
715 | Warning("","newcont=%d>=baseline=%d",newcont,baseline); | |
716 | } // end if | |
717 | // back to analog: ? | |
718 | fHitMap2->SetHit(i,k,newcont); | |
719 | } // end for k | |
720 | }else{ | |
20f3f947 | 721 | FastFourierTransform(&fInZR[0],&fInZI[0],1); |
5683bd96 | 722 | for(k=0; k<fScaleSize*fMaxNofSamples; k++) { |
723 | Double_t rw = fElectronics->GetTraFunReal(k); | |
724 | Double_t iw = fElectronics->GetTraFunImag(k); | |
725 | fOutZR[k] = fInZR[k]*rw - fInZI[k]*iw; | |
726 | fOutZI[k] = fInZR[k]*iw + fInZI[k]*rw; | |
727 | } // end for k | |
20f3f947 | 728 | FastFourierTransform(&fOutZR[0],&fOutZI[0],-1); |
5683bd96 | 729 | for(k=0; k<fMaxNofSamples; k++) { |
730 | Double_t newcont1 = 0.; | |
731 | Double_t maxcont1 = 0.; | |
732 | for(kk=0;kk<fScaleSize;kk++) { | |
733 | newcont1 = fOutZR[fScaleSize*k+kk]; | |
734 | if(newcont1 > maxcont1) maxcont1 = newcont1; | |
735 | } // end for kk | |
736 | newcont1 = maxcont1; | |
737 | if (newcont1 >= maxadc) newcont1 = maxadc -1; | |
738 | fHitMap2->SetHit(i,k,newcont1); | |
739 | } // end for k | |
740 | } | |
741 | } // end for i loop over anodes | |
742 | return; | |
50d05d7b | 743 | } |
5683bd96 | 744 | |
50d05d7b | 745 | //______________________________________________________________________ |
8ba39da9 | 746 | void AliITSsimulationSDD::ApplyCrosstalk(Int_t mod) { |
aacedc3e | 747 | // function add the crosstalk effect to signal |
748 | // temporal function, should be checked...!!! | |
8ba39da9 | 749 | |
aacedc3e | 750 | // create and inizialice crosstalk map |
751 | Float_t* ctk = new Float_t[fNofMaps*fMaxNofSamples+1]; | |
752 | if( ctk == NULL ) { | |
753 | Error( "ApplyCrosstalk", "no memory for temporal map: exit \n" ); | |
754 | return; | |
755 | } | |
756 | memset( ctk, 0, sizeof(Float_t)*(fNofMaps*fMaxNofSamples+1) ); | |
f45f6658 | 757 | AliITSCalibrationSDD* calibr = (AliITSCalibrationSDD*)GetCalibrationModel(mod); |
aacedc3e | 758 | for( Int_t z=0; z<fNofMaps; z++ ) { |
f45f6658 | 759 | Double_t baseline = calibr->GetBaseline(z); |
aacedc3e | 760 | Bool_t on = kFALSE; |
761 | Int_t tstart = 0; | |
762 | Int_t tstop = 0; | |
763 | Int_t nTsteps = 0; | |
50d05d7b | 764 | |
aacedc3e | 765 | for( Int_t l=0; l<fMaxNofSamples; l++ ) { |
766 | Float_t fadc = (Float_t)fHitMap2->GetSignal( z, l ); | |
767 | if( fadc > baseline ) { | |
768 | if( on == kFALSE && l<fMaxNofSamples-4 ) { | |
769 | Float_t fadc1 = (Float_t)fHitMap2->GetSignal( z, l+1 ); | |
770 | if( fadc1 < fadc ) continue; | |
771 | on = kTRUE; | |
772 | nTsteps = 0; | |
773 | tstart = l; | |
774 | } | |
775 | nTsteps++; | |
776 | } | |
777 | else { // end fadc > baseline | |
778 | if( on == kTRUE ) { | |
779 | if( nTsteps > 2 ) { | |
780 | tstop = l; | |
781 | // make smooth derivative | |
782 | Float_t* dev = new Float_t[fMaxNofSamples+1]; | |
783 | memset( dev, 0, sizeof(Float_t)*(fMaxNofSamples+1) ); | |
784 | if( ctk == NULL ) { | |
785 | Error( "ApplyCrosstalk", | |
786 | "no memory for temporal array: exit \n" ); | |
787 | return; | |
788 | } | |
789 | for( Int_t i=tstart; i<tstop; i++ ) { | |
790 | if( i > 2 && i < fMaxNofSamples-2 ) | |
791 | dev[i] = -0.2*fHitMap2->GetSignal( z,i-2 ) | |
792 | -0.1*fHitMap2->GetSignal( z,i-1 ) | |
793 | +0.1*fHitMap2->GetSignal( z,i+1 ) | |
794 | +0.2*fHitMap2->GetSignal( z,i+2 ); | |
795 | } | |
50d05d7b | 796 | |
aacedc3e | 797 | // add crosstalk contribution to neibourg anodes |
798 | for( Int_t i=tstart; i<tstop; i++ ) { | |
799 | Int_t anode = z - 1; | |
800 | Int_t i1 = (Int_t)((i-tstart)*.61+tstart+0.5); // | |
801 | Float_t ctktmp = -dev[i1] * 0.25; | |
802 | if( anode > 0 ) { | |
803 | ctk[anode*fMaxNofSamples+i] += ctktmp; | |
804 | } | |
805 | anode = z + 1; | |
806 | if( anode < fNofMaps ) { | |
807 | ctk[anode*fMaxNofSamples+i] += ctktmp; | |
808 | } | |
809 | } | |
810 | delete [] dev; | |
50d05d7b | 811 | |
aacedc3e | 812 | } // if( nTsteps > 2 ) |
813 | on = kFALSE; | |
814 | } // if( on == kTRUE ) | |
815 | } // else | |
816 | } | |
3d2c9d72 | 817 | } |
50d05d7b | 818 | |
aacedc3e | 819 | for( Int_t a=0; a<fNofMaps; a++ ) |
820 | for( Int_t t=0; t<fMaxNofSamples; t++ ) { | |
821 | Float_t signal = fHitMap2->GetSignal(a,t)+ctk[a*fMaxNofSamples+t]; | |
822 | fHitMap2->SetHit( a, t, signal ); | |
823 | } | |
824 | ||
825 | delete [] ctk; | |
50d05d7b | 826 | } |
f45f6658 | 827 | |
8a33ae9e | 828 | //______________________________________________________________________ |
829 | Int_t AliITSsimulationSDD::Convert10to8(Int_t signal) const { | |
aacedc3e | 830 | // To the 10 to 8 bit lossive compression. |
831 | // code from Davide C. and Albert W. | |
832 | ||
833 | if (signal < 128) return signal; | |
834 | if (signal < 256) return (128+((signal-128)>>1)); | |
835 | if (signal < 512) return (192+((signal-256)>>3)); | |
836 | if (signal < 1024) return (224+((signal-512)>>4)); | |
837 | return 0; | |
b0f5e3fc | 838 | } |
8a33ae9e | 839 | //______________________________________________________________________ |
83ec5e27 | 840 | Int_t AliITSsimulationSDD::Convert8to10(Int_t signal) const { |
841 | // Decompression from 8 to 10 bit | |
842 | ||
843 | if (signal < 0 || signal > 255) { | |
844 | AliWarning(Form("Signal value %d out of range",signal)); | |
845 | return 0; | |
846 | } // end if signal <0 || signal >255 | |
847 | ||
848 | if (signal < 128) return signal; | |
849 | if (signal < 192) { | |
850 | if (TMath::Odd(signal)) return (128+((signal-128)<<1)); | |
851 | else return (128+((signal-128)<<1)+1); | |
852 | } // end if signal < 192 | |
853 | if (signal < 224) { | |
854 | if (TMath::Odd(signal)) return (256+((signal-192)<<3)+3); | |
855 | else return (256+((signal-192)<<3)+4); | |
856 | } // end if signal < 224 | |
857 | if (TMath::Odd(signal)) return (512+((signal-224)<<4)+7); | |
858 | return (512+((signal-224)<<4)+8); | |
859 | } | |
860 | //______________________________________________________________________ | |
b0f5e3fc | 861 | void AliITSsimulationSDD::Compress2D(){ |
20f3f947 | 862 | // 2D zero-suppression algorithm as described in ALICE-INT-1999-28 V10 |
863 | AliITSCalibrationSDD* res = (AliITSCalibrationSDD*)GetCalibrationModel(fModule); | |
20f3f947 | 864 | for (Int_t iWing=0; iWing<2; iWing++) { |
865 | Int_t tL=res->GetZSLowThreshold(iWing); | |
866 | Int_t tH=res->GetZSHighThreshold(iWing); | |
867 | for (Int_t i=0; i<fNofMaps/2; i++) { | |
868 | Int_t ian=i+iWing*fNofMaps/2; | |
869 | if( !fAnodeFire[ian] ) continue; | |
870 | for (Int_t itb=0; itb<fMaxNofSamples; itb++) { | |
8343dab6 | 871 | Int_t nLow=0, nHigh=0; |
20f3f947 | 872 | Float_t cC=fHitMap2->GetSignal(ian,itb); |
873 | if(cC<=tL) continue; | |
8343dab6 | 874 | nLow++; // cC is greater than tL |
875 | if(cC>tH) nHigh++; | |
20f3f947 | 876 | // N |
877 | // Get "quintuple": WCE | |
878 | // S | |
879 | Float_t wW=0.; | |
880 | if(itb>0) wW=fHitMap2->GetSignal(ian,itb-1); | |
8343dab6 | 881 | if(wW>tL) nLow++; |
882 | if(wW>tH) nHigh++; | |
20f3f947 | 883 | Float_t eE=0.; |
884 | if(itb<fMaxNofSamples-1) eE=fHitMap2->GetSignal(ian,itb+1); | |
8343dab6 | 885 | if(eE>tL) nLow++; |
886 | if(eE>tH) nHigh++; | |
20f3f947 | 887 | Float_t nN=0.; |
888 | if(i<(fNofMaps/2-1)) nN=fHitMap2->GetSignal(ian+1,itb); | |
8343dab6 | 889 | if(nN>tL) nLow++; |
890 | if(nN>tH) nHigh++; | |
20f3f947 | 891 | Float_t sS=0.; |
892 | if(i>0) sS=fHitMap2->GetSignal(ian-1,itb); | |
8343dab6 | 893 | if(sS>tL) nLow++; |
894 | if(sS>tH) nHigh++; | |
895 | ||
896 | if(nLow>=3 && nHigh>=1){ | |
83ec5e27 | 897 | Int_t signal=(Int_t)cC; |
898 | Int_t signalc = Convert10to8(signal); | |
899 | Int_t signale = Convert8to10(signalc); | |
900 | signalc-=tL; // subtract low threshold after 10 to 8 bit compression | |
901 | AddDigit(ian,itb,signalc,signale); // store C | |
20f3f947 | 902 | } |
903 | } | |
904 | } | |
905 | } | |
b0f5e3fc | 906 | } |
8ba39da9 | 907 | |
aacedc3e | 908 | |
8a33ae9e | 909 | //______________________________________________________________________ |
b0f5e3fc | 910 | void AliITSsimulationSDD::StoreAllDigits(){ |
fa4f0f62 | 911 | // store digits for non-zero-suppressed data |
912 | for (Int_t ian=0; ian<fNofMaps; ian++) { | |
913 | for (Int_t itb=0; itb<fMaxNofSamples; itb++){ | |
914 | Int_t signal=(Int_t)(fHitMap2->GetSignal(ian,itb)); | |
915 | Int_t signalc = Convert10to8(signal); | |
916 | Int_t signale = Convert8to10(signalc); | |
917 | AddDigit(ian,itb,signalc,signale); | |
918 | } | |
919 | } | |
b0f5e3fc | 920 | } |
8a33ae9e | 921 | //______________________________________________________________________ |
ece86d9a | 922 | void AliITSsimulationSDD::CreateHistograms(Int_t scale){ |
aacedc3e | 923 | // Creates histograms of maps for debugging |
924 | Int_t i; | |
925 | ||
926 | fHis=new TObjArray(fNofMaps); | |
927 | for (i=0;i<fNofMaps;i++) { | |
928 | TString sddName("sdd_"); | |
929 | Char_t candNum[4]; | |
930 | sprintf(candNum,"%d",i+1); | |
931 | sddName.Append(candNum); | |
932 | fHis->AddAt(new TH1F(sddName.Data(),"SDD maps",scale*fMaxNofSamples, | |
933 | 0.,(Float_t) scale*fMaxNofSamples), i); | |
934 | } // end for i | |
b0f5e3fc | 935 | } |
8a33ae9e | 936 | //______________________________________________________________________ |
ece86d9a | 937 | void AliITSsimulationSDD::FillHistograms(){ |
aacedc3e | 938 | // fill 1D histograms from map |
8a33ae9e | 939 | |
aacedc3e | 940 | if (!fHis) return; |
8a33ae9e | 941 | |
aacedc3e | 942 | for( Int_t i=0; i<fNofMaps; i++) { |
943 | TH1F *hist =(TH1F *)fHis->UncheckedAt(i); | |
944 | Int_t nsamples = hist->GetNbinsX(); | |
945 | for( Int_t j=0; j<nsamples; j++) { | |
946 | Double_t signal=fHitMap2->GetSignal(i,j); | |
947 | hist->Fill((Float_t)j,signal); | |
948 | } // end for j | |
949 | } // end for i | |
ece86d9a | 950 | } |
8a33ae9e | 951 | //______________________________________________________________________ |
b0f5e3fc | 952 | void AliITSsimulationSDD::ResetHistograms(){ |
aacedc3e | 953 | // Reset histograms for this detector |
954 | Int_t i; | |
8a33ae9e | 955 | |
aacedc3e | 956 | for (i=0;i<fNofMaps;i++ ) { |
957 | if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset(); | |
958 | } // end for i | |
b0f5e3fc | 959 | } |
8a33ae9e | 960 | //______________________________________________________________________ |
b0f5e3fc | 961 | TH1F *AliITSsimulationSDD::GetAnode(Int_t wing, Int_t anode) { |
aacedc3e | 962 | // Fills a histogram from a give anode. |
8a33ae9e | 963 | |
aacedc3e | 964 | if (!fHis) return 0; |
8a33ae9e | 965 | |
aacedc3e | 966 | if(wing <=0 || wing > 2) { |
967 | Warning("GetAnode","Wrong wing number: %d",wing); | |
968 | return NULL; | |
969 | } // end if wing <=0 || wing >2 | |
970 | if(anode <=0 || anode > fNofMaps/2) { | |
971 | Warning("GetAnode","Wrong anode number: %d",anode); | |
972 | return NULL; | |
973 | } // end if ampde <=0 || andoe > fNofMaps/2 | |
8a33ae9e | 974 | |
aacedc3e | 975 | Int_t index = (wing-1)*fNofMaps/2 + anode-1; |
976 | return (TH1F*)(fHis->At(index)); | |
b0f5e3fc | 977 | } |
8a33ae9e | 978 | //______________________________________________________________________ |
b0f5e3fc | 979 | void AliITSsimulationSDD::WriteToFile(TFile *hfile) { |
aacedc3e | 980 | // Writes the histograms to a file |
b0f5e3fc | 981 | |
aacedc3e | 982 | if (!fHis) return; |
8a33ae9e | 983 | |
aacedc3e | 984 | hfile->cd(); |
985 | Int_t i; | |
986 | for(i=0; i<fNofMaps; i++) fHis->At(i)->Write(); //fAdcs[i]->Write(); | |
987 | return; | |
b0f5e3fc | 988 | } |
8a33ae9e | 989 | //______________________________________________________________________ |
50d05d7b | 990 | void AliITSsimulationSDD::WriteSDigits(){ |
aacedc3e | 991 | // Fills the Summable digits Tree |
992 | static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS"); | |
993 | ||
994 | for( Int_t i=0; i<fNofMaps; i++ ) { | |
995 | if( !fAnodeFire[i] ) continue; | |
f6b6d58e | 996 | for( Int_t j=0; j<fMaxNofSamples; j++ ) { |
aacedc3e | 997 | Double_t sig = fHitMap2->GetSignal( i, j ); |
998 | if( sig > 0.2 ) { | |
999 | Int_t jdx = j*fScaleSize; | |
1000 | Int_t index = fpList->GetHitIndex( i, j ); | |
1001 | AliITSpListItem pItemTmp2( fModule, index, 0. ); | |
1002 | // put the fScaleSize analog digits in only one | |
1003 | for( Int_t ik=0; ik<fScaleSize; ik++ ) { | |
1004 | AliITSpListItem *pItemTmp = fpList->GetpListItem(i,jdx+ik); | |
1005 | if( pItemTmp == 0 ) continue; | |
1006 | pItemTmp2.Add( pItemTmp ); | |
1007 | } | |
1008 | pItemTmp2.AddSignalAfterElect( fModule, index, sig ); | |
1009 | pItemTmp2.AddNoise(fModule,index,fHitNoiMap2->GetSignal(i,j)); | |
1010 | aliITS->AddSumDigit( pItemTmp2 ); | |
1011 | } // end if (sig > 0.2) | |
1012 | } | |
48058160 | 1013 | } |
aacedc3e | 1014 | return; |
b0f5e3fc | 1015 | } |
8a33ae9e | 1016 | //______________________________________________________________________ |
d2f55a22 | 1017 | void AliITSsimulationSDD::PrintStatus() const { |
aacedc3e | 1018 | // Print SDD simulation Parameters |
1019 | ||
1020 | cout << "**************************************************" << endl; | |
1021 | cout << " Silicon Drift Detector Simulation Parameters " << endl; | |
1022 | cout << "**************************************************" << endl; | |
1023 | cout << "Flag for Perpendicular tracks: " << (Int_t) fFlag << endl; | |
aacedc3e | 1024 | cout << "Flag to switch off electronics: " << (Int_t) fDoFFT << endl; |
20f3f947 | 1025 | cout << "Number of Anodes used: " << fNofMaps << endl; |
aacedc3e | 1026 | cout << "Number of Time Samples: " << fMaxNofSamples << endl; |
1027 | cout << "Scale size factor: " << fScaleSize << endl; | |
1028 | cout << "**************************************************" << endl; | |
44a312c3 | 1029 | } |