]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFSDigitizer.cxx
Adding AliTPCKalmanSegment
[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>
f8014e68 37#include <Riostream.h>
38#include <Riostream.h>
517b7f8f 39
5919c40c 40#include "AliTOFHitMap.h"
41#include "AliTOFSDigit.h"
f73548c4 42#include "AliTOFConstants.h"
517b7f8f 43#include "AliTOFhit.h"
016e1f91 44#include "AliTOFhitT0.h"
517b7f8f 45#include "AliTOF.h"
46#include "AliTOFv1.h"
47#include "AliTOFv2.h"
48#include "AliTOFv3.h"
49#include "AliTOFv4.h"
50#include "AliTOFSDigitizer.h"
51#include "AliRun.h"
52#include "AliDetector.h"
517b7f8f 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
016e1f91 181 Int_t version=TOF->IsVersion();
55991c8b 182
ea7a588a 183 if (fEdgeTails) ftail = new TF1("tail",TimeWithTail,-2,2,3);
184
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;
f73548c4 193
ea7a588a 194 if (strstr(allEvents,"all")){
195 fEvent1=0;
196 fEvent2= (Int_t) gAlice->TreeE()->GetEntries();
197 }
198
55991c8b 199 Bool_t thereIsNotASelection=(fSelectedSector==0) && (fSelectedPlate==0);
200
ea7a588a 201 for (Int_t ievent = fEvent1; ievent < fEvent2; ievent++) {
202 cout << "------------------- "<< GetName() << " -------------" << endl ;
203 cout << "Sdigitizing event " << ievent << endl;
204
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;
517b7f8f 210
5919c40c 211 gAlice->GetEvent(ievent);
212 TTree *TH = gAlice->TreeH ();
213 if (!TH)
214 return;
215 if (gAlice->TreeS () == 0)
216 gAlice->MakeTree ("S");
517b7f8f 217
218
5919c40c 219 //Make branches
220 char branchname[20];
221 sprintf (branchname, "%s", TOF->GetName ());
222 //Make branch for digits
223 TOF->MakeBranch ("S");
517b7f8f 224
5919c40c 225 //Now made SDigits from hits
226
016e1f91 227
5919c40c 228 TParticle *particle;
016e1f91 229 //AliTOFhit *tofHit;
5919c40c 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 {
016e1f91 258 Int_t vol[5]; // location for a digit
259 Float_t digit[2]; // TOF digit variables
260 Int_t tracknum;
261 Float_t Xpad;
262 Float_t Zpad;
263 Float_t geantTime;
264
265 // fp: really sorry for this, it is a temporary trick to have
266 // track length too
267 if(version!=6){
268 AliTOFhit *tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit);
269 tracknum = tofHit->GetTrack();
270 vol[0] = tofHit->GetSector();
271 vol[1] = tofHit->GetPlate();
272 vol[2] = tofHit->GetStrip();
273 vol[3] = tofHit->GetPadx();
274 vol[4] = tofHit->GetPadz();
275 Xpad = tofHit->GetDx();
276 Zpad = tofHit->GetDz();
277 geantTime = tofHit->GetTof(); // unit [s]
278 } else {
279 AliTOFhitT0 *tofHit = (AliTOFhitT0 *) TOFhits->UncheckedAt(hit);
280 tracknum = tofHit->GetTrack();
281 vol[0] = tofHit->GetSector();
282 vol[1] = tofHit->GetPlate();
55991c8b 283 vol[2] = tofHit->GetStrip();
284 vol[3] = tofHit->GetPadx();
285 vol[4] = tofHit->GetPadz();
016e1f91 286 Xpad = tofHit->GetDx();
287 Zpad = tofHit->GetDz();
288 geantTime = tofHit->GetTof(); // unit [s]
289 }
290
291 geantTime *= 1.e+09; // conversion from [s] to [ns]
292
293 // selection case for sdigitizing only hits in a given plate of a given sector
294 if(thereIsNotASelection || (vol[0]==fSelectedSector && vol[1]==fSelectedPlate)){
55991c8b 295
296 Bool_t dummy=((tracknum==previousTrack) && (vol[0]==previousSector) && (vol[1]==previousPlate) && (vol[2]==previousStrip));
297
298 Bool_t isCloneOfThePrevious=dummy && ((vol[3]==previousPadX) && (vol[4]==previousPadZ));
299
b213b8bd 300 Bool_t isNeighOfThePrevious=dummy && ((((vol[3]==previousPadX-1) || (vol[3]==previousPadX+1)) && (vol[4]==previousPadZ)) || ((vol[3]==previousPadX) && ((vol[4]==previousPadZ+1) || (vol[4]==previousPadZ-1))));
55991c8b 301
b213b8bd 302 if(!isCloneOfThePrevious && !isNeighOfThePrevious){
55991c8b 303 // update "previous" values
304 // in fact, we are yet in the future, so the present is past
305 previousTrack=tracknum;
306 previousSector=vol[0];
307 previousPlate=vol[1];
308 previousStrip=vol[2];
309 previousPadX=vol[3];
310 previousPadZ=vol[4];
311
312 nselectedHits++;
313 nselectedHitsinEv++;
314 if (particle->GetFirstMother() < 0){
315 nHitsFromPrim++;
316 } // counts hits due to primary particles
317
55991c8b 318 Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad;
319 Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad;
016e1f91 320
55991c8b 321 //cout << "geantTime " << geantTime << " [ns]" << endl;
322 Int_t nActivatedPads = 0, nFiredPads = 0;
323 Bool_t isFired[4] = {kFALSE, kFALSE, kFALSE, kFALSE};
324 Float_t tofAfterSimul[4] = {0., 0., 0., 0.};
325 Float_t qInduced[4] = {0.,0.,0.,0.};
326 Int_t nPlace[4] = {0, 0, 0, 0};
327 Float_t averageTime = 0.;
328 SimulateDetectorResponse(zStrip,xStrip,geantTime,nActivatedPads,nFiredPads,isFired,nPlace,qInduced,tofAfterSimul,averageTime);
329 if(nFiredPads) {
330 for(Int_t indexOfPad=0; indexOfPad<nActivatedPads; indexOfPad++) {
331 if(isFired[indexOfPad]){ // the pad has fired
332 Float_t timediff=geantTime-tofAfterSimul[indexOfPad];
333
334 if(timediff>=0.2) nlargeTofDiff++;
335
b213b8bd 336 digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/fTdcBin); // TDC bin number (each bin -> 50. ps)
55991c8b 337
338 Float_t landauFactor = gRandom->Landau(fAdcMean, fAdcRms);
339 digit[1] = (Int_t) (qInduced[indexOfPad] * landauFactor); // ADC bins (each bin -> 0.25 (or 0.03) pC)
340
341 // recalculate the volume only for neighbouring pads
ea7a588a 342 if(indexOfPad){
55991c8b 343 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[4] = 1 : vol[4] = 2;
344 (nPlace[indexOfPad]<=AliTOFConstants::fgkNpadX) ? vol[3] = nPlace[indexOfPad] : vol[3] = nPlace[indexOfPad] - AliTOFConstants::fgkNpadX;
ea7a588a 345 }
55991c8b 346
347 // check if two sdigit are on the same pad; in that case we sum
348 // the two or more sdigits
349 if (hitMap->TestHit(vol) != kEmpty) {
350 AliTOFSDigit *sdig = static_cast<AliTOFSDigit*>(hitMap->GetHit(vol));
351 Int_t tdctime = (Int_t) digit[0];
352 Int_t adccharge = (Int_t) digit[1];
b213b8bd 353 sdig->Update(fTdcBin,tdctime,adccharge,tracknum);
55991c8b 354 ntotalupdatesinEv++;
355 ntotalupdates++;
356 } else {
357
358 TOF->AddSDigit(tracknum, vol, digit);
359
360 if(indexOfPad){
361 nnoisesdigits++;
362 nnoisesdigitsinEv++;
363 } else {
364 nsignalsdigits++;
365 nsignalsdigitsinEv++;
366 }
367 ntotalsdigitsinEv++;
368 ntotalsdigits++;
369 hitMap->SetHit(vol);
370 } // if (hitMap->TestHit(vol) != kEmpty)
371 } // if(isFired[indexOfPad])
372 } // end loop on nActivatedPads
373 } // if(nFiredPads) i.e. if some pads has fired
374 } // close if(!isCloneOfThePrevious)
375 } // close the selection on sector and plate
5919c40c 376 } // end loop on hits for the current track
377 } // end loop on ntracks
55991c8b 378
5919c40c 379 delete hitMap;
517b7f8f 380
5919c40c 381 gAlice->TreeS()->Reset();
382 gAlice->TreeS()->Fill();
ea7a588a 383 //gAlice->TreeS()->Write(0,TObject::kOverwrite) ;
384 gAlice->TreeS()->AutoSave();
385
386 if(strstr(verboseOption,"all")){
387 cout << "----------------------------------------" << endl;
388 cout << " <AliTOFSDigitizer> " << endl;
389 cout << "After sdigitizing " << nselectedHitsinEv << " hits" << " in event " << ievent << endl;
390 //" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
391 cout << ntotalsdigitsinEv << " digits have been created " << endl;
392 cout << "(" << nsignalsdigitsinEv << " due to signals and " << nnoisesdigitsinEv << " due to border effect)" << endl;
393 cout << ntotalupdatesinEv << " total updates of the hit map have been performed in current event" << endl;
394 cout << "----------------------------------------" << endl;
395 }
396
397 } //event loop on events
398
399 // free used memory
400 if (ftail){
401 delete ftail;
402 ftail = 0;
403 }
404
405 nHitsFromSec=nselectedHits-nHitsFromPrim;
406 if(strstr(verboseOption,"all")){
407 cout << "----------------------------------------" << endl;
408 cout << "----------------------------------------" << endl;
409 cout << "-----------SDigitization Summary--------" << endl;
410 cout << " <AliTOFSDigitizer> " << endl;
411 cout << "After sdigitizing " << nselectedHits << " hits" << endl;
412 cout << "in " << (fEvent2-fEvent1) << " events" << endl;
413//" (" << nHitsFromPrim << " from primaries and " << nHitsFromSec << " from secondaries) TOF hits, "
414 cout << ntotalsdigits << " sdigits have been created " << endl;
415 cout << "(" << nsignalsdigits << " due to signals and " << nnoisesdigits << " due to border effect)" << endl;
416 cout << ntotalupdates << " total updates of the hit map have been performed" << endl;
417 cout << "in " << nlargeTofDiff << " cases the time of flight difference is greater than 200 ps" << endl;
418 }
419
517b7f8f 420
ea7a588a 421 if(strstr(verboseOption,"tim") || strstr(verboseOption,"all")){
422 gBenchmark->Stop("TOFSDigitizer");
423 cout << "AliTOFSDigitizer:" << endl ;
424 cout << " took " << gBenchmark->GetCpuTime("TOFSDigitizer") << " seconds in order to make sdigits "
425 << gBenchmark->GetCpuTime("TOFSDigitizer")/(fEvent2-fEvent1) << " seconds per event " << endl ;
426 cout << endl ;
427 }
517b7f8f 428
ea7a588a 429 Print("");
517b7f8f 430}
ea7a588a 431
517b7f8f 432//__________________________________________________________________
ea7a588a 433void AliTOFSDigitizer::Print(Option_t* opt)const
517b7f8f 434{
435 cout << "------------------- "<< GetName() << " -------------" << endl ;
bfec09a6 436
517b7f8f 437}
f73548c4 438
55991c8b 439//__________________________________________________________________
440void AliTOFSDigitizer::SelectSectorAndPlate(Int_t sector, Int_t plate)
441{
442 Bool_t isaWrongSelection=(sector < 1) || (sector > AliTOFConstants::fgkNSectors) || (plate < 1) || (plate > AliTOFConstants::fgkNPlates);
443 if(isaWrongSelection){
444 cout << "You have selected an invalid value for sector or plate " << endl;
445 cout << "The correct range for sector is [1,"<< AliTOFConstants::fgkNSectors <<"]" << endl;
446 cout << "The correct range for plate is [1,"<< AliTOFConstants::fgkNPlates <<"]" << endl;
447 cout << "By default we continue sdigitizing all hits in all plates of all sectors" << endl;
448 } else {
449 fSelectedSector=sector;
450 fSelectedPlate =plate;
451 cout << "SDigitizing only hits in plate " << fSelectedPlate << " of the sector " << fSelectedSector << endl;
452 }
453}
454
f73548c4 455//__________________________________________________________________
456void 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)
457{
458 // Description:
459 // Input: z0, x0 - hit position in the strip system (0,0 - center of the strip), cm
460 // geantTime - time generated by Geant, ns
461 // Output: nActivatedPads - the number of pads activated by the hit (1 || 2 || 4)
462 // nFiredPads - the number of pads fired (really activated) by the hit (nFiredPads <= nActivatedPads)
463 // qInduced[iPad]- charge induced on pad, arb. units
464 // this array is initialized at zero by the caller
465 // tofAfterSimul[iPad] - time calculated with edge effect algorithm, ns
466 // this array is initialized at zero by the caller
467 // averageTime - time given by pad hited by the Geant track taking into account the times (weighted) given by the pads fired for edge effect also.
468 // The weight is given by the qInduced[iPad]/qCenterPad
469 // this variable is initialized at zero by the caller
470 // nPlace[iPad] - the number of the pad place, iPad = 0, 1, 2, 3
471 // this variable is initialized at zero by the caller
472 //
473 // Description of used variables:
474 // eff[iPad] - efficiency of the pad
475 // res[iPad] - resolution of the pad, ns
476 // timeWalk[iPad] - time walk of the pad, ns
477 // timeDelay[iPad] - time delay for neighbouring pad to hited pad, ns
478 // PadId[iPad] - Pad Identifier
479 // E | F --> PadId[iPad] = 5 | 6
480 // A | B --> PadId[iPad] = 1 | 2
481 // C | D --> PadId[iPad] = 3 | 4
482 // nTail[iPad] - the tail number, = 1 for tailA, = 2 for tailB
483 // qCenterPad - charge extimated for each pad, arb. units
484 // weightsSum - sum of weights extimated for each pad fired, arb. units
485
486 const Float_t kSigmaForTail[2] = {AliTOFConstants::fgkSigmaForTail1,AliTOFConstants::fgkSigmaForTail2}; //for tail
487 Int_t iz = 0, ix = 0;
488 Float_t dX = 0., dZ = 0., x = 0., z = 0.;
489 Float_t h = fHparameter, h2 = fH2parameter, k = fKparameter, k2 = fK2parameter;
490 Float_t effX = 0., effZ = 0., resX = 0., resZ = 0., timeWalkX = 0., timeWalkZ = 0.;
491 Float_t logOfqInd = 0.;
492 Float_t weightsSum = 0.;
493 Int_t nTail[4] = {0,0,0,0};
494 Int_t padId[4] = {0,0,0,0};
495 Float_t eff[4] = {0.,0.,0.,0.};
496 Float_t res[4] = {0.,0.,0.,0.};
497 // Float_t qCenterPad = fMinimumCharge * fMinimumCharge;
498 Float_t qCenterPad = 1.;
499 Float_t timeWalk[4] = {0.,0.,0.,0.};
500 Float_t timeDelay[4] = {0.,0.,0.,0.};
501
502 nActivatedPads = 0;
503 nFiredPads = 0;
504
505 (z0 <= 0) ? iz = 0 : iz = 1;
506 dZ = z0 + (0.5 * AliTOFConstants::fgkNpadZ - iz - 0.5) * AliTOFConstants::fgkZPad; // hit position in the pad frame, (0,0) - center of the pad
507 z = 0.5 * AliTOFConstants::fgkZPad - TMath::Abs(dZ); // variable for eff., res. and timeWalk. functions
508 iz++; // z row: 1, ..., AliTOFConstants::fgkNpadZ = 2
509 ix = (Int_t)((x0 + 0.5 * AliTOFConstants::fgkNpadX * AliTOFConstants::fgkXPad) / AliTOFConstants::fgkXPad);
510 dX = x0 + (0.5 * AliTOFConstants::fgkNpadX - ix - 0.5) * AliTOFConstants::fgkXPad; // hit position in the pad frame, (0,0) - center of the pad
511 x = 0.5 * AliTOFConstants::fgkXPad - TMath::Abs(dX); // variable for eff., res. and timeWalk. functions;
512 ix++; // x row: 1, ..., AliTOFConstants::fgkNpadX = 48
513
514 ////// Pad A:
515 nActivatedPads++;
516 nPlace[nActivatedPads-1] = (iz - 1) * AliTOFConstants::fgkNpadX + ix;
517 qInduced[nActivatedPads-1] = qCenterPad;
518 padId[nActivatedPads-1] = 1;
519
520 if (fEdgeEffect == 0) {
521 eff[nActivatedPads-1] = fEffCenter;
522 if (gRandom->Rndm() < eff[nActivatedPads-1]) {
523 nFiredPads = 1;
524 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + fResCenter * fResCenter); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns;
525 isFired[nActivatedPads-1] = kTRUE;
526 tofTime[nActivatedPads-1] = gRandom->Gaus(geantTime + fTimeWalkCenter, res[0]);
527 averageTime = tofTime[nActivatedPads-1];
528 }
529 } else {
530
531 if(z < h) {
532 if(z < h2) {
533 effZ = fEffBoundary + (fEff2Boundary - fEffBoundary) * z / h2;
534 } else {
535 effZ = fEff2Boundary + (fEffCenter - fEff2Boundary) * (z - h2) / (h - h2);
536 }
537 resZ = fResBoundary + (fResCenter - fResBoundary) * z / h;
538 timeWalkZ = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * z / h;
539 nTail[nActivatedPads-1] = 1;
540 } else {
541 effZ = fEffCenter;
542 resZ = fResCenter;
543 timeWalkZ = fTimeWalkCenter;
544 }
545
546 if(x < h) {
547 if(x < h2) {
548 effX = fEffBoundary + (fEff2Boundary - fEffBoundary) * x / h2;
549 } else {
550 effX = fEff2Boundary + (fEffCenter - fEff2Boundary) * (x - h2) / (h - h2);
551 }
552 resX = fResBoundary + (fResCenter - fResBoundary) * x / h;
553 timeWalkX = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * x / h;
554 nTail[nActivatedPads-1] = 1;
555 } else {
556 effX = fEffCenter;
557 resX = fResCenter;
558 timeWalkX = fTimeWalkCenter;
559 }
560
561 (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX;
562 (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
563 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
564
565
566 ////// Pad B:
567 if(z < k2) {
568 effZ = fEffBoundary - (fEffBoundary - fEff3Boundary) * (z / k2);
569 } else {
570 effZ = fEff3Boundary * (k - z) / (k - k2);
571 }
572 resZ = fResBoundary + fResSlope * z / k;
573 timeWalkZ = fTimeWalkBoundary + fTimeWalkSlope * z / k;
574
575 if(z < k && z > 0) {
576 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
577 nActivatedPads++;
578 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX;
579 eff[nActivatedPads-1] = effZ;
580 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
581 timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ; // ns
582 nTail[nActivatedPads-1] = 2;
583 if (fTimeDelayFlag) {
584 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
585 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
586 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
587 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
588 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
589 } else {
590 timeDelay[nActivatedPads-1] = 0.;
591 }
592 padId[nActivatedPads-1] = 2;
593 }
594 }
595
596
597 ////// Pad C, D, E, F:
598 if(x < k2) {
599 effX = fEffBoundary - (fEffBoundary - fEff3Boundary) * (x / k2);
600 } else {
601 effX = fEff3Boundary * (k - x) / (k - k2);
602 }
603 resX = fResBoundary + fResSlope*x/k;
604 timeWalkX = fTimeWalkBoundary + fTimeWalkSlope*x/k;
605
606 if(x < k && x > 0) {
607 // C:
608 if(ix > 1 && dX < 0) {
609 nActivatedPads++;
610 nPlace[nActivatedPads-1] = nPlace[0] - 1;
611 eff[nActivatedPads-1] = effX;
612 res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
613 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
614 nTail[nActivatedPads-1] = 2;
615 if (fTimeDelayFlag) {
616 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
617 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
618 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
619 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
620 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
621 } else {
622 timeDelay[nActivatedPads-1] = 0.;
623 }
624 padId[nActivatedPads-1] = 3;
625
626 // D:
627 if(z < k && z > 0) {
628 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
629 nActivatedPads++;
630 nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX - 1;
631 eff[nActivatedPads-1] = effX * effZ;
632 (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
633 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
634
635 nTail[nActivatedPads-1] = 2;
636 if (fTimeDelayFlag) {
637 if (TMath::Abs(x) < TMath::Abs(z)) {
638 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
639 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
640 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
641 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
642 } else {
643 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
644 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
645 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
646 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
647 }
648 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
649 } else {
650 timeDelay[nActivatedPads-1] = 0.;
651 }
652 padId[nActivatedPads-1] = 4;
653 }
654 } // end D
655 } // end C
656
657 // E:
658 if(ix < AliTOFConstants::fgkNpadX && dX > 0) {
659 nActivatedPads++;
660 nPlace[nActivatedPads-1] = nPlace[0] + 1;
661 eff[nActivatedPads-1] = effX;
662 res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(10400 + resX * resX)); // ns
663 timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
664 nTail[nActivatedPads-1] = 2;
665 if (fTimeDelayFlag) {
666 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
667 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
668 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
669 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
670 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
671 } else {
672 timeDelay[nActivatedPads-1] = 0.;
673 }
674 padId[nActivatedPads-1] = 5;
675
676
677 // F:
678 if(z < k && z > 0) {
679 if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
680 nActivatedPads++;
681 nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFConstants::fgkNpadX + 1;
682 eff[nActivatedPads - 1] = effX * effZ;
683 (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(10400 + resZ * resZ); // 10400=30^2+20^2+40^2+50^2+50^2+50^2 ns
684 (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001*timeWalkX; // ns
685 nTail[nActivatedPads-1] = 2;
686 if (fTimeDelayFlag) {
687 if (TMath::Abs(x) < TMath::Abs(z)) {
688 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * z / 2.);
689 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * z / 2.);
690 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
691 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
692 } else {
693 // qInduced[0] = fMinimumCharge * TMath::Exp(fPulseHeightSlope * x / 2.);
694 // qInduced[nActivatedPads-1] = fMinimumCharge * TMath::Exp(-fPulseHeightSlope * x / 2.);
695 qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
696 logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
697 }
698 timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
699 } else {
700 timeDelay[nActivatedPads-1] = 0.;
701 }
702 padId[nActivatedPads-1] = 6;
703 }
704 } // end F
705 } // end E
706 } // end if(x < k)
707
708
709 for (Int_t iPad = 0; iPad < nActivatedPads; iPad++) {
710 if (res[iPad] < fTimeResolution) res[iPad] = fTimeResolution;
711 if(gRandom->Rndm() < eff[iPad]) {
712 isFired[iPad] = kTRUE;
713 nFiredPads++;
714 if(fEdgeTails) {
715 if(nTail[iPad] == 0) {
716 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
717 } else {
718 ftail->SetParameters(res[iPad], 2. * res[iPad], kSigmaForTail[nTail[iPad]-1]);
719 Double_t timeAB = ftail->GetRandom();
720 tofTime[iPad] = geantTime + timeWalk[iPad] + timeDelay[iPad] + timeAB;
721 }
722 } else {
723 tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
724 }
725 if (fAverageTimeFlag) {
726 averageTime += tofTime[iPad] * qInduced[iPad];
727 weightsSum += qInduced[iPad];
728 } else {
729 averageTime += tofTime[iPad];
730 weightsSum += 1.;
731 }
732 }
733 }
734 if (weightsSum!=0) averageTime /= weightsSum;
735 } // end else (fEdgeEffect != 0)
736}
737
738//__________________________________________________________________
739void AliTOFSDigitizer::PrintParameters()const
740{
741 //
742 // Print parameters used for sdigitization
743 //
744 cout << " ------------------- "<< GetName() << " -------------" << endl ;
745 cout << " Parameters used for TOF SDigitization " << endl ;
746 // Printing the parameters
747
ea7a588a 748 cout << " Number of events: " << (fEvent2-fEvent1) << endl;
749 cout << " from event " << fEvent1 << " to event " << (fEvent2-1) << endl;
f73548c4 750 cout << " Time Resolution (ns) "<< fTimeResolution <<" Pad Efficiency: "<< fpadefficiency << endl;
751 cout << " Edge Effect option: "<< fEdgeEffect<< endl;
752
753 cout << " Boundary Effect Simulation Parameters " << endl;
754 cout << " Hparameter: "<< fHparameter<<" H2parameter:"<< fH2parameter <<" Kparameter:"<< fKparameter<<" K2parameter: "<< fK2parameter << endl;
755 cout << " Efficiency in the central region of the pad: "<< fEffCenter << endl;
756 cout << " Efficiency at the boundary region of the pad: "<< fEffBoundary << endl;
757 cout << " Efficiency value at H2parameter "<< fEff2Boundary << endl;
758 cout << " Efficiency value at K2parameter "<< fEff3Boundary << endl;
759 cout << " Resolution (ps) in the central region of the pad: "<< fResCenter << endl;
760 cout << " Resolution (ps) at the boundary of the pad : "<< fResBoundary << endl;
761 cout << " Slope (ps/K) for neighbouring pad : "<< fResSlope <<endl;
762 cout << " Time walk (ps) in the central region of the pad : "<< fTimeWalkCenter << endl;
763 cout << " Time walk (ps) at the boundary of the pad : "<< fTimeWalkBoundary<< endl;
764 cout << " Slope (ps/K) for neighbouring pad : "<< fTimeWalkSlope<<endl;
765 cout << " Pulse Heigth Simulation Parameters " << endl;
766 cout << " Flag for delay due to the PulseHeightEffect: "<< fTimeDelayFlag <<endl;
767 cout << " Pulse Height Slope : "<< fPulseHeightSlope<<endl;
768 cout << " Time Delay Slope : "<< fTimeDelaySlope<<endl;
769 cout << " Minimum charge amount which could be induced : "<< fMinimumCharge<<endl;
770 cout << " Smearing in charge in (q1/q2) vs x plot : "<< fChargeSmearing<<endl;
771 cout << " Smearing in log of charge ratio : "<< fLogChargeSmearing<<endl;
772 cout << " Smearing in time in time vs log(q1/q2) plot : "<< fTimeSmearing<<endl;
773 cout << " Flag for average time : "<< fAverageTimeFlag<<endl;
774 cout << " Edge tails option : "<< fEdgeTails << endl;
775
776}