Introducing Copyright include file
[u/mrichter/AliRoot.git] / TRD / AliTRDv1.cxx
CommitLineData
fe4da5cc 1///////////////////////////////////////////////////////////////////////////////
2// //
d3f347ff 3// Transition Radiation Detector version 1 -- coarse simulation //
4// This version has two detector arms, leaving the space in front of the //
5// HMPID and PHOS empty //
fe4da5cc 6// //
7//Begin_Html
8/*
1439f98e 9<img src="picts/AliTRDv1Class.gif">
fe4da5cc 10*/
11//End_Html
12// //
13// //
14///////////////////////////////////////////////////////////////////////////////
15
16#include <TMath.h>
17#include <TRandom.h>
18#include <TVector.h>
fe4da5cc 19
fe4da5cc 20#include "AliTRDv1.h"
21#include "AliRun.h"
fe4da5cc 22#include "AliMC.h"
d3f347ff 23#include "AliConst.h"
fe4da5cc 24
25ClassImp(AliTRDv1)
26
27//_____________________________________________________________________________
28AliTRDv1::AliTRDv1(const char *name, const char *title)
29 :AliTRD(name, title)
30{
31 //
32 // Standard constructor for the Transition Radiation Detector version 1
33 //
82bbf98a 34
35 fIdSens = 0;
36 fHitsOn = 0;
37
38 fIdSpace1 = 0;
39 fIdSpace2 = 0;
40 fIdSpace3 = 0;
41
42 fIdChamber1 = 0;
43 fIdChamber2 = 0;
44 fIdChamber3 = 0;
45
fe4da5cc 46}
47
48//_____________________________________________________________________________
49void AliTRDv1::CreateGeometry()
50{
51 //
82bbf98a 52 // Create the GEANT geometry for the Transition Radiation Detector - Version 1
53 // This version covers only part of the azimuth.
d3f347ff 54 //
82bbf98a 55 // Author: Christoph Blume (C.Blume@gsi.de) 20/07/99
d3f347ff 56 //
57
82bbf98a 58 Float_t xpos, ypos, zpos;
d3f347ff 59
82bbf98a 60 // Check that FRAME is there otherwise we have no place where to put the TRD
61 AliModule* FRAME = gAlice->GetModule("FRAME");
62 if (!FRAME) return;
d3f347ff 63
82bbf98a 64 // Define the chambers
65 AliTRD::CreateGeometry();
d3f347ff 66
82bbf98a 67 // Position the the TRD-sectors only in one TRD-volume in the spaceframe
68 xpos = 0.;
69 ypos = 0.;
70 zpos = 0.;
71 gMC->Gspos("TRD ",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
fe4da5cc 72
fe4da5cc 73}
74
75//_____________________________________________________________________________
76void AliTRDv1::CreateMaterials()
77{
78 //
79 // Create materials for the Transition Radiation Detector version 1
80 //
82bbf98a 81
d3f347ff 82 AliTRD::CreateMaterials();
82bbf98a 83
fe4da5cc 84}
85
86//_____________________________________________________________________________
87void AliTRDv1::Init()
88{
89 //
90 // Initialise the Transition Radiation Detector after the geometry is built
91 //
82bbf98a 92
fe4da5cc 93 AliTRD::Init();
82bbf98a 94
95 for (Int_t i = 0; i < 80; i++) printf("*");
96 printf("\n");
97
98 // Identifier of the sensitive volume (amplification region)
99 fIdSens = gMC->VolId("UL06");
100
101 // Identifier of the TRD-spaceframe volumina
102 fIdSpace1 = gMC->VolId("B028");
103 fIdSpace2 = gMC->VolId("B029");
104 fIdSpace3 = gMC->VolId("B030");
105
106 // Identifier of the TRD-driftchambers
107 fIdChamber1 = gMC->VolId("UCIO");
108 fIdChamber2 = gMC->VolId("UCIM");
109 fIdChamber3 = gMC->VolId("UCII");
110
fe4da5cc 111}
112
113//_____________________________________________________________________________
114void AliTRDv1::StepManager()
115{
116 //
d3f347ff 117 // Procedure called at every step in the TRD
82bbf98a 118 // Fast simulator. If switched on, a hit is produced when a track
119 // crosses the border between amplification region and pad plane.
fe4da5cc 120 //
d3f347ff 121
82bbf98a 122 Int_t vol[3];
123 Int_t iIdSens, icSens;
124 Int_t iIdSpace, icSpace;
125 Int_t iIdChamber, icChamber;
126
127 Int_t secMap1[10] = { 3, 7, 8, 9, 10, 11, 2, 1, 18, 17 };
128 Int_t secMap2[ 5] = { 16, 15, 14, 13, 12 };
129 Int_t secMap3[ 3] = { 5, 6, 4 };
130
131 Float_t hits[4];
132
133 TLorentzVector p;
134 TClonesArray &lhits = *fHits;
135
136 // Writing out hits enabled?
137 if (!(fHitsOn)) return;
fe4da5cc 138
fe4da5cc 139 // Use only charged tracks and count them only once per volume
82bbf98a 140 if (gMC->TrackCharge() &&
141 gMC->IsTrackExiting()) {
fe4da5cc 142
143 // Check on sensitive volume
82bbf98a 144 iIdSens = gMC->CurrentVolID(icSens);
145 if (iIdSens == fIdSens) {
146
147 gMC->TrackPosition(p);
148 for (Int_t i = 0; i < 3; i++) hits[i] = p[i];
149 // No charge created
150 hits[3] = 0;
151
152 iIdSpace = gMC->CurrentVolOffID(4,icSpace );
153 iIdChamber = gMC->CurrentVolOffID(1,icChamber);
fe4da5cc 154
fe4da5cc 155 // The sector number
82bbf98a 156 if (iIdSpace == fIdSpace1)
157 vol[0] = secMap1[icSpace-1];
158 else if (iIdSpace == fIdSpace2)
159 vol[0] = secMap2[icSpace-1];
160 else if (iIdSpace == fIdSpace3)
161 vol[0] = secMap3[icSpace-1];
162
d3f347ff 163 // The chamber number
164 // 1: outer left
82bbf98a 165 // 2: middle left
d3f347ff 166 // 3: inner
82bbf98a 167 // 4: middle right
d3f347ff 168 // 5: outer right
82bbf98a 169 if (iIdChamber == fIdChamber1)
170 vol[1] = (hits[2] < 0 ? 1 : 5);
171 else if (iIdChamber == fIdChamber2)
172 vol[1] = (hits[2] < 0 ? 2 : 4);
173 else if (iIdChamber == fIdChamber3)
d3f347ff 174 vol[1] = 3;
82bbf98a 175
fe4da5cc 176 // The plane number
82bbf98a 177 vol[2] = icChamber - TMath::Nint((Float_t) (icChamber / 7)) * 6;
178
179 new(lhits[fNhits++]) AliTRDhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
d3f347ff 180
181 }
182
82bbf98a 183 }
d3f347ff 184
fe4da5cc 185}