]>
Commit | Line | Data |
---|---|---|
517b7f8f | 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 | ||
16 | //_________________________________________________________________________ | |
17 | // This is a TTask that constructs SDigits out of Hits | |
ea7a588a | 18 | // A Summable Digits is the "sum" of all hits in a pad |
19 | // Detector response has been simulated via the method | |
20 | // SimulateDetectorResponse | |
517b7f8f | 21 | // |
ea7a588a | 22 | //-- Authors: F. Pierella, A. De Caro |
23 | // Use case: see AliTOFhits2sdigits.C macro in the CVS | |
517b7f8f | 24 | ////////////////////////////////////////////////////////////////////////////// |
25 | ||
ea7a588a | 26 | #include "TBenchmark.h" |
517b7f8f | 27 | #include "TTask.h" |
28 | #include "TTree.h" | |
29 | #include "TSystem.h" | |
ea7a588a | 30 | #include "TParticle.h" |
31 | #include "TH1.h" | |
bfec09a6 | 32 | #include "TFile.h" |
33 | #include "TROOT.h" | |
34 | #include "TFolder.h" | |
35 | #include <TF1.h> | |
36 | #include <stdlib.h> | |
37 | #include <iostream.h> | |
38 | #include <fstream.h> | |
517b7f8f | 39 | |
5919c40c | 40 | #include "AliTOFHitMap.h" |
41 | #include "AliTOFSDigit.h" | |
f73548c4 | 42 | #include "AliTOFConstants.h" |
517b7f8f | 43 | #include "AliTOFhit.h" |
44 | #include "AliTOF.h" | |
45 | #include "AliTOFv1.h" | |
46 | #include "AliTOFv2.h" | |
47 | #include "AliTOFv3.h" | |
48 | #include "AliTOFv4.h" | |
49 | #include "AliTOFSDigitizer.h" | |
50 | #include "AliRun.h" | |
51 | #include "AliDetector.h" | |
52 | #include "AliMC.h" | |
53 | ||
517b7f8f | 54 | |
55 | ClassImp(AliTOFSDigitizer) | |
56 | ||
57 | //____________________________________________________________________________ | |
58 | AliTOFSDigitizer::AliTOFSDigitizer():TTask("AliTOFSDigitizer","") | |
59 | { | |
60 | // ctor | |
ea7a588a | 61 | fEvent1=0; |
62 | fEvent2=0; | |
f73548c4 | 63 | ftail = 0; |
517b7f8f | 64 | } |
65 | ||
66 | //____________________________________________________________________________ | |
bfec09a6 | 67 | AliTOFSDigitizer::AliTOFSDigitizer(char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("AliTOFSDigitizer","") |
517b7f8f | 68 | { |
ea7a588a | 69 | fEvent1=evNumber1; |
70 | fEvent2=fEvent1+nEvents; | |
f73548c4 | 71 | ftail = 0; |
72 | ||
ea7a588a | 73 | fHeadersFile = HeaderFile ; // input filename (with hits) |
ea7a588a | 74 | TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data() ) ; |
75 | ||
76 | //File was not opened yet | |
77 | // open file and get alirun object | |
78 | if(file == 0){ | |
79 | file = TFile::Open(fHeadersFile.Data(),"update") ; | |
80 | gAlice = (AliRun *) file->Get("gAlice") ; | |
81 | } | |
82 | ||
f73548c4 | 83 | // init parameters for sdigitization |
84 | InitParameters(); | |
85 | ||
517b7f8f | 86 | // add Task to //root/Tasks folder |
87 | TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ; | |
88 | roottasks->Add(this) ; | |
89 | } | |
90 | ||
91 | //____________________________________________________________________________ | |
92 | AliTOFSDigitizer::~AliTOFSDigitizer() | |
93 | { | |
94 | // dtor | |
f73548c4 | 95 | } |
96 | ||
97 | //____________________________________________________________________________ | |
98 | void AliTOFSDigitizer::InitParameters() | |
99 | { | |
100 | // set parameters for detector simulation | |
101 | ||
102 | fTimeResolution =0.120; | |
103 | fpadefficiency =0.99 ; | |
104 | fEdgeEffect = 2 ; | |
105 | fEdgeTails = 0 ; | |
106 | fHparameter = 0.4 ; | |
107 | fH2parameter = 0.15; | |
108 | fKparameter = 0.5 ; | |
109 | fK2parameter = 0.35; | |
110 | fEffCenter = fpadefficiency; | |
111 | fEffBoundary = 0.65; | |
112 | fEff2Boundary = 0.90; | |
113 | fEff3Boundary = 0.08; | |
114 | fResCenter = 50. ; | |
115 | fResBoundary = 70. ; | |
116 | fResSlope = 40. ; | |
117 | fTimeWalkCenter = 0. ; | |
118 | fTimeWalkBoundary=0. ; | |
119 | fTimeWalkSlope = 0. ; | |
120 | fTimeDelayFlag = 1 ; | |
121 | fPulseHeightSlope=2.0 ; | |
122 | fTimeDelaySlope =0.060; | |
123 | // was fMinimumCharge = TMath::Exp(fPulseHeightSlope*fKparameter/2.); | |
124 | fMinimumCharge = TMath::Exp(-fPulseHeightSlope*fHparameter); | |
125 | fChargeSmearing=0.0 ; | |
126 | fLogChargeSmearing=0.13; | |
127 | fTimeSmearing =0.022; | |
128 | fAverageTimeFlag=0 ; | |
ea7a588a | 129 | fTdcBin = 50.; // 1 TDC bin = 50 ps |
130 | fAdcBin = 0.25; // 1 ADC bin = 0.25 pC (or 0.03 pC) | |
131 | fAdcMean = 50.; // ADC distribution mpv value for Landau (in bins) | |
132 | // it corresponds to a mean value of ~100 bins | |
133 | fAdcRms = 25.; // ADC distribution rms value (in bins) | |
134 | // it corresponds to distribution rms ~50 bins | |
f73548c4 | 135 | } |
136 | ||
137 | //__________________________________________________________________ | |
ea7a588a | 138 | Double_t TimeWithTail(Double_t* x, Double_t* par) |
f73548c4 | 139 | { |
140 | // sigma - par[0], alpha - par[1], part - par[2] | |
141 | // at x<part*sigma - gauss | |
142 | // at x>part*sigma - TMath::Exp(-x/alpha) | |
143 | Float_t xx =x[0]; | |
144 | Double_t f; | |
145 | if(xx<par[0]*par[2]) { | |
146 | f = TMath::Exp(-xx*xx/(2*par[0]*par[0])); | |
147 | } else { | |
148 | f = TMath::Exp(-(xx-par[0]*par[2])/par[1]-0.5*par[2]*par[2]); | |
149 | } | |
150 | return f; | |
517b7f8f | 151 | } |
152 | ||
f73548c4 | 153 | |
517b7f8f | 154 | //____________________________________________________________________________ |
ea7a588a | 155 | void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) { |
517b7f8f | 156 | |
ea7a588a | 157 | if(strstr(verboseOption,"tim") || strstr(verboseOption,"all")) |
158 | gBenchmark->Start("TOFSDigitizer"); | |
517b7f8f | 159 | |
517b7f8f | 160 | AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF"); |
161 | ||
5919c40c | 162 | if (!TOF) { |
163 | Error("AliTOFSDigitizer","TOF not found"); | |
164 | return; | |
165 | } | |
166 | ||
ea7a588a | 167 | if (fEdgeTails) ftail = new TF1("tail",TimeWithTail,-2,2,3); |
168 | ||
169 | Int_t nselectedHits=0; | |
170 | Int_t ntotalsdigits=0; | |
171 | Int_t ntotalupdates=0; | |
172 | Int_t nnoisesdigits=0; | |
173 | Int_t nsignalsdigits=0; | |
174 | Int_t nHitsFromPrim=0; | |
175 | Int_t nHitsFromSec=0; | |
176 | Int_t nlargeTofDiff=0; | |
f73548c4 | 177 | |
ea7a588a | 178 | if (strstr(allEvents,"all")){ |
179 | fEvent1=0; | |
180 | fEvent2= (Int_t) gAlice->TreeE()->GetEntries(); | |
181 | } | |
182 | ||
183 | for (Int_t ievent = fEvent1; ievent < fEvent2; ievent++) { | |
184 | cout << "------------------- "<< GetName() << " -------------" << endl ; | |
185 | cout << "Sdigitizing event " << ievent << endl; | |
186 | ||
187 | Int_t nselectedHitsinEv=0; | |
188 | Int_t ntotalsdigitsinEv=0; | |
189 | Int_t ntotalupdatesinEv=0; | |
190 | Int_t nnoisesdigitsinEv=0; | |
191 | Int_t nsignalsdigitsinEv=0; | |
517b7f8f | 192 | |
5919c40c | 193 | gAlice->GetEvent(ievent); |
194 | TTree *TH = gAlice->TreeH (); | |
195 | if (!TH) | |
196 | return; | |
197 | if (gAlice->TreeS () == 0) | |
198 | gAlice->MakeTree ("S"); | |
517b7f8f | 199 | |
200 | ||
5919c40c | 201 | //Make branches |
202 | char branchname[20]; | |
203 | sprintf (branchname, "%s", TOF->GetName ()); | |
204 | //Make branch for digits | |
205 | TOF->MakeBranch ("S"); | |
517b7f8f | 206 | |
5919c40c | 207 | //Now made SDigits from hits |
208 | ||
209 | Int_t vol[5]; // location for a digit | |
210 | Float_t digit[2]; // TOF digit variables | |
211 | TParticle *particle; | |
212 | AliTOFhit *tofHit; | |
213 | TClonesArray *TOFhits = TOF->Hits(); | |
214 | ||
f73548c4 | 215 | // create hit map |
5919c40c | 216 | AliTOFHitMap *hitMap = new AliTOFHitMap(TOF->SDigits()); |
217 | ||
bfec09a6 | 218 | // decrease required CPU time |
219 | TH->SetBranchStatus("*",0); // switch off all branches | |
220 | TH->SetBranchStatus("TOF*",1); // switch on only TOF | |
221 | ||
5919c40c | 222 | Int_t ntracks = static_cast<Int_t>(TH->GetEntries()); |
223 | for (Int_t track = 0; track < ntracks; track++) | |
224 | { | |
225 | gAlice->ResetHits(); | |
226 | TH->GetEvent(track); | |
227 | particle = gAlice->Particle(track); | |
228 | Int_t nhits = TOFhits->GetEntriesFast(); | |
f73548c4 | 229 | // cleaning all hits of the same track in the same pad volume |
230 | // it is a rare event, however it happens | |
231 | ||
232 | Int_t previousTrack =0; | |
233 | Int_t previousSector=0; | |
234 | Int_t previousPlate =0; | |
235 | Int_t previousStrip =0; | |
236 | Int_t previousPadX =0; | |
237 | Int_t previousPadZ =0; | |
5919c40c | 238 | |
239 | for (Int_t hit = 0; hit < nhits; hit++) | |
240 | { | |
241 | tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit); | |
f73548c4 | 242 | Int_t tracknum = tofHit->GetTrack(); |
5919c40c | 243 | vol[0] = tofHit->GetSector(); |
244 | vol[1] = tofHit->GetPlate(); | |
245 | vol[2] = tofHit->GetStrip(); | |
246 | vol[3] = tofHit->GetPadx(); | |
247 | vol[4] = tofHit->GetPadz(); | |
248 | ||
ea7a588a | 249 | Bool_t dummy=((tracknum==previousTrack) && (vol[0]==previousSector) && (vol[1]==previousPlate) && (vol[2]==previousStrip)); |
250 | ||
251 | Bool_t isCloneOfThePrevious=dummy && ((vol[3]==previousPadX) && (vol[4]==previousPadZ)); | |
252 | ||
253 | // much stronger check to be inserted here | |
254 | ||
f73548c4 | 255 | if(!isCloneOfThePrevious){ |
256 | // update "previous" values | |
257 | // in fact, we are yet in the future, so the present is past | |
258 | previousTrack=tracknum; | |
259 | previousSector=vol[0]; | |
260 | previousPlate=vol[1]; | |
261 | previousStrip=vol[2]; | |
262 | previousPadX=vol[3]; | |
263 | previousPadZ=vol[4]; | |
5919c40c | 264 | |
ea7a588a | 265 | nselectedHits++; |
266 | nselectedHitsinEv++; | |
267 | if (particle->GetFirstMother() < 0){ | |
268 | nHitsFromPrim++; | |
269 | } // counts hits due to primary particles | |
270 | ||
271 | Float_t Xpad = tofHit->GetDx(); | |
272 | Float_t Zpad = tofHit->GetDz(); | |
273 | Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad; | |
274 | Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad; | |
275 | Float_t geantTime = tofHit->GetTof(); // unit [s] | |
276 | geantTime *= 1.e+09; // conversion from [s] to [ns] | |
277 | ||
278 | //cout << "geantTime " << geantTime << " [ns]" << endl; | |
279 | Int_t nActivatedPads = 0, nFiredPads = 0; | |
280 | Bool_t isFired[4] = {kFALSE, kFALSE, kFALSE, kFALSE}; | |
281 | Float_t tofAfterSimul[4] = {0., 0., 0., 0.}; | |
282 | Float_t qInduced[4] = {0.,0.,0.,0.}; | |
283 | Int_t nPlace[4] = {0, 0, 0, 0}; | |
284 | Float_t averageTime = 0.; | |
285 | SimulateDetectorResponse(zStrip,xStrip,geantTime,nActivatedPads,nFiredPads,isFired,nPlace,qInduced,tofAfterSimul,averageTime); | |
286 | if(nFiredPads) { | |
287 | for(Int_t indexOfPad=0; indexOfPad<nActivatedPads; indexOfPad++) { | |
288 | if(isFired[indexOfPad]){ // the pad has fired | |
289 | Float_t timediff=geantTime-tofAfterSimul[indexOfPad]; | |
290 | ||
291 | if(timediff>=0.2) nlargeTofDiff++; | |
292 | ||
293 | digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/fTdcBin); // TDC bin number (each bin -> 25. ps) | |
294 | ||
295 | Float_t landauFactor = gRandom->Landau(fAdcMean, fAdcRms); | |
296 | digit[1] = (Int_t) (qInduced[indexOfPad] * landauFactor); // ADC bins (each bin -> 0.25 (or 0.03) pC) | |
297 | ||
298 | // recalculate the volume only for neighbouring pads | |
299 | if(indexOfPad){ | |
300 | (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[4] = 1 : vol[4] = 2; | |
301 | (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[3] = nPlace[indexOfPad] : vol[3] = nPlace[indexOfPad] - AliTOFConstants::fgkNpadX; | |
302 | } | |
303 | ||
304 | // check if two sdigit are on the same pad; in that case we sum | |
305 | // the two or more sdigits | |
306 | if (hitMap->TestHit(vol) != kEmpty) { | |
307 | AliTOFSDigit *sdig = static_cast<AliTOFSDigit*>(hitMap->GetHit(vol)); | |
308 | Int_t tdctime = (Int_t) digit[0]; | |
309 | Int_t adccharge = (Int_t) digit[1]; | |
310 | sdig->Update(tdctime,adccharge,tracknum); | |
311 | ntotalupdatesinEv++; | |
312 | ntotalupdates++; | |
313 | } else { | |
314 | ||
315 | TOF->AddSDigit(tracknum, vol, digit); | |
316 | ||
317 | if(indexOfPad){ | |
318 | nnoisesdigits++; | |
319 | nnoisesdigitsinEv++; | |
320 | } else { | |
321 | nsignalsdigits++; | |
322 | nsignalsdigitsinEv++; | |
323 | } | |
324 | ntotalsdigitsinEv++; | |
325 | ntotalsdigits++; | |
326 | hitMap->SetHit(vol); | |
327 | } // if (hitMap->TestHit(vol) != kEmpty) | |
328 | } // if(isFired[indexOfPad]) | |
329 | } // end loop on nActivatedPads | |
330 | } // if(nFiredPads) i.e. if some pads has fired | |
f73548c4 | 331 | } // close if(!isCloneOfThePrevious) |
5919c40c | 332 | } // end loop on hits for the current track |
333 | } // end loop on ntracks | |
334 | ||
335 | delete hitMap; | |
517b7f8f | 336 | |
5919c40c | 337 | gAlice->TreeS()->Reset(); |
338 | gAlice->TreeS()->Fill(); | |
ea7a588a | 339 | //gAlice->TreeS()->Write(0,TObject::kOverwrite) ; |
340 | gAlice->TreeS()->AutoSave(); | |
341 | ||
342 | if(strstr(verboseOption,"all")){ | |
343 | cout << "----------------------------------------" << endl; | |
344 | cout << " <AliTOFSDigitizer> " << endl; | |
345 | cout << "After sdigitizing " << nselectedHitsinEv << " hits" << " in event " << ievent << endl; | |
346 | //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, " | |
347 | cout << ntotalsdigitsinEv << " digits have been created " << endl; | |
348 | cout << "(" << nsignalsdigitsinEv << " due to signals and " << nnoisesdigitsinEv << " due to border effect)" << endl; | |
349 | cout << ntotalupdatesinEv << " total updates of the hit map have been performed in current event" << endl; | |
350 | cout << "----------------------------------------" << endl; | |
351 | } | |
352 | ||
353 | } //event loop on events | |
354 | ||
355 | // free used memory | |
356 | if (ftail){ | |
357 | delete ftail; | |
358 | ftail = 0; | |
359 | } | |
360 | ||
361 | nHitsFromSec=nselectedHits-nHitsFromPrim; | |
362 | if(strstr(verboseOption,"all")){ | |
363 | cout << "----------------------------------------" << endl; | |
364 | cout << "----------------------------------------" << endl; | |
365 | cout << "-----------SDigitization Summary--------" << endl; | |
366 | cout << " <AliTOFSDigitizer> " << endl; | |
367 | cout << "After sdigitizing " << nselectedHits << " hits" << endl; | |
368 | cout << "in " << (fEvent2-fEvent1) << " events" << endl; | |
369 | //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, " | |
370 | cout << ntotalsdigits << " sdigits have been created " << endl; | |
371 | cout << "(" << nsignalsdigits << " due to signals and " << nnoisesdigits << " due to border effect)" << endl; | |
372 | cout << ntotalupdates << " total updates of the hit map have been performed" << endl; | |
373 | cout << "in " << nlargeTofDiff << " cases the time of flight difference is greater than 200 ps" << endl; | |
374 | } | |
375 | ||
517b7f8f | 376 | |
ea7a588a | 377 | if(strstr(verboseOption,"tim") || strstr(verboseOption,"all")){ |
378 | gBenchmark->Stop("TOFSDigitizer"); | |
379 | cout << "AliTOFSDigitizer:" << endl ; | |
380 | cout << " took " << gBenchmark->GetCpuTime("TOFSDigitizer") << " seconds in order to make sdigits " | |
381 | << gBenchmark->GetCpuTime("TOFSDigitizer")/(fEvent2-fEvent1) << " seconds per event " << endl ; | |
382 | cout << endl ; | |
383 | } | |
517b7f8f | 384 | |
ea7a588a | 385 | Print(""); |
517b7f8f | 386 | } |
ea7a588a | 387 | |
517b7f8f | 388 | //__________________________________________________________________ |
ea7a588a | 389 | void AliTOFSDigitizer::Print(Option_t* opt)const |
517b7f8f | 390 | { |
391 | cout << "------------------- "<< GetName() << " -------------" << endl ; | |
bfec09a6 | 392 | |
517b7f8f | 393 | } |
f73548c4 | 394 | |
395 | //__________________________________________________________________ | |
396 | void AliTOFSDigitizer::SimulateDetectorResponse(Float_t z0, Float_t x0, Float_t geantTime, Int_t& nActivatedPads, Int_t& nFiredPads, Bool_t* isFired, Int_t* nPlace, Float_t* qInduced, Float_t* tofTime, Float_t& averageTime) | |
397 | { | |
398 | // Description: | |
399 | // Input: z0, x0 - hit position in the strip system (0,0 - center of the strip), cm | |
400 | // geantTime - time generated by Geant, ns | |
401 | // Output: nActivatedPads - the number of pads activated by the hit (1 || 2 || 4) | |
402 | // nFiredPads - the number of pads fired (really activated) by the hit (nFiredPads <= nActivatedPads) | |
403 | // qInduced[iPad]- charge induced on pad, arb. units | |
404 | // this array is initialized at zero by the caller | |
405 | // tofAfterSimul[iPad] - time calculated with edge effect algorithm, ns | |
406 | // this array is initialized at zero by the caller | |
407 | // averageTime - time given by pad hited by the Geant track taking into account the times (weighted) given by the pads fired for edge effect also. | |
408 | // The weight is given by the qInduced[iPad]/qCenterPad | |
409 | // this variable is initialized at zero by the caller | |
410 | // nPlace[iPad] - the number of the pad place, iPad = 0, 1, 2, 3 | |
411 | // this variable is initialized at zero by the caller | |
412 | // | |
413 | // Description of used variables: | |
414 | // eff[iPad] - efficiency of the pad | |
415 | // res[iPad] - resolution of the pad, ns | |
416 | // timeWalk[iPad] - time walk of the pad, ns | |
417 | // timeDelay[iPad] - time delay for neighbouring pad to hited pad, ns | |
418 | // PadId[iPad] - Pad Identifier | |
419 | // E | F --> PadId[iPad] = 5 | 6 | |
420 | // A | B --> PadId[iPad] = 1 | 2 | |
421 | // C | D --> PadId[iPad] = 3 | 4 | |
422 | // nTail[iPad] - the tail number, = 1 for tailA, = 2 for tailB | |
423 | // qCenterPad - charge extimated for each pad, arb. units | |
424 | // weightsSum - sum of weights extimated for each pad fired, arb. units | |
425 | ||
426 | const Float_t kSigmaForTail[2] = {AliTOFConstants::fgkSigmaForTail1,AliTOFConstants::fgkSigmaForTail2}; //for tail | |
427 | Int_t iz = 0, ix = 0; | |
428 | Float_t dX = 0., dZ = 0., x = 0., z = 0.; | |
429 | Float_t h = fHparameter, h2 = fH2parameter, k = fKparameter, k2 = fK2parameter; | |
430 | Float_t effX = 0., effZ = 0., resX = 0., resZ = 0., timeWalkX = 0., timeWalkZ = 0.; | |
431 | Float_t logOfqInd = 0.; | |
432 | Float_t weightsSum = 0.; | |
433 | Int_t nTail[4] = {0,0,0,0}; | |
434 | Int_t padId[4] = {0,0,0,0}; | |
435 | Float_t eff[4] = {0.,0.,0.,0.}; | |
436 | Float_t res[4] = {0.,0.,0.,0.}; | |
437 | // Float_t qCenterPad = fMinimumCharge * fMinimumCharge; | |
438 | Float_t qCenterPad = 1.; | |
439 | Float_t timeWalk[4] = {0.,0.,0.,0.}; | |
440 | Float_t timeDelay[4] = {0.,0.,0.,0.}; | |
441 | ||
442 | nActivatedPads = 0; | |
443 | nFiredPads = 0; | |
444 | ||
445 | (z0 <= 0) ? iz = 0 : iz = 1; | |
446 | dZ = z0 + (0.5 * AliTOFConstants::fgkNpadZ - iz - 0.5) * AliTOFConstants::fgkZPad; // hit position in the pad frame, (0,0) - center of the pad | |
447 | z = 0.5 * AliTOFConstants::fgkZPad - TMath::Abs(dZ); // variable for eff., res. and timeWalk. functions | |
448 | iz++; // z row: 1, ..., AliTOFConstants::fgkNpadZ = 2 | |
449 | ix = (Int_t)((x0 + 0.5 * AliTOFConstants::fgkNpadX * AliTOFConstants::fgkXPad) / AliTOFConstants::fgkXPad); | |
450 | dX = x0 + (0.5 * AliTOFConstants::fgkNpadX - ix - 0.5) * AliTOFConstants::fgkXPad; // hit position in the pad frame, (0,0) - center of the pad | |
451 | x = 0.5 * AliTOFConstants::fgkXPad - TMath::Abs(dX); // variable for eff., res. and timeWalk. functions; | |
452 | ix++; // x row: 1, ..., AliTOFConstants::fgkNpadX = 48 | |
453 | ||
454 | ////// Pad A: | |
455 | nActivatedPads++; | |
456 | nPlace[nActivatedPads-1] = (iz - 1) * AliTOFConstants::fgkNpadX + ix; | |
457 | qInduced[nActivatedPads-1] = qCenterPad; | |
458 | padId[nActivatedPads-1] = 1; | |
459 | ||
460 | if (fEdgeEffect == 0) { | |
461 | eff[nActivatedPads-1] = fEffCenter; | |
462 | if (gRandom->Rndm() < eff[nActivatedPads-1]) { | |
463 | nFiredPads = 1; | |
464 | res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + fResCenter * fResCenter); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns; | |
465 | isFired[nActivatedPads-1] = kTRUE; | |
466 | tofTime[nActivatedPads-1] = gRandom->Gaus(geantTime + fTimeWalkCenter, res[0]); | |
467 | averageTime = tofTime[nActivatedPads-1]; | |
468 | } | |
469 | } else { | |
470 | ||
471 | if(z < h) { | |
472 | if(z < h2) { | |
473 | effZ = fEffBoundary + (fEff2Boundary - fEffBoundary) * z / h2; | |
474 | } else { | |
475 | effZ = fEff2Boundary + (fEffCenter - fEff2Boundary) * (z - h2) / (h - h2); | |
476 | } | |
477 | resZ = fResBoundary + (fResCenter - fResBoundary) * z / h; | |
478 | timeWalkZ = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * z / h; | |
479 | nTail[nActivatedPads-1] = 1; | |
480 | } else { | |
481 | effZ = fEffCenter; | |
482 | resZ = fResCenter; | |
483 | timeWalkZ = fTimeWalkCenter; | |
484 | } | |
485 | ||
486 | if(x < h) { | |
487 | if(x < h2) { | |
488 | effX = fEffBoundary + (fEff2Boundary - fEffBoundary) * x / h2; | |
489 | } else { | |
490 | effX = fEff2Boundary + (fEffCenter - fEff2Boundary) * (x - h2) / (h - h2); | |
491 | } | |
492 | resX = fResBoundary + (fResCenter - fResBoundary) * x / h; | |
493 | timeWalkX = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * x / h; | |
494 | nTail[nActivatedPads-1] = 1; | |
495 | } else { | |
496 | effX = fEffCenter; | |
497 | resX = fResCenter; | |
498 | timeWalkX = fTimeWalkCenter; | |
499 | } | |
500 | ||
501 | (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX; | |
502 | (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns | |
503 | (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns | |
504 | ||
505 | ||
506 | ////// Pad B: | |
507 | if(z < k2) { | |
508 | effZ = fEffBoundary - (fEffBoundary - fEff3Boundary) * (z / k2); | |
509 | } else { | |
510 | effZ = fEff3Boundary * (k - z) / (k - k2); | |
511 | } | |
512 | resZ = fResBoundary + fResSlope * z / k; | |
513 | timeWalkZ = fTimeWalkBoundary + fTimeWalkSlope * z / k; | |
514 | ||
515 | if(z < k && z > 0) { | |
516 | if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) { | |
517 | nActivatedPads++; | |
518 | nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX; | |
519 | eff[nActivatedPads-1] = effZ; | |
520 | res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns | |
521 | timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ; // ns | |
522 | nTail[nActivatedPads-1] = 2; | |
523 | if (fTimeDelayFlag) { | |
524 | // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.); | |
525 | // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.); | |
526 | qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z); | |
527 | logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing); | |
528 | timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing); | |
529 | } else { | |
530 | timeDelay[nActivatedPads-1] = 0.; | |
531 | } | |
532 | padId[nActivatedPads-1] = 2; | |
533 | } | |
534 | } | |
535 | ||
536 | ||
537 | ////// Pad C, D, E, F: | |
538 | if(x < k2) { | |
539 | effX = fEffBoundary - (fEffBoundary - fEff3Boundary) * (x / k2); | |
540 | } else { | |
541 | effX = fEff3Boundary * (k - x) / (k - k2); | |
542 | } | |
543 | resX = fResBoundary + fResSlope*x/k; | |
544 | timeWalkX = fTimeWalkBoundary + fTimeWalkSlope*x/k; | |
545 | ||
546 | if(x < k && x > 0) { | |
547 | // C: | |
548 | if(ix > 1 && dX < 0) { | |
549 | nActivatedPads++; | |
550 | nPlace[nActivatedPads-1] = nPlace[0] - 1; | |
551 | eff[nActivatedPads-1] = effX; | |
552 | res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns | |
553 | timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns | |
554 | nTail[nActivatedPads-1] = 2; | |
555 | if (fTimeDelayFlag) { | |
556 | // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.); | |
557 | // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.); | |
558 | qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x); | |
559 | logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing); | |
560 | timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing); | |
561 | } else { | |
562 | timeDelay[nActivatedPads-1] = 0.; | |
563 | } | |
564 | padId[nActivatedPads-1] = 3; | |
565 | ||
566 | // D: | |
567 | if(z < k && z > 0) { | |
568 | if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) { | |
569 | nActivatedPads++; | |
570 | nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX - 1; | |
571 | eff[nActivatedPads-1] = effX * effZ; | |
572 | (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns | |
573 | (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns | |
574 | ||
575 | nTail[nActivatedPads-1] = 2; | |
576 | if (fTimeDelayFlag) { | |
577 | if (TMath::Abs(x) < TMath::Abs(z)) { | |
578 | // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.); | |
579 | // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.); | |
580 | qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z); | |
581 | logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing); | |
582 | } else { | |
583 | // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.); | |
584 | // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.); | |
585 | qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x); | |
586 | logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing); | |
587 | } | |
588 | timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing); | |
589 | } else { | |
590 | timeDelay[nActivatedPads-1] = 0.; | |
591 | } | |
592 | padId[nActivatedPads-1] = 4; | |
593 | } | |
594 | } // end D | |
595 | } // end C | |
596 | ||
597 | // E: | |
598 | if(ix < AliTOFConstants::fgkNpadX && dX > 0) { | |
599 | nActivatedPads++; | |
600 | nPlace[nActivatedPads-1] = nPlace[0] + 1; | |
601 | eff[nActivatedPads-1] = effX; | |
602 | res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(10400 + resX * resX)); // ns | |
603 | timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns | |
604 | nTail[nActivatedPads-1] = 2; | |
605 | if (fTimeDelayFlag) { | |
606 | // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.); | |
607 | // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.); | |
608 | qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x); | |
609 | logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing); | |
610 | timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing); | |
611 | } else { | |
612 | timeDelay[nActivatedPads-1] = 0.; | |
613 | } | |
614 | padId[nActivatedPads-1] = 5; | |
615 | ||
616 | ||
617 | // F: | |
618 | if(z < k && z > 0) { | |
619 | if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) { | |
620 | nActivatedPads++; | |
621 | nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX + 1; | |
622 | eff[nActivatedPads - 1] = effX * effZ; | |
623 | (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns | |
624 | (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001*timeWalkX; // ns | |
625 | nTail[nActivatedPads-1] = 2; | |
626 | if (fTimeDelayFlag) { | |
627 | if (TMath::Abs(x) < TMath::Abs(z)) { | |
628 | // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.); | |
629 | // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.); | |
630 | qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z); | |
631 | logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing); | |
632 | } else { | |
633 | // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.); | |
634 | // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.); | |
635 | qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x); | |
636 | logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing); | |
637 | } | |
638 | timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing); | |
639 | } else { | |
640 | timeDelay[nActivatedPads-1] = 0.; | |
641 | } | |
642 | padId[nActivatedPads-1] = 6; | |
643 | } | |
644 | } // end F | |
645 | } // end E | |
646 | } // end if(x < k) | |
647 | ||
648 | ||
649 | for (Int_t iPad = 0; iPad < nActivatedPads; iPad++) { | |
650 | if (res[iPad] < fTimeResolution) res[iPad] = fTimeResolution; | |
651 | if(gRandom->Rndm() < eff[iPad]) { | |
652 | isFired[iPad] = kTRUE; | |
653 | nFiredPads++; | |
654 | if(fEdgeTails) { | |
655 | if(nTail[iPad] == 0) { | |
656 | tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]); | |
657 | } else { | |
658 | ftail->SetParameters(res[iPad], 2. * res[iPad], kSigmaForTail[nTail[iPad]-1]); | |
659 | Double_t timeAB = ftail->GetRandom(); | |
660 | tofTime[iPad] = geantTime + timeWalk[iPad] + timeDelay[iPad] + timeAB; | |
661 | } | |
662 | } else { | |
663 | tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]); | |
664 | } | |
665 | if (fAverageTimeFlag) { | |
666 | averageTime += tofTime[iPad] * qInduced[iPad]; | |
667 | weightsSum += qInduced[iPad]; | |
668 | } else { | |
669 | averageTime += tofTime[iPad]; | |
670 | weightsSum += 1.; | |
671 | } | |
672 | } | |
673 | } | |
674 | if (weightsSum!=0) averageTime /= weightsSum; | |
675 | } // end else (fEdgeEffect != 0) | |
676 | } | |
677 | ||
678 | //__________________________________________________________________ | |
679 | void AliTOFSDigitizer::PrintParameters()const | |
680 | { | |
681 | // | |
682 | // Print parameters used for sdigitization | |
683 | // | |
684 | cout << " ------------------- "<< GetName() << " -------------" << endl ; | |
685 | cout << " Parameters used for TOF SDigitization " << endl ; | |
686 | // Printing the parameters | |
687 | ||
ea7a588a | 688 | cout << " Number of events: " << (fEvent2-fEvent1) << endl; |
689 | cout << " from event " << fEvent1 << " to event " << (fEvent2-1) << endl; | |
f73548c4 | 690 | cout << " Time Resolution (ns) "<< fTimeResolution <<" Pad Efficiency: "<< fpadefficiency << endl; |
691 | cout << " Edge Effect option: "<< fEdgeEffect<< endl; | |
692 | ||
693 | cout << " Boundary Effect Simulation Parameters " << endl; | |
694 | cout << " Hparameter: "<< fHparameter<<" H2parameter:"<< fH2parameter <<" Kparameter:"<< fKparameter<<" K2parameter: "<< fK2parameter << endl; | |
695 | cout << " Efficiency in the central region of the pad: "<< fEffCenter << endl; | |
696 | cout << " Efficiency at the boundary region of the pad: "<< fEffBoundary << endl; | |
697 | cout << " Efficiency value at H2parameter "<< fEff2Boundary << endl; | |
698 | cout << " Efficiency value at K2parameter "<< fEff3Boundary << endl; | |
699 | cout << " Resolution (ps) in the central region of the pad: "<< fResCenter << endl; | |
700 | cout << " Resolution (ps) at the boundary of the pad : "<< fResBoundary << endl; | |
701 | cout << " Slope (ps/K) for neighbouring pad : "<< fResSlope <<endl; | |
702 | cout << " Time walk (ps) in the central region of the pad : "<< fTimeWalkCenter << endl; | |
703 | cout << " Time walk (ps) at the boundary of the pad : "<< fTimeWalkBoundary<< endl; | |
704 | cout << " Slope (ps/K) for neighbouring pad : "<< fTimeWalkSlope<<endl; | |
705 | cout << " Pulse Heigth Simulation Parameters " << endl; | |
706 | cout << " Flag for delay due to the PulseHeightEffect: "<< fTimeDelayFlag <<endl; | |
707 | cout << " Pulse Height Slope : "<< fPulseHeightSlope<<endl; | |
708 | cout << " Time Delay Slope : "<< fTimeDelaySlope<<endl; | |
709 | cout << " Minimum charge amount which could be induced : "<< fMinimumCharge<<endl; | |
710 | cout << " Smearing in charge in (q1/q2) vs x plot : "<< fChargeSmearing<<endl; | |
711 | cout << " Smearing in log of charge ratio : "<< fLogChargeSmearing<<endl; | |
712 | cout << " Smearing in time in time vs log(q1/q2) plot : "<< fTimeSmearing<<endl; | |
713 | cout << " Flag for average time : "<< fAverageTimeFlag<<endl; | |
714 | cout << " Edge tails option : "<< fEdgeTails << endl; | |
715 | ||
716 | } |