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"
56 ClassImp(AliTOFSDigitizer)
58 //____________________________________________________________________________
59 AliTOFSDigitizer::AliTOFSDigitizer():TTask("AliTOFSDigitizer","")
69 //____________________________________________________________________________
70 AliTOFSDigitizer::AliTOFSDigitizer(char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("AliTOFSDigitizer","")
73 fEvent2=fEvent1+nEvents;
75 fSelectedSector=0; // by default we sdigitize all sectors
76 fSelectedPlate =0; // by default we sdigitize all plates in all sectors
78 fHeadersFile = HeaderFile ; // input filename (with hits)
79 TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data() ) ;
81 //File was not opened yet
82 // open file and get alirun object
84 file = TFile::Open(fHeadersFile.Data(),"update") ;
85 gAlice = (AliRun *) file->Get("gAlice") ;
88 // init parameters for sdigitization
91 // add Task to //root/Tasks folder
92 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
93 roottasks->Add(this) ;
96 //____________________________________________________________________________
97 AliTOFSDigitizer::~AliTOFSDigitizer()
102 //____________________________________________________________________________
103 void AliTOFSDigitizer::InitParameters()
105 // set parameters for detector simulation
107 fTimeResolution =0.120;
108 fpadefficiency =0.99 ;
115 fEffCenter = fpadefficiency;
117 fEff2Boundary = 0.90;
118 fEff3Boundary = 0.08;
122 fTimeWalkCenter = 0. ;
123 fTimeWalkBoundary=0. ;
124 fTimeWalkSlope = 0. ;
126 fPulseHeightSlope=2.0 ;
127 fTimeDelaySlope =0.060;
128 // was fMinimumCharge = TMath::Exp(fPulseHeightSlope*fKparameter/2.);
129 fMinimumCharge = TMath::Exp(-fPulseHeightSlope*fHparameter);
130 fChargeSmearing=0.0 ;
131 fLogChargeSmearing=0.13;
132 fTimeSmearing =0.022;
134 fTdcBin = 50.; // 1 TDC bin = 50 ps
135 fAdcBin = 0.25; // 1 ADC bin = 0.25 pC (or 0.03 pC)
136 fAdcMean = 50.; // ADC distribution mpv value for Landau (in bins)
137 // it corresponds to a mean value of ~100 bins
138 fAdcRms = 25.; // ADC distribution rms value (in bins)
139 // it corresponds to distribution rms ~50 bins
142 //__________________________________________________________________
143 Double_t TimeWithTail(Double_t* x, Double_t* par)
145 // sigma - par[0], alpha - par[1], part - par[2]
146 // at x<part*sigma - gauss
147 // at x>part*sigma - TMath::Exp(-x/alpha)
150 if(xx<par[0]*par[2]) {
151 f = TMath::Exp(-xx*xx/(2*par[0]*par[0]));
153 f = TMath::Exp(-(xx-par[0]*par[2])/par[1]-0.5*par[2]*par[2]);
159 //____________________________________________________________________________
160 void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
162 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all"))
163 gBenchmark->Start("TOFSDigitizer");
165 AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF");
168 Error("AliTOFSDigitizer","TOF not found");
172 // is pointer to fSDigits non zero after changes?
173 cout<<"TOF fSDigits pointer:"<<TOF->SDigits()<<endl;
175 // recreate TClonesArray fSDigits - for backward compatibility
176 if (TOF->SDigits() == 0) {
177 TOF->CreateSDigitsArray();
179 TOF->RecreateSDigitsArray();
182 Int_t version=TOF->IsVersion();
184 if (fEdgeTails) ftail = new TF1("tail",TimeWithTail,-2,2,3);
186 Int_t nselectedHits=0;
187 Int_t ntotalsdigits=0;
188 Int_t ntotalupdates=0;
189 Int_t nnoisesdigits=0;
190 Int_t nsignalsdigits=0;
191 Int_t nHitsFromPrim=0;
192 Int_t nHitsFromSec=0;
193 Int_t nlargeTofDiff=0;
195 if (strstr(allEvents,"all")){
197 fEvent2= (Int_t) gAlice->TreeE()->GetEntries();
200 Bool_t thereIsNotASelection=(fSelectedSector==0) && (fSelectedPlate==0);
202 for (Int_t ievent = fEvent1; ievent < fEvent2; ievent++) {
203 cout << "------------------- "<< GetName() << " -------------" << endl ;
204 cout << "Sdigitizing event " << ievent << endl;
206 Int_t nselectedHitsinEv=0;
207 Int_t ntotalsdigitsinEv=0;
208 Int_t ntotalupdatesinEv=0;
209 Int_t nnoisesdigitsinEv=0;
210 Int_t nsignalsdigitsinEv=0;
212 gAlice->GetEvent(ievent);
213 TTree *TH = gAlice->TreeH ();
216 if (gAlice->TreeS () == 0)
217 gAlice->MakeTree ("S");
222 sprintf (branchname, "%s", TOF->GetName ());
223 //Make branch for digits
224 TOF->MakeBranch ("S");
226 //Now made SDigits from hits
231 TClonesArray *TOFhits = TOF->Hits();
234 AliTOFHitMap *hitMap = new AliTOFHitMap(TOF->SDigits());
236 // increase performances in terms of CPU time
237 TH->SetBranchStatus("*",0); // switch off all branches
238 TH->SetBranchStatus("TOF*",1); // switch on only TOF
240 Int_t ntracks = static_cast<Int_t>(TH->GetEntries());
241 for (Int_t track = 0; track < ntracks; track++)
245 particle = gAlice->Particle(track);
246 Int_t nhits = TOFhits->GetEntriesFast();
247 // cleaning all hits of the same track in the same pad volume
248 // it is a rare event, however it happens
250 Int_t previousTrack =0;
251 Int_t previousSector=0;
252 Int_t previousPlate =0;
253 Int_t previousStrip =0;
254 Int_t previousPadX =0;
255 Int_t previousPadZ =0;
257 for (Int_t hit = 0; hit < nhits; hit++)
259 Int_t vol[5]; // location for a digit
260 Float_t digit[2]; // TOF digit variables
266 // fp: really sorry for this, it is a temporary trick to have
269 AliTOFhit *tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit);
270 tracknum = tofHit->GetTrack();
271 vol[0] = tofHit->GetSector();
272 vol[1] = tofHit->GetPlate();
273 vol[2] = tofHit->GetStrip();
274 vol[3] = tofHit->GetPadx();
275 vol[4] = tofHit->GetPadz();
276 Xpad = tofHit->GetDx();
277 Zpad = tofHit->GetDz();
278 geantTime = tofHit->GetTof(); // unit [s]
280 AliTOFhitT0 *tofHit = (AliTOFhitT0 *) TOFhits->UncheckedAt(hit);
281 tracknum = tofHit->GetTrack();
282 vol[0] = tofHit->GetSector();
283 vol[1] = tofHit->GetPlate();
284 vol[2] = tofHit->GetStrip();
285 vol[3] = tofHit->GetPadx();
286 vol[4] = tofHit->GetPadz();
287 Xpad = tofHit->GetDx();
288 Zpad = tofHit->GetDz();
289 geantTime = tofHit->GetTof(); // unit [s]
292 geantTime *= 1.e+09; // conversion from [s] to [ns]
294 // selection case for sdigitizing only hits in a given plate of a given sector
295 if(thereIsNotASelection || (vol[0]==fSelectedSector && vol[1]==fSelectedPlate)){
297 Bool_t dummy=((tracknum==previousTrack) && (vol[0]==previousSector) && (vol[1]==previousPlate) && (vol[2]==previousStrip));
299 Bool_t isCloneOfThePrevious=dummy && ((vol[3]==previousPadX) && (vol[4]==previousPadZ));
301 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))));
303 if(!isCloneOfThePrevious && !isNeighOfThePrevious){
304 // update "previous" values
305 // in fact, we are yet in the future, so the present is past
306 previousTrack=tracknum;
307 previousSector=vol[0];
308 previousPlate=vol[1];
309 previousStrip=vol[2];
315 if (particle->GetFirstMother() < 0){
317 } // counts hits due to primary particles
319 Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad;
320 Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad;
322 //cout << "geantTime " << geantTime << " [ns]" << endl;
323 Int_t nActivatedPads = 0, nFiredPads = 0;
324 Bool_t isFired[4] = {kFALSE, kFALSE, kFALSE, kFALSE};
325 Float_t tofAfterSimul[4] = {0., 0., 0., 0.};
326 Float_t qInduced[4] = {0.,0.,0.,0.};
327 Int_t nPlace[4] = {0, 0, 0, 0};
328 Float_t averageTime = 0.;
329 SimulateDetectorResponse(zStrip,xStrip,geantTime,nActivatedPads,nFiredPads,isFired,nPlace,qInduced,tofAfterSimul,averageTime);
331 for(Int_t indexOfPad=0; indexOfPad<nActivatedPads; indexOfPad++) {
332 if(isFired[indexOfPad]){ // the pad has fired
333 Float_t timediff=geantTime-tofAfterSimul[indexOfPad];
335 if(timediff>=0.2) nlargeTofDiff++;
337 digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/fTdcBin); // TDC bin number (each bin -> 50. ps)
339 Float_t landauFactor = gRandom->Landau(fAdcMean, fAdcRms);
340 digit[1] = (Int_t) (qInduced[indexOfPad] * landauFactor); // ADC bins (each bin -> 0.25 (or 0.03) pC)
342 // recalculate the volume only for neighbouring pads
344 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[4] = 1 : vol[4] = 2;
345 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[3] = nPlace[indexOfPad] : vol[3] = nPlace[indexOfPad] - AliTOFConstants::fgkNpadX;
348 // check if two sdigit are on the same pad; in that case we sum
349 // the two or more sdigits
350 if (hitMap->TestHit(vol) != kEmpty) {
351 AliTOFSDigit *sdig = static_cast<AliTOFSDigit*>(hitMap->GetHit(vol));
352 Int_t tdctime = (Int_t) digit[0];
353 Int_t adccharge = (Int_t) digit[1];
354 sdig->Update(fTdcBin,tdctime,adccharge,tracknum);
359 TOF->AddSDigit(tracknum, vol, digit);
366 nsignalsdigitsinEv++;
371 } // if (hitMap->TestHit(vol) != kEmpty)
372 } // if(isFired[indexOfPad])
373 } // end loop on nActivatedPads
374 } // if(nFiredPads) i.e. if some pads has fired
375 } // close if(!isCloneOfThePrevious)
376 } // close the selection on sector and plate
377 } // end loop on hits for the current track
378 } // end loop on ntracks
382 gAlice->TreeS()->Reset();
383 gAlice->TreeS()->Fill();
384 //gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
385 gAlice->TreeS()->AutoSave();
387 if(strstr(verboseOption,"all")){
388 cout << "----------------------------------------" << endl;
389 cout << " <AliTOFSDigitizer> " << endl;
390 cout << "After sdigitizing " << nselectedHitsinEv << " hits" << " in event " << ievent << endl;
391 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
392 cout << ntotalsdigitsinEv << " digits have been created " << endl;
393 cout << "(" << nsignalsdigitsinEv << " due to signals and " << nnoisesdigitsinEv << " due to border effect)" << endl;
394 cout << ntotalupdatesinEv << " total updates of the hit map have been performed in current event" << endl;
395 cout << "----------------------------------------" << endl;
398 } //event loop on events
406 nHitsFromSec=nselectedHits-nHitsFromPrim;
407 if(strstr(verboseOption,"all")){
408 cout << "----------------------------------------" << endl;
409 cout << "----------------------------------------" << endl;
410 cout << "-----------SDigitization Summary--------" << endl;
411 cout << " <AliTOFSDigitizer> " << endl;
412 cout << "After sdigitizing " << nselectedHits << " hits" << endl;
413 cout << "in " << (fEvent2-fEvent1) << " events" << endl;
414 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
415 cout << ntotalsdigits << " sdigits have been created " << endl;
416 cout << "(" << nsignalsdigits << " due to signals and " << nnoisesdigits << " due to border effect)" << endl;
417 cout << ntotalupdates << " total updates of the hit map have been performed" << endl;
418 cout << "in " << nlargeTofDiff << " cases the time of flight difference is greater than 200 ps" << endl;
422 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all")){
423 gBenchmark->Stop("TOFSDigitizer");
424 cout << "AliTOFSDigitizer:" << endl ;
425 cout << " took " << gBenchmark->GetCpuTime("TOFSDigitizer") << " seconds in order to make sdigits "
426 << gBenchmark->GetCpuTime("TOFSDigitizer")/(fEvent2-fEvent1) << " seconds per event " << endl ;
433 //__________________________________________________________________
434 void AliTOFSDigitizer::Print(Option_t* opt)const
436 cout << "------------------- "<< GetName() << " -------------" << endl ;
440 //__________________________________________________________________
441 void AliTOFSDigitizer::SelectSectorAndPlate(Int_t sector, Int_t plate)
443 Bool_t isaWrongSelection=(sector < 1) || (sector > AliTOFConstants::fgkNSectors) || (plate < 1) || (plate > AliTOFConstants::fgkNPlates);
444 if(isaWrongSelection){
445 cout << "You have selected an invalid value for sector or plate " << endl;
446 cout << "The correct range for sector is [1,"<< AliTOFConstants::fgkNSectors <<"]" << endl;
447 cout << "The correct range for plate is [1,"<< AliTOFConstants::fgkNPlates <<"]" << endl;
448 cout << "By default we continue sdigitizing all hits in all plates of all sectors" << endl;
450 fSelectedSector=sector;
451 fSelectedPlate =plate;
452 cout << "SDigitizing only hits in plate " << fSelectedPlate << " of the sector " << fSelectedSector << endl;
456 //__________________________________________________________________
457 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)
460 // Input: z0, x0 - hit position in the strip system (0,0 - center of the strip), cm
461 // geantTime - time generated by Geant, ns
462 // Output: nActivatedPads - the number of pads activated by the hit (1 || 2 || 4)
463 // nFiredPads - the number of pads fired (really activated) by the hit (nFiredPads <= nActivatedPads)
464 // qInduced[iPad]- charge induced on pad, arb. units
465 // this array is initialized at zero by the caller
466 // tofAfterSimul[iPad] - time calculated with edge effect algorithm, ns
467 // this array is initialized at zero by the caller
468 // 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.
469 // The weight is given by the qInduced[iPad]/qCenterPad
470 // this variable is initialized at zero by the caller
471 // nPlace[iPad] - the number of the pad place, iPad = 0, 1, 2, 3
472 // this variable is initialized at zero by the caller
474 // Description of used variables:
475 // eff[iPad] - efficiency of the pad
476 // res[iPad] - resolution of the pad, ns
477 // timeWalk[iPad] - time walk of the pad, ns
478 // timeDelay[iPad] - time delay for neighbouring pad to hited pad, ns
479 // PadId[iPad] - Pad Identifier
480 // E | F --> PadId[iPad] = 5 | 6
481 // A | B --> PadId[iPad] = 1 | 2
482 // C | D --> PadId[iPad] = 3 | 4
483 // nTail[iPad] - the tail number, = 1 for tailA, = 2 for tailB
484 // qCenterPad - charge extimated for each pad, arb. units
485 // weightsSum - sum of weights extimated for each pad fired, arb. units
487 const Float_t kSigmaForTail[2] = {AliTOFConstants::fgkSigmaForTail1,AliTOFConstants::fgkSigmaForTail2}; //for tail
488 Int_t iz = 0, ix = 0;
489 Float_t dX = 0., dZ = 0., x = 0., z = 0.;
490 Float_t h = fHparameter, h2 = fH2parameter, k = fKparameter, k2 = fK2parameter;
491 Float_t effX = 0., effZ = 0., resX = 0., resZ = 0., timeWalkX = 0., timeWalkZ = 0.;
492 Float_t logOfqInd = 0.;
493 Float_t weightsSum = 0.;
494 Int_t nTail[4] = {0,0,0,0};
495 Int_t padId[4] = {0,0,0,0};
496 Float_t eff[4] = {0.,0.,0.,0.};
497 Float_t res[4] = {0.,0.,0.,0.};
498 // Float_t qCenterPad = fMinimumCharge * fMinimumCharge;
499 Float_t qCenterPad = 1.;
500 Float_t timeWalk[4] = {0.,0.,0.,0.};
501 Float_t timeDelay[4] = {0.,0.,0.,0.};
506 (z0 <= 0) ? iz = 0 : iz = 1;
507 dZ = z0 + (0.5 * AliTOFConstants::fgkNpadZ - iz - 0.5) * AliTOFConstants::fgkZPad; // hit position in the pad frame, (0,0) - center of the pad
508 z = 0.5 * AliTOFConstants::fgkZPad - TMath::Abs(dZ); // variable for eff., res. and timeWalk. functions
509 iz++; // z row: 1, ..., AliTOFConstants::fgkNpadZ = 2
510 ix = (Int_t)((x0 + 0.5 * AliTOFConstants::fgkNpadX * AliTOFConstants::fgkXPad) / AliTOFConstants::fgkXPad);
511 dX = x0 + (0.5 * AliTOFConstants::fgkNpadX - ix - 0.5) * AliTOFConstants::fgkXPad; // hit position in the pad frame, (0,0) - center of the pad
512 x = 0.5 * AliTOFConstants::fgkXPad - TMath::Abs(dX); // variable for eff., res. and timeWalk. functions;
513 ix++; // x row: 1, ..., AliTOFConstants::fgkNpadX = 48
517 nPlace[nActivatedPads-1] = (iz - 1) * AliTOFConstants::fgkNpadX + ix;
518 qInduced[nActivatedPads-1] = qCenterPad;
519 padId[nActivatedPads-1] = 1;
521 if (fEdgeEffect == 0) {
522 eff[nActivatedPads-1] = fEffCenter;
523 if (gRandom->Rndm() < eff[nActivatedPads-1]) {
525 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + fResCenter * fResCenter); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns;
526 isFired[nActivatedPads-1] = kTRUE;
527 tofTime[nActivatedPads-1] = gRandom->Gaus(geantTime + fTimeWalkCenter, res[0]);
528 averageTime = tofTime[nActivatedPads-1];
534 effZ = fEffBoundary + (fEff2Boundary - fEffBoundary) * z / h2;
536 effZ = fEff2Boundary + (fEffCenter - fEff2Boundary) * (z - h2) / (h - h2);
538 resZ = fResBoundary + (fResCenter - fResBoundary) * z / h;
539 timeWalkZ = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * z / h;
540 nTail[nActivatedPads-1] = 1;
544 timeWalkZ = fTimeWalkCenter;
549 effX = fEffBoundary + (fEff2Boundary - fEffBoundary) * x / h2;
551 effX = fEff2Boundary + (fEffCenter - fEff2Boundary) * (x - h2) / (h - h2);
553 resX = fResBoundary + (fResCenter - fResBoundary) * x / h;
554 timeWalkX = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * x / h;
555 nTail[nActivatedPads-1] = 1;
559 timeWalkX = fTimeWalkCenter;
562 (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX;
563 (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
564 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
569 effZ = fEffBoundary - (fEffBoundary - fEff3Boundary) * (z / k2);
571 effZ = fEff3Boundary * (k - z) / (k - k2);
573 resZ = fResBoundary + fResSlope * z / k;
574 timeWalkZ = fTimeWalkBoundary + fTimeWalkSlope * z / k;
577 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
579 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX;
580 eff[nActivatedPads-1] = effZ;
581 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
582 timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ; // ns
583 nTail[nActivatedPads-1] = 2;
584 if (fTimeDelayFlag) {
585 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
586 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
587 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
588 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
589 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
591 timeDelay[nActivatedPads-1] = 0.;
593 padId[nActivatedPads-1] = 2;
598 ////// Pad C, D, E, F:
600 effX = fEffBoundary - (fEffBoundary - fEff3Boundary) * (x / k2);
602 effX = fEff3Boundary * (k - x) / (k - k2);
604 resX = fResBoundary + fResSlope*x/k;
605 timeWalkX = fTimeWalkBoundary + fTimeWalkSlope*x/k;
609 if(ix > 1 && dX < 0) {
611 nPlace[nActivatedPads-1] = nPlace[0] - 1;
612 eff[nActivatedPads-1] = effX;
613 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
614 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
615 nTail[nActivatedPads-1] = 2;
616 if (fTimeDelayFlag) {
617 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
618 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
619 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
620 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
621 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
623 timeDelay[nActivatedPads-1] = 0.;
625 padId[nActivatedPads-1] = 3;
629 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
631 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX - 1;
632 eff[nActivatedPads-1] = effX * effZ;
633 (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
634 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
636 nTail[nActivatedPads-1] = 2;
637 if (fTimeDelayFlag) {
638 if (TMath::Abs(x) < TMath::Abs(z)) {
639 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
640 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
641 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
642 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
644 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
645 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
646 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
647 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
649 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
651 timeDelay[nActivatedPads-1] = 0.;
653 padId[nActivatedPads-1] = 4;
659 if(ix < AliTOFConstants::fgkNpadX && dX > 0) {
661 nPlace[nActivatedPads-1] = nPlace[0] + 1;
662 eff[nActivatedPads-1] = effX;
663 res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(10400 + resX * resX)); // ns
664 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
665 nTail[nActivatedPads-1] = 2;
666 if (fTimeDelayFlag) {
667 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
668 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
669 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
670 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
671 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
673 timeDelay[nActivatedPads-1] = 0.;
675 padId[nActivatedPads-1] = 5;
680 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
682 nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX + 1;
683 eff[nActivatedPads - 1] = effX * effZ;
684 (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
685 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001*timeWalkX; // ns
686 nTail[nActivatedPads-1] = 2;
687 if (fTimeDelayFlag) {
688 if (TMath::Abs(x) < TMath::Abs(z)) {
689 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
690 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
691 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
692 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
694 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
695 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
696 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
697 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
699 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
701 timeDelay[nActivatedPads-1] = 0.;
703 padId[nActivatedPads-1] = 6;
710 for (Int_t iPad = 0; iPad < nActivatedPads; iPad++) {
711 if (res[iPad] < fTimeResolution) res[iPad] = fTimeResolution;
712 if(gRandom->Rndm() < eff[iPad]) {
713 isFired[iPad] = kTRUE;
716 if(nTail[iPad] == 0) {
717 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
719 ftail->SetParameters(res[iPad], 2. * res[iPad], kSigmaForTail[nTail[iPad]-1]);
720 Double_t timeAB = ftail->GetRandom();
721 tofTime[iPad] = geantTime + timeWalk[iPad] + timeDelay[iPad] + timeAB;
724 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
726 if (fAverageTimeFlag) {
727 averageTime += tofTime[iPad] * qInduced[iPad];
728 weightsSum += qInduced[iPad];
730 averageTime += tofTime[iPad];
735 if (weightsSum!=0) averageTime /= weightsSum;
736 } // end else (fEdgeEffect != 0)
739 //__________________________________________________________________
740 void AliTOFSDigitizer::PrintParameters()const
743 // Print parameters used for sdigitization
745 cout << " ------------------- "<< GetName() << " -------------" << endl ;
746 cout << " Parameters used for TOF SDigitization " << endl ;
747 // Printing the parameters
749 cout << " Number of events: " << (fEvent2-fEvent1) << endl;
750 cout << " from event " << fEvent1 << " to event " << (fEvent2-1) << endl;
751 cout << " Time Resolution (ns) "<< fTimeResolution <<" Pad Efficiency: "<< fpadefficiency << endl;
752 cout << " Edge Effect option: "<< fEdgeEffect<< endl;
754 cout << " Boundary Effect Simulation Parameters " << endl;
755 cout << " Hparameter: "<< fHparameter<<" H2parameter:"<< fH2parameter <<" Kparameter:"<< fKparameter<<" K2parameter: "<< fK2parameter << endl;
756 cout << " Efficiency in the central region of the pad: "<< fEffCenter << endl;
757 cout << " Efficiency at the boundary region of the pad: "<< fEffBoundary << endl;
758 cout << " Efficiency value at H2parameter "<< fEff2Boundary << endl;
759 cout << " Efficiency value at K2parameter "<< fEff3Boundary << endl;
760 cout << " Resolution (ps) in the central region of the pad: "<< fResCenter << endl;
761 cout << " Resolution (ps) at the boundary of the pad : "<< fResBoundary << endl;
762 cout << " Slope (ps/K) for neighbouring pad : "<< fResSlope <<endl;
763 cout << " Time walk (ps) in the central region of the pad : "<< fTimeWalkCenter << endl;
764 cout << " Time walk (ps) at the boundary of the pad : "<< fTimeWalkBoundary<< endl;
765 cout << " Slope (ps/K) for neighbouring pad : "<< fTimeWalkSlope<<endl;
766 cout << " Pulse Heigth Simulation Parameters " << endl;
767 cout << " Flag for delay due to the PulseHeightEffect: "<< fTimeDelayFlag <<endl;
768 cout << " Pulse Height Slope : "<< fPulseHeightSlope<<endl;
769 cout << " Time Delay Slope : "<< fTimeDelaySlope<<endl;
770 cout << " Minimum charge amount which could be induced : "<< fMinimumCharge<<endl;
771 cout << " Smearing in charge in (q1/q2) vs x plot : "<< fChargeSmearing<<endl;
772 cout << " Smearing in log of charge ratio : "<< fLogChargeSmearing<<endl;
773 cout << " Smearing in time in time vs log(q1/q2) plot : "<< fTimeSmearing<<endl;
774 cout << " Flag for average time : "<< fAverageTimeFlag<<endl;
775 cout << " Edge tails option : "<< fEdgeTails << endl;