1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.24 2000/11/10 14:58:36 cblume
19 Introduce additional hit with amplitude 0 at the chamber borders
21 Revision 1.23 2000/11/01 14:53:21 cblume
22 Merge with TRD-develop
24 Revision 1.17.2.5 2000/10/15 23:40:01 cblume
27 Revision 1.17.2.4 2000/10/06 16:49:46 cblume
30 Revision 1.17.2.3 2000/10/04 16:34:58 cblume
31 Replace include files by forward declarations
33 Revision 1.17.2.2 2000/09/18 13:50:17 cblume
34 Include TR photon generation and adapt to new AliTRDhit
36 Revision 1.22 2000/06/27 13:08:50 cblume
37 Changed to Copy(TObject &A) to appease the HP-compiler
39 Revision 1.21 2000/06/09 11:10:07 cblume
40 Compiler warnings and coding conventions, next round
42 Revision 1.20 2000/06/08 18:32:58 cblume
43 Make code compliant to coding conventions
45 Revision 1.19 2000/06/07 16:27:32 cblume
46 Try to remove compiler warnings on Sun and HP
48 Revision 1.18 2000/05/08 16:17:27 cblume
51 Revision 1.17.2.1 2000/05/08 14:59:16 cblume
52 Made inline function non-virtual. Bug fix in setting sensitive chamber
54 Revision 1.17 2000/02/28 19:10:26 cblume
55 Include the new TRD classes
57 Revision 1.16.4.1 2000/02/28 18:04:35 cblume
58 Change to new hit version, introduce geometry class, and move digitization and clustering to AliTRDdigitizer/AliTRDclusterizerV1
60 Revision 1.16 1999/11/05 22:50:28 fca
61 Do not use Atan, removed from ROOT too
63 Revision 1.15 1999/11/02 17:20:19 fca
64 initialise nbytes before using it
66 Revision 1.14 1999/11/02 17:15:54 fca
67 Correct ansi scoping not accepted by HP compilers
69 Revision 1.13 1999/11/02 17:14:51 fca
70 Correct ansi scoping not accepted by HP compilers
72 Revision 1.12 1999/11/02 16:35:56 fca
73 New version of TRD introduced
75 Revision 1.11 1999/11/01 20:41:51 fca
76 Added protections against using the wrong version of FRAME
78 Revision 1.10 1999/09/29 09:24:35 fca
79 Introduction of the Copyright and cvs Log
83 ///////////////////////////////////////////////////////////////////////////////
85 // Transition Radiation Detector version 1 -- slow simulator //
89 <img src="picts/AliTRDfullClass.gif">
94 ///////////////////////////////////////////////////////////////////////////////
105 #include "AliConst.h"
107 #include "AliTRDv1.h"
108 #include "AliTRDhit.h"
109 #include "AliTRDmatrix.h"
110 #include "AliTRDgeometry.h"
111 #include "AliTRDsim.h"
115 //_____________________________________________________________________________
116 AliTRDv1::AliTRDv1():AliTRD()
119 // Default constructor
132 fSensSectorRange = 0;
139 //_____________________________________________________________________________
140 AliTRDv1::AliTRDv1(const char *name, const char *title)
144 // Standard constructor for Transition Radiation Detector version 1
157 fSensSectorRange = 0;
162 SetBufferSize(128000);
166 //_____________________________________________________________________________
167 AliTRDv1::AliTRDv1(const AliTRDv1 &trd)
173 ((AliTRDv1 &) trd).Copy(*this);
177 //_____________________________________________________________________________
178 AliTRDv1::~AliTRDv1()
181 // AliTRDv1 destructor
184 if (fDeltaE) delete fDeltaE;
189 //_____________________________________________________________________________
190 AliTRDv1 &AliTRDv1::operator=(const AliTRDv1 &trd)
193 // Assignment operator
196 if (this != &trd) ((AliTRDv1 &) trd).Copy(*this);
201 //_____________________________________________________________________________
202 void AliTRDv1::Copy(TObject &trd)
208 ((AliTRDv1 &) trd).fIdSens = fIdSens;
210 ((AliTRDv1 &) trd).fIdChamber1 = fIdChamber1;
211 ((AliTRDv1 &) trd).fIdChamber2 = fIdChamber2;
212 ((AliTRDv1 &) trd).fIdChamber3 = fIdChamber3;
214 ((AliTRDv1 &) trd).fSensSelect = fSensSelect;
215 ((AliTRDv1 &) trd).fSensPlane = fSensPlane;
216 ((AliTRDv1 &) trd).fSensChamber = fSensChamber;
217 ((AliTRDv1 &) trd).fSensSector = fSensSector;
218 ((AliTRDv1 &) trd).fSensSectorRange = fSensSectorRange;
220 fDeltaE->Copy(*((AliTRDv1 &) trd).fDeltaE);
221 fTR->Copy(*((AliTRDv1 &) trd).fTR);
225 //_____________________________________________________________________________
226 void AliTRDv1::CreateGeometry()
229 // Create the GEANT geometry for the Transition Radiation Detector - Version 1
230 // This version covers the full azimuth.
233 // Check that FRAME is there otherwise we have no place where to put the TRD
234 AliModule* frame = gAlice->GetModule("FRAME");
237 // Define the chambers
238 AliTRD::CreateGeometry();
242 //_____________________________________________________________________________
243 void AliTRDv1::CreateMaterials()
246 // Create materials for the Transition Radiation Detector version 1
249 AliTRD::CreateMaterials();
253 //_____________________________________________________________________________
254 void AliTRDv1::CreateTRhit(Int_t det)
257 // Creates an electron cluster from a TR photon.
258 // The photon is assumed to be created a the end of the radiator. The
259 // distance after which it deposits its energy takes into account the
260 // absorbtion of the entrance window and of the gas mixture in drift
265 const Int_t kPdgElectron = 11;
268 const Float_t kWion = 22.04;
270 // Maximum number of TR photons per track
271 const Int_t kNTR = 50;
273 TLorentzVector mom, pos;
274 TClonesArray &lhits = *fHits;
276 // Create TR only for electrons
277 Int_t iPdg = gMC->TrackPid();
278 if (TMath::Abs(iPdg) != kPdgElectron) return;
280 // Create TR at the entrance of the chamber
281 if (gMC->IsTrackEntering()) {
287 gMC->TrackMomentum(mom);
288 Float_t pTot = mom.Rho();
289 fTR->CreatePhotons(iPdg,pTot,nTR,eTR);
291 printf("AliTRDv1::CreateTRhit -- ");
292 printf("Boundary error: nTR = %d, kNTR = %d\n",nTR,kNTR);
296 // Loop through the TR photons
297 for (Int_t iTR = 0; iTR < nTR; iTR++) {
299 Float_t energyMeV = eTR[iTR] * 0.001;
300 Float_t energyeV = eTR[iTR] * 1000.0;
301 Float_t absLength = 0;
304 // Take the absorbtion in the entrance window into account
305 Double_t muMy = fTR->GetMuMy(energyMeV);
306 sigma = muMy * fFoilDensity;
307 absLength = gRandom->Exp(sigma);
308 if (absLength < AliTRDgeometry::MyThick()) continue;
310 // The absorbtion cross sections in the drift gas
312 // Gas-mixture (Xe/CO2)
313 Double_t muXe = fTR->GetMuXe(energyMeV);
314 Double_t muCO = fTR->GetMuCO(energyMeV);
315 sigma = (0.90 * muXe + 0.10 * muCO) * fGasDensity;
318 // Gas-mixture (Xe/Isobutane)
319 Double_t muXe = fTR->GetMuXe(energyMeV);
320 Double_t muBu = fTR->GetMuBu(energyMeV);
321 sigma = (0.97 * muXe + 0.03 * muBu) * fGasDensity;
324 // The distance after which the energy of the TR photon
326 absLength = gRandom->Exp(sigma);
327 if (absLength > AliTRDgeometry::DrThick()) continue;
329 // The position of the absorbtion
331 gMC->TrackPosition(pos);
332 posHit[0] = pos[0] + mom[0] / pTot * absLength;
333 posHit[1] = pos[1] + mom[1] / pTot * absLength;
334 posHit[2] = pos[2] + mom[2] / pTot * absLength;
337 Int_t q = ((Int_t) (energyeV / kWion));
339 // Add the hit to the array. TR photon hits are marked
340 // by negative charge
341 new(lhits[fNhits++]) AliTRDhit(fIshunt,gAlice->CurrentTrack()
350 //_____________________________________________________________________________
351 void AliTRDv1::Init()
354 // Initialise Transition Radiation Detector after geometry has been built.
359 printf(" Slow simulator\n\n");
362 printf(" Only plane %d is sensitive\n",fSensPlane);
363 if (fSensChamber >= 0)
364 printf(" Only chamber %d is sensitive\n",fSensChamber);
365 if (fSensSector >= 0) {
366 Int_t sens1 = fSensSector;
367 Int_t sens2 = fSensSector + fSensSectorRange;
368 sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect()))
369 * AliTRDgeometry::Nsect();
370 printf(" Only sectors %d - %d are sensitive\n",sens1,sens2-1);
374 printf(" TR simulation on\n");
376 printf(" TR simulation off\n");
379 // First ionization potential (eV) for the gas mixture (90% Xe + 10% CO2)
380 const Float_t kPoti = 12.1;
381 // Maximum energy (50 keV);
382 const Float_t kEend = 50000.0;
383 // Ermilova distribution for the delta-ray spectrum
384 Float_t poti = TMath::Log(kPoti);
385 Float_t eEnd = TMath::Log(kEend);
386 fDeltaE = new TF1("deltae",Ermilova,poti,eEnd,0);
388 // Identifier of the sensitive volume (drift region)
389 fIdSens = gMC->VolId("UL05");
391 // Identifier of the TRD-driftchambers
392 fIdChamber1 = gMC->VolId("UCIO");
393 fIdChamber2 = gMC->VolId("UCIM");
394 fIdChamber3 = gMC->VolId("UCII");
396 for (Int_t i = 0; i < 80; i++) printf("*");
401 //_____________________________________________________________________________
402 AliTRDsim *AliTRDv1::CreateTR()
405 // Enables the simulation of TR
408 fTR = new AliTRDsim();
413 //_____________________________________________________________________________
414 void AliTRDv1::SetSensPlane(Int_t iplane)
417 // Defines the hit-sensitive plane (0-5)
420 if ((iplane < 0) || (iplane > 5)) {
421 printf("Wrong input value: %d\n",iplane);
422 printf("Use standard setting\n");
433 //_____________________________________________________________________________
434 void AliTRDv1::SetSensChamber(Int_t ichamber)
437 // Defines the hit-sensitive chamber (0-4)
440 if ((ichamber < 0) || (ichamber > 4)) {
441 printf("Wrong input value: %d\n",ichamber);
442 printf("Use standard setting\n");
449 fSensChamber = ichamber;
453 //_____________________________________________________________________________
454 void AliTRDv1::SetSensSector(Int_t isector)
457 // Defines the hit-sensitive sector (0-17)
460 SetSensSector(isector,1);
464 //_____________________________________________________________________________
465 void AliTRDv1::SetSensSector(Int_t isector, Int_t nsector)
468 // Defines a range of hit-sensitive sectors. The range is defined by
469 // <isector> (0-17) as the starting point and <nsector> as the number
470 // of sectors to be included.
473 if ((isector < 0) || (isector > 17)) {
474 printf("Wrong input value <isector>: %d\n",isector);
475 printf("Use standard setting\n");
477 fSensSectorRange = 0;
482 if ((nsector < 1) || (nsector > 18)) {
483 printf("Wrong input value <nsector>: %d\n",nsector);
484 printf("Use standard setting\n");
486 fSensSectorRange = 0;
492 fSensSector = isector;
493 fSensSectorRange = nsector;
497 //_____________________________________________________________________________
498 void AliTRDv1::StepManager()
501 // Slow simulator. Every charged track produces electron cluster as hits
502 // along its path across the drift volume. The step size is set acording
503 // to Bethe-Bloch. The energy distribution of the delta electrons follows
504 // a spectrum taken from Ermilova et al.
507 Int_t iIdSens, icSens;
508 Int_t iIdSpace, icSpace;
509 Int_t iIdChamber, icChamber;
525 Double_t betaGamma, pp;
527 TLorentzVector pos, mom;
528 TClonesArray &lhits = *fHits;
530 const Double_t kBig = 1.0E+12;
533 const Float_t kWion = 22.04;
534 // Maximum energy for e+ e- g for the step-size calculation
535 const Float_t kPTotMax = 0.002;
536 // Plateau value of the energy-loss for electron in xenon
537 // taken from: Allison + Comb, Ann. Rev. Nucl. Sci. (1980), 30, 253
538 //const Double_t kPlateau = 1.70;
539 // the averaged value (26/3/99)
540 const Float_t kPlateau = 1.55;
541 // dN1/dx|min for the gas mixture (90% Xe + 10% CO2)
542 const Float_t kPrim = 48.0;
543 // First ionization potential (eV) for the gas mixture (90% Xe + 10% CO2)
544 const Float_t kPoti = 12.1;
547 const Int_t kPdgElectron = 11;
549 // Set the maximum step size to a very large number for all
550 // neutral particles and those outside the driftvolume
551 gMC->SetMaxStep(kBig);
553 // Create some special hits with amplitude 0 at the entrance and
554 // exit of each chamber that contain the momentum components of the particle
555 if (gMC->TrackCharge() &&
556 (gMC->IsTrackEntering() || gMC->IsTrackExiting())) {
558 // Inside a sensitive volume?
559 iIdSens = gMC->CurrentVolID(icSens);
560 if (iIdSens == fIdSens) {
562 iIdSpace = gMC->CurrentVolOffID(4,icSpace );
563 iIdChamber = gMC->CurrentVolOffID(1,icChamber);
565 // The hit coordinates
566 gMC->TrackPosition(pos);
571 // The track momentum
572 gMC->TrackMomentum(mom);
577 // The sector number (0 - 17)
578 // The numbering goes clockwise and starts at y = 0
579 Float_t phi = kRaddeg*TMath::ATan2(pos[0],pos[1]);
584 sec = ((Int_t) (phi / 20));
586 // The chamber number
592 if (iIdChamber == fIdChamber1)
593 cha = (hits[2] < 0 ? 0 : 4);
594 else if (iIdChamber == fIdChamber2)
595 cha = (hits[2] < 0 ? 1 : 3);
596 else if (iIdChamber == fIdChamber3)
600 // The numbering starts at the innermost plane
601 pla = icChamber - TMath::Nint((Float_t) (icChamber / 7)) * 6 - 1;
603 // Check on selected volumes
604 Int_t addthishit = 1;
606 if ((fSensPlane >= 0) && (pla != fSensPlane )) addthishit = 0;
607 if ((fSensChamber >= 0) && (cha != fSensChamber)) addthishit = 0;
608 if (fSensSector >= 0) {
609 Int_t sens1 = fSensSector;
610 Int_t sens2 = fSensSector + fSensSectorRange;
611 sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect()))
612 * AliTRDgeometry::Nsect();
614 if ((sec < sens1) || (sec >= sens2)) addthishit = 0;
617 if ((sec < sens1) && (sec >= sens2)) addthishit = 0;
624 det = fGeometry->GetDetector(pla,cha,sec);
625 new(lhits[fNhits++]) AliTRDhit(fIshunt
626 ,gAlice->CurrentTrack()
636 // Use only charged tracks
637 if (( gMC->TrackCharge() ) &&
638 (!gMC->IsTrackStop() ) &&
639 (!gMC->IsTrackDisappeared())) {
641 // Inside a sensitive volume?
642 iIdSens = gMC->CurrentVolID(icSens);
643 if (iIdSens == fIdSens) {
645 iIdSpace = gMC->CurrentVolOffID(4,icSpace );
646 iIdChamber = gMC->CurrentVolOffID(1,icChamber);
648 // Calculate the energy of the delta-electrons
649 eDelta = TMath::Exp(fDeltaE->GetRandom()) - kPoti;
650 eDelta = TMath::Max(eDelta,0.0);
652 // The number of secondary electrons created
653 qTot = ((Int_t) (eDelta / kWion) + 1);
655 // The hit coordinates and charge
656 gMC->TrackPosition(pos);
661 // The sector number (0 - 17)
662 // The numbering goes clockwise and starts at y = 0
663 Float_t phi = kRaddeg*TMath::ATan2(pos[0],pos[1]);
668 sec = ((Int_t) (phi / 20));
670 // The chamber number
676 if (iIdChamber == fIdChamber1)
677 cha = (hits[2] < 0 ? 0 : 4);
678 else if (iIdChamber == fIdChamber2)
679 cha = (hits[2] < 0 ? 1 : 3);
680 else if (iIdChamber == fIdChamber3)
684 // The numbering starts at the innermost plane
685 pla = icChamber - TMath::Nint((Float_t) (icChamber / 7)) * 6 - 1;
687 // Check on selected volumes
688 Int_t addthishit = 1;
690 if ((fSensPlane >= 0) && (pla != fSensPlane )) addthishit = 0;
691 if ((fSensChamber >= 0) && (cha != fSensChamber)) addthishit = 0;
692 if (fSensSector >= 0) {
693 Int_t sens1 = fSensSector;
694 Int_t sens2 = fSensSector + fSensSectorRange;
695 sens2 -= ((Int_t) (sens2 / AliTRDgeometry::Nsect()))
696 * AliTRDgeometry::Nsect();
698 if ((sec < sens1) || (sec >= sens2)) addthishit = 0;
701 if ((sec < sens1) && (sec >= sens2)) addthishit = 0;
709 det = fGeometry->GetDetector(pla,cha,sec);
711 // Create the electron cluster from TR photons
712 if (fTR) CreateTRhit(det);
714 new(lhits[fNhits++]) AliTRDhit(fIshunt
715 ,gAlice->CurrentTrack()
720 // The energy loss according to Bethe Bloch
721 gMC->TrackMomentum(mom);
723 iPdg = TMath::Abs(gMC->TrackPid());
724 if ( (iPdg != kPdgElectron) ||
725 ((iPdg == kPdgElectron) && (pTot < kPTotMax))) {
726 aMass = gMC->TrackMass();
727 betaGamma = pTot / aMass;
728 pp = kPrim * BetheBloch(betaGamma);
729 // Take charge > 1 into account
730 charge = gMC->TrackCharge();
731 if (TMath::Abs(charge) > 1) pp = pp * charge*charge;
733 // Electrons above 20 Mev/c are at the plateau
735 pp = kPrim * kPlateau;
738 // Calculate the maximum step size for the next tracking step
742 while ((random[0] == 1.) || (random[0] == 0.));
743 gMC->SetMaxStep( - TMath::Log(random[0]) / pp);
748 // set step size to maximal value
749 gMC->SetMaxStep(kBig);
758 //_____________________________________________________________________________
759 Double_t AliTRDv1::BetheBloch(Double_t bg)
762 // Parametrization of the Bethe-Bloch-curve
763 // The parametrization is the same as for the TPC and is taken from Lehrhaus.
766 // This parameters have been adjusted to averaged values from GEANT
767 const Double_t kP1 = 7.17960e-02;
768 const Double_t kP2 = 8.54196;
769 const Double_t kP3 = 1.38065e-06;
770 const Double_t kP4 = 5.30972;
771 const Double_t kP5 = 2.83798;
773 // This parameters have been adjusted to Xe-data found in:
774 // Allison & Cobb, Ann. Rev. Nucl. Sci. (1980), 30, 253
775 //const Double_t kP1 = 0.76176E-1;
776 //const Double_t kP2 = 10.632;
777 //const Double_t kP3 = 3.17983E-6;
778 //const Double_t kP4 = 1.8631;
779 //const Double_t kP5 = 1.9479;
782 Double_t yy = bg / TMath::Sqrt(1. + bg*bg);
783 Double_t aa = TMath::Power(yy,kP4);
784 Double_t bb = TMath::Power((1./bg),kP5);
785 bb = TMath::Log(kP3 + bb);
786 return ((kP2 - aa - bb)*kP1 / aa);
793 //_____________________________________________________________________________
794 Double_t Ermilova(Double_t *x, Double_t *)
797 // Calculates the delta-ray energy distribution according to Ermilova.
798 // Logarithmic scale !
807 const Int_t kNv = 31;
809 Float_t vxe[kNv] = { 2.3026, 2.9957, 3.4012, 3.6889, 3.9120
810 , 4.0943, 4.2485, 4.3820, 4.4998, 4.6052
811 , 4.7005, 5.0752, 5.2983, 5.7038, 5.9915
812 , 6.2146, 6.5221, 6.9078, 7.3132, 7.6009
813 , 8.0064, 8.5172, 8.6995, 8.9872, 9.2103
814 , 9.4727, 9.9035,10.3735,10.5966,10.8198
817 Float_t vye[kNv] = { 80.0 , 31.0 , 23.3 , 21.1 , 21.0
818 , 20.9 , 20.8 , 20.0 , 16.0 , 11.0
819 , 8.0 , 6.0 , 5.2 , 4.6 , 4.0
820 , 3.5 , 3.0 , 1.4 , 0.67 , 0.44
821 , 0.3 , 0.18 , 0.12 , 0.08 , 0.056
822 , 0.04 , 0.023, 0.015, 0.011, 0.01
831 dpos = energy - vxe[pos2++];
835 if (pos2 > kNv) pos2 = kNv;
838 // Differentiate between the sampling points
839 dnde = (vye[pos1] - vye[pos2]) / (vxe[pos2] - vxe[pos1]);