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 **************************************************************************/
18 //_________________________________________________________________________
19 // This is a TTask that constructs SDigits out of Hits
20 // A Summable Digits is the "sum" of all hits in a pad
21 // Detector response has been simulated via the method
22 // SimulateDetectorResponse
24 //-- Authors: F. Pierella, A. De Caro
25 // Use case: see AliTOFhits2sdigits.C macro in the CVS
26 //////////////////////////////////////////////////////////////////////////////
29 #include <Riostream.h>
32 #include <TBenchmark.h>
37 #include <TParticle.h>
43 #include "AliDetector.h"
44 #include "AliLoader.h"
46 #include "AliRunLoader.h"
48 #include "AliTOFConstants.h"
49 #include "AliTOFHitMap.h"
50 #include "AliTOFSDigit.h"
51 #include "AliTOFSDigitizer.h"
52 #include "AliTOFhit.h"
53 #include "AliTOFhitT0.h"
60 ClassImp(AliTOFSDigitizer)
62 //____________________________________________________________________________
63 AliTOFSDigitizer::AliTOFSDigitizer():TTask("AliTOFSDigitizer","")
72 fSelectedSector=-1; //0; // AdC
73 fSelectedPlate =-1; //0; // AdC
76 //____________________________________________________________________________
77 AliTOFSDigitizer::AliTOFSDigitizer(char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("AliTOFSDigitizer","")
80 fEvent2=fEvent1+nEvents;
82 fSelectedSector=-1; //0; // AdC // by default we sdigitize all sectors
83 fSelectedPlate =-1; //0; // AdC // by default we sdigitize all plates in all sectors
85 fHeadersFile = HeaderFile ; // input filename (with hits)
86 TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data() ) ;
88 //File was not opened yet
89 // open file and get alirun object
91 file = TFile::Open(fHeadersFile.Data(),"update") ;
92 gAlice = (AliRun *) file->Get("gAlice") ;
95 // init parameters for sdigitization
98 // add Task to //root/Tasks folder
99 fRunLoader = AliRunLoader::Open(HeaderFile);//open session and mount on default event folder
100 if (fRunLoader == 0x0)
102 Fatal("AliTOFSDigitizer","Event is not loaded. Exiting");
105 AliLoader* gime = fRunLoader->GetLoader("TOFLoader");
108 Fatal("AliTOFSDigitizer","Can not find TOF loader in event. Exiting.");
111 gime->PostSDigitizer(this);
114 //____________________________________________________________________________
115 AliTOFSDigitizer::~AliTOFSDigitizer()
120 //____________________________________________________________________________
121 void AliTOFSDigitizer::InitParameters()
123 // set parameters for detector simulation
125 fTimeResolution =0.120;
126 fpadefficiency =0.99 ;
133 fEffCenter = fpadefficiency;
135 fEff2Boundary = 0.90;
136 fEff3Boundary = 0.08;
140 fTimeWalkCenter = 0. ;
141 fTimeWalkBoundary=0. ;
142 fTimeWalkSlope = 0. ;
144 fPulseHeightSlope=2.0 ;
145 fTimeDelaySlope =0.060;
146 // was fMinimumCharge = TMath::Exp(fPulseHeightSlope*fKparameter/2.);
147 fMinimumCharge = TMath::Exp(-fPulseHeightSlope*fHparameter);
148 fChargeSmearing=0.0 ;
149 fLogChargeSmearing=0.13;
150 fTimeSmearing =0.022;
152 fTdcBin = 50.; // 1 TDC bin = 50 ps
153 fAdcBin = 0.25; // 1 ADC bin = 0.25 pC (or 0.03 pC)
154 fAdcMean = 50.; // ADC distribution mpv value for Landau (in bins)
155 // it corresponds to a mean value of ~100 bins
156 fAdcRms = 25.; // ADC distribution rms value (in bins)
157 // it corresponds to distribution rms ~50 bins
160 //__________________________________________________________________
161 Double_t TimeWithTail(Double_t* x, Double_t* par)
163 // sigma - par[0], alpha - par[1], part - par[2]
164 // at x<part*sigma - gauss
165 // at x>part*sigma - TMath::Exp(-x/alpha)
168 if(xx<par[0]*par[2]) {
169 f = TMath::Exp(-xx*xx/(2*par[0]*par[0]));
171 f = TMath::Exp(-(xx-par[0]*par[2])/par[1]-0.5*par[2]*par[2]);
177 //____________________________________________________________________________
178 void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
180 fRunLoader->LoadgAlice();
181 fRunLoader->LoadHeader();
182 fRunLoader->LoadKinematics();
183 gAlice = fRunLoader->GetAliRun();
185 AliLoader* gime = fRunLoader->GetLoader("TOFLoader");
186 gime->LoadHits("read");
187 gime->LoadSDigits("recreate");
188 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all"))
189 gBenchmark->Start("TOFSDigitizer");
191 AliTOF *TOF = (AliTOF *) gAlice->GetDetector("TOF");
194 Error("AliTOFSDigitizer","TOF not found");
198 // is pointer to fSDigits non zero after changes?
199 cout<<"TOF fSDigits pointer:"<<TOF->SDigits()<<endl;
201 // recreate TClonesArray fSDigits - for backward compatibility
202 if (TOF->SDigits() == 0) {
203 TOF->CreateSDigitsArray();
205 TOF->RecreateSDigitsArray();
208 Int_t version=TOF->IsVersion();
210 if (fEdgeTails) ftail = new TF1("tail",TimeWithTail,-2,2,3);
212 Int_t nselectedHits=0;
213 Int_t ntotalsdigits=0;
214 Int_t ntotalupdates=0;
215 Int_t nnoisesdigits=0;
216 Int_t nsignalsdigits=0;
217 Int_t nHitsFromPrim=0;
218 Int_t nHitsFromSec=0;
219 Int_t nlargeTofDiff=0;
221 if (strstr(allEvents,"all")){
223 fEvent2= (Int_t) gAlice->TreeE()->GetEntries();
226 //Bool_t thereIsNotASelection=(fSelectedSector==0) && (fSelectedPlate==0); // AdC
227 Bool_t thereIsNotASelection=(fSelectedSector==-1) && (fSelectedPlate==-1);
229 for (Int_t ievent = fEvent1; ievent < fEvent2; ievent++) {
230 cout << "------------------- "<< GetName() << " -------------" << endl ;
231 cout << "Sdigitizing event " << ievent << endl;
233 Int_t nselectedHitsinEv=0;
234 Int_t ntotalsdigitsinEv=0;
235 Int_t ntotalupdatesinEv=0;
236 Int_t nnoisesdigitsinEv=0;
237 Int_t nsignalsdigitsinEv=0;
239 fRunLoader->GetEvent(ievent);
240 TOF->SetTreeAddress();
241 TTree *TH = gime->TreeH ();
244 if (gime->TreeS () == 0)
245 gime->MakeTree ("S");
250 sprintf (branchname, "%s", TOF->GetName ());
251 //Make branch for digits
252 TOF->MakeBranch("S");
254 //Now made SDigits from hits
259 TClonesArray *TOFhits = TOF->Hits();
262 AliTOFHitMap *hitMap = new AliTOFHitMap(TOF->SDigits());
264 // increase performances in terms of CPU time
265 //PH TH->SetBranchStatus("*",0); // switch off all branches
266 //PH TH->SetBranchStatus("TOF*",1); // switch on only TOF
268 TBranch * tofHitsBranch = TH->GetBranch("TOF");
270 Int_t ntracks = static_cast<Int_t>(TH->GetEntries());
271 for (Int_t track = 0; track < ntracks; track++)
274 //PH TH->GetEvent(track);
275 tofHitsBranch->GetEvent(track);
276 particle = gAlice->GetMCApp()->Particle(track);
277 Int_t nhits = TOFhits->GetEntriesFast();
278 // cleaning all hits of the same track in the same pad volume
279 // it is a rare event, however it happens
281 Int_t previousTrack =-1; //0; // AdC
282 Int_t previousSector=-1; //0; // AdC
283 Int_t previousPlate =-1; //0; // AdC
284 Int_t previousStrip =-1; //0; // AdC
285 Int_t previousPadX =-1; //0; // AdC
286 Int_t previousPadZ =-1; //0; // AdC
288 for (Int_t hit = 0; hit < nhits; hit++)
290 Int_t vol[5]; // location for a digit
291 Float_t digit[2]; // TOF digit variables
297 // fp: really sorry for this, it is a temporary trick to have
300 AliTOFhit *tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit);
301 tracknum = tofHit->GetTrack();
302 vol[0] = tofHit->GetSector();
303 vol[1] = tofHit->GetPlate();
304 vol[2] = tofHit->GetStrip();
305 vol[3] = tofHit->GetPadx();
306 vol[4] = tofHit->GetPadz();
307 Xpad = tofHit->GetDx();
308 Zpad = tofHit->GetDz();
309 geantTime = tofHit->GetTof(); // unit [s]
311 AliTOFhitT0 *tofHit = (AliTOFhitT0 *) TOFhits->UncheckedAt(hit);
312 tracknum = tofHit->GetTrack();
313 vol[0] = tofHit->GetSector();
314 vol[1] = tofHit->GetPlate();
315 vol[2] = tofHit->GetStrip();
316 vol[3] = tofHit->GetPadx();
317 vol[4] = tofHit->GetPadz();
318 Xpad = tofHit->GetDx();
319 Zpad = tofHit->GetDz();
320 geantTime = tofHit->GetTof(); // unit [s]
323 geantTime *= 1.e+09; // conversion from [s] to [ns]
325 // selection case for sdigitizing only hits in a given plate of a given sector
326 if(thereIsNotASelection || (vol[0]==fSelectedSector && vol[1]==fSelectedPlate)){
328 Bool_t dummy=((tracknum==previousTrack) && (vol[0]==previousSector) && (vol[1]==previousPlate) && (vol[2]==previousStrip));
330 Bool_t isCloneOfThePrevious=dummy && ((vol[3]==previousPadX) && (vol[4]==previousPadZ));
332 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))));
334 if(!isCloneOfThePrevious && !isNeighOfThePrevious){
335 // update "previous" values
336 // in fact, we are yet in the future, so the present is past
337 previousTrack=tracknum;
338 previousSector=vol[0];
339 previousPlate=vol[1];
340 previousStrip=vol[2];
346 if (particle->GetFirstMother() < 0){
348 } // counts hits due to primary particles
350 //Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad;
351 //Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad;
352 Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]+0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad; // AdC
353 Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]+0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad; // AdC
355 //cout << "geantTime " << geantTime << " [ns]" << endl;
356 Int_t nActivatedPads = 0, nFiredPads = 0;
357 Bool_t isFired[4] = {kFALSE, kFALSE, kFALSE, kFALSE};
358 Float_t tofAfterSimul[4] = {0., 0., 0., 0.};
359 Float_t qInduced[4] = {0.,0.,0.,0.};
360 Int_t nPlace[4] = {0, 0, 0, 0};
361 Float_t averageTime = 0.;
362 SimulateDetectorResponse(zStrip,xStrip,geantTime,nActivatedPads,nFiredPads,isFired,nPlace,qInduced,tofAfterSimul,averageTime);
364 for(Int_t indexOfPad=0; indexOfPad<nActivatedPads; indexOfPad++) {
365 if(isFired[indexOfPad]){ // the pad has fired
366 Float_t timediff=geantTime-tofAfterSimul[indexOfPad];
368 if(timediff>=0.2) nlargeTofDiff++;
370 digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/fTdcBin); // TDC bin number (each bin -> 50. ps)
372 Float_t landauFactor = gRandom->Landau(fAdcMean, fAdcRms);
373 digit[1] = (Int_t) (qInduced[indexOfPad] * landauFactor); // ADC bins (each bin -> 0.25 (or 0.03) pC)
375 // recalculate the volume only for neighbouring pads
377 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[4] = 0/*1*/ : vol[4] = 1/*2*/; // AdC
378 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[3] = nPlace[indexOfPad] - 1 : vol[3] = nPlace[indexOfPad] - AliTOFConstants::fgkNpadX - 1; // AdC
381 // check if two sdigit are on the same pad; in that case we sum
382 // the two or more sdigits
383 if (hitMap->TestHit(vol) != kEmpty) {
384 AliTOFSDigit *sdig = static_cast<AliTOFSDigit*>(hitMap->GetHit(vol));
385 Int_t tdctime = (Int_t) digit[0];
386 Int_t adccharge = (Int_t) digit[1];
387 sdig->Update(fTdcBin,tdctime,adccharge,tracknum);
392 TOF->AddSDigit(tracknum, vol, digit);
399 nsignalsdigitsinEv++;
404 } // if (hitMap->TestHit(vol) != kEmpty)
405 } // if(isFired[indexOfPad])
406 } // end loop on nActivatedPads
407 } // if(nFiredPads) i.e. if some pads has fired
408 } // close if(!isCloneOfThePrevious)
409 } // close the selection on sector and plate
410 } // end loop on hits for the current track
411 } // end loop on ntracks
415 gime->TreeS()->Reset();
416 gime->TreeS()->Fill();
417 //gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
418 gime->WriteSDigits("OVERWRITE");
420 if(strstr(verboseOption,"all")){
421 cout << "----------------------------------------" << endl;
422 cout << " <AliTOFSDigitizer> " << endl;
423 cout << "After sdigitizing " << nselectedHitsinEv << " hits" << " in event " << ievent << endl;
424 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
425 cout << ntotalsdigitsinEv << " digits have been created " << endl;
426 cout << "(" << nsignalsdigitsinEv << " due to signals and " << nnoisesdigitsinEv << " due to border effect)" << endl;
427 cout << ntotalupdatesinEv << " total updates of the hit map have been performed in current event" << endl;
428 cout << "----------------------------------------" << endl;
431 } //event loop on events
439 nHitsFromSec=nselectedHits-nHitsFromPrim;
440 if(strstr(verboseOption,"all")){
441 cout << "----------------------------------------" << endl;
442 cout << "----------------------------------------" << endl;
443 cout << "-----------SDigitization Summary--------" << endl;
444 cout << " <AliTOFSDigitizer> " << endl;
445 cout << "After sdigitizing " << nselectedHits << " hits" << endl;
446 cout << "in " << (fEvent2-fEvent1) << " events" << endl;
447 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
448 cout << ntotalsdigits << " sdigits have been created " << endl;
449 cout << "(" << nsignalsdigits << " due to signals and " << nnoisesdigits << " due to border effect)" << endl;
450 cout << ntotalupdates << " total updates of the hit map have been performed" << endl;
451 cout << "in " << nlargeTofDiff << " cases the time of flight difference is greater than 200 ps" << endl;
455 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all")){
456 gBenchmark->Stop("TOFSDigitizer");
457 cout << "AliTOFSDigitizer:" << endl ;
458 cout << " took " << gBenchmark->GetCpuTime("TOFSDigitizer") << " seconds in order to make sdigits "
459 << gBenchmark->GetCpuTime("TOFSDigitizer")/(fEvent2-fEvent1) << " seconds per event " << endl ;
466 //__________________________________________________________________
467 void AliTOFSDigitizer::Print(Option_t* /*opt*/)const
469 cout << "------------------- "<< GetName() << " -------------" << endl ;
473 //__________________________________________________________________
474 void AliTOFSDigitizer::SelectSectorAndPlate(Int_t sector, Int_t plate)
476 //Bool_t isaWrongSelection=(sector < 1) || (sector > AliTOFConstants::fgkNSectors) || (plate < 1) || (plate > AliTOFConstants::fgkNPlates);
477 Bool_t isaWrongSelection=(sector < 0) || (sector >= AliTOFConstants::fgkNSectors) || (plate < 0) || (plate >= AliTOFConstants::fgkNPlates); // AdC
478 if(isaWrongSelection){
479 cout << "You have selected an invalid value for sector or plate " << endl;
480 //cout << "The correct range for sector is [1,"<< AliTOFConstants::fgkNSectors <<"]" << endl;
481 //cout << "The correct range for plate is [1,"<< AliTOFConstants::fgkNPlates <<"]" << endl;
482 cout << "The correct range for sector is [0,"<< AliTOFConstants::fgkNSectors-1 <<"]\n"; // AdC
483 cout << "The correct range for plate is [0,"<< AliTOFConstants::fgkNPlates-1 <<"]\n"; // AdC
484 cout << "By default we continue sdigitizing all hits in all plates of all sectors" << endl;
486 fSelectedSector=sector;
487 fSelectedPlate =plate;
488 cout << "SDigitizing only hits in plate " << fSelectedPlate << " of the sector " << fSelectedSector << endl;
492 //__________________________________________________________________
493 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)
496 // Input: z0, x0 - hit position in the strip system (0,0 - center of the strip), cm
497 // geantTime - time generated by Geant, ns
498 // Output: nActivatedPads - the number of pads activated by the hit (1 || 2 || 4)
499 // nFiredPads - the number of pads fired (really activated) by the hit (nFiredPads <= nActivatedPads)
500 // qInduced[iPad]- charge induced on pad, arb. units
501 // this array is initialized at zero by the caller
502 // tofAfterSimul[iPad] - time calculated with edge effect algorithm, ns
503 // this array is initialized at zero by the caller
504 // 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.
505 // The weight is given by the qInduced[iPad]/qCenterPad
506 // this variable is initialized at zero by the caller
507 // nPlace[iPad] - the number of the pad place, iPad = 0, 1, 2, 3
508 // this variable is initialized at zero by the caller
510 // Description of used variables:
511 // eff[iPad] - efficiency of the pad
512 // res[iPad] - resolution of the pad, ns
513 // timeWalk[iPad] - time walk of the pad, ns
514 // timeDelay[iPad] - time delay for neighbouring pad to hited pad, ns
515 // PadId[iPad] - Pad Identifier
516 // E | F --> PadId[iPad] = 5 | 6
517 // A | B --> PadId[iPad] = 1 | 2
518 // C | D --> PadId[iPad] = 3 | 4
519 // nTail[iPad] - the tail number, = 1 for tailA, = 2 for tailB
520 // qCenterPad - charge extimated for each pad, arb. units
521 // weightsSum - sum of weights extimated for each pad fired, arb. units
523 const Float_t kSigmaForTail[2] = {AliTOFConstants::fgkSigmaForTail1,AliTOFConstants::fgkSigmaForTail2}; //for tail
524 Int_t iz = 0, ix = 0;
525 Float_t dX = 0., dZ = 0., x = 0., z = 0.;
526 Float_t h = fHparameter, h2 = fH2parameter, k = fKparameter, k2 = fK2parameter;
527 Float_t effX = 0., effZ = 0., resX = 0., resZ = 0., timeWalkX = 0., timeWalkZ = 0.;
528 Float_t logOfqInd = 0.;
529 Float_t weightsSum = 0.;
530 Int_t nTail[4] = {0,0,0,0};
531 Int_t padId[4] = {0,0,0,0};
532 Float_t eff[4] = {0.,0.,0.,0.};
533 Float_t res[4] = {0.,0.,0.,0.};
534 // Float_t qCenterPad = fMinimumCharge * fMinimumCharge;
535 Float_t qCenterPad = 1.;
536 Float_t timeWalk[4] = {0.,0.,0.,0.};
537 Float_t timeDelay[4] = {0.,0.,0.,0.};
542 (z0 <= 0) ? iz = 0 : iz = 1;
543 dZ = z0 + (0.5 * AliTOFConstants::fgkNpadZ - iz - 0.5) * AliTOFConstants::fgkZPad; // hit position in the pad frame, (0,0) - center of the pad
544 z = 0.5 * AliTOFConstants::fgkZPad - TMath::Abs(dZ); // variable for eff., res. and timeWalk. functions
545 iz++; // z row: 1, ..., AliTOFConstants::fgkNpadZ = 2
546 ix = (Int_t)((x0 + 0.5 * AliTOFConstants::fgkNpadX * AliTOFConstants::fgkXPad) / AliTOFConstants::fgkXPad);
547 dX = x0 + (0.5 * AliTOFConstants::fgkNpadX - ix - 0.5) * AliTOFConstants::fgkXPad; // hit position in the pad frame, (0,0) - center of the pad
548 x = 0.5 * AliTOFConstants::fgkXPad - TMath::Abs(dX); // variable for eff., res. and timeWalk. functions;
549 ix++; // x row: 1, ..., AliTOFConstants::fgkNpadX = 48
553 nPlace[nActivatedPads-1] = (iz - 1) * AliTOFConstants::fgkNpadX + ix;
554 qInduced[nActivatedPads-1] = qCenterPad;
555 padId[nActivatedPads-1] = 1;
557 if (fEdgeEffect == 0) {
558 eff[nActivatedPads-1] = fEffCenter;
559 if (gRandom->Rndm() < eff[nActivatedPads-1]) {
561 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + fResCenter * fResCenter); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns;
562 isFired[nActivatedPads-1] = kTRUE;
563 tofTime[nActivatedPads-1] = gRandom->Gaus(geantTime + fTimeWalkCenter, res[0]);
564 averageTime = tofTime[nActivatedPads-1];
570 effZ = fEffBoundary + (fEff2Boundary - fEffBoundary) * z / h2;
572 effZ = fEff2Boundary + (fEffCenter - fEff2Boundary) * (z - h2) / (h - h2);
574 resZ = fResBoundary + (fResCenter - fResBoundary) * z / h;
575 timeWalkZ = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * z / h;
576 nTail[nActivatedPads-1] = 1;
580 timeWalkZ = fTimeWalkCenter;
585 effX = fEffBoundary + (fEff2Boundary - fEffBoundary) * x / h2;
587 effX = fEff2Boundary + (fEffCenter - fEff2Boundary) * (x - h2) / (h - h2);
589 resX = fResBoundary + (fResCenter - fResBoundary) * x / h;
590 timeWalkX = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * x / h;
591 nTail[nActivatedPads-1] = 1;
595 timeWalkX = fTimeWalkCenter;
598 (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX;
599 (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
600 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
605 effZ = fEffBoundary - (fEffBoundary - fEff3Boundary) * (z / k2);
607 effZ = fEff3Boundary * (k - z) / (k - k2);
609 resZ = fResBoundary + fResSlope * z / k;
610 timeWalkZ = fTimeWalkBoundary + fTimeWalkSlope * z / k;
613 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
615 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX;
616 eff[nActivatedPads-1] = effZ;
617 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
618 timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ; // ns
619 nTail[nActivatedPads-1] = 2;
620 if (fTimeDelayFlag) {
621 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
622 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
623 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
624 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
625 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
627 timeDelay[nActivatedPads-1] = 0.;
629 padId[nActivatedPads-1] = 2;
634 ////// Pad C, D, E, F:
636 effX = fEffBoundary - (fEffBoundary - fEff3Boundary) * (x / k2);
638 effX = fEff3Boundary * (k - x) / (k - k2);
640 resX = fResBoundary + fResSlope*x/k;
641 timeWalkX = fTimeWalkBoundary + fTimeWalkSlope*x/k;
645 if(ix > 1 && dX < 0) {
647 nPlace[nActivatedPads-1] = nPlace[0] - 1;
648 eff[nActivatedPads-1] = effX;
649 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
650 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
651 nTail[nActivatedPads-1] = 2;
652 if (fTimeDelayFlag) {
653 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
654 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
655 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
656 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
657 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
659 timeDelay[nActivatedPads-1] = 0.;
661 padId[nActivatedPads-1] = 3;
665 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
667 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX - 1;
668 eff[nActivatedPads-1] = effX * effZ;
669 (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
670 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
672 nTail[nActivatedPads-1] = 2;
673 if (fTimeDelayFlag) {
674 if (TMath::Abs(x) < TMath::Abs(z)) {
675 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
676 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
677 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
678 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
680 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
681 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
682 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
683 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
685 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
687 timeDelay[nActivatedPads-1] = 0.;
689 padId[nActivatedPads-1] = 4;
695 if(ix < AliTOFConstants::fgkNpadX && dX > 0) {
697 nPlace[nActivatedPads-1] = nPlace[0] + 1;
698 eff[nActivatedPads-1] = effX;
699 res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(10400 + resX * resX)); // ns
700 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
701 nTail[nActivatedPads-1] = 2;
702 if (fTimeDelayFlag) {
703 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
704 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
705 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
706 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
707 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
709 timeDelay[nActivatedPads-1] = 0.;
711 padId[nActivatedPads-1] = 5;
716 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
718 nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX + 1;
719 eff[nActivatedPads - 1] = effX * effZ;
720 (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
721 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001*timeWalkX; // ns
722 nTail[nActivatedPads-1] = 2;
723 if (fTimeDelayFlag) {
724 if (TMath::Abs(x) < TMath::Abs(z)) {
725 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
726 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
727 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
728 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
730 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
731 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
732 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
733 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
735 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
737 timeDelay[nActivatedPads-1] = 0.;
739 padId[nActivatedPads-1] = 6;
746 for (Int_t iPad = 0; iPad < nActivatedPads; iPad++) {
747 if (res[iPad] < fTimeResolution) res[iPad] = fTimeResolution;
748 if(gRandom->Rndm() < eff[iPad]) {
749 isFired[iPad] = kTRUE;
752 if(nTail[iPad] == 0) {
753 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
755 ftail->SetParameters(res[iPad], 2. * res[iPad], kSigmaForTail[nTail[iPad]-1]);
756 Double_t timeAB = ftail->GetRandom();
757 tofTime[iPad] = geantTime + timeWalk[iPad] + timeDelay[iPad] + timeAB;
760 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
762 if (fAverageTimeFlag) {
763 averageTime += tofTime[iPad] * qInduced[iPad];
764 weightsSum += qInduced[iPad];
766 averageTime += tofTime[iPad];
771 if (weightsSum!=0) averageTime /= weightsSum;
772 } // end else (fEdgeEffect != 0)
775 //__________________________________________________________________
776 void AliTOFSDigitizer::PrintParameters()const
779 // Print parameters used for sdigitization
781 cout << " ------------------- "<< GetName() << " -------------" << endl ;
782 cout << " Parameters used for TOF SDigitization " << endl ;
783 // Printing the parameters
785 cout << " Number of events: " << (fEvent2-fEvent1) << endl;
786 cout << " from event " << fEvent1 << " to event " << (fEvent2-1) << endl;
787 cout << " Time Resolution (ns) "<< fTimeResolution <<" Pad Efficiency: "<< fpadefficiency << endl;
788 cout << " Edge Effect option: "<< fEdgeEffect<< endl;
790 cout << " Boundary Effect Simulation Parameters " << endl;
791 cout << " Hparameter: "<< fHparameter<<" H2parameter:"<< fH2parameter <<" Kparameter:"<< fKparameter<<" K2parameter: "<< fK2parameter << endl;
792 cout << " Efficiency in the central region of the pad: "<< fEffCenter << endl;
793 cout << " Efficiency at the boundary region of the pad: "<< fEffBoundary << endl;
794 cout << " Efficiency value at H2parameter "<< fEff2Boundary << endl;
795 cout << " Efficiency value at K2parameter "<< fEff3Boundary << endl;
796 cout << " Resolution (ps) in the central region of the pad: "<< fResCenter << endl;
797 cout << " Resolution (ps) at the boundary of the pad : "<< fResBoundary << endl;
798 cout << " Slope (ps/K) for neighbouring pad : "<< fResSlope <<endl;
799 cout << " Time walk (ps) in the central region of the pad : "<< fTimeWalkCenter << endl;
800 cout << " Time walk (ps) at the boundary of the pad : "<< fTimeWalkBoundary<< endl;
801 cout << " Slope (ps/K) for neighbouring pad : "<< fTimeWalkSlope<<endl;
802 cout << " Pulse Heigth Simulation Parameters " << endl;
803 cout << " Flag for delay due to the PulseHeightEffect: "<< fTimeDelayFlag <<endl;
804 cout << " Pulse Height Slope : "<< fPulseHeightSlope<<endl;
805 cout << " Time Delay Slope : "<< fTimeDelaySlope<<endl;
806 cout << " Minimum charge amount which could be induced : "<< fMinimumCharge<<endl;
807 cout << " Smearing in charge in (q1/q2) vs x plot : "<< fChargeSmearing<<endl;
808 cout << " Smearing in log of charge ratio : "<< fLogChargeSmearing<<endl;
809 cout << " Smearing in time in time vs log(q1/q2) plot : "<< fTimeSmearing<<endl;
810 cout << " Flag for average time : "<< fAverageTimeFlag<<endl;
811 cout << " Edge tails option : "<< fEdgeTails << endl;