Include the new TRD classes
[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$
851d3db9 18Revision 1.16.4.1 2000/02/28 18:04:35 cblume
19Change to new hit version, introduce geometry class, and move digitization and clustering to AliTRDdigitizer/AliTRDclusterizerV1
20
21Revision 1.16 1999/11/05 22:50:28 fca
22Do not use Atan, removed from ROOT too
23
90f8d287 24Revision 1.15 1999/11/02 17:20:19 fca
25initialise nbytes before using it
26
036da493 27Revision 1.14 1999/11/02 17:15:54 fca
28Correct ansi scoping not accepted by HP compilers
29
0549c011 30Revision 1.13 1999/11/02 17:14:51 fca
31Correct ansi scoping not accepted by HP compilers
32
9c767df4 33Revision 1.12 1999/11/02 16:35:56 fca
34New version of TRD introduced
35
5c7f4665 36Revision 1.11 1999/11/01 20:41:51 fca
37Added protections against using the wrong version of FRAME
38
ab76897d 39Revision 1.10 1999/09/29 09:24:35 fca
40Introduction of the Copyright and cvs Log
41
4c039060 42*/
43
fe4da5cc 44///////////////////////////////////////////////////////////////////////////////
45// //
5c7f4665 46// Transition Radiation Detector version 2 -- slow simulator //
fe4da5cc 47// //
48//Begin_Html
49/*
5c7f4665 50<img src="picts/AliTRDfullClass.gif">
fe4da5cc 51*/
52//End_Html
53// //
54// //
55///////////////////////////////////////////////////////////////////////////////
56
57#include <TMath.h>
fe4da5cc 58#include <TVector.h>
5c7f4665 59#include <TRandom.h>
fe4da5cc 60
fe4da5cc 61#include "AliRun.h"
fe4da5cc 62#include "AliMC.h"
d3f347ff 63#include "AliConst.h"
5c7f4665 64
851d3db9 65#include "AliTRDv1.h"
66#include "AliTRDmatrix.h"
67#include "AliTRDgeometry.h"
68
fe4da5cc 69ClassImp(AliTRDv1)
70
71//_____________________________________________________________________________
72AliTRDv1::AliTRDv1(const char *name, const char *title)
73 :AliTRD(name, title)
74{
75 //
851d3db9 76 // Standard constructor for Transition Radiation Detector version 1
fe4da5cc 77 //
82bbf98a 78
851d3db9 79 fIdSens = 0;
82bbf98a 80
851d3db9 81 fIdChamber1 = 0;
82 fIdChamber2 = 0;
83 fIdChamber3 = 0;
5c7f4665 84
851d3db9 85 fSensSelect = 0;
86 fSensPlane = -1;
87 fSensChamber = -1;
88 fSensSector = -1;
5c7f4665 89
90 fDeltaE = NULL;
91
92 SetBufferSize(128000);
93
94}
95
96//_____________________________________________________________________________
97AliTRDv1::~AliTRDv1()
98{
82bbf98a 99
5c7f4665 100 if (fDeltaE) delete fDeltaE;
82bbf98a 101
fe4da5cc 102}
103
104//_____________________________________________________________________________
105void AliTRDv1::CreateGeometry()
106{
107 //
851d3db9 108 // Create the GEANT geometry for the Transition Radiation Detector - Version 1
5c7f4665 109 // This version covers the full azimuth.
d3f347ff 110 //
111
82bbf98a 112 // Check that FRAME is there otherwise we have no place where to put the TRD
113 AliModule* FRAME = gAlice->GetModule("FRAME");
114 if (!FRAME) return;
d3f347ff 115
82bbf98a 116 // Define the chambers
117 AliTRD::CreateGeometry();
d3f347ff 118
fe4da5cc 119}
120
121//_____________________________________________________________________________
122void AliTRDv1::CreateMaterials()
123{
124 //
851d3db9 125 // Create materials for the Transition Radiation Detector version 1
fe4da5cc 126 //
82bbf98a 127
d3f347ff 128 AliTRD::CreateMaterials();
82bbf98a 129
fe4da5cc 130}
131
5c7f4665 132//_____________________________________________________________________________
133void AliTRDv1::Init()
134{
135 //
136 // Initialise Transition Radiation Detector after geometry has been built.
5c7f4665 137 //
138
139 AliTRD::Init();
140
851d3db9 141 printf(" Slow simulator\n\n");
142 if (fSensSelect) {
143 if (fSensPlane >= 0)
144 printf(" Only plane %d is sensitive\n",fSensPlane);
145 if (fSensChamber >= 0)
146 printf(" Only chamber %d is sensitive\n",fSensChamber);
147 if (fSensSector >= 0)
148 printf(" Only sector %d is sensitive\n",fSensSector);
149 }
150 printf("\n");
5c7f4665 151
152 // First ionization potential (eV) for the gas mixture (90% Xe + 10% CO2)
153 const Float_t kPoti = 12.1;
154 // Maximum energy (50 keV);
155 const Float_t kEend = 50000.0;
156 // Ermilova distribution for the delta-ray spectrum
157 Float_t Poti = TMath::Log(kPoti);
158 Float_t Eend = TMath::Log(kEend);
159 fDeltaE = new TF1("deltae",Ermilova,Poti,Eend,0);
160
161 // Identifier of the sensitive volume (drift region)
162 fIdSens = gMC->VolId("UL05");
82bbf98a 163
164 // Identifier of the TRD-driftchambers
165 fIdChamber1 = gMC->VolId("UCIO");
166 fIdChamber2 = gMC->VolId("UCIM");
167 fIdChamber3 = gMC->VolId("UCII");
168
5c7f4665 169 for (Int_t i = 0; i < 80; i++) printf("*");
170 printf("\n");
171
fe4da5cc 172}
173
5c7f4665 174//_____________________________________________________________________________
175void AliTRDv1::SetSensPlane(Int_t iplane)
176{
177 //
851d3db9 178 // Defines the hit-sensitive plane (0-5)
5c7f4665 179 //
82bbf98a 180
851d3db9 181 if ((iplane < 0) || (iplane > 5)) {
5c7f4665 182 printf("Wrong input value: %d\n",iplane);
183 printf("Use standard setting\n");
851d3db9 184 fSensPlane = -1;
185 fSensSelect = 0;
5c7f4665 186 return;
187 }
82bbf98a 188
5c7f4665 189 fSensSelect = 1;
190 fSensPlane = iplane;
82bbf98a 191
5c7f4665 192}
193
194//_____________________________________________________________________________
195void AliTRDv1::SetSensChamber(Int_t ichamber)
196{
197 //
851d3db9 198 // Defines the hit-sensitive chamber (0-4)
5c7f4665 199 //
200
851d3db9 201 if ((ichamber < 0) || (ichamber > 4)) {
5c7f4665 202 printf("Wrong input value: %d\n",ichamber);
203 printf("Use standard setting\n");
851d3db9 204 fSensChamber = -1;
205 fSensSelect = 0;
5c7f4665 206 return;
207 }
208
209 fSensSelect = 1;
210 fSensChamber = ichamber;
211
212}
213
214//_____________________________________________________________________________
215void AliTRDv1::SetSensSector(Int_t isector)
216{
217 //
851d3db9 218 // Defines the hit-sensitive sector (0-17)
5c7f4665 219 //
220
851d3db9 221 if ((isector < 0) || (isector > 17)) {
5c7f4665 222 printf("Wrong input value: %d\n",isector);
223 printf("Use standard setting\n");
851d3db9 224 fSensSector = -1;
225 fSensSelect = 0;
5c7f4665 226 return;
227 }
228
229 fSensSelect = 1;
230 fSensSector = isector;
231
232}
233
234//_____________________________________________________________________________
235void AliTRDv1::StepManager()
236{
237 //
5c7f4665 238 // Slow simulator. Every charged track produces electron cluster as hits
239 // along its path across the drift volume. The step size is set acording
240 // to Bethe-Bloch. The energy distribution of the delta electrons follows
241 // a spectrum taken from Ermilova et al.
242 //
243
244 Int_t iIdSens, icSens;
245 Int_t iIdSpace, icSpace;
246 Int_t iIdChamber, icChamber;
851d3db9 247 Int_t pla = 0;
248 Int_t cha = 0;
249 Int_t sec = 0;
250 Int_t iPdg;
5c7f4665 251
252 Float_t hits[4];
253 Float_t random[1];
254 Float_t charge;
255 Float_t aMass;
256
257 Double_t pTot;
258 Double_t qTot;
259 Double_t eDelta;
260 Double_t betaGamma, pp;
261
262 TLorentzVector pos, mom;
82bbf98a 263 TClonesArray &lhits = *fHits;
264
851d3db9 265 const Double_t kBig = 1.0E+12;
5c7f4665 266
267 // Ionization energy
851d3db9 268 const Float_t kWion = 22.04;
5c7f4665 269 // Maximum energy for e+ e- g for the step-size calculation
851d3db9 270 const Float_t kPTotMax = 0.002;
5c7f4665 271 // Plateau value of the energy-loss for electron in xenon
272 // taken from: Allison + Comb, Ann. Rev. Nucl. Sci. (1980), 30, 253
273 //const Double_t kPlateau = 1.70;
274 // the averaged value (26/3/99)
851d3db9 275 const Float_t kPlateau = 1.55;
5c7f4665 276 // dN1/dx|min for the gas mixture (90% Xe + 10% CO2)
851d3db9 277 const Float_t kPrim = 48.0;
5c7f4665 278 // First ionization potential (eV) for the gas mixture (90% Xe + 10% CO2)
851d3db9 279 const Float_t kPoti = 12.1;
280
281 // PDG code electron
282 const Int_t pdgElectron = 11;
5c7f4665 283
284 // Set the maximum step size to a very large number for all
285 // neutral particles and those outside the driftvolume
286 gMC->SetMaxStep(kBig);
287
288 // Use only charged tracks
289 if (( gMC->TrackCharge() ) &&
290 (!gMC->IsTrackStop() ) &&
291 (!gMC->IsTrackDisappeared())) {
fe4da5cc 292
5c7f4665 293 // Inside a sensitive volume?
82bbf98a 294 iIdSens = gMC->CurrentVolID(icSens);
295 if (iIdSens == fIdSens) {
296
82bbf98a 297 iIdSpace = gMC->CurrentVolOffID(4,icSpace );
298 iIdChamber = gMC->CurrentVolOffID(1,icChamber);
fe4da5cc 299
5c7f4665 300 // Calculate the energy of the delta-electrons
301 eDelta = TMath::Exp(fDeltaE->GetRandom()) - kPoti;
302 eDelta = TMath::Max(eDelta,0.0);
303
304 // The number of secondary electrons created
305 qTot = (Double_t) ((Int_t) (eDelta / kWion) + 1);
306
307 // The hit coordinates and charge
308 gMC->TrackPosition(pos);
309 hits[0] = pos[0];
310 hits[1] = pos[1];
311 hits[2] = pos[2];
312 hits[3] = qTot;
313
851d3db9 314 // The sector number (0 - 17)
315 // The numbering goes clockwise and starts at y = 0
316 Float_t phi = kRaddeg*TMath::ATan2(pos[0],pos[1]);
317 if (phi < 90.)
318 phi = phi + 270.;
319 else
320 phi = phi - 90.;
321 sec = ((Int_t) (phi / 20));
82bbf98a 322
d3f347ff 323 // The chamber number
851d3db9 324 // 0: outer left
325 // 1: middle left
326 // 2: inner
327 // 3: middle right
328 // 4: outer right
82bbf98a 329 if (iIdChamber == fIdChamber1)
851d3db9 330 cha = (hits[2] < 0 ? 0 : 4);
82bbf98a 331 else if (iIdChamber == fIdChamber2)
851d3db9 332 cha = (hits[2] < 0 ? 1 : 3);
82bbf98a 333 else if (iIdChamber == fIdChamber3)
851d3db9 334 cha = 2;
82bbf98a 335
fe4da5cc 336 // The plane number
851d3db9 337 // The numbering starts at the innermost plane
338 pla = icChamber - TMath::Nint((Float_t) (icChamber / 7)) * 6 - 1;
82bbf98a 339
5c7f4665 340 // Check on selected volumes
341 Int_t addthishit = 1;
342 if (fSensSelect) {
851d3db9 343 if ((fSensPlane) && (pla != fSensPlane )) addthishit = 0;
344 if ((fSensChamber) && (cha != fSensChamber)) addthishit = 0;
345 if ((fSensSector) && (sec != fSensSector )) addthishit = 0;
5c7f4665 346 }
347
348 // Add this hit
349 if (addthishit) {
350
851d3db9 351 new(lhits[fNhits++]) AliTRDhit(fIshunt
352 ,gAlice->CurrentTrack()
353 ,fGeometry->GetDetector(pla,cha,sec)
354 ,hits);
5c7f4665 355
356 // The energy loss according to Bethe Bloch
357 gMC->TrackMomentum(mom);
358 pTot = mom.Rho();
851d3db9 359 iPdg = TMath::Abs(gMC->TrackPid());
360 if ( (iPdg != pdgElectron) ||
361 ((iPdg == pdgElectron) && (pTot < kPTotMax))) {
5c7f4665 362 aMass = gMC->TrackMass();
363 betaGamma = pTot / aMass;
364 pp = kPrim * BetheBloch(betaGamma);
365 // Take charge > 1 into account
366 charge = gMC->TrackCharge();
367 if (TMath::Abs(charge) > 1) pp = pp * charge*charge;
368 }
369 // Electrons above 20 Mev/c are at the plateau
370 else {
371 pp = kPrim * kPlateau;
372 }
373
374 // Calculate the maximum step size for the next tracking step
375 if (pp > 0) {
376 do
377 gMC->Rndm(random,1);
378 while ((random[0] == 1.) || (random[0] == 0.));
379 gMC->SetMaxStep( - TMath::Log(random[0]) / pp);
380 }
381
382 }
383 else {
384 // set step size to maximal value
385 gMC->SetMaxStep(kBig);
386 }
d3f347ff 387
388 }
389
5c7f4665 390 }
391
392}
393
394//_____________________________________________________________________________
395Double_t AliTRDv1::BetheBloch(Double_t bg)
396{
397 //
398 // Parametrization of the Bethe-Bloch-curve
399 // The parametrization is the same as for the TPC and is taken from Lehrhaus.
400 //
401
402 // This parameters have been adjusted to averaged values from GEANT
403 const Double_t kP1 = 7.17960e-02;
404 const Double_t kP2 = 8.54196;
405 const Double_t kP3 = 1.38065e-06;
406 const Double_t kP4 = 5.30972;
407 const Double_t kP5 = 2.83798;
408
409 // This parameters have been adjusted to Xe-data found in:
410 // Allison & Cobb, Ann. Rev. Nucl. Sci. (1980), 30, 253
411 //const Double_t kP1 = 0.76176E-1;
412 //const Double_t kP2 = 10.632;
413 //const Double_t kP3 = 3.17983E-6;
414 //const Double_t kP4 = 1.8631;
415 //const Double_t kP5 = 1.9479;
416
417 if (bg > 0) {
418 Double_t yy = bg / TMath::Sqrt(1. + bg*bg);
419 Double_t aa = TMath::Power(yy,kP4);
420 Double_t bb = TMath::Power((1./bg),kP5);
421 bb = TMath::Log(kP3 + bb);
422 return ((kP2 - aa - bb)*kP1 / aa);
423 }
424 else
425 return 0;
d3f347ff 426
fe4da5cc 427}
5c7f4665 428
429//_____________________________________________________________________________
430Double_t Ermilova(Double_t *x, Double_t *)
431{
432 //
433 // Calculates the delta-ray energy distribution according to Ermilova.
434 // Logarithmic scale !
435 //
436
437 Double_t energy;
438 Double_t dpos;
439 Double_t dnde;
440
441 Int_t pos1, pos2;
442
443 const Int_t nV = 31;
444
445 Float_t vxe[nV] = { 2.3026, 2.9957, 3.4012, 3.6889, 3.9120
446 , 4.0943, 4.2485, 4.3820, 4.4998, 4.6052
447 , 4.7005, 5.0752, 5.2983, 5.7038, 5.9915
448 , 6.2146, 6.5221, 6.9078, 7.3132, 7.6009
449 , 8.0064, 8.5172, 8.6995, 8.9872, 9.2103
450 , 9.4727, 9.9035,10.3735,10.5966,10.8198
451 ,11.5129 };
452
453 Float_t vye[nV] = { 80.0 , 31.0 , 23.3 , 21.1 , 21.0
454 , 20.9 , 20.8 , 20.0 , 16.0 , 11.0
455 , 8.0 , 6.0 , 5.2 , 4.6 , 4.0
456 , 3.5 , 3.0 , 1.4 , 0.67 , 0.44
457 , 0.3 , 0.18 , 0.12 , 0.08 , 0.056
458 , 0.04 , 0.023, 0.015, 0.011, 0.01
459 , 0.004 };
460
461 energy = x[0];
462
463 // Find the position
464 pos1 = pos2 = 0;
465 dpos = 0;
466 do {
467 dpos = energy - vxe[pos2++];
468 }
469 while (dpos > 0);
470 pos2--;
471 if (pos2 > nV) pos2 = nV;
472 pos1 = pos2 - 1;
473
474 // Differentiate between the sampling points
475 dnde = (vye[pos1] - vye[pos2]) / (vxe[pos2] - vxe[pos1]);
476
477 return dnde;
478
479}