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