1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //_________________________________________________________________________
17 // This is a TTask that constructs SDigits out of Hits
18 // A Summable Digits is the "sum" of all hits in a pad
19 // Detector response has been simulated via the method
20 // SimulateDetectorResponse
22 //-- Authors: F. Pierella, A. De Caro
23 // Use case: see AliTOFhits2sdigits.C macro in the CVS
24 //////////////////////////////////////////////////////////////////////////////
26 #include "TBenchmark.h"
31 #include "TParticle.h"
34 #include "AliTOFHitMap.h"
35 #include "AliTOFSDigit.h"
36 #include "AliTOFConstants.h"
37 #include "AliTOFhit.h"
43 #include "AliTOFSDigitizer.h"
45 #include "AliDetector.h"
59 ClassImp(AliTOFSDigitizer)
61 //____________________________________________________________________________
62 AliTOFSDigitizer::AliTOFSDigitizer():TTask("AliTOFSDigitizer","")
71 //____________________________________________________________________________
72 AliTOFSDigitizer::AliTOFSDigitizer(char* HeaderFile,char *SdigitsFile, Int_t evNumber1, Int_t nEvents):TTask("AliTOFSDigitizer","")
75 fEvent2=fEvent1+nEvents;
79 fHeadersFile = HeaderFile ; // input filename (with hits)
80 fSDigitsFile = SdigitsFile; // output filename for sdigits
81 TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data() ) ;
83 //File was not opened yet
84 // open file and get alirun object
86 file = TFile::Open(fHeadersFile.Data(),"update") ;
87 gAlice = (AliRun *) file->Get("gAlice") ;
90 // init parameters for sdigitization
93 // add Task to //root/Tasks folder
94 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
95 roottasks->Add(this) ;
98 //____________________________________________________________________________
99 AliTOFSDigitizer::~AliTOFSDigitizer()
109 //____________________________________________________________________________
110 void AliTOFSDigitizer::InitParameters()
112 // set parameters for detector simulation
114 fTimeResolution =0.120;
115 fpadefficiency =0.99 ;
122 fEffCenter = fpadefficiency;
124 fEff2Boundary = 0.90;
125 fEff3Boundary = 0.08;
129 fTimeWalkCenter = 0. ;
130 fTimeWalkBoundary=0. ;
131 fTimeWalkSlope = 0. ;
133 fPulseHeightSlope=2.0 ;
134 fTimeDelaySlope =0.060;
135 // was fMinimumCharge = TMath::Exp(fPulseHeightSlope*fKparameter/2.);
136 fMinimumCharge = TMath::Exp(-fPulseHeightSlope*fHparameter);
137 fChargeSmearing=0.0 ;
138 fLogChargeSmearing=0.13;
139 fTimeSmearing =0.022;
141 fTdcBin = 50.; // 1 TDC bin = 50 ps
142 fAdcBin = 0.25; // 1 ADC bin = 0.25 pC (or 0.03 pC)
143 fAdcMean = 50.; // ADC distribution mpv value for Landau (in bins)
144 // it corresponds to a mean value of ~100 bins
145 fAdcRms = 25.; // ADC distribution rms value (in bins)
146 // it corresponds to distribution rms ~50 bins
149 //__________________________________________________________________
150 Double_t TimeWithTail(Double_t* x, Double_t* par)
152 // sigma - par[0], alpha - par[1], part - par[2]
153 // at x<part*sigma - gauss
154 // at x>part*sigma - TMath::Exp(-x/alpha)
157 if(xx<par[0]*par[2]) {
158 f = TMath::Exp(-xx*xx/(2*par[0]*par[0]));
160 f = TMath::Exp(-(xx-par[0]*par[2])/par[1]-0.5*par[2]*par[2]);
166 //____________________________________________________________________________
167 void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
169 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all"))
170 gBenchmark->Start("TOFSDigitizer");
172 AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF");
175 Error("AliTOFSDigitizer","TOF not found");
179 if (fEdgeTails) ftail = new TF1("tail",TimeWithTail,-2,2,3);
181 Int_t nselectedHits=0;
182 Int_t ntotalsdigits=0;
183 Int_t ntotalupdates=0;
184 Int_t nnoisesdigits=0;
185 Int_t nsignalsdigits=0;
186 Int_t nHitsFromPrim=0;
187 Int_t nHitsFromSec=0;
188 Int_t nlargeTofDiff=0;
190 if (strstr(allEvents,"all")){
192 fEvent2= (Int_t) gAlice->TreeE()->GetEntries();
195 for (Int_t ievent = fEvent1; ievent < fEvent2; ievent++) {
196 cout << "------------------- "<< GetName() << " -------------" << endl ;
197 cout << "Sdigitizing event " << ievent << endl;
199 Int_t nselectedHitsinEv=0;
200 Int_t ntotalsdigitsinEv=0;
201 Int_t ntotalupdatesinEv=0;
202 Int_t nnoisesdigitsinEv=0;
203 Int_t nsignalsdigitsinEv=0;
205 gAlice->GetEvent(ievent);
206 TTree *TH = gAlice->TreeH ();
209 if (gAlice->TreeS () == 0)
210 gAlice->MakeTree ("S");
215 sprintf (branchname, "%s", TOF->GetName ());
216 //Make branch for digits
217 TOF->MakeBranch ("S");
219 //Now made SDigits from hits
221 Int_t vol[5]; // location for a digit
222 Float_t digit[2]; // TOF digit variables
225 TClonesArray *TOFhits = TOF->Hits();
228 AliTOFHitMap *hitMap = new AliTOFHitMap(TOF->SDigits());
230 Int_t ntracks = static_cast<Int_t>(TH->GetEntries());
231 for (Int_t track = 0; track < ntracks; track++)
235 particle = gAlice->Particle(track);
236 Int_t nhits = TOFhits->GetEntriesFast();
237 // cleaning all hits of the same track in the same pad volume
238 // it is a rare event, however it happens
240 Int_t previousTrack =0;
241 Int_t previousSector=0;
242 Int_t previousPlate =0;
243 Int_t previousStrip =0;
244 Int_t previousPadX =0;
245 Int_t previousPadZ =0;
247 for (Int_t hit = 0; hit < nhits; hit++)
249 tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit);
250 Int_t tracknum = tofHit->GetTrack();
251 vol[0] = tofHit->GetSector();
252 vol[1] = tofHit->GetPlate();
253 vol[2] = tofHit->GetStrip();
254 vol[3] = tofHit->GetPadx();
255 vol[4] = tofHit->GetPadz();
257 Bool_t dummy=((tracknum==previousTrack) && (vol[0]==previousSector) && (vol[1]==previousPlate) && (vol[2]==previousStrip));
259 Bool_t isCloneOfThePrevious=dummy && ((vol[3]==previousPadX) && (vol[4]==previousPadZ));
261 // much stronger check to be inserted here
263 if(!isCloneOfThePrevious){
264 // update "previous" values
265 // in fact, we are yet in the future, so the present is past
266 previousTrack=tracknum;
267 previousSector=vol[0];
268 previousPlate=vol[1];
269 previousStrip=vol[2];
275 if (particle->GetFirstMother() < 0){
277 } // counts hits due to primary particles
279 Float_t Xpad = tofHit->GetDx();
280 Float_t Zpad = tofHit->GetDz();
281 Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad;
282 Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad;
283 Float_t geantTime = tofHit->GetTof(); // unit [s]
284 geantTime *= 1.e+09; // conversion from [s] to [ns]
286 //cout << "geantTime " << geantTime << " [ns]" << endl;
287 Int_t nActivatedPads = 0, nFiredPads = 0;
288 Bool_t isFired[4] = {kFALSE, kFALSE, kFALSE, kFALSE};
289 Float_t tofAfterSimul[4] = {0., 0., 0., 0.};
290 Float_t qInduced[4] = {0.,0.,0.,0.};
291 Int_t nPlace[4] = {0, 0, 0, 0};
292 Float_t averageTime = 0.;
293 SimulateDetectorResponse(zStrip,xStrip,geantTime,nActivatedPads,nFiredPads,isFired,nPlace,qInduced,tofAfterSimul,averageTime);
295 for(Int_t indexOfPad=0; indexOfPad<nActivatedPads; indexOfPad++) {
296 if(isFired[indexOfPad]){ // the pad has fired
297 Float_t timediff=geantTime-tofAfterSimul[indexOfPad];
299 if(timediff>=0.2) nlargeTofDiff++;
301 digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/fTdcBin); // TDC bin number (each bin -> 25. ps)
303 Float_t landauFactor = gRandom->Landau(fAdcMean, fAdcRms);
304 digit[1] = (Int_t) (qInduced[indexOfPad] * landauFactor); // ADC bins (each bin -> 0.25 (or 0.03) pC)
306 // recalculate the volume only for neighbouring pads
308 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[4] = 1 : vol[4] = 2;
309 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[3] = nPlace[indexOfPad] : vol[3] = nPlace[indexOfPad] - AliTOFConstants::fgkNpadX;
312 // check if two sdigit are on the same pad; in that case we sum
313 // the two or more sdigits
314 if (hitMap->TestHit(vol) != kEmpty) {
315 AliTOFSDigit *sdig = static_cast<AliTOFSDigit*>(hitMap->GetHit(vol));
316 Int_t tdctime = (Int_t) digit[0];
317 Int_t adccharge = (Int_t) digit[1];
318 sdig->Update(tdctime,adccharge,tracknum);
323 TOF->AddSDigit(tracknum, vol, digit);
330 nsignalsdigitsinEv++;
335 } // if (hitMap->TestHit(vol) != kEmpty)
336 } // if(isFired[indexOfPad])
337 } // end loop on nActivatedPads
338 } // if(nFiredPads) i.e. if some pads has fired
339 } // close if(!isCloneOfThePrevious)
340 } // end loop on hits for the current track
341 } // end loop on ntracks
345 gAlice->TreeS()->Reset();
346 gAlice->TreeS()->Fill();
347 //gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
348 gAlice->TreeS()->AutoSave();
350 if(strstr(verboseOption,"all")){
351 cout << "----------------------------------------" << endl;
352 cout << " <AliTOFSDigitizer> " << endl;
353 cout << "After sdigitizing " << nselectedHitsinEv << " hits" << " in event " << ievent << endl;
354 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
355 cout << ntotalsdigitsinEv << " digits have been created " << endl;
356 cout << "(" << nsignalsdigitsinEv << " due to signals and " << nnoisesdigitsinEv << " due to border effect)" << endl;
357 cout << ntotalupdatesinEv << " total updates of the hit map have been performed in current event" << endl;
358 cout << "----------------------------------------" << endl;
361 } //event loop on events
369 nHitsFromSec=nselectedHits-nHitsFromPrim;
370 if(strstr(verboseOption,"all")){
371 cout << "----------------------------------------" << endl;
372 cout << "----------------------------------------" << endl;
373 cout << "-----------SDigitization Summary--------" << endl;
374 cout << " <AliTOFSDigitizer> " << endl;
375 cout << "After sdigitizing " << nselectedHits << " hits" << endl;
376 cout << "in " << (fEvent2-fEvent1) << " events" << endl;
377 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
378 cout << ntotalsdigits << " sdigits have been created " << endl;
379 cout << "(" << nsignalsdigits << " due to signals and " << nnoisesdigits << " due to border effect)" << endl;
380 cout << ntotalupdates << " total updates of the hit map have been performed" << endl;
381 cout << "in " << nlargeTofDiff << " cases the time of flight difference is greater than 200 ps" << endl;
385 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all")){
386 gBenchmark->Stop("TOFSDigitizer");
387 cout << "AliTOFSDigitizer:" << endl ;
388 cout << " took " << gBenchmark->GetCpuTime("TOFSDigitizer") << " seconds in order to make sdigits "
389 << gBenchmark->GetCpuTime("TOFSDigitizer")/(fEvent2-fEvent1) << " seconds per event " << endl ;
396 //__________________________________________________________________
397 void AliTOFSDigitizer::SetSDigitsFile(char * file ){
398 if(!fSDigitsFile.IsNull())
399 cout << "Changing SDigits file from " <<(char *)fSDigitsFile.Data() << " to " << file << endl ;
403 //__________________________________________________________________
404 void AliTOFSDigitizer::Print(Option_t* opt)const
406 cout << "------------------- "<< GetName() << " -------------" << endl ;
407 if(fSDigitsFile.IsNull())
408 cout << " Writing SDigits to file with hits "<< endl ;
410 cout << " Writing SDigits to file " << (char*) fSDigitsFile.Data() << endl ;
411 cout << "--------------------------------------------------" << endl;
414 //__________________________________________________________________
415 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)
418 // Input: z0, x0 - hit position in the strip system (0,0 - center of the strip), cm
419 // geantTime - time generated by Geant, ns
420 // Output: nActivatedPads - the number of pads activated by the hit (1 || 2 || 4)
421 // nFiredPads - the number of pads fired (really activated) by the hit (nFiredPads <= nActivatedPads)
422 // qInduced[iPad]- charge induced on pad, arb. units
423 // this array is initialized at zero by the caller
424 // tofAfterSimul[iPad] - time calculated with edge effect algorithm, ns
425 // this array is initialized at zero by the caller
426 // 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.
427 // The weight is given by the qInduced[iPad]/qCenterPad
428 // this variable is initialized at zero by the caller
429 // nPlace[iPad] - the number of the pad place, iPad = 0, 1, 2, 3
430 // this variable is initialized at zero by the caller
432 // Description of used variables:
433 // eff[iPad] - efficiency of the pad
434 // res[iPad] - resolution of the pad, ns
435 // timeWalk[iPad] - time walk of the pad, ns
436 // timeDelay[iPad] - time delay for neighbouring pad to hited pad, ns
437 // PadId[iPad] - Pad Identifier
438 // E | F --> PadId[iPad] = 5 | 6
439 // A | B --> PadId[iPad] = 1 | 2
440 // C | D --> PadId[iPad] = 3 | 4
441 // nTail[iPad] - the tail number, = 1 for tailA, = 2 for tailB
442 // qCenterPad - charge extimated for each pad, arb. units
443 // weightsSum - sum of weights extimated for each pad fired, arb. units
445 const Float_t kSigmaForTail[2] = {AliTOFConstants::fgkSigmaForTail1,AliTOFConstants::fgkSigmaForTail2}; //for tail
446 Int_t iz = 0, ix = 0;
447 Float_t dX = 0., dZ = 0., x = 0., z = 0.;
448 Float_t h = fHparameter, h2 = fH2parameter, k = fKparameter, k2 = fK2parameter;
449 Float_t effX = 0., effZ = 0., resX = 0., resZ = 0., timeWalkX = 0., timeWalkZ = 0.;
450 Float_t logOfqInd = 0.;
451 Float_t weightsSum = 0.;
452 Int_t nTail[4] = {0,0,0,0};
453 Int_t padId[4] = {0,0,0,0};
454 Float_t eff[4] = {0.,0.,0.,0.};
455 Float_t res[4] = {0.,0.,0.,0.};
456 // Float_t qCenterPad = fMinimumCharge * fMinimumCharge;
457 Float_t qCenterPad = 1.;
458 Float_t timeWalk[4] = {0.,0.,0.,0.};
459 Float_t timeDelay[4] = {0.,0.,0.,0.};
464 (z0 <= 0) ? iz = 0 : iz = 1;
465 dZ = z0 + (0.5 * AliTOFConstants::fgkNpadZ - iz - 0.5) * AliTOFConstants::fgkZPad; // hit position in the pad frame, (0,0) - center of the pad
466 z = 0.5 * AliTOFConstants::fgkZPad - TMath::Abs(dZ); // variable for eff., res. and timeWalk. functions
467 iz++; // z row: 1, ..., AliTOFConstants::fgkNpadZ = 2
468 ix = (Int_t)((x0 + 0.5 * AliTOFConstants::fgkNpadX * AliTOFConstants::fgkXPad) / AliTOFConstants::fgkXPad);
469 dX = x0 + (0.5 * AliTOFConstants::fgkNpadX - ix - 0.5) * AliTOFConstants::fgkXPad; // hit position in the pad frame, (0,0) - center of the pad
470 x = 0.5 * AliTOFConstants::fgkXPad - TMath::Abs(dX); // variable for eff., res. and timeWalk. functions;
471 ix++; // x row: 1, ..., AliTOFConstants::fgkNpadX = 48
475 nPlace[nActivatedPads-1] = (iz - 1) * AliTOFConstants::fgkNpadX + ix;
476 qInduced[nActivatedPads-1] = qCenterPad;
477 padId[nActivatedPads-1] = 1;
479 if (fEdgeEffect == 0) {
480 eff[nActivatedPads-1] = fEffCenter;
481 if (gRandom->Rndm() < eff[nActivatedPads-1]) {
483 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + fResCenter * fResCenter); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns;
484 isFired[nActivatedPads-1] = kTRUE;
485 tofTime[nActivatedPads-1] = gRandom->Gaus(geantTime + fTimeWalkCenter, res[0]);
486 averageTime = tofTime[nActivatedPads-1];
492 effZ = fEffBoundary + (fEff2Boundary - fEffBoundary) * z / h2;
494 effZ = fEff2Boundary + (fEffCenter - fEff2Boundary) * (z - h2) / (h - h2);
496 resZ = fResBoundary + (fResCenter - fResBoundary) * z / h;
497 timeWalkZ = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * z / h;
498 nTail[nActivatedPads-1] = 1;
502 timeWalkZ = fTimeWalkCenter;
507 effX = fEffBoundary + (fEff2Boundary - fEffBoundary) * x / h2;
509 effX = fEff2Boundary + (fEffCenter - fEff2Boundary) * (x - h2) / (h - h2);
511 resX = fResBoundary + (fResCenter - fResBoundary) * x / h;
512 timeWalkX = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * x / h;
513 nTail[nActivatedPads-1] = 1;
517 timeWalkX = fTimeWalkCenter;
520 (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX;
521 (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
522 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
527 effZ = fEffBoundary - (fEffBoundary - fEff3Boundary) * (z / k2);
529 effZ = fEff3Boundary * (k - z) / (k - k2);
531 resZ = fResBoundary + fResSlope * z / k;
532 timeWalkZ = fTimeWalkBoundary + fTimeWalkSlope * z / k;
535 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
537 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX;
538 eff[nActivatedPads-1] = effZ;
539 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
540 timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ; // ns
541 nTail[nActivatedPads-1] = 2;
542 if (fTimeDelayFlag) {
543 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
544 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
545 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
546 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
547 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
549 timeDelay[nActivatedPads-1] = 0.;
551 padId[nActivatedPads-1] = 2;
556 ////// Pad C, D, E, F:
558 effX = fEffBoundary - (fEffBoundary - fEff3Boundary) * (x / k2);
560 effX = fEff3Boundary * (k - x) / (k - k2);
562 resX = fResBoundary + fResSlope*x/k;
563 timeWalkX = fTimeWalkBoundary + fTimeWalkSlope*x/k;
567 if(ix > 1 && dX < 0) {
569 nPlace[nActivatedPads-1] = nPlace[0] - 1;
570 eff[nActivatedPads-1] = effX;
571 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
572 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
573 nTail[nActivatedPads-1] = 2;
574 if (fTimeDelayFlag) {
575 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
576 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
577 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
578 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
579 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
581 timeDelay[nActivatedPads-1] = 0.;
583 padId[nActivatedPads-1] = 3;
587 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
589 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX - 1;
590 eff[nActivatedPads-1] = effX * effZ;
591 (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
592 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
594 nTail[nActivatedPads-1] = 2;
595 if (fTimeDelayFlag) {
596 if (TMath::Abs(x) < TMath::Abs(z)) {
597 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
598 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
599 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
600 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
602 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
603 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
604 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
605 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
607 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
609 timeDelay[nActivatedPads-1] = 0.;
611 padId[nActivatedPads-1] = 4;
617 if(ix < AliTOFConstants::fgkNpadX && dX > 0) {
619 nPlace[nActivatedPads-1] = nPlace[0] + 1;
620 eff[nActivatedPads-1] = effX;
621 res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(10400 + resX * resX)); // ns
622 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
623 nTail[nActivatedPads-1] = 2;
624 if (fTimeDelayFlag) {
625 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
626 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
627 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
628 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
629 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
631 timeDelay[nActivatedPads-1] = 0.;
633 padId[nActivatedPads-1] = 5;
638 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
640 nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX + 1;
641 eff[nActivatedPads - 1] = effX * effZ;
642 (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
643 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001*timeWalkX; // ns
644 nTail[nActivatedPads-1] = 2;
645 if (fTimeDelayFlag) {
646 if (TMath::Abs(x) < TMath::Abs(z)) {
647 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
648 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
649 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
650 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
652 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
653 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
654 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
655 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
657 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
659 timeDelay[nActivatedPads-1] = 0.;
661 padId[nActivatedPads-1] = 6;
668 for (Int_t iPad = 0; iPad < nActivatedPads; iPad++) {
669 if (res[iPad] < fTimeResolution) res[iPad] = fTimeResolution;
670 if(gRandom->Rndm() < eff[iPad]) {
671 isFired[iPad] = kTRUE;
674 if(nTail[iPad] == 0) {
675 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
677 ftail->SetParameters(res[iPad], 2. * res[iPad], kSigmaForTail[nTail[iPad]-1]);
678 Double_t timeAB = ftail->GetRandom();
679 tofTime[iPad] = geantTime + timeWalk[iPad] + timeDelay[iPad] + timeAB;
682 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
684 if (fAverageTimeFlag) {
685 averageTime += tofTime[iPad] * qInduced[iPad];
686 weightsSum += qInduced[iPad];
688 averageTime += tofTime[iPad];
693 if (weightsSum!=0) averageTime /= weightsSum;
694 } // end else (fEdgeEffect != 0)
697 //__________________________________________________________________
698 void AliTOFSDigitizer::PrintParameters()const
701 // Print parameters used for sdigitization
703 cout << " ------------------- "<< GetName() << " -------------" << endl ;
704 cout << " Parameters used for TOF SDigitization " << endl ;
705 // Printing the parameters
707 cout << " Number of events: " << (fEvent2-fEvent1) << endl;
708 cout << " from event " << fEvent1 << " to event " << (fEvent2-1) << endl;
709 cout << " Time Resolution (ns) "<< fTimeResolution <<" Pad Efficiency: "<< fpadefficiency << endl;
710 cout << " Edge Effect option: "<< fEdgeEffect<< endl;
712 cout << " Boundary Effect Simulation Parameters " << endl;
713 cout << " Hparameter: "<< fHparameter<<" H2parameter:"<< fH2parameter <<" Kparameter:"<< fKparameter<<" K2parameter: "<< fK2parameter << endl;
714 cout << " Efficiency in the central region of the pad: "<< fEffCenter << endl;
715 cout << " Efficiency at the boundary region of the pad: "<< fEffBoundary << endl;
716 cout << " Efficiency value at H2parameter "<< fEff2Boundary << endl;
717 cout << " Efficiency value at K2parameter "<< fEff3Boundary << endl;
718 cout << " Resolution (ps) in the central region of the pad: "<< fResCenter << endl;
719 cout << " Resolution (ps) at the boundary of the pad : "<< fResBoundary << endl;
720 cout << " Slope (ps/K) for neighbouring pad : "<< fResSlope <<endl;
721 cout << " Time walk (ps) in the central region of the pad : "<< fTimeWalkCenter << endl;
722 cout << " Time walk (ps) at the boundary of the pad : "<< fTimeWalkBoundary<< endl;
723 cout << " Slope (ps/K) for neighbouring pad : "<< fTimeWalkSlope<<endl;
724 cout << " Pulse Heigth Simulation Parameters " << endl;
725 cout << " Flag for delay due to the PulseHeightEffect: "<< fTimeDelayFlag <<endl;
726 cout << " Pulse Height Slope : "<< fPulseHeightSlope<<endl;
727 cout << " Time Delay Slope : "<< fTimeDelaySlope<<endl;
728 cout << " Minimum charge amount which could be induced : "<< fMinimumCharge<<endl;
729 cout << " Smearing in charge in (q1/q2) vs x plot : "<< fChargeSmearing<<endl;
730 cout << " Smearing in log of charge ratio : "<< fLogChargeSmearing<<endl;
731 cout << " Smearing in time in time vs log(q1/q2) plot : "<< fTimeSmearing<<endl;
732 cout << " Flag for average time : "<< fAverageTimeFlag<<endl;
733 cout << " Edge tails option : "<< fEdgeTails << endl;