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"
30 #include "TParticle.h"
37 #include <Riostream.h>
38 #include <Riostream.h>
40 #include "AliTOFHitMap.h"
41 #include "AliTOFSDigit.h"
42 #include "AliTOFConstants.h"
43 #include "AliTOFhit.h"
44 #include "AliTOFhitT0.h"
50 #include "AliTOFSDigitizer.h"
52 #include "AliDetector.h"
55 ClassImp(AliTOFSDigitizer)
57 //____________________________________________________________________________
58 AliTOFSDigitizer::AliTOFSDigitizer():TTask("AliTOFSDigitizer","")
68 //____________________________________________________________________________
69 AliTOFSDigitizer::AliTOFSDigitizer(char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("AliTOFSDigitizer","")
72 fEvent2=fEvent1+nEvents;
74 fSelectedSector=0; // by default we sdigitize all sectors
75 fSelectedPlate =0; // by default we sdigitize all plates in all sectors
77 fHeadersFile = HeaderFile ; // input filename (with hits)
78 TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data() ) ;
80 //File was not opened yet
81 // open file and get alirun object
83 file = TFile::Open(fHeadersFile.Data(),"update") ;
84 gAlice = (AliRun *) file->Get("gAlice") ;
87 // init parameters for sdigitization
90 // add Task to //root/Tasks folder
91 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
92 roottasks->Add(this) ;
95 //____________________________________________________________________________
96 AliTOFSDigitizer::~AliTOFSDigitizer()
101 //____________________________________________________________________________
102 void AliTOFSDigitizer::InitParameters()
104 // set parameters for detector simulation
106 fTimeResolution =0.120;
107 fpadefficiency =0.99 ;
114 fEffCenter = fpadefficiency;
116 fEff2Boundary = 0.90;
117 fEff3Boundary = 0.08;
121 fTimeWalkCenter = 0. ;
122 fTimeWalkBoundary=0. ;
123 fTimeWalkSlope = 0. ;
125 fPulseHeightSlope=2.0 ;
126 fTimeDelaySlope =0.060;
127 // was fMinimumCharge = TMath::Exp(fPulseHeightSlope*fKparameter/2.);
128 fMinimumCharge = TMath::Exp(-fPulseHeightSlope*fHparameter);
129 fChargeSmearing=0.0 ;
130 fLogChargeSmearing=0.13;
131 fTimeSmearing =0.022;
133 fTdcBin = 50.; // 1 TDC bin = 50 ps
134 fAdcBin = 0.25; // 1 ADC bin = 0.25 pC (or 0.03 pC)
135 fAdcMean = 50.; // ADC distribution mpv value for Landau (in bins)
136 // it corresponds to a mean value of ~100 bins
137 fAdcRms = 25.; // ADC distribution rms value (in bins)
138 // it corresponds to distribution rms ~50 bins
141 //__________________________________________________________________
142 Double_t TimeWithTail(Double_t* x, Double_t* par)
144 // sigma - par[0], alpha - par[1], part - par[2]
145 // at x<part*sigma - gauss
146 // at x>part*sigma - TMath::Exp(-x/alpha)
149 if(xx<par[0]*par[2]) {
150 f = TMath::Exp(-xx*xx/(2*par[0]*par[0]));
152 f = TMath::Exp(-(xx-par[0]*par[2])/par[1]-0.5*par[2]*par[2]);
158 //____________________________________________________________________________
159 void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
161 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all"))
162 gBenchmark->Start("TOFSDigitizer");
164 AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF");
167 Error("AliTOFSDigitizer","TOF not found");
171 // is pointer to fSDigits non zero after changes?
172 cout<<"TOF fSDigits pointer:"<<TOF->SDigits()<<endl;
174 // recreate TClonesArray fSDigits - for backward compatibility
175 if (TOF->SDigits() == 0) {
176 TOF->CreateSDigitsArray();
178 TOF->RecreateSDigitsArray();
181 Int_t version=TOF->IsVersion();
183 if (fEdgeTails) ftail = new TF1("tail",TimeWithTail,-2,2,3);
185 Int_t nselectedHits=0;
186 Int_t ntotalsdigits=0;
187 Int_t ntotalupdates=0;
188 Int_t nnoisesdigits=0;
189 Int_t nsignalsdigits=0;
190 Int_t nHitsFromPrim=0;
191 Int_t nHitsFromSec=0;
192 Int_t nlargeTofDiff=0;
194 if (strstr(allEvents,"all")){
196 fEvent2= (Int_t) gAlice->TreeE()->GetEntries();
199 Bool_t thereIsNotASelection=(fSelectedSector==0) && (fSelectedPlate==0);
201 for (Int_t ievent = fEvent1; ievent < fEvent2; ievent++) {
202 cout << "------------------- "<< GetName() << " -------------" << endl ;
203 cout << "Sdigitizing event " << ievent << endl;
205 Int_t nselectedHitsinEv=0;
206 Int_t ntotalsdigitsinEv=0;
207 Int_t ntotalupdatesinEv=0;
208 Int_t nnoisesdigitsinEv=0;
209 Int_t nsignalsdigitsinEv=0;
211 gAlice->GetEvent(ievent);
212 TTree *TH = gAlice->TreeH ();
215 if (gAlice->TreeS () == 0)
216 gAlice->MakeTree ("S");
221 sprintf (branchname, "%s", TOF->GetName ());
222 //Make branch for digits
223 TOF->MakeBranch ("S");
225 //Now made SDigits from hits
230 TClonesArray *TOFhits = TOF->Hits();
233 AliTOFHitMap *hitMap = new AliTOFHitMap(TOF->SDigits());
235 // increase performances in terms of CPU time
236 TH->SetBranchStatus("*",0); // switch off all branches
237 TH->SetBranchStatus("TOF*",1); // switch on only TOF
239 Int_t ntracks = static_cast<Int_t>(TH->GetEntries());
240 for (Int_t track = 0; track < ntracks; track++)
244 particle = gAlice->Particle(track);
245 Int_t nhits = TOFhits->GetEntriesFast();
246 // cleaning all hits of the same track in the same pad volume
247 // it is a rare event, however it happens
249 Int_t previousTrack =0;
250 Int_t previousSector=0;
251 Int_t previousPlate =0;
252 Int_t previousStrip =0;
253 Int_t previousPadX =0;
254 Int_t previousPadZ =0;
256 for (Int_t hit = 0; hit < nhits; hit++)
258 Int_t vol[5]; // location for a digit
259 Float_t digit[2]; // TOF digit variables
265 // fp: really sorry for this, it is a temporary trick to have
268 AliTOFhit *tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit);
269 tracknum = tofHit->GetTrack();
270 vol[0] = tofHit->GetSector();
271 vol[1] = tofHit->GetPlate();
272 vol[2] = tofHit->GetStrip();
273 vol[3] = tofHit->GetPadx();
274 vol[4] = tofHit->GetPadz();
275 Xpad = tofHit->GetDx();
276 Zpad = tofHit->GetDz();
277 geantTime = tofHit->GetTof(); // unit [s]
279 AliTOFhitT0 *tofHit = (AliTOFhitT0 *) TOFhits->UncheckedAt(hit);
280 tracknum = tofHit->GetTrack();
281 vol[0] = tofHit->GetSector();
282 vol[1] = tofHit->GetPlate();
283 vol[2] = tofHit->GetStrip();
284 vol[3] = tofHit->GetPadx();
285 vol[4] = tofHit->GetPadz();
286 Xpad = tofHit->GetDx();
287 Zpad = tofHit->GetDz();
288 geantTime = tofHit->GetTof(); // unit [s]
291 geantTime *= 1.e+09; // conversion from [s] to [ns]
293 // selection case for sdigitizing only hits in a given plate of a given sector
294 if(thereIsNotASelection || (vol[0]==fSelectedSector && vol[1]==fSelectedPlate)){
296 Bool_t dummy=((tracknum==previousTrack) && (vol[0]==previousSector) && (vol[1]==previousPlate) && (vol[2]==previousStrip));
298 Bool_t isCloneOfThePrevious=dummy && ((vol[3]==previousPadX) && (vol[4]==previousPadZ));
300 Bool_t isNeighOfThePrevious=dummy && ((((vol[3]==previousPadX-1) || (vol[3]==previousPadX+1)) && (vol[4]==previousPadZ)) || ((vol[3]==previousPadX) && ((vol[4]==previousPadZ+1) || (vol[4]==previousPadZ-1))));
302 if(!isCloneOfThePrevious && !isNeighOfThePrevious){
303 // update "previous" values
304 // in fact, we are yet in the future, so the present is past
305 previousTrack=tracknum;
306 previousSector=vol[0];
307 previousPlate=vol[1];
308 previousStrip=vol[2];
314 if (particle->GetFirstMother() < 0){
316 } // counts hits due to primary particles
318 Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad;
319 Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad;
321 //cout << "geantTime " << geantTime << " [ns]" << endl;
322 Int_t nActivatedPads = 0, nFiredPads = 0;
323 Bool_t isFired[4] = {kFALSE, kFALSE, kFALSE, kFALSE};
324 Float_t tofAfterSimul[4] = {0., 0., 0., 0.};
325 Float_t qInduced[4] = {0.,0.,0.,0.};
326 Int_t nPlace[4] = {0, 0, 0, 0};
327 Float_t averageTime = 0.;
328 SimulateDetectorResponse(zStrip,xStrip,geantTime,nActivatedPads,nFiredPads,isFired,nPlace,qInduced,tofAfterSimul,averageTime);
330 for(Int_t indexOfPad=0; indexOfPad<nActivatedPads; indexOfPad++) {
331 if(isFired[indexOfPad]){ // the pad has fired
332 Float_t timediff=geantTime-tofAfterSimul[indexOfPad];
334 if(timediff>=0.2) nlargeTofDiff++;
336 digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/fTdcBin); // TDC bin number (each bin -> 50. ps)
338 Float_t landauFactor = gRandom->Landau(fAdcMean, fAdcRms);
339 digit[1] = (Int_t) (qInduced[indexOfPad] * landauFactor); // ADC bins (each bin -> 0.25 (or 0.03) pC)
341 // recalculate the volume only for neighbouring pads
343 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[4] = 1 : vol[4] = 2;
344 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[3] = nPlace[indexOfPad] : vol[3] = nPlace[indexOfPad] - AliTOFConstants::fgkNpadX;
347 // check if two sdigit are on the same pad; in that case we sum
348 // the two or more sdigits
349 if (hitMap->TestHit(vol) != kEmpty) {
350 AliTOFSDigit *sdig = static_cast<AliTOFSDigit*>(hitMap->GetHit(vol));
351 Int_t tdctime = (Int_t) digit[0];
352 Int_t adccharge = (Int_t) digit[1];
353 sdig->Update(fTdcBin,tdctime,adccharge,tracknum);
358 TOF->AddSDigit(tracknum, vol, digit);
365 nsignalsdigitsinEv++;
370 } // if (hitMap->TestHit(vol) != kEmpty)
371 } // if(isFired[indexOfPad])
372 } // end loop on nActivatedPads
373 } // if(nFiredPads) i.e. if some pads has fired
374 } // close if(!isCloneOfThePrevious)
375 } // close the selection on sector and plate
376 } // end loop on hits for the current track
377 } // end loop on ntracks
381 gAlice->TreeS()->Reset();
382 gAlice->TreeS()->Fill();
383 //gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
384 gAlice->TreeS()->AutoSave();
386 if(strstr(verboseOption,"all")){
387 cout << "----------------------------------------" << endl;
388 cout << " <AliTOFSDigitizer> " << endl;
389 cout << "After sdigitizing " << nselectedHitsinEv << " hits" << " in event " << ievent << endl;
390 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
391 cout << ntotalsdigitsinEv << " digits have been created " << endl;
392 cout << "(" << nsignalsdigitsinEv << " due to signals and " << nnoisesdigitsinEv << " due to border effect)" << endl;
393 cout << ntotalupdatesinEv << " total updates of the hit map have been performed in current event" << endl;
394 cout << "----------------------------------------" << endl;
397 } //event loop on events
405 nHitsFromSec=nselectedHits-nHitsFromPrim;
406 if(strstr(verboseOption,"all")){
407 cout << "----------------------------------------" << endl;
408 cout << "----------------------------------------" << endl;
409 cout << "-----------SDigitization Summary--------" << endl;
410 cout << " <AliTOFSDigitizer> " << endl;
411 cout << "After sdigitizing " << nselectedHits << " hits" << endl;
412 cout << "in " << (fEvent2-fEvent1) << " events" << endl;
413 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
414 cout << ntotalsdigits << " sdigits have been created " << endl;
415 cout << "(" << nsignalsdigits << " due to signals and " << nnoisesdigits << " due to border effect)" << endl;
416 cout << ntotalupdates << " total updates of the hit map have been performed" << endl;
417 cout << "in " << nlargeTofDiff << " cases the time of flight difference is greater than 200 ps" << endl;
421 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all")){
422 gBenchmark->Stop("TOFSDigitizer");
423 cout << "AliTOFSDigitizer:" << endl ;
424 cout << " took " << gBenchmark->GetCpuTime("TOFSDigitizer") << " seconds in order to make sdigits "
425 << gBenchmark->GetCpuTime("TOFSDigitizer")/(fEvent2-fEvent1) << " seconds per event " << endl ;
432 //__________________________________________________________________
433 void AliTOFSDigitizer::Print(Option_t* opt)const
435 cout << "------------------- "<< GetName() << " -------------" << endl ;
439 //__________________________________________________________________
440 void AliTOFSDigitizer::SelectSectorAndPlate(Int_t sector, Int_t plate)
442 Bool_t isaWrongSelection=(sector < 1) || (sector > AliTOFConstants::fgkNSectors) || (plate < 1) || (plate > AliTOFConstants::fgkNPlates);
443 if(isaWrongSelection){
444 cout << "You have selected an invalid value for sector or plate " << endl;
445 cout << "The correct range for sector is [1,"<< AliTOFConstants::fgkNSectors <<"]" << endl;
446 cout << "The correct range for plate is [1,"<< AliTOFConstants::fgkNPlates <<"]" << endl;
447 cout << "By default we continue sdigitizing all hits in all plates of all sectors" << endl;
449 fSelectedSector=sector;
450 fSelectedPlate =plate;
451 cout << "SDigitizing only hits in plate " << fSelectedPlate << " of the sector " << fSelectedSector << endl;
455 //__________________________________________________________________
456 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)
459 // Input: z0, x0 - hit position in the strip system (0,0 - center of the strip), cm
460 // geantTime - time generated by Geant, ns
461 // Output: nActivatedPads - the number of pads activated by the hit (1 || 2 || 4)
462 // nFiredPads - the number of pads fired (really activated) by the hit (nFiredPads <= nActivatedPads)
463 // qInduced[iPad]- charge induced on pad, arb. units
464 // this array is initialized at zero by the caller
465 // tofAfterSimul[iPad] - time calculated with edge effect algorithm, ns
466 // this array is initialized at zero by the caller
467 // 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.
468 // The weight is given by the qInduced[iPad]/qCenterPad
469 // this variable is initialized at zero by the caller
470 // nPlace[iPad] - the number of the pad place, iPad = 0, 1, 2, 3
471 // this variable is initialized at zero by the caller
473 // Description of used variables:
474 // eff[iPad] - efficiency of the pad
475 // res[iPad] - resolution of the pad, ns
476 // timeWalk[iPad] - time walk of the pad, ns
477 // timeDelay[iPad] - time delay for neighbouring pad to hited pad, ns
478 // PadId[iPad] - Pad Identifier
479 // E | F --> PadId[iPad] = 5 | 6
480 // A | B --> PadId[iPad] = 1 | 2
481 // C | D --> PadId[iPad] = 3 | 4
482 // nTail[iPad] - the tail number, = 1 for tailA, = 2 for tailB
483 // qCenterPad - charge extimated for each pad, arb. units
484 // weightsSum - sum of weights extimated for each pad fired, arb. units
486 const Float_t kSigmaForTail[2] = {AliTOFConstants::fgkSigmaForTail1,AliTOFConstants::fgkSigmaForTail2}; //for tail
487 Int_t iz = 0, ix = 0;
488 Float_t dX = 0., dZ = 0., x = 0., z = 0.;
489 Float_t h = fHparameter, h2 = fH2parameter, k = fKparameter, k2 = fK2parameter;
490 Float_t effX = 0., effZ = 0., resX = 0., resZ = 0., timeWalkX = 0., timeWalkZ = 0.;
491 Float_t logOfqInd = 0.;
492 Float_t weightsSum = 0.;
493 Int_t nTail[4] = {0,0,0,0};
494 Int_t padId[4] = {0,0,0,0};
495 Float_t eff[4] = {0.,0.,0.,0.};
496 Float_t res[4] = {0.,0.,0.,0.};
497 // Float_t qCenterPad = fMinimumCharge * fMinimumCharge;
498 Float_t qCenterPad = 1.;
499 Float_t timeWalk[4] = {0.,0.,0.,0.};
500 Float_t timeDelay[4] = {0.,0.,0.,0.};
505 (z0 <= 0) ? iz = 0 : iz = 1;
506 dZ = z0 + (0.5 * AliTOFConstants::fgkNpadZ - iz - 0.5) * AliTOFConstants::fgkZPad; // hit position in the pad frame, (0,0) - center of the pad
507 z = 0.5 * AliTOFConstants::fgkZPad - TMath::Abs(dZ); // variable for eff., res. and timeWalk. functions
508 iz++; // z row: 1, ..., AliTOFConstants::fgkNpadZ = 2
509 ix = (Int_t)((x0 + 0.5 * AliTOFConstants::fgkNpadX * AliTOFConstants::fgkXPad) / AliTOFConstants::fgkXPad);
510 dX = x0 + (0.5 * AliTOFConstants::fgkNpadX - ix - 0.5) * AliTOFConstants::fgkXPad; // hit position in the pad frame, (0,0) - center of the pad
511 x = 0.5 * AliTOFConstants::fgkXPad - TMath::Abs(dX); // variable for eff., res. and timeWalk. functions;
512 ix++; // x row: 1, ..., AliTOFConstants::fgkNpadX = 48
516 nPlace[nActivatedPads-1] = (iz - 1) * AliTOFConstants::fgkNpadX + ix;
517 qInduced[nActivatedPads-1] = qCenterPad;
518 padId[nActivatedPads-1] = 1;
520 if (fEdgeEffect == 0) {
521 eff[nActivatedPads-1] = fEffCenter;
522 if (gRandom->Rndm() < eff[nActivatedPads-1]) {
524 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + fResCenter * fResCenter); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns;
525 isFired[nActivatedPads-1] = kTRUE;
526 tofTime[nActivatedPads-1] = gRandom->Gaus(geantTime + fTimeWalkCenter, res[0]);
527 averageTime = tofTime[nActivatedPads-1];
533 effZ = fEffBoundary + (fEff2Boundary - fEffBoundary) * z / h2;
535 effZ = fEff2Boundary + (fEffCenter - fEff2Boundary) * (z - h2) / (h - h2);
537 resZ = fResBoundary + (fResCenter - fResBoundary) * z / h;
538 timeWalkZ = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * z / h;
539 nTail[nActivatedPads-1] = 1;
543 timeWalkZ = fTimeWalkCenter;
548 effX = fEffBoundary + (fEff2Boundary - fEffBoundary) * x / h2;
550 effX = fEff2Boundary + (fEffCenter - fEff2Boundary) * (x - h2) / (h - h2);
552 resX = fResBoundary + (fResCenter - fResBoundary) * x / h;
553 timeWalkX = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * x / h;
554 nTail[nActivatedPads-1] = 1;
558 timeWalkX = fTimeWalkCenter;
561 (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX;
562 (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
563 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
568 effZ = fEffBoundary - (fEffBoundary - fEff3Boundary) * (z / k2);
570 effZ = fEff3Boundary * (k - z) / (k - k2);
572 resZ = fResBoundary + fResSlope * z / k;
573 timeWalkZ = fTimeWalkBoundary + fTimeWalkSlope * z / k;
576 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
578 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX;
579 eff[nActivatedPads-1] = effZ;
580 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
581 timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ; // ns
582 nTail[nActivatedPads-1] = 2;
583 if (fTimeDelayFlag) {
584 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
585 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
586 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
587 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
588 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
590 timeDelay[nActivatedPads-1] = 0.;
592 padId[nActivatedPads-1] = 2;
597 ////// Pad C, D, E, F:
599 effX = fEffBoundary - (fEffBoundary - fEff3Boundary) * (x / k2);
601 effX = fEff3Boundary * (k - x) / (k - k2);
603 resX = fResBoundary + fResSlope*x/k;
604 timeWalkX = fTimeWalkBoundary + fTimeWalkSlope*x/k;
608 if(ix > 1 && dX < 0) {
610 nPlace[nActivatedPads-1] = nPlace[0] - 1;
611 eff[nActivatedPads-1] = effX;
612 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
613 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
614 nTail[nActivatedPads-1] = 2;
615 if (fTimeDelayFlag) {
616 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
617 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
618 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
619 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
620 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
622 timeDelay[nActivatedPads-1] = 0.;
624 padId[nActivatedPads-1] = 3;
628 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
630 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX - 1;
631 eff[nActivatedPads-1] = effX * effZ;
632 (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
633 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
635 nTail[nActivatedPads-1] = 2;
636 if (fTimeDelayFlag) {
637 if (TMath::Abs(x) < TMath::Abs(z)) {
638 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
639 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
640 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
641 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
643 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
644 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
645 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
646 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
648 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
650 timeDelay[nActivatedPads-1] = 0.;
652 padId[nActivatedPads-1] = 4;
658 if(ix < AliTOFConstants::fgkNpadX && dX > 0) {
660 nPlace[nActivatedPads-1] = nPlace[0] + 1;
661 eff[nActivatedPads-1] = effX;
662 res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(10400 + resX * resX)); // ns
663 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
664 nTail[nActivatedPads-1] = 2;
665 if (fTimeDelayFlag) {
666 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
667 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
668 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
669 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
670 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
672 timeDelay[nActivatedPads-1] = 0.;
674 padId[nActivatedPads-1] = 5;
679 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
681 nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX + 1;
682 eff[nActivatedPads - 1] = effX * effZ;
683 (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
684 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001*timeWalkX; // ns
685 nTail[nActivatedPads-1] = 2;
686 if (fTimeDelayFlag) {
687 if (TMath::Abs(x) < TMath::Abs(z)) {
688 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
689 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
690 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
691 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
693 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
694 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
695 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
696 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
698 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
700 timeDelay[nActivatedPads-1] = 0.;
702 padId[nActivatedPads-1] = 6;
709 for (Int_t iPad = 0; iPad < nActivatedPads; iPad++) {
710 if (res[iPad] < fTimeResolution) res[iPad] = fTimeResolution;
711 if(gRandom->Rndm() < eff[iPad]) {
712 isFired[iPad] = kTRUE;
715 if(nTail[iPad] == 0) {
716 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
718 ftail->SetParameters(res[iPad], 2. * res[iPad], kSigmaForTail[nTail[iPad]-1]);
719 Double_t timeAB = ftail->GetRandom();
720 tofTime[iPad] = geantTime + timeWalk[iPad] + timeDelay[iPad] + timeAB;
723 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
725 if (fAverageTimeFlag) {
726 averageTime += tofTime[iPad] * qInduced[iPad];
727 weightsSum += qInduced[iPad];
729 averageTime += tofTime[iPad];
734 if (weightsSum!=0) averageTime /= weightsSum;
735 } // end else (fEdgeEffect != 0)
738 //__________________________________________________________________
739 void AliTOFSDigitizer::PrintParameters()const
742 // Print parameters used for sdigitization
744 cout << " ------------------- "<< GetName() << " -------------" << endl ;
745 cout << " Parameters used for TOF SDigitization " << endl ;
746 // Printing the parameters
748 cout << " Number of events: " << (fEvent2-fEvent1) << endl;
749 cout << " from event " << fEvent1 << " to event " << (fEvent2-1) << endl;
750 cout << " Time Resolution (ns) "<< fTimeResolution <<" Pad Efficiency: "<< fpadefficiency << endl;
751 cout << " Edge Effect option: "<< fEdgeEffect<< endl;
753 cout << " Boundary Effect Simulation Parameters " << endl;
754 cout << " Hparameter: "<< fHparameter<<" H2parameter:"<< fH2parameter <<" Kparameter:"<< fKparameter<<" K2parameter: "<< fK2parameter << endl;
755 cout << " Efficiency in the central region of the pad: "<< fEffCenter << endl;
756 cout << " Efficiency at the boundary region of the pad: "<< fEffBoundary << endl;
757 cout << " Efficiency value at H2parameter "<< fEff2Boundary << endl;
758 cout << " Efficiency value at K2parameter "<< fEff3Boundary << endl;
759 cout << " Resolution (ps) in the central region of the pad: "<< fResCenter << endl;
760 cout << " Resolution (ps) at the boundary of the pad : "<< fResBoundary << endl;
761 cout << " Slope (ps/K) for neighbouring pad : "<< fResSlope <<endl;
762 cout << " Time walk (ps) in the central region of the pad : "<< fTimeWalkCenter << endl;
763 cout << " Time walk (ps) at the boundary of the pad : "<< fTimeWalkBoundary<< endl;
764 cout << " Slope (ps/K) for neighbouring pad : "<< fTimeWalkSlope<<endl;
765 cout << " Pulse Heigth Simulation Parameters " << endl;
766 cout << " Flag for delay due to the PulseHeightEffect: "<< fTimeDelayFlag <<endl;
767 cout << " Pulse Height Slope : "<< fPulseHeightSlope<<endl;
768 cout << " Time Delay Slope : "<< fTimeDelaySlope<<endl;
769 cout << " Minimum charge amount which could be induced : "<< fMinimumCharge<<endl;
770 cout << " Smearing in charge in (q1/q2) vs x plot : "<< fChargeSmearing<<endl;
771 cout << " Smearing in log of charge ratio : "<< fLogChargeSmearing<<endl;
772 cout << " Smearing in time in time vs log(q1/q2) plot : "<< fTimeSmearing<<endl;
773 cout << " Flag for average time : "<< fAverageTimeFlag<<endl;
774 cout << " Edge tails option : "<< fEdgeTails << endl;