Bug fix reported by Jiri. Make atoi input zero terminated in StepManager()
[u/mrichter/AliRoot.git] / TRD / AliTRDv1.cxx
CommitLineData
4c039060 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$Log$
593a9fc3 18Revision 1.31 2002/02/11 14:25:27 cblume
19Geometry update, compressed hit structure
20
332e9569 21Revision 1.30 2001/05/21 16:45:47 hristov
22Last minute changes (C.Blume)
23
db30bf0f 24Revision 1.29 2001/05/16 14:57:28 alibrary
25New files for folders and Stack
26
9e1a0ddb 27Revision 1.28 2001/05/07 08:03:22 cblume
28Generate also hits in the amplification region
29
f73816f5 30Revision 1.27 2001/03/30 14:40:15 cblume
31Update of the digitization parameter
32
a3c76cdc 33Revision 1.26 2000/11/30 17:38:08 cblume
34Changes to get in line with new STEER and EVGEN
35
1819f4bb 36Revision 1.25 2000/11/15 14:30:16 cblume
37Fixed bug in calculating detector no. of extra hit
38
990e4068 39Revision 1.24 2000/11/10 14:58:36 cblume
40Introduce additional hit with amplitude 0 at the chamber borders
41
769257f4 42Revision 1.23 2000/11/01 14:53:21 cblume
43Merge with TRD-develop
44
793ff80c 45Revision 1.17.2.5 2000/10/15 23:40:01 cblume
46Remove AliTRDconst
47
48Revision 1.17.2.4 2000/10/06 16:49:46 cblume
49Made Getters const
50
51Revision 1.17.2.3 2000/10/04 16:34:58 cblume
52Replace include files by forward declarations
53
54Revision 1.17.2.2 2000/09/18 13:50:17 cblume
55Include TR photon generation and adapt to new AliTRDhit
56
57Revision 1.22 2000/06/27 13:08:50 cblume
58Changed to Copy(TObject &A) to appease the HP-compiler
59
43da34c0 60Revision 1.21 2000/06/09 11:10:07 cblume
61Compiler warnings and coding conventions, next round
62
dd9a6ee3 63Revision 1.20 2000/06/08 18:32:58 cblume
64Make code compliant to coding conventions
65
8230f242 66Revision 1.19 2000/06/07 16:27:32 cblume
67Try to remove compiler warnings on Sun and HP
68
9d0b222b 69Revision 1.18 2000/05/08 16:17:27 cblume
70Merge TRD-develop
71
6f1e466d 72Revision 1.17.2.1 2000/05/08 14:59:16 cblume
73Made inline function non-virtual. Bug fix in setting sensitive chamber
74
75Revision 1.17 2000/02/28 19:10:26 cblume
76Include the new TRD classes
77
851d3db9 78Revision 1.16.4.1 2000/02/28 18:04:35 cblume
79Change to new hit version, introduce geometry class, and move digitization and clustering to AliTRDdigitizer/AliTRDclusterizerV1
80
81Revision 1.16 1999/11/05 22:50:28 fca
82Do not use Atan, removed from ROOT too
83
90f8d287 84Revision 1.15 1999/11/02 17:20:19 fca
85initialise nbytes before using it
86
036da493 87Revision 1.14 1999/11/02 17:15:54 fca
88Correct ansi scoping not accepted by HP compilers
89
0549c011 90Revision 1.13 1999/11/02 17:14:51 fca
91Correct ansi scoping not accepted by HP compilers
92
9c767df4 93Revision 1.12 1999/11/02 16:35:56 fca
94New version of TRD introduced
95
5c7f4665 96Revision 1.11 1999/11/01 20:41:51 fca
97Added protections against using the wrong version of FRAME
98
ab76897d 99Revision 1.10 1999/09/29 09:24:35 fca
100Introduction of the Copyright and cvs Log
101
4c039060 102*/
103
fe4da5cc 104///////////////////////////////////////////////////////////////////////////////
105// //
769257f4 106// Transition Radiation Detector version 1 -- slow simulator //
fe4da5cc 107// //
108//Begin_Html
109/*
5c7f4665 110<img src="picts/AliTRDfullClass.gif">
fe4da5cc 111*/
112//End_Html
113// //
114// //
115///////////////////////////////////////////////////////////////////////////////
116
769257f4 117#include <stdlib.h>
118
fe4da5cc 119#include <TMath.h>
fe4da5cc 120#include <TVector.h>
5c7f4665 121#include <TRandom.h>
793ff80c 122#include <TF1.h>
1819f4bb 123#include <TLorentzVector.h>
fe4da5cc 124
fe4da5cc 125#include "AliRun.h"
fe4da5cc 126#include "AliMC.h"
d3f347ff 127#include "AliConst.h"
5c7f4665 128
851d3db9 129#include "AliTRDv1.h"
793ff80c 130#include "AliTRDhit.h"
851d3db9 131#include "AliTRDmatrix.h"
132#include "AliTRDgeometry.h"
793ff80c 133#include "AliTRDsim.h"
851d3db9 134
fe4da5cc 135ClassImp(AliTRDv1)
8230f242 136
137//_____________________________________________________________________________
138AliTRDv1::AliTRDv1():AliTRD()
139{
140 //
141 // Default constructor
142 //
143
8230f242 144 fSensSelect = 0;
145 fSensPlane = -1;
146 fSensChamber = -1;
147 fSensSector = -1;
148 fSensSectorRange = 0;
149
150 fDeltaE = NULL;
793ff80c 151 fTR = NULL;
8230f242 152
153}
154
fe4da5cc 155//_____________________________________________________________________________
156AliTRDv1::AliTRDv1(const char *name, const char *title)
157 :AliTRD(name, title)
158{
159 //
851d3db9 160 // Standard constructor for Transition Radiation Detector version 1
fe4da5cc 161 //
82bbf98a 162
9d0b222b 163 fSensSelect = 0;
164 fSensPlane = -1;
165 fSensChamber = -1;
166 fSensSector = -1;
8230f242 167 fSensSectorRange = 0;
5c7f4665 168
9d0b222b 169 fDeltaE = NULL;
793ff80c 170 fTR = NULL;
5c7f4665 171
172 SetBufferSize(128000);
173
174}
175
8230f242 176//_____________________________________________________________________________
dd9a6ee3 177AliTRDv1::AliTRDv1(const AliTRDv1 &trd)
8230f242 178{
179 //
180 // Copy constructor
181 //
182
dd9a6ee3 183 ((AliTRDv1 &) trd).Copy(*this);
8230f242 184
185}
186
5c7f4665 187//_____________________________________________________________________________
188AliTRDv1::~AliTRDv1()
189{
dd9a6ee3 190 //
191 // AliTRDv1 destructor
192 //
82bbf98a 193
5c7f4665 194 if (fDeltaE) delete fDeltaE;
793ff80c 195 if (fTR) delete fTR;
82bbf98a 196
fe4da5cc 197}
198
dd9a6ee3 199//_____________________________________________________________________________
200AliTRDv1 &AliTRDv1::operator=(const AliTRDv1 &trd)
201{
202 //
203 // Assignment operator
204 //
205
206 if (this != &trd) ((AliTRDv1 &) trd).Copy(*this);
207 return *this;
208
209}
8230f242 210
211//_____________________________________________________________________________
43da34c0 212void AliTRDv1::Copy(TObject &trd)
8230f242 213{
214 //
215 // Copy function
216 //
217
43da34c0 218 ((AliTRDv1 &) trd).fSensSelect = fSensSelect;
219 ((AliTRDv1 &) trd).fSensPlane = fSensPlane;
220 ((AliTRDv1 &) trd).fSensChamber = fSensChamber;
221 ((AliTRDv1 &) trd).fSensSector = fSensSector;
222 ((AliTRDv1 &) trd).fSensSectorRange = fSensSectorRange;
8230f242 223
793ff80c 224 fDeltaE->Copy(*((AliTRDv1 &) trd).fDeltaE);
225 fTR->Copy(*((AliTRDv1 &) trd).fTR);
8230f242 226
227}
228
fe4da5cc 229//_____________________________________________________________________________
230void AliTRDv1::CreateGeometry()
231{
232 //
851d3db9 233 // Create the GEANT geometry for the Transition Radiation Detector - Version 1
5c7f4665 234 // This version covers the full azimuth.
d3f347ff 235 //
236
82bbf98a 237 // Check that FRAME is there otherwise we have no place where to put the TRD
8230f242 238 AliModule* frame = gAlice->GetModule("FRAME");
239 if (!frame) return;
d3f347ff 240
82bbf98a 241 // Define the chambers
242 AliTRD::CreateGeometry();
d3f347ff 243
fe4da5cc 244}
245
246//_____________________________________________________________________________
247void AliTRDv1::CreateMaterials()
248{
249 //
851d3db9 250 // Create materials for the Transition Radiation Detector version 1
fe4da5cc 251 //
82bbf98a 252
d3f347ff 253 AliTRD::CreateMaterials();
82bbf98a 254
fe4da5cc 255}
256
793ff80c 257//_____________________________________________________________________________
258void AliTRDv1::CreateTRhit(Int_t det)
259{
260 //
261 // Creates an electron cluster from a TR photon.
262 // The photon is assumed to be created a the end of the radiator. The
263 // distance after which it deposits its energy takes into account the
264 // absorbtion of the entrance window and of the gas mixture in drift
265 // volume.
266 //
267
268 // PDG code electron
269 const Int_t kPdgElectron = 11;
270
271 // Ionization energy
272 const Float_t kWion = 22.04;
273
274 // Maximum number of TR photons per track
275 const Int_t kNTR = 50;
276
277 TLorentzVector mom, pos;
793ff80c 278
793ff80c 279 // Create TR at the entrance of the chamber
280 if (gMC->IsTrackEntering()) {
281
f73816f5 282 // Create TR only for electrons
283 Int_t iPdg = gMC->TrackPid();
284 if (TMath::Abs(iPdg) != kPdgElectron) return;
285
793ff80c 286 Float_t eTR[kNTR];
287 Int_t nTR;
288
289 // Create TR photons
290 gMC->TrackMomentum(mom);
291 Float_t pTot = mom.Rho();
292 fTR->CreatePhotons(iPdg,pTot,nTR,eTR);
293 if (nTR > kNTR) {
294 printf("AliTRDv1::CreateTRhit -- ");
295 printf("Boundary error: nTR = %d, kNTR = %d\n",nTR,kNTR);
296 exit(1);
297 }
298
299 // Loop through the TR photons
300 for (Int_t iTR = 0; iTR < nTR; iTR++) {
301
302 Float_t energyMeV = eTR[iTR] * 0.001;
303 Float_t energyeV = eTR[iTR] * 1000.0;
304 Float_t absLength = 0;
305 Float_t sigma = 0;
306
307 // Take the absorbtion in the entrance window into account
308 Double_t muMy = fTR->GetMuMy(energyMeV);
309 sigma = muMy * fFoilDensity;
310 absLength = gRandom->Exp(sigma);
311 if (absLength < AliTRDgeometry::MyThick()) continue;
312
313 // The absorbtion cross sections in the drift gas
314 if (fGasMix == 1) {
315 // Gas-mixture (Xe/CO2)
316 Double_t muXe = fTR->GetMuXe(energyMeV);
317 Double_t muCO = fTR->GetMuCO(energyMeV);
db30bf0f 318 sigma = (0.85 * muXe + 0.15 * muCO) * fGasDensity;
793ff80c 319 }
320 else {
321 // Gas-mixture (Xe/Isobutane)
322 Double_t muXe = fTR->GetMuXe(energyMeV);
323 Double_t muBu = fTR->GetMuBu(energyMeV);
324 sigma = (0.97 * muXe + 0.03 * muBu) * fGasDensity;
325 }
326
327 // The distance after which the energy of the TR photon
328 // is deposited.
329 absLength = gRandom->Exp(sigma);
330 if (absLength > AliTRDgeometry::DrThick()) continue;
331
332 // The position of the absorbtion
333 Float_t posHit[3];
334 gMC->TrackPosition(pos);
335 posHit[0] = pos[0] + mom[0] / pTot * absLength;
336 posHit[1] = pos[1] + mom[1] / pTot * absLength;
337 posHit[2] = pos[2] + mom[2] / pTot * absLength;
338
339 // Create the charge
340 Int_t q = ((Int_t) (energyeV / kWion));
341
342 // Add the hit to the array. TR photon hits are marked
343 // by negative charge
332e9569 344 AddHit(gAlice->CurrentTrack(),det,posHit,-q,kTRUE);
793ff80c 345
346 }
347
348 }
349
350}
351
5c7f4665 352//_____________________________________________________________________________
353void AliTRDv1::Init()
354{
355 //
356 // Initialise Transition Radiation Detector after geometry has been built.
5c7f4665 357 //
358
359 AliTRD::Init();
360
9e1a0ddb 361 if(fDebug) printf("%s: Slow simulator\n",ClassName());
851d3db9 362 if (fSensSelect) {
363 if (fSensPlane >= 0)
364 printf(" Only plane %d is sensitive\n",fSensPlane);
365 if (fSensChamber >= 0)
366 printf(" Only chamber %d is sensitive\n",fSensChamber);
9d0b222b 367 if (fSensSector >= 0) {
368 Int_t sens1 = fSensSector;
369 Int_t sens2 = fSensSector + fSensSectorRange;
793ff80c 370 sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect()))
371 * AliTRDgeometry::Nsect();
9d0b222b 372 printf(" Only sectors %d - %d are sensitive\n",sens1,sens2-1);
373 }
851d3db9 374 }
793ff80c 375 if (fTR)
9e1a0ddb 376 printf("%s: TR simulation on\n",ClassName());
793ff80c 377 else
9e1a0ddb 378 printf("%s: TR simulation off\n",ClassName());
851d3db9 379 printf("\n");
5c7f4665 380
381 // First ionization potential (eV) for the gas mixture (90% Xe + 10% CO2)
382 const Float_t kPoti = 12.1;
383 // Maximum energy (50 keV);
384 const Float_t kEend = 50000.0;
385 // Ermilova distribution for the delta-ray spectrum
8230f242 386 Float_t poti = TMath::Log(kPoti);
387 Float_t eEnd = TMath::Log(kEend);
793ff80c 388 fDeltaE = new TF1("deltae",Ermilova,poti,eEnd,0);
5c7f4665 389
9e1a0ddb 390 if(fDebug) {
391 printf("%s: ",ClassName());
392 for (Int_t i = 0; i < 80; i++) printf("*");
393 printf("\n");
394 }
5c7f4665 395
fe4da5cc 396}
397
793ff80c 398//_____________________________________________________________________________
399AliTRDsim *AliTRDv1::CreateTR()
400{
401 //
402 // Enables the simulation of TR
403 //
404
405 fTR = new AliTRDsim();
406 return fTR;
407
408}
409
5c7f4665 410//_____________________________________________________________________________
411void AliTRDv1::SetSensPlane(Int_t iplane)
412{
413 //
851d3db9 414 // Defines the hit-sensitive plane (0-5)
5c7f4665 415 //
82bbf98a 416
851d3db9 417 if ((iplane < 0) || (iplane > 5)) {
5c7f4665 418 printf("Wrong input value: %d\n",iplane);
419 printf("Use standard setting\n");
851d3db9 420 fSensPlane = -1;
421 fSensSelect = 0;
5c7f4665 422 return;
423 }
82bbf98a 424
5c7f4665 425 fSensSelect = 1;
426 fSensPlane = iplane;
82bbf98a 427
5c7f4665 428}
429
430//_____________________________________________________________________________
431void AliTRDv1::SetSensChamber(Int_t ichamber)
432{
433 //
851d3db9 434 // Defines the hit-sensitive chamber (0-4)
5c7f4665 435 //
436
851d3db9 437 if ((ichamber < 0) || (ichamber > 4)) {
5c7f4665 438 printf("Wrong input value: %d\n",ichamber);
439 printf("Use standard setting\n");
851d3db9 440 fSensChamber = -1;
441 fSensSelect = 0;
5c7f4665 442 return;
443 }
444
445 fSensSelect = 1;
446 fSensChamber = ichamber;
447
448}
449
450//_____________________________________________________________________________
451void AliTRDv1::SetSensSector(Int_t isector)
452{
453 //
851d3db9 454 // Defines the hit-sensitive sector (0-17)
5c7f4665 455 //
456
9d0b222b 457 SetSensSector(isector,1);
458
459}
460
461//_____________________________________________________________________________
462void AliTRDv1::SetSensSector(Int_t isector, Int_t nsector)
463{
464 //
465 // Defines a range of hit-sensitive sectors. The range is defined by
466 // <isector> (0-17) as the starting point and <nsector> as the number
467 // of sectors to be included.
468 //
469
851d3db9 470 if ((isector < 0) || (isector > 17)) {
9d0b222b 471 printf("Wrong input value <isector>: %d\n",isector);
5c7f4665 472 printf("Use standard setting\n");
9d0b222b 473 fSensSector = -1;
474 fSensSectorRange = 0;
475 fSensSelect = 0;
5c7f4665 476 return;
477 }
478
9d0b222b 479 if ((nsector < 1) || (nsector > 18)) {
480 printf("Wrong input value <nsector>: %d\n",nsector);
481 printf("Use standard setting\n");
482 fSensSector = -1;
483 fSensSectorRange = 0;
484 fSensSelect = 0;
485 return;
486 }
487
488 fSensSelect = 1;
489 fSensSector = isector;
490 fSensSectorRange = nsector;
5c7f4665 491
492}
493
494//_____________________________________________________________________________
495void AliTRDv1::StepManager()
496{
497 //
5c7f4665 498 // Slow simulator. Every charged track produces electron cluster as hits
499 // along its path across the drift volume. The step size is set acording
500 // to Bethe-Bloch. The energy distribution of the delta electrons follows
501 // a spectrum taken from Ermilova et al.
502 //
503
851d3db9 504 Int_t pla = 0;
505 Int_t cha = 0;
506 Int_t sec = 0;
793ff80c 507 Int_t det = 0;
851d3db9 508 Int_t iPdg;
793ff80c 509 Int_t qTot;
5c7f4665 510
793ff80c 511 Float_t hits[3];
990e4068 512 Float_t moms[3];
5c7f4665 513 Float_t random[1];
514 Float_t charge;
515 Float_t aMass;
516
f73816f5 517 Double_t pTot = 0;
5c7f4665 518 Double_t eDelta;
519 Double_t betaGamma, pp;
f73816f5 520 Double_t stepSize;
5c7f4665 521
332e9569 522 Bool_t drRegion = kFALSE;
523 Bool_t amRegion = kFALSE;
524
525 TString cIdCurrent;
526 TString cIdSensDr = "J";
527 TString cIdSensAm = "K";
593a9fc3 528 Char_t cIdChamber[3];
529 cIdChamber[2] = 0;
332e9569 530
5c7f4665 531 TLorentzVector pos, mom;
82bbf98a 532
332e9569 533 const Int_t kNplan = AliTRDgeometry::Nplan();
534 const Double_t kBig = 1.0E+12;
5c7f4665 535
536 // Ionization energy
a3c76cdc 537 const Float_t kWion = 22.04;
538 // Maximum momentum for e+ e- g
539 const Float_t kPTotMaxEl = 0.002;
f73816f5 540 // Minimum energy for the step size adjustment
541 const Float_t kEkinMinStep = 1.0e-5;
5c7f4665 542 // Plateau value of the energy-loss for electron in xenon
543 // taken from: Allison + Comb, Ann. Rev. Nucl. Sci. (1980), 30, 253
544 //const Double_t kPlateau = 1.70;
545 // the averaged value (26/3/99)
a3c76cdc 546 const Float_t kPlateau = 1.55;
5c7f4665 547 // dN1/dx|min for the gas mixture (90% Xe + 10% CO2)
a3c76cdc 548 const Float_t kPrim = 48.0;
5c7f4665 549 // First ionization potential (eV) for the gas mixture (90% Xe + 10% CO2)
a3c76cdc 550 const Float_t kPoti = 12.1;
851d3db9 551
552 // PDG code electron
8230f242 553 const Int_t kPdgElectron = 11;
5c7f4665 554
555 // Set the maximum step size to a very large number for all
556 // neutral particles and those outside the driftvolume
557 gMC->SetMaxStep(kBig);
558
559 // Use only charged tracks
560 if (( gMC->TrackCharge() ) &&
561 (!gMC->IsTrackStop() ) &&
562 (!gMC->IsTrackDisappeared())) {
fe4da5cc 563
5c7f4665 564 // Inside a sensitive volume?
332e9569 565 drRegion = kFALSE;
566 amRegion = kFALSE;
567 cIdCurrent = gMC->CurrentVolName();
568 if (cIdCurrent[1] == cIdSensDr) {
569 drRegion = kTRUE;
570 }
571 if (cIdCurrent[1] == cIdSensAm) {
572 amRegion = kTRUE;
573 }
574 if (drRegion || amRegion) {
fe4da5cc 575
5c7f4665 576 // The hit coordinates and charge
577 gMC->TrackPosition(pos);
578 hits[0] = pos[0];
579 hits[1] = pos[1];
580 hits[2] = pos[2];
5c7f4665 581
851d3db9 582 // The sector number (0 - 17)
583 // The numbering goes clockwise and starts at y = 0
584 Float_t phi = kRaddeg*TMath::ATan2(pos[0],pos[1]);
585 if (phi < 90.)
586 phi = phi + 270.;
587 else
588 phi = phi - 90.;
589 sec = ((Int_t) (phi / 20));
82bbf98a 590
332e9569 591 // The plane and chamber number
592 cIdChamber[0] = cIdCurrent[2];
593 cIdChamber[1] = cIdCurrent[3];
594 Int_t idChamber = atoi(cIdChamber);
595 cha = ((Int_t) idChamber / kNplan);
596 pla = ((Int_t) idChamber % kNplan);
82bbf98a 597
5c7f4665 598 // Check on selected volumes
599 Int_t addthishit = 1;
600 if (fSensSelect) {
6f1e466d 601 if ((fSensPlane >= 0) && (pla != fSensPlane )) addthishit = 0;
602 if ((fSensChamber >= 0) && (cha != fSensChamber)) addthishit = 0;
9d0b222b 603 if (fSensSector >= 0) {
604 Int_t sens1 = fSensSector;
605 Int_t sens2 = fSensSector + fSensSectorRange;
793ff80c 606 sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect()))
607 * AliTRDgeometry::Nsect();
9d0b222b 608 if (sens1 < sens2) {
609 if ((sec < sens1) || (sec >= sens2)) addthishit = 0;
610 }
611 else {
612 if ((sec < sens1) && (sec >= sens2)) addthishit = 0;
613 }
614 }
5c7f4665 615 }
616
617 // Add this hit
618 if (addthishit) {
619
f73816f5 620 // The detector number
793ff80c 621 det = fGeometry->GetDetector(pla,cha,sec);
622
f73816f5 623 // Special hits and TR photons only in the drift region
332e9569 624 if (drRegion) {
f73816f5 625
626 // Create some special hits with amplitude 0 at the entrance and
627 // exit of each chamber that contain the momentum components of the particle
628 if (gMC->IsTrackEntering() || gMC->IsTrackExiting()) {
629 gMC->TrackMomentum(mom);
630 moms[0] = mom[0];
631 moms[1] = mom[1];
632 moms[2] = mom[2];
332e9569 633 AddHit(gAlice->CurrentTrack(),det,moms,0,kTRUE);
634 AddHit(gAlice->CurrentTrack(),det,hits,0,kTRUE);
f73816f5 635 }
636
637 // Create the hits from TR photons
638 if (fTR) CreateTRhit(det);
639
640 }
641
642 // Calculate the energy of the delta-electrons
643 eDelta = TMath::Exp(fDeltaE->GetRandom()) - kPoti;
644 eDelta = TMath::Max(eDelta,0.0);
645
646 // The number of secondary electrons created
647 qTot = ((Int_t) (eDelta / kWion) + 1);
648
649 // Create a new dEdx hit
332e9569 650 if (drRegion) {
651 AddHit(gAlice->CurrentTrack(),det,hits,qTot,kTRUE);
f73816f5 652 }
5c7f4665 653 else {
332e9569 654 AddHit(gAlice->CurrentTrack(),det,hits,qTot,kFALSE);
f73816f5 655 }
656
5c7f4665 657 // Calculate the maximum step size for the next tracking step
f73816f5 658 // Produce only one hit if Ekin is below cutoff
659 aMass = gMC->TrackMass();
660 if ((gMC->Etot() - aMass) > kEkinMinStep) {
661
662 // The energy loss according to Bethe Bloch
663 iPdg = TMath::Abs(gMC->TrackPid());
664 if ( (iPdg != kPdgElectron) ||
665 ((iPdg == kPdgElectron) && (pTot < kPTotMaxEl))) {
666 gMC->TrackMomentum(mom);
667 pTot = mom.Rho();
668 betaGamma = pTot / aMass;
669 pp = kPrim * BetheBloch(betaGamma);
670 // Take charge > 1 into account
671 charge = gMC->TrackCharge();
672 if (TMath::Abs(charge) > 1) pp = pp * charge*charge;
673 }
674 // Electrons above 20 Mev/c are at the plateau
675 else {
676 pp = kPrim * kPlateau;
677 }
678
679 if (pp > 0) {
680 do
681 gMC->Rndm(random,1);
682 while ((random[0] == 1.) || (random[0] == 0.));
683 stepSize = - TMath::Log(random[0]) / pp;
684 gMC->SetMaxStep(stepSize);
685 }
686
5c7f4665 687 }
688
689 }
d3f347ff 690
691 }
692
5c7f4665 693 }
694
695}
696
697//_____________________________________________________________________________
698Double_t AliTRDv1::BetheBloch(Double_t bg)
699{
700 //
701 // Parametrization of the Bethe-Bloch-curve
702 // The parametrization is the same as for the TPC and is taken from Lehrhaus.
703 //
704
705 // This parameters have been adjusted to averaged values from GEANT
706 const Double_t kP1 = 7.17960e-02;
707 const Double_t kP2 = 8.54196;
708 const Double_t kP3 = 1.38065e-06;
709 const Double_t kP4 = 5.30972;
710 const Double_t kP5 = 2.83798;
711
712 // This parameters have been adjusted to Xe-data found in:
713 // Allison & Cobb, Ann. Rev. Nucl. Sci. (1980), 30, 253
714 //const Double_t kP1 = 0.76176E-1;
715 //const Double_t kP2 = 10.632;
716 //const Double_t kP3 = 3.17983E-6;
717 //const Double_t kP4 = 1.8631;
718 //const Double_t kP5 = 1.9479;
719
f73816f5 720 // Lower cutoff of the Bethe-Bloch-curve to limit step sizes
721 const Double_t kBgMin = 0.8;
722 const Double_t kBBMax = 6.83298;
723 //const Double_t kBgMin = 0.6;
724 //const Double_t kBBMax = 17.2809;
725 //const Double_t kBgMin = 0.4;
726 //const Double_t kBBMax = 82.0;
727
728 if (bg > kBgMin) {
5c7f4665 729 Double_t yy = bg / TMath::Sqrt(1. + bg*bg);
730 Double_t aa = TMath::Power(yy,kP4);
731 Double_t bb = TMath::Power((1./bg),kP5);
732 bb = TMath::Log(kP3 + bb);
733 return ((kP2 - aa - bb)*kP1 / aa);
734 }
f73816f5 735 else {
736 return kBBMax;
737 }
d3f347ff 738
fe4da5cc 739}
5c7f4665 740
741//_____________________________________________________________________________
742Double_t Ermilova(Double_t *x, Double_t *)
743{
744 //
745 // Calculates the delta-ray energy distribution according to Ermilova.
746 // Logarithmic scale !
747 //
748
749 Double_t energy;
750 Double_t dpos;
751 Double_t dnde;
752
753 Int_t pos1, pos2;
754
8230f242 755 const Int_t kNv = 31;
5c7f4665 756
8230f242 757 Float_t vxe[kNv] = { 2.3026, 2.9957, 3.4012, 3.6889, 3.9120
758 , 4.0943, 4.2485, 4.3820, 4.4998, 4.6052
759 , 4.7005, 5.0752, 5.2983, 5.7038, 5.9915
760 , 6.2146, 6.5221, 6.9078, 7.3132, 7.6009
761 , 8.0064, 8.5172, 8.6995, 8.9872, 9.2103
762 , 9.4727, 9.9035,10.3735,10.5966,10.8198
763 ,11.5129 };
5c7f4665 764
8230f242 765 Float_t vye[kNv] = { 80.0 , 31.0 , 23.3 , 21.1 , 21.0
766 , 20.9 , 20.8 , 20.0 , 16.0 , 11.0
767 , 8.0 , 6.0 , 5.2 , 4.6 , 4.0
768 , 3.5 , 3.0 , 1.4 , 0.67 , 0.44
769 , 0.3 , 0.18 , 0.12 , 0.08 , 0.056
770 , 0.04 , 0.023, 0.015, 0.011, 0.01
771 , 0.004 };
5c7f4665 772
773 energy = x[0];
774
775 // Find the position
776 pos1 = pos2 = 0;
777 dpos = 0;
778 do {
779 dpos = energy - vxe[pos2++];
780 }
781 while (dpos > 0);
782 pos2--;
f73816f5 783 if (pos2 > kNv) pos2 = kNv - 1;
5c7f4665 784 pos1 = pos2 - 1;
785
786 // Differentiate between the sampling points
787 dnde = (vye[pos1] - vye[pos2]) / (vxe[pos2] - vxe[pos1]);
788
789 return dnde;
790
791}