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(const 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 //PH TH->SetBranchStatus("*",0); // switch off all branches
237 //PH TH->SetBranchStatus("TOF*",1); // switch on only TOF
239 TBranch * tofHitsBranch = TH->GetBranch("TOF");
241 Int_t ntracks = static_cast<Int_t>(TH->GetEntries());
242 for (Int_t track = 0; track < ntracks; track++)
245 //PH TH->GetEvent(track);
246 tofHitsBranch->GetEvent(track);
247 particle = gAlice->Particle(track);
248 Int_t nhits = TOFhits->GetEntriesFast();
249 // cleaning all hits of the same track in the same pad volume
250 // it is a rare event, however it happens
252 Int_t previousTrack =0;
253 Int_t previousSector=0;
254 Int_t previousPlate =0;
255 Int_t previousStrip =0;
256 Int_t previousPadX =0;
257 Int_t previousPadZ =0;
259 for (Int_t hit = 0; hit < nhits; hit++)
261 Int_t vol[5]; // location for a digit
262 Float_t digit[2]; // TOF digit variables
268 // fp: really sorry for this, it is a temporary trick to have
271 AliTOFhit *tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit);
272 tracknum = tofHit->GetTrack();
273 vol[0] = tofHit->GetSector();
274 vol[1] = tofHit->GetPlate();
275 vol[2] = tofHit->GetStrip();
276 vol[3] = tofHit->GetPadx();
277 vol[4] = tofHit->GetPadz();
278 Xpad = tofHit->GetDx();
279 Zpad = tofHit->GetDz();
280 geantTime = tofHit->GetTof(); // unit [s]
282 AliTOFhitT0 *tofHit = (AliTOFhitT0 *) TOFhits->UncheckedAt(hit);
283 tracknum = tofHit->GetTrack();
284 vol[0] = tofHit->GetSector();
285 vol[1] = tofHit->GetPlate();
286 vol[2] = tofHit->GetStrip();
287 vol[3] = tofHit->GetPadx();
288 vol[4] = tofHit->GetPadz();
289 Xpad = tofHit->GetDx();
290 Zpad = tofHit->GetDz();
291 geantTime = tofHit->GetTof(); // unit [s]
294 geantTime *= 1.e+09; // conversion from [s] to [ns]
296 // selection case for sdigitizing only hits in a given plate of a given sector
297 if(thereIsNotASelection || (vol[0]==fSelectedSector && vol[1]==fSelectedPlate)){
299 Bool_t dummy=((tracknum==previousTrack) && (vol[0]==previousSector) && (vol[1]==previousPlate) && (vol[2]==previousStrip));
301 Bool_t isCloneOfThePrevious=dummy && ((vol[3]==previousPadX) && (vol[4]==previousPadZ));
303 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))));
305 if(!isCloneOfThePrevious && !isNeighOfThePrevious){
306 // update "previous" values
307 // in fact, we are yet in the future, so the present is past
308 previousTrack=tracknum;
309 previousSector=vol[0];
310 previousPlate=vol[1];
311 previousStrip=vol[2];
317 if (particle->GetFirstMother() < 0){
319 } // counts hits due to primary particles
321 Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad;
322 Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad;
324 //cout << "geantTime " << geantTime << " [ns]" << endl;
325 Int_t nActivatedPads = 0, nFiredPads = 0;
326 Bool_t isFired[4] = {kFALSE, kFALSE, kFALSE, kFALSE};
327 Float_t tofAfterSimul[4] = {0., 0., 0., 0.};
328 Float_t qInduced[4] = {0.,0.,0.,0.};
329 Int_t nPlace[4] = {0, 0, 0, 0};
330 Float_t averageTime = 0.;
331 SimulateDetectorResponse(zStrip,xStrip,geantTime,nActivatedPads,nFiredPads,isFired,nPlace,qInduced,tofAfterSimul,averageTime);
333 for(Int_t indexOfPad=0; indexOfPad<nActivatedPads; indexOfPad++) {
334 if(isFired[indexOfPad]){ // the pad has fired
335 Float_t timediff=geantTime-tofAfterSimul[indexOfPad];
337 if(timediff>=0.2) nlargeTofDiff++;
339 digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/fTdcBin); // TDC bin number (each bin -> 50. ps)
341 Float_t landauFactor = gRandom->Landau(fAdcMean, fAdcRms);
342 digit[1] = (Int_t) (qInduced[indexOfPad] * landauFactor); // ADC bins (each bin -> 0.25 (or 0.03) pC)
344 // recalculate the volume only for neighbouring pads
346 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[4] = 1 : vol[4] = 2;
347 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[3] = nPlace[indexOfPad] : vol[3] = nPlace[indexOfPad] - AliTOFConstants::fgkNpadX;
350 // check if two sdigit are on the same pad; in that case we sum
351 // the two or more sdigits
352 if (hitMap->TestHit(vol) != kEmpty) {
353 AliTOFSDigit *sdig = static_cast<AliTOFSDigit*>(hitMap->GetHit(vol));
354 Int_t tdctime = (Int_t) digit[0];
355 Int_t adccharge = (Int_t) digit[1];
356 sdig->Update(fTdcBin,tdctime,adccharge,tracknum);
361 TOF->AddSDigit(tracknum, vol, digit);
368 nsignalsdigitsinEv++;
373 } // if (hitMap->TestHit(vol) != kEmpty)
374 } // if(isFired[indexOfPad])
375 } // end loop on nActivatedPads
376 } // if(nFiredPads) i.e. if some pads has fired
377 } // close if(!isCloneOfThePrevious)
378 } // close the selection on sector and plate
379 } // end loop on hits for the current track
380 } // end loop on ntracks
384 gAlice->TreeS()->Reset();
385 gAlice->TreeS()->Fill();
386 //gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
387 gAlice->TreeS()->AutoSave();
389 if(strstr(verboseOption,"all")){
390 cout << "----------------------------------------" << endl;
391 cout << " <AliTOFSDigitizer> " << endl;
392 cout << "After sdigitizing " << nselectedHitsinEv << " hits" << " in event " << ievent << endl;
393 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
394 cout << ntotalsdigitsinEv << " digits have been created " << endl;
395 cout << "(" << nsignalsdigitsinEv << " due to signals and " << nnoisesdigitsinEv << " due to border effect)" << endl;
396 cout << ntotalupdatesinEv << " total updates of the hit map have been performed in current event" << endl;
397 cout << "----------------------------------------" << endl;
400 } //event loop on events
408 nHitsFromSec=nselectedHits-nHitsFromPrim;
409 if(strstr(verboseOption,"all")){
410 cout << "----------------------------------------" << endl;
411 cout << "----------------------------------------" << endl;
412 cout << "-----------SDigitization Summary--------" << endl;
413 cout << " <AliTOFSDigitizer> " << endl;
414 cout << "After sdigitizing " << nselectedHits << " hits" << endl;
415 cout << "in " << (fEvent2-fEvent1) << " events" << endl;
416 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
417 cout << ntotalsdigits << " sdigits have been created " << endl;
418 cout << "(" << nsignalsdigits << " due to signals and " << nnoisesdigits << " due to border effect)" << endl;
419 cout << ntotalupdates << " total updates of the hit map have been performed" << endl;
420 cout << "in " << nlargeTofDiff << " cases the time of flight difference is greater than 200 ps" << endl;
424 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all")){
425 gBenchmark->Stop("TOFSDigitizer");
426 cout << "AliTOFSDigitizer:" << endl ;
427 cout << " took " << gBenchmark->GetCpuTime("TOFSDigitizer") << " seconds in order to make sdigits "
428 << gBenchmark->GetCpuTime("TOFSDigitizer")/(fEvent2-fEvent1) << " seconds per event " << endl ;
435 //__________________________________________________________________
436 void AliTOFSDigitizer::Print(Option_t* opt)const
438 cout << "------------------- "<< GetName() << " -------------" << endl ;
442 //__________________________________________________________________
443 void AliTOFSDigitizer::SelectSectorAndPlate(Int_t sector, Int_t plate)
445 Bool_t isaWrongSelection=(sector < 1) || (sector > AliTOFConstants::fgkNSectors) || (plate < 1) || (plate > AliTOFConstants::fgkNPlates);
446 if(isaWrongSelection){
447 cout << "You have selected an invalid value for sector or plate " << endl;
448 cout << "The correct range for sector is [1,"<< AliTOFConstants::fgkNSectors <<"]" << endl;
449 cout << "The correct range for plate is [1,"<< AliTOFConstants::fgkNPlates <<"]" << endl;
450 cout << "By default we continue sdigitizing all hits in all plates of all sectors" << endl;
452 fSelectedSector=sector;
453 fSelectedPlate =plate;
454 cout << "SDigitizing only hits in plate " << fSelectedPlate << " of the sector " << fSelectedSector << endl;
458 //__________________________________________________________________
459 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)
462 // Input: z0, x0 - hit position in the strip system (0,0 - center of the strip), cm
463 // geantTime - time generated by Geant, ns
464 // Output: nActivatedPads - the number of pads activated by the hit (1 || 2 || 4)
465 // nFiredPads - the number of pads fired (really activated) by the hit (nFiredPads <= nActivatedPads)
466 // qInduced[iPad]- charge induced on pad, arb. units
467 // this array is initialized at zero by the caller
468 // tofAfterSimul[iPad] - time calculated with edge effect algorithm, ns
469 // this array is initialized at zero by the caller
470 // 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.
471 // The weight is given by the qInduced[iPad]/qCenterPad
472 // this variable is initialized at zero by the caller
473 // nPlace[iPad] - the number of the pad place, iPad = 0, 1, 2, 3
474 // this variable is initialized at zero by the caller
476 // Description of used variables:
477 // eff[iPad] - efficiency of the pad
478 // res[iPad] - resolution of the pad, ns
479 // timeWalk[iPad] - time walk of the pad, ns
480 // timeDelay[iPad] - time delay for neighbouring pad to hited pad, ns
481 // PadId[iPad] - Pad Identifier
482 // E | F --> PadId[iPad] = 5 | 6
483 // A | B --> PadId[iPad] = 1 | 2
484 // C | D --> PadId[iPad] = 3 | 4
485 // nTail[iPad] - the tail number, = 1 for tailA, = 2 for tailB
486 // qCenterPad - charge extimated for each pad, arb. units
487 // weightsSum - sum of weights extimated for each pad fired, arb. units
489 const Float_t kSigmaForTail[2] = {AliTOFConstants::fgkSigmaForTail1,AliTOFConstants::fgkSigmaForTail2}; //for tail
490 Int_t iz = 0, ix = 0;
491 Float_t dX = 0., dZ = 0., x = 0., z = 0.;
492 Float_t h = fHparameter, h2 = fH2parameter, k = fKparameter, k2 = fK2parameter;
493 Float_t effX = 0., effZ = 0., resX = 0., resZ = 0., timeWalkX = 0., timeWalkZ = 0.;
494 Float_t logOfqInd = 0.;
495 Float_t weightsSum = 0.;
496 Int_t nTail[4] = {0,0,0,0};
497 Int_t padId[4] = {0,0,0,0};
498 Float_t eff[4] = {0.,0.,0.,0.};
499 Float_t res[4] = {0.,0.,0.,0.};
500 // Float_t qCenterPad = fMinimumCharge * fMinimumCharge;
501 Float_t qCenterPad = 1.;
502 Float_t timeWalk[4] = {0.,0.,0.,0.};
503 Float_t timeDelay[4] = {0.,0.,0.,0.};
508 (z0 <= 0) ? iz = 0 : iz = 1;
509 dZ = z0 + (0.5 * AliTOFConstants::fgkNpadZ - iz - 0.5) * AliTOFConstants::fgkZPad; // hit position in the pad frame, (0,0) - center of the pad
510 z = 0.5 * AliTOFConstants::fgkZPad - TMath::Abs(dZ); // variable for eff., res. and timeWalk. functions
511 iz++; // z row: 1, ..., AliTOFConstants::fgkNpadZ = 2
512 ix = (Int_t)((x0 + 0.5 * AliTOFConstants::fgkNpadX * AliTOFConstants::fgkXPad) / AliTOFConstants::fgkXPad);
513 dX = x0 + (0.5 * AliTOFConstants::fgkNpadX - ix - 0.5) * AliTOFConstants::fgkXPad; // hit position in the pad frame, (0,0) - center of the pad
514 x = 0.5 * AliTOFConstants::fgkXPad - TMath::Abs(dX); // variable for eff., res. and timeWalk. functions;
515 ix++; // x row: 1, ..., AliTOFConstants::fgkNpadX = 48
519 nPlace[nActivatedPads-1] = (iz - 1) * AliTOFConstants::fgkNpadX + ix;
520 qInduced[nActivatedPads-1] = qCenterPad;
521 padId[nActivatedPads-1] = 1;
523 if (fEdgeEffect == 0) {
524 eff[nActivatedPads-1] = fEffCenter;
525 if (gRandom->Rndm() < eff[nActivatedPads-1]) {
527 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + fResCenter * fResCenter); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns;
528 isFired[nActivatedPads-1] = kTRUE;
529 tofTime[nActivatedPads-1] = gRandom->Gaus(geantTime + fTimeWalkCenter, res[0]);
530 averageTime = tofTime[nActivatedPads-1];
536 effZ = fEffBoundary + (fEff2Boundary - fEffBoundary) * z / h2;
538 effZ = fEff2Boundary + (fEffCenter - fEff2Boundary) * (z - h2) / (h - h2);
540 resZ = fResBoundary + (fResCenter - fResBoundary) * z / h;
541 timeWalkZ = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * z / h;
542 nTail[nActivatedPads-1] = 1;
546 timeWalkZ = fTimeWalkCenter;
551 effX = fEffBoundary + (fEff2Boundary - fEffBoundary) * x / h2;
553 effX = fEff2Boundary + (fEffCenter - fEff2Boundary) * (x - h2) / (h - h2);
555 resX = fResBoundary + (fResCenter - fResBoundary) * x / h;
556 timeWalkX = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * x / h;
557 nTail[nActivatedPads-1] = 1;
561 timeWalkX = fTimeWalkCenter;
564 (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX;
565 (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
566 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
571 effZ = fEffBoundary - (fEffBoundary - fEff3Boundary) * (z / k2);
573 effZ = fEff3Boundary * (k - z) / (k - k2);
575 resZ = fResBoundary + fResSlope * z / k;
576 timeWalkZ = fTimeWalkBoundary + fTimeWalkSlope * z / k;
579 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
581 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX;
582 eff[nActivatedPads-1] = effZ;
583 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
584 timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ; // ns
585 nTail[nActivatedPads-1] = 2;
586 if (fTimeDelayFlag) {
587 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
588 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
589 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
590 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
591 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
593 timeDelay[nActivatedPads-1] = 0.;
595 padId[nActivatedPads-1] = 2;
600 ////// Pad C, D, E, F:
602 effX = fEffBoundary - (fEffBoundary - fEff3Boundary) * (x / k2);
604 effX = fEff3Boundary * (k - x) / (k - k2);
606 resX = fResBoundary + fResSlope*x/k;
607 timeWalkX = fTimeWalkBoundary + fTimeWalkSlope*x/k;
611 if(ix > 1 && dX < 0) {
613 nPlace[nActivatedPads-1] = nPlace[0] - 1;
614 eff[nActivatedPads-1] = effX;
615 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
616 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
617 nTail[nActivatedPads-1] = 2;
618 if (fTimeDelayFlag) {
619 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
620 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
621 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
622 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
623 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
625 timeDelay[nActivatedPads-1] = 0.;
627 padId[nActivatedPads-1] = 3;
631 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
633 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX - 1;
634 eff[nActivatedPads-1] = effX * effZ;
635 (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
636 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
638 nTail[nActivatedPads-1] = 2;
639 if (fTimeDelayFlag) {
640 if (TMath::Abs(x) < TMath::Abs(z)) {
641 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
642 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
643 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
644 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
646 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
647 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
648 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
649 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
651 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
653 timeDelay[nActivatedPads-1] = 0.;
655 padId[nActivatedPads-1] = 4;
661 if(ix < AliTOFConstants::fgkNpadX && dX > 0) {
663 nPlace[nActivatedPads-1] = nPlace[0] + 1;
664 eff[nActivatedPads-1] = effX;
665 res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(10400 + resX * resX)); // ns
666 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
667 nTail[nActivatedPads-1] = 2;
668 if (fTimeDelayFlag) {
669 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
670 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
671 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
672 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
673 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
675 timeDelay[nActivatedPads-1] = 0.;
677 padId[nActivatedPads-1] = 5;
682 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
684 nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX + 1;
685 eff[nActivatedPads - 1] = effX * effZ;
686 (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
687 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001*timeWalkX; // ns
688 nTail[nActivatedPads-1] = 2;
689 if (fTimeDelayFlag) {
690 if (TMath::Abs(x) < TMath::Abs(z)) {
691 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
692 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
693 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
694 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
696 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
697 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
698 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
699 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
701 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
703 timeDelay[nActivatedPads-1] = 0.;
705 padId[nActivatedPads-1] = 6;
712 for (Int_t iPad = 0; iPad < nActivatedPads; iPad++) {
713 if (res[iPad] < fTimeResolution) res[iPad] = fTimeResolution;
714 if(gRandom->Rndm() < eff[iPad]) {
715 isFired[iPad] = kTRUE;
718 if(nTail[iPad] == 0) {
719 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
721 ftail->SetParameters(res[iPad], 2. * res[iPad], kSigmaForTail[nTail[iPad]-1]);
722 Double_t timeAB = ftail->GetRandom();
723 tofTime[iPad] = geantTime + timeWalk[iPad] + timeDelay[iPad] + timeAB;
726 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
728 if (fAverageTimeFlag) {
729 averageTime += tofTime[iPad] * qInduced[iPad];
730 weightsSum += qInduced[iPad];
732 averageTime += tofTime[iPad];
737 if (weightsSum!=0) averageTime /= weightsSum;
738 } // end else (fEdgeEffect != 0)
741 //__________________________________________________________________
742 void AliTOFSDigitizer::PrintParameters()const
745 // Print parameters used for sdigitization
747 cout << " ------------------- "<< GetName() << " -------------" << endl ;
748 cout << " Parameters used for TOF SDigitization " << endl ;
749 // Printing the parameters
751 cout << " Number of events: " << (fEvent2-fEvent1) << endl;
752 cout << " from event " << fEvent1 << " to event " << (fEvent2-1) << endl;
753 cout << " Time Resolution (ns) "<< fTimeResolution <<" Pad Efficiency: "<< fpadefficiency << endl;
754 cout << " Edge Effect option: "<< fEdgeEffect<< endl;
756 cout << " Boundary Effect Simulation Parameters " << endl;
757 cout << " Hparameter: "<< fHparameter<<" H2parameter:"<< fH2parameter <<" Kparameter:"<< fKparameter<<" K2parameter: "<< fK2parameter << endl;
758 cout << " Efficiency in the central region of the pad: "<< fEffCenter << endl;
759 cout << " Efficiency at the boundary region of the pad: "<< fEffBoundary << endl;
760 cout << " Efficiency value at H2parameter "<< fEff2Boundary << endl;
761 cout << " Efficiency value at K2parameter "<< fEff3Boundary << endl;
762 cout << " Resolution (ps) in the central region of the pad: "<< fResCenter << endl;
763 cout << " Resolution (ps) at the boundary of the pad : "<< fResBoundary << endl;
764 cout << " Slope (ps/K) for neighbouring pad : "<< fResSlope <<endl;
765 cout << " Time walk (ps) in the central region of the pad : "<< fTimeWalkCenter << endl;
766 cout << " Time walk (ps) at the boundary of the pad : "<< fTimeWalkBoundary<< endl;
767 cout << " Slope (ps/K) for neighbouring pad : "<< fTimeWalkSlope<<endl;
768 cout << " Pulse Heigth Simulation Parameters " << endl;
769 cout << " Flag for delay due to the PulseHeightEffect: "<< fTimeDelayFlag <<endl;
770 cout << " Pulse Height Slope : "<< fPulseHeightSlope<<endl;
771 cout << " Time Delay Slope : "<< fTimeDelaySlope<<endl;
772 cout << " Minimum charge amount which could be induced : "<< fMinimumCharge<<endl;
773 cout << " Smearing in charge in (q1/q2) vs x plot : "<< fChargeSmearing<<endl;
774 cout << " Smearing in log of charge ratio : "<< fLogChargeSmearing<<endl;
775 cout << " Smearing in time in time vs log(q1/q2) plot : "<< fTimeSmearing<<endl;
776 cout << " Flag for average time : "<< fAverageTimeFlag<<endl;
777 cout << " Edge tails option : "<< fEdgeTails << endl;