]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFSDigitizer.cxx
Latest version
[u/mrichter/AliRoot.git] / TOF / AliTOFSDigitizer.cxx
CommitLineData
517b7f8f 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16//_________________________________________________________________________
17// This is a TTask that constructs SDigits out of Hits
ea7a588a 18// A Summable Digits is the "sum" of all hits in a pad
19// Detector response has been simulated via the method
20// SimulateDetectorResponse
517b7f8f 21//
ea7a588a 22//-- Authors: F. Pierella, A. De Caro
23// Use case: see AliTOFhits2sdigits.C macro in the CVS
517b7f8f 24//////////////////////////////////////////////////////////////////////////////
25
ea7a588a 26#include "TBenchmark.h"
517b7f8f 27#include "TTask.h"
28#include "TTree.h"
29#include "TSystem.h"
ea7a588a 30#include "TParticle.h"
31#include "TH1.h"
bfec09a6 32#include "TFile.h"
33#include "TROOT.h"
34#include "TFolder.h"
35#include <TF1.h>
36#include <stdlib.h>
37#include <iostream.h>
38#include <fstream.h>
517b7f8f 39
5919c40c 40#include "AliTOFHitMap.h"
41#include "AliTOFSDigit.h"
f73548c4 42#include "AliTOFConstants.h"
517b7f8f 43#include "AliTOFhit.h"
44#include "AliTOF.h"
45#include "AliTOFv1.h"
46#include "AliTOFv2.h"
47#include "AliTOFv3.h"
48#include "AliTOFv4.h"
49#include "AliTOFSDigitizer.h"
50#include "AliRun.h"
51#include "AliDetector.h"
52#include "AliMC.h"
53
517b7f8f 54
55ClassImp(AliTOFSDigitizer)
56
57//____________________________________________________________________________
58 AliTOFSDigitizer::AliTOFSDigitizer():TTask("AliTOFSDigitizer","")
59{
60 // ctor
ea7a588a 61 fEvent1=0;
62 fEvent2=0;
f73548c4 63 ftail = 0;
55991c8b 64 fSelectedSector=0;
65 fSelectedPlate =0;
517b7f8f 66}
67
68//____________________________________________________________________________
bfec09a6 69 AliTOFSDigitizer::AliTOFSDigitizer(char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("AliTOFSDigitizer","")
517b7f8f 70{
ea7a588a 71 fEvent1=evNumber1;
72 fEvent2=fEvent1+nEvents;
f73548c4 73 ftail = 0;
55991c8b 74 fSelectedSector=0; // by default we sdigitize all sectors
75 fSelectedPlate =0; // by default we sdigitize all plates in all sectors
f73548c4 76
ea7a588a 77 fHeadersFile = HeaderFile ; // input filename (with hits)
ea7a588a 78 TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data() ) ;
79
80 //File was not opened yet
81 // open file and get alirun object
82 if(file == 0){
83 file = TFile::Open(fHeadersFile.Data(),"update") ;
84 gAlice = (AliRun *) file->Get("gAlice") ;
85 }
86
f73548c4 87 // init parameters for sdigitization
88 InitParameters();
89
517b7f8f 90 // add Task to //root/Tasks folder
91 TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
92 roottasks->Add(this) ;
93}
94
95//____________________________________________________________________________
96 AliTOFSDigitizer::~AliTOFSDigitizer()
97{
98 // dtor
f73548c4 99}
100
101//____________________________________________________________________________
102void AliTOFSDigitizer::InitParameters()
103{
104 // set parameters for detector simulation
105
106 fTimeResolution =0.120;
107 fpadefficiency =0.99 ;
108 fEdgeEffect = 2 ;
109 fEdgeTails = 0 ;
110 fHparameter = 0.4 ;
111 fH2parameter = 0.15;
112 fKparameter = 0.5 ;
113 fK2parameter = 0.35;
114 fEffCenter = fpadefficiency;
115 fEffBoundary = 0.65;
116 fEff2Boundary = 0.90;
117 fEff3Boundary = 0.08;
118 fResCenter = 50. ;
119 fResBoundary = 70. ;
120 fResSlope = 40. ;
121 fTimeWalkCenter = 0. ;
122 fTimeWalkBoundary=0. ;
123 fTimeWalkSlope = 0. ;
124 fTimeDelayFlag = 1 ;
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;
132 fAverageTimeFlag=0 ;
ea7a588a 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
f73548c4 139}
140
141//__________________________________________________________________
ea7a588a 142Double_t TimeWithTail(Double_t* x, Double_t* par)
f73548c4 143{
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)
147 Float_t xx =x[0];
148 Double_t f;
149 if(xx<par[0]*par[2]) {
150 f = TMath::Exp(-xx*xx/(2*par[0]*par[0]));
151 } else {
152 f = TMath::Exp(-(xx-par[0]*par[2])/par[1]-0.5*par[2]*par[2]);
153 }
154 return f;
517b7f8f 155}
156
f73548c4 157
517b7f8f 158//____________________________________________________________________________
ea7a588a 159void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
517b7f8f 160
ea7a588a 161 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all"))
162 gBenchmark->Start("TOFSDigitizer");
517b7f8f 163
517b7f8f 164 AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF");
165
5919c40c 166 if (!TOF) {
167 Error("AliTOFSDigitizer","TOF not found");
168 return;
169 }
170
55991c8b 171 // is pointer to fSDigits non zero after changes?
172 cout<<"TOF fSDigits pointer:"<<TOF->SDigits()<<endl;
173
174 // recreate TClonesArray fSDigits - for backward compatibility
175 if (TOF->SDigits() == 0) {
176 TOF->CreateSDigitsArray();
177 } else {
178 TOF->RecreateSDigitsArray();
179 }
180
181
ea7a588a 182 if (fEdgeTails) ftail = new TF1("tail",TimeWithTail,-2,2,3);
183
184 Int_t nselectedHits=0;
185 Int_t ntotalsdigits=0;
186 Int_t ntotalupdates=0;
187 Int_t nnoisesdigits=0;
188 Int_t nsignalsdigits=0;
189 Int_t nHitsFromPrim=0;
190 Int_t nHitsFromSec=0;
191 Int_t nlargeTofDiff=0;
f73548c4 192
ea7a588a 193 if (strstr(allEvents,"all")){
194 fEvent1=0;
195 fEvent2= (Int_t) gAlice->TreeE()->GetEntries();
196 }
197
55991c8b 198 Bool_t thereIsNotASelection=(fSelectedSector==0) && (fSelectedPlate==0);
199
ea7a588a 200 for (Int_t ievent = fEvent1; ievent < fEvent2; ievent++) {
201 cout << "------------------- "<< GetName() << " -------------" << endl ;
202 cout << "Sdigitizing event " << ievent << endl;
203
204 Int_t nselectedHitsinEv=0;
205 Int_t ntotalsdigitsinEv=0;
206 Int_t ntotalupdatesinEv=0;
207 Int_t nnoisesdigitsinEv=0;
208 Int_t nsignalsdigitsinEv=0;
517b7f8f 209
5919c40c 210 gAlice->GetEvent(ievent);
211 TTree *TH = gAlice->TreeH ();
212 if (!TH)
213 return;
214 if (gAlice->TreeS () == 0)
215 gAlice->MakeTree ("S");
517b7f8f 216
217
5919c40c 218 //Make branches
219 char branchname[20];
220 sprintf (branchname, "%s", TOF->GetName ());
221 //Make branch for digits
222 TOF->MakeBranch ("S");
517b7f8f 223
5919c40c 224 //Now made SDigits from hits
225
226 Int_t vol[5]; // location for a digit
227 Float_t digit[2]; // TOF digit variables
228 TParticle *particle;
229 AliTOFhit *tofHit;
230 TClonesArray *TOFhits = TOF->Hits();
231
f73548c4 232 // create hit map
5919c40c 233 AliTOFHitMap *hitMap = new AliTOFHitMap(TOF->SDigits());
234
55991c8b 235 // increase performances in terms of CPU time
bfec09a6 236 TH->SetBranchStatus("*",0); // switch off all branches
237 TH->SetBranchStatus("TOF*",1); // switch on only TOF
238
5919c40c 239 Int_t ntracks = static_cast<Int_t>(TH->GetEntries());
240 for (Int_t track = 0; track < ntracks; track++)
241 {
242 gAlice->ResetHits();
243 TH->GetEvent(track);
244 particle = gAlice->Particle(track);
245 Int_t nhits = TOFhits->GetEntriesFast();
f73548c4 246 // cleaning all hits of the same track in the same pad volume
247 // it is a rare event, however it happens
248
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;
5919c40c 255
256 for (Int_t hit = 0; hit < nhits; hit++)
257 {
258 tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit);
f73548c4 259 Int_t tracknum = tofHit->GetTrack();
5919c40c 260 vol[0] = tofHit->GetSector();
261 vol[1] = tofHit->GetPlate();
ea7a588a 262
55991c8b 263 // selection case for sdigitizing only hits in a given plate of a given sector
264 if(thereIsNotASelection || (vol[0]==fSelectedSector && vol[1]==fSelectedPlate)){
265
266 vol[2] = tofHit->GetStrip();
267 vol[3] = tofHit->GetPadx();
268 vol[4] = tofHit->GetPadz();
269
270 Bool_t dummy=((tracknum==previousTrack) && (vol[0]==previousSector) && (vol[1]==previousPlate) && (vol[2]==previousStrip));
271
272 Bool_t isCloneOfThePrevious=dummy && ((vol[3]==previousPadX) && (vol[4]==previousPadZ));
273
b213b8bd 274 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))));
55991c8b 275
b213b8bd 276 if(!isCloneOfThePrevious && !isNeighOfThePrevious){
55991c8b 277 // update "previous" values
278 // in fact, we are yet in the future, so the present is past
279 previousTrack=tracknum;
280 previousSector=vol[0];
281 previousPlate=vol[1];
282 previousStrip=vol[2];
283 previousPadX=vol[3];
284 previousPadZ=vol[4];
285
286 nselectedHits++;
287 nselectedHitsinEv++;
288 if (particle->GetFirstMother() < 0){
289 nHitsFromPrim++;
290 } // counts hits due to primary particles
291
292 Float_t Xpad = tofHit->GetDx();
293 Float_t Zpad = tofHit->GetDz();
294 Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad;
295 Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad;
296 Float_t geantTime = tofHit->GetTof(); // unit [s]
297 geantTime *= 1.e+09; // conversion from [s] to [ns]
298
299 //cout << "geantTime " << geantTime << " [ns]" << endl;
300 Int_t nActivatedPads = 0, nFiredPads = 0;
301 Bool_t isFired[4] = {kFALSE, kFALSE, kFALSE, kFALSE};
302 Float_t tofAfterSimul[4] = {0., 0., 0., 0.};
303 Float_t qInduced[4] = {0.,0.,0.,0.};
304 Int_t nPlace[4] = {0, 0, 0, 0};
305 Float_t averageTime = 0.;
306 SimulateDetectorResponse(zStrip,xStrip,geantTime,nActivatedPads,nFiredPads,isFired,nPlace,qInduced,tofAfterSimul,averageTime);
307 if(nFiredPads) {
308 for(Int_t indexOfPad=0; indexOfPad<nActivatedPads; indexOfPad++) {
309 if(isFired[indexOfPad]){ // the pad has fired
310 Float_t timediff=geantTime-tofAfterSimul[indexOfPad];
311
312 if(timediff>=0.2) nlargeTofDiff++;
313
b213b8bd 314 digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/fTdcBin); // TDC bin number (each bin -> 50. ps)
55991c8b 315
316 Float_t landauFactor = gRandom->Landau(fAdcMean, fAdcRms);
317 digit[1] = (Int_t) (qInduced[indexOfPad] * landauFactor); // ADC bins (each bin -> 0.25 (or 0.03) pC)
318
319 // recalculate the volume only for neighbouring pads
ea7a588a 320 if(indexOfPad){
55991c8b 321 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[4] = 1 : vol[4] = 2;
322 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[3] = nPlace[indexOfPad] : vol[3] = nPlace[indexOfPad] - AliTOFConstants::fgkNpadX;
ea7a588a 323 }
55991c8b 324
325 // check if two sdigit are on the same pad; in that case we sum
326 // the two or more sdigits
327 if (hitMap->TestHit(vol) != kEmpty) {
328 AliTOFSDigit *sdig = static_cast<AliTOFSDigit*>(hitMap->GetHit(vol));
329 Int_t tdctime = (Int_t) digit[0];
330 Int_t adccharge = (Int_t) digit[1];
b213b8bd 331 sdig->Update(fTdcBin,tdctime,adccharge,tracknum);
55991c8b 332 ntotalupdatesinEv++;
333 ntotalupdates++;
334 } else {
335
336 TOF->AddSDigit(tracknum, vol, digit);
337
338 if(indexOfPad){
339 nnoisesdigits++;
340 nnoisesdigitsinEv++;
341 } else {
342 nsignalsdigits++;
343 nsignalsdigitsinEv++;
344 }
345 ntotalsdigitsinEv++;
346 ntotalsdigits++;
347 hitMap->SetHit(vol);
348 } // if (hitMap->TestHit(vol) != kEmpty)
349 } // if(isFired[indexOfPad])
350 } // end loop on nActivatedPads
351 } // if(nFiredPads) i.e. if some pads has fired
352 } // close if(!isCloneOfThePrevious)
353 } // close the selection on sector and plate
5919c40c 354 } // end loop on hits for the current track
355 } // end loop on ntracks
55991c8b 356
5919c40c 357 delete hitMap;
517b7f8f 358
5919c40c 359 gAlice->TreeS()->Reset();
360 gAlice->TreeS()->Fill();
ea7a588a 361 //gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
362 gAlice->TreeS()->AutoSave();
363
364 if(strstr(verboseOption,"all")){
365 cout << "----------------------------------------" << endl;
366 cout << " <AliTOFSDigitizer> " << endl;
367 cout << "After sdigitizing " << nselectedHitsinEv << " hits" << " in event " << ievent << endl;
368 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
369 cout << ntotalsdigitsinEv << " digits have been created " << endl;
370 cout << "(" << nsignalsdigitsinEv << " due to signals and " << nnoisesdigitsinEv << " due to border effect)" << endl;
371 cout << ntotalupdatesinEv << " total updates of the hit map have been performed in current event" << endl;
372 cout << "----------------------------------------" << endl;
373 }
374
375 } //event loop on events
376
377 // free used memory
378 if (ftail){
379 delete ftail;
380 ftail = 0;
381 }
382
383 nHitsFromSec=nselectedHits-nHitsFromPrim;
384 if(strstr(verboseOption,"all")){
385 cout << "----------------------------------------" << endl;
386 cout << "----------------------------------------" << endl;
387 cout << "-----------SDigitization Summary--------" << endl;
388 cout << " <AliTOFSDigitizer> " << endl;
389 cout << "After sdigitizing " << nselectedHits << " hits" << endl;
390 cout << "in " << (fEvent2-fEvent1) << " events" << endl;
391//" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
392 cout << ntotalsdigits << " sdigits have been created " << endl;
393 cout << "(" << nsignalsdigits << " due to signals and " << nnoisesdigits << " due to border effect)" << endl;
394 cout << ntotalupdates << " total updates of the hit map have been performed" << endl;
395 cout << "in " << nlargeTofDiff << " cases the time of flight difference is greater than 200 ps" << endl;
396 }
397
517b7f8f 398
ea7a588a 399 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all")){
400 gBenchmark->Stop("TOFSDigitizer");
401 cout << "AliTOFSDigitizer:" << endl ;
402 cout << " took " << gBenchmark->GetCpuTime("TOFSDigitizer") << " seconds in order to make sdigits "
403 << gBenchmark->GetCpuTime("TOFSDigitizer")/(fEvent2-fEvent1) << " seconds per event " << endl ;
404 cout << endl ;
405 }
517b7f8f 406
ea7a588a 407 Print("");
517b7f8f 408}
ea7a588a 409
517b7f8f 410//__________________________________________________________________
ea7a588a 411void AliTOFSDigitizer::Print(Option_t* opt)const
517b7f8f 412{
413 cout << "------------------- "<< GetName() << " -------------" << endl ;
bfec09a6 414
517b7f8f 415}
f73548c4 416
55991c8b 417//__________________________________________________________________
418void AliTOFSDigitizer::SelectSectorAndPlate(Int_t sector, Int_t plate)
419{
420 Bool_t isaWrongSelection=(sector < 1) || (sector > AliTOFConstants::fgkNSectors) || (plate < 1) || (plate > AliTOFConstants::fgkNPlates);
421 if(isaWrongSelection){
422 cout << "You have selected an invalid value for sector or plate " << endl;
423 cout << "The correct range for sector is [1,"<< AliTOFConstants::fgkNSectors <<"]" << endl;
424 cout << "The correct range for plate is [1,"<< AliTOFConstants::fgkNPlates <<"]" << endl;
425 cout << "By default we continue sdigitizing all hits in all plates of all sectors" << endl;
426 } else {
427 fSelectedSector=sector;
428 fSelectedPlate =plate;
429 cout << "SDigitizing only hits in plate " << fSelectedPlate << " of the sector " << fSelectedSector << endl;
430 }
431}
432
f73548c4 433//__________________________________________________________________
434void 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)
435{
436 // Description:
437 // Input: z0, x0 - hit position in the strip system (0,0 - center of the strip), cm
438 // geantTime - time generated by Geant, ns
439 // Output: nActivatedPads - the number of pads activated by the hit (1 || 2 || 4)
440 // nFiredPads - the number of pads fired (really activated) by the hit (nFiredPads <= nActivatedPads)
441 // qInduced[iPad]- charge induced on pad, arb. units
442 // this array is initialized at zero by the caller
443 // tofAfterSimul[iPad] - time calculated with edge effect algorithm, ns
444 // this array is initialized at zero by the caller
445 // 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.
446 // The weight is given by the qInduced[iPad]/qCenterPad
447 // this variable is initialized at zero by the caller
448 // nPlace[iPad] - the number of the pad place, iPad = 0, 1, 2, 3
449 // this variable is initialized at zero by the caller
450 //
451 // Description of used variables:
452 // eff[iPad] - efficiency of the pad
453 // res[iPad] - resolution of the pad, ns
454 // timeWalk[iPad] - time walk of the pad, ns
455 // timeDelay[iPad] - time delay for neighbouring pad to hited pad, ns
456 // PadId[iPad] - Pad Identifier
457 // E | F --> PadId[iPad] = 5 | 6
458 // A | B --> PadId[iPad] = 1 | 2
459 // C | D --> PadId[iPad] = 3 | 4
460 // nTail[iPad] - the tail number, = 1 for tailA, = 2 for tailB
461 // qCenterPad - charge extimated for each pad, arb. units
462 // weightsSum - sum of weights extimated for each pad fired, arb. units
463
464 const Float_t kSigmaForTail[2] = {AliTOFConstants::fgkSigmaForTail1,AliTOFConstants::fgkSigmaForTail2}; //for tail
465 Int_t iz = 0, ix = 0;
466 Float_t dX = 0., dZ = 0., x = 0., z = 0.;
467 Float_t h = fHparameter, h2 = fH2parameter, k = fKparameter, k2 = fK2parameter;
468 Float_t effX = 0., effZ = 0., resX = 0., resZ = 0., timeWalkX = 0., timeWalkZ = 0.;
469 Float_t logOfqInd = 0.;
470 Float_t weightsSum = 0.;
471 Int_t nTail[4] = {0,0,0,0};
472 Int_t padId[4] = {0,0,0,0};
473 Float_t eff[4] = {0.,0.,0.,0.};
474 Float_t res[4] = {0.,0.,0.,0.};
475 // Float_t qCenterPad = fMinimumCharge * fMinimumCharge;
476 Float_t qCenterPad = 1.;
477 Float_t timeWalk[4] = {0.,0.,0.,0.};
478 Float_t timeDelay[4] = {0.,0.,0.,0.};
479
480 nActivatedPads = 0;
481 nFiredPads = 0;
482
483 (z0 <= 0) ? iz = 0 : iz = 1;
484 dZ = z0 + (0.5 * AliTOFConstants::fgkNpadZ - iz - 0.5) * AliTOFConstants::fgkZPad; // hit position in the pad frame, (0,0) - center of the pad
485 z = 0.5 * AliTOFConstants::fgkZPad - TMath::Abs(dZ); // variable for eff., res. and timeWalk. functions
486 iz++; // z row: 1, ..., AliTOFConstants::fgkNpadZ = 2
487 ix = (Int_t)((x0 + 0.5 * AliTOFConstants::fgkNpadX * AliTOFConstants::fgkXPad) / AliTOFConstants::fgkXPad);
488 dX = x0 + (0.5 * AliTOFConstants::fgkNpadX - ix - 0.5) * AliTOFConstants::fgkXPad; // hit position in the pad frame, (0,0) - center of the pad
489 x = 0.5 * AliTOFConstants::fgkXPad - TMath::Abs(dX); // variable for eff., res. and timeWalk. functions;
490 ix++; // x row: 1, ..., AliTOFConstants::fgkNpadX = 48
491
492 ////// Pad A:
493 nActivatedPads++;
494 nPlace[nActivatedPads-1] = (iz - 1) * AliTOFConstants::fgkNpadX + ix;
495 qInduced[nActivatedPads-1] = qCenterPad;
496 padId[nActivatedPads-1] = 1;
497
498 if (fEdgeEffect == 0) {
499 eff[nActivatedPads-1] = fEffCenter;
500 if (gRandom->Rndm() < eff[nActivatedPads-1]) {
501 nFiredPads = 1;
502 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + fResCenter * fResCenter); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns;
503 isFired[nActivatedPads-1] = kTRUE;
504 tofTime[nActivatedPads-1] = gRandom->Gaus(geantTime + fTimeWalkCenter, res[0]);
505 averageTime = tofTime[nActivatedPads-1];
506 }
507 } else {
508
509 if(z < h) {
510 if(z < h2) {
511 effZ = fEffBoundary + (fEff2Boundary - fEffBoundary) * z / h2;
512 } else {
513 effZ = fEff2Boundary + (fEffCenter - fEff2Boundary) * (z - h2) / (h - h2);
514 }
515 resZ = fResBoundary + (fResCenter - fResBoundary) * z / h;
516 timeWalkZ = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * z / h;
517 nTail[nActivatedPads-1] = 1;
518 } else {
519 effZ = fEffCenter;
520 resZ = fResCenter;
521 timeWalkZ = fTimeWalkCenter;
522 }
523
524 if(x < h) {
525 if(x < h2) {
526 effX = fEffBoundary + (fEff2Boundary - fEffBoundary) * x / h2;
527 } else {
528 effX = fEff2Boundary + (fEffCenter - fEff2Boundary) * (x - h2) / (h - h2);
529 }
530 resX = fResBoundary + (fResCenter - fResBoundary) * x / h;
531 timeWalkX = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * x / h;
532 nTail[nActivatedPads-1] = 1;
533 } else {
534 effX = fEffCenter;
535 resX = fResCenter;
536 timeWalkX = fTimeWalkCenter;
537 }
538
539 (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX;
540 (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
541 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
542
543
544 ////// Pad B:
545 if(z < k2) {
546 effZ = fEffBoundary - (fEffBoundary - fEff3Boundary) * (z / k2);
547 } else {
548 effZ = fEff3Boundary * (k - z) / (k - k2);
549 }
550 resZ = fResBoundary + fResSlope * z / k;
551 timeWalkZ = fTimeWalkBoundary + fTimeWalkSlope * z / k;
552
553 if(z < k && z > 0) {
554 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
555 nActivatedPads++;
556 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX;
557 eff[nActivatedPads-1] = effZ;
558 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
559 timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ; // ns
560 nTail[nActivatedPads-1] = 2;
561 if (fTimeDelayFlag) {
562 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
563 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
564 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
565 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
566 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
567 } else {
568 timeDelay[nActivatedPads-1] = 0.;
569 }
570 padId[nActivatedPads-1] = 2;
571 }
572 }
573
574
575 ////// Pad C, D, E, F:
576 if(x < k2) {
577 effX = fEffBoundary - (fEffBoundary - fEff3Boundary) * (x / k2);
578 } else {
579 effX = fEff3Boundary * (k - x) / (k - k2);
580 }
581 resX = fResBoundary + fResSlope*x/k;
582 timeWalkX = fTimeWalkBoundary + fTimeWalkSlope*x/k;
583
584 if(x < k && x > 0) {
585 // C:
586 if(ix > 1 && dX < 0) {
587 nActivatedPads++;
588 nPlace[nActivatedPads-1] = nPlace[0] - 1;
589 eff[nActivatedPads-1] = effX;
590 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
591 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
592 nTail[nActivatedPads-1] = 2;
593 if (fTimeDelayFlag) {
594 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
595 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
596 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
597 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
598 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
599 } else {
600 timeDelay[nActivatedPads-1] = 0.;
601 }
602 padId[nActivatedPads-1] = 3;
603
604 // D:
605 if(z < k && z > 0) {
606 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
607 nActivatedPads++;
608 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX - 1;
609 eff[nActivatedPads-1] = effX * effZ;
610 (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
611 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
612
613 nTail[nActivatedPads-1] = 2;
614 if (fTimeDelayFlag) {
615 if (TMath::Abs(x) < TMath::Abs(z)) {
616 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
617 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
618 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
619 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
620 } else {
621 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
622 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
623 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
624 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
625 }
626 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
627 } else {
628 timeDelay[nActivatedPads-1] = 0.;
629 }
630 padId[nActivatedPads-1] = 4;
631 }
632 } // end D
633 } // end C
634
635 // E:
636 if(ix < AliTOFConstants::fgkNpadX && dX > 0) {
637 nActivatedPads++;
638 nPlace[nActivatedPads-1] = nPlace[0] + 1;
639 eff[nActivatedPads-1] = effX;
640 res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(10400 + resX * resX)); // ns
641 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
642 nTail[nActivatedPads-1] = 2;
643 if (fTimeDelayFlag) {
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);
648 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
649 } else {
650 timeDelay[nActivatedPads-1] = 0.;
651 }
652 padId[nActivatedPads-1] = 5;
653
654
655 // F:
656 if(z < k && z > 0) {
657 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
658 nActivatedPads++;
659 nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX + 1;
660 eff[nActivatedPads - 1] = effX * effZ;
661 (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
662 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001*timeWalkX; // ns
663 nTail[nActivatedPads-1] = 2;
664 if (fTimeDelayFlag) {
665 if (TMath::Abs(x) < TMath::Abs(z)) {
666 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
667 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
668 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
669 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
670 } else {
671 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
672 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
673 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
674 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
675 }
676 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
677 } else {
678 timeDelay[nActivatedPads-1] = 0.;
679 }
680 padId[nActivatedPads-1] = 6;
681 }
682 } // end F
683 } // end E
684 } // end if(x < k)
685
686
687 for (Int_t iPad = 0; iPad < nActivatedPads; iPad++) {
688 if (res[iPad] < fTimeResolution) res[iPad] = fTimeResolution;
689 if(gRandom->Rndm() < eff[iPad]) {
690 isFired[iPad] = kTRUE;
691 nFiredPads++;
692 if(fEdgeTails) {
693 if(nTail[iPad] == 0) {
694 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
695 } else {
696 ftail->SetParameters(res[iPad], 2. * res[iPad], kSigmaForTail[nTail[iPad]-1]);
697 Double_t timeAB = ftail->GetRandom();
698 tofTime[iPad] = geantTime + timeWalk[iPad] + timeDelay[iPad] + timeAB;
699 }
700 } else {
701 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
702 }
703 if (fAverageTimeFlag) {
704 averageTime += tofTime[iPad] * qInduced[iPad];
705 weightsSum += qInduced[iPad];
706 } else {
707 averageTime += tofTime[iPad];
708 weightsSum += 1.;
709 }
710 }
711 }
712 if (weightsSum!=0) averageTime /= weightsSum;
713 } // end else (fEdgeEffect != 0)
714}
715
716//__________________________________________________________________
717void AliTOFSDigitizer::PrintParameters()const
718{
719 //
720 // Print parameters used for sdigitization
721 //
722 cout << " ------------------- "<< GetName() << " -------------" << endl ;
723 cout << " Parameters used for TOF SDigitization " << endl ;
724 // Printing the parameters
725
ea7a588a 726 cout << " Number of events: " << (fEvent2-fEvent1) << endl;
727 cout << " from event " << fEvent1 << " to event " << (fEvent2-1) << endl;
f73548c4 728 cout << " Time Resolution (ns) "<< fTimeResolution <<" Pad Efficiency: "<< fpadefficiency << endl;
729 cout << " Edge Effect option: "<< fEdgeEffect<< endl;
730
731 cout << " Boundary Effect Simulation Parameters " << endl;
732 cout << " Hparameter: "<< fHparameter<<" H2parameter:"<< fH2parameter <<" Kparameter:"<< fKparameter<<" K2parameter: "<< fK2parameter << endl;
733 cout << " Efficiency in the central region of the pad: "<< fEffCenter << endl;
734 cout << " Efficiency at the boundary region of the pad: "<< fEffBoundary << endl;
735 cout << " Efficiency value at H2parameter "<< fEff2Boundary << endl;
736 cout << " Efficiency value at K2parameter "<< fEff3Boundary << endl;
737 cout << " Resolution (ps) in the central region of the pad: "<< fResCenter << endl;
738 cout << " Resolution (ps) at the boundary of the pad : "<< fResBoundary << endl;
739 cout << " Slope (ps/K) for neighbouring pad : "<< fResSlope <<endl;
740 cout << " Time walk (ps) in the central region of the pad : "<< fTimeWalkCenter << endl;
741 cout << " Time walk (ps) at the boundary of the pad : "<< fTimeWalkBoundary<< endl;
742 cout << " Slope (ps/K) for neighbouring pad : "<< fTimeWalkSlope<<endl;
743 cout << " Pulse Heigth Simulation Parameters " << endl;
744 cout << " Flag for delay due to the PulseHeightEffect: "<< fTimeDelayFlag <<endl;
745 cout << " Pulse Height Slope : "<< fPulseHeightSlope<<endl;
746 cout << " Time Delay Slope : "<< fTimeDelaySlope<<endl;
747 cout << " Minimum charge amount which could be induced : "<< fMinimumCharge<<endl;
748 cout << " Smearing in charge in (q1/q2) vs x plot : "<< fChargeSmearing<<endl;
749 cout << " Smearing in log of charge ratio : "<< fLogChargeSmearing<<endl;
750 cout << " Smearing in time in time vs log(q1/q2) plot : "<< fTimeSmearing<<endl;
751 cout << " Flag for average time : "<< fAverageTimeFlag<<endl;
752 cout << " Edge tails option : "<< fEdgeTails << endl;
753
754}