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