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