Merge with TRD-develop
[u/mrichter/AliRoot.git] / TRD / AliTRDv0.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$
793ff80c 18Revision 1.14.2.3 2000/10/06 16:49:46 cblume
19Made Getters const
20
21Revision 1.14.2.2 2000/10/04 16:34:58 cblume
22Replace include files by forward declarations
23
24Revision 1.14.2.1 2000/09/18 13:48:18 cblume
25Adapt to new AliTRDhit
26
27Revision 1.16 2000/06/08 18:32:58 cblume
28Make code compliant to coding conventions
29
8230f242 30Revision 1.15 2000/06/07 16:25:37 cblume
31Try to remove compiler warnings on Sun and HP
32
9d0b222b 33Revision 1.14 2000/02/28 19:10:26 cblume
34Include the new TRD classes
35
851d3db9 36Revision 1.13.4.1 2000/02/28 18:01:53 cblume
37Change to new hit version and introduce geometry class
38
39Revision 1.13 1999/11/05 22:50:28 fca
40Do not use Atan, removed from ROOT too
41
90f8d287 42Revision 1.12 1999/11/02 16:35:56 fca
43New version of TRD introduced
44
5c7f4665 45Revision 1.11 1999/11/01 20:41:51 fca
46Added protections against using the wrong version of FRAME
47
ab76897d 48Revision 1.10 1999/09/29 09:24:35 fca
49Introduction of the Copyright and cvs Log
50
4c039060 51*/
52
fe4da5cc 53///////////////////////////////////////////////////////////////////////////////
54// //
5c7f4665 55// Transition Radiation Detector version 0 -- fast simulator //
fe4da5cc 56// //
57//Begin_Html
58/*
5c7f4665 59<img src="picts/AliTRDfullClass.gif">
fe4da5cc 60*/
61//End_Html
62// //
63// //
64///////////////////////////////////////////////////////////////////////////////
65
66#include <TMath.h>
67#include <TRandom.h>
68#include <TVector.h>
fe4da5cc 69
fe4da5cc 70#include "AliRun.h"
71#include "AliMC.h"
72#include "AliConst.h"
73
851d3db9 74#include "AliTRDv0.h"
793ff80c 75#include "AliTRDhit.h"
851d3db9 76#include "AliTRDgeometry.h"
fe4da5cc 77
851d3db9 78ClassImp(AliTRDv0)
8230f242 79
80//_____________________________________________________________________________
81AliTRDv0::AliTRDv0():AliTRD()
82{
83 //
84 // AliTRDv0 default constructor
85 //
86
87 fIdSens = 0;
88 fHitsOn = 0;
89
90 fIdChamber1 = 0;
91 fIdChamber2 = 0;
92 fIdChamber3 = 0;
93
94}
95
fe4da5cc 96//_____________________________________________________________________________
97AliTRDv0::AliTRDv0(const char *name, const char *title)
98 :AliTRD(name, title)
99{
100 //
101 // Standard constructor for Transition Radiation Detector version 0
102 //
82bbf98a 103
104 fIdSens = 0;
105 fHitsOn = 0;
106
82bbf98a 107 fIdChamber1 = 0;
108 fIdChamber2 = 0;
109 fIdChamber3 = 0;
110
fe4da5cc 111}
851d3db9 112
fe4da5cc 113//_____________________________________________________________________________
8230f242 114AliTRDv0::~AliTRDv0()
115{
116 //
117 // AliTRDv0 destructor
118 //
119
120}
121
122//_____________________________________________________________________________
fe4da5cc 123void AliTRDv0::CreateGeometry()
124{
125 //
82bbf98a 126 // Create the GEANT geometry for the Transition Radiation Detector - Version 0
127 // This version covers the full azimuth.
d3f347ff 128 //
d3f347ff 129
82bbf98a 130 // Check that FRAME is there otherwise we have no place where to put the TRD
8230f242 131 AliModule* frame = gAlice->GetModule("FRAME");
132 if (!frame) return;
fe4da5cc 133
82bbf98a 134 // Define the chambers
135 AliTRD::CreateGeometry();
fe4da5cc 136
fe4da5cc 137}
138
139//_____________________________________________________________________________
140void AliTRDv0::CreateMaterials()
141{
142 //
143 // Create materials for the Transition Radiation Detector
144 //
82bbf98a 145
fe4da5cc 146 AliTRD::CreateMaterials();
82bbf98a 147
fe4da5cc 148}
149
150//_____________________________________________________________________________
151void AliTRDv0::Init()
152{
153 //
851d3db9 154 // Initialize Transition Radiation Detector after geometry is built
fe4da5cc 155 //
82bbf98a 156
fe4da5cc 157 AliTRD::Init();
82bbf98a 158
82bbf98a 159 // Identifier of the sensitive volume (amplification region)
160 fIdSens = gMC->VolId("UL06");
161
82bbf98a 162 // Identifier of the TRD-driftchambers
163 fIdChamber1 = gMC->VolId("UCIO");
164 fIdChamber2 = gMC->VolId("UCIM");
165 fIdChamber3 = gMC->VolId("UCII");
166
851d3db9 167 printf(" Fast simulator\n\n");
5c7f4665 168 for (Int_t i = 0; i < 80; i++) printf("*");
169 printf("\n");
170
fe4da5cc 171}
172
173//_____________________________________________________________________________
174void AliTRDv0::StepManager()
175{
176 //
177 // Procedure called at every step in the TRD
82bbf98a 178 // Fast simulator. If switched on, a hit is produced when a track
179 // crosses the border between amplification region and pad plane.
fe4da5cc 180 //
181
851d3db9 182 Int_t pla = 0;
183 Int_t cha = 0;
184 Int_t sec = 0;
82bbf98a 185 Int_t iIdSens, icSens;
82bbf98a 186 Int_t iIdChamber, icChamber;
187
793ff80c 188 Float_t hits[3];
189 Int_t det;
fe4da5cc 190
0a6d8768 191 TLorentzVector p;
82bbf98a 192 TClonesArray &lhits = *fHits;
fe4da5cc 193
82bbf98a 194 // Writing out hits enabled?
195 if (!(fHitsOn)) return;
fe4da5cc 196
fe4da5cc 197 // Use only charged tracks and count them only once per volume
82bbf98a 198 if (gMC->TrackCharge() &&
199 gMC->IsTrackExiting()) {
fe4da5cc 200
201 // Check on sensitive volume
82bbf98a 202 iIdSens = gMC->CurrentVolID(icSens);
203 if (iIdSens == fIdSens) {
204
205 gMC->TrackPosition(p);
206 for (Int_t i = 0; i < 3; i++) hits[i] = p[i];
82bbf98a 207
851d3db9 208 // The sector number (0 - 17)
209 // The numbering goes clockwise and starts at y = 0
210 Float_t phi = kRaddeg*TMath::ATan2(hits[0],hits[1]);
211 if (phi < 90.)
212 phi = phi + 270.;
213 else
214 phi = phi - 90.;
215 sec = ((Int_t) (phi / 20));
82bbf98a 216
d3f347ff 217 // The chamber number
851d3db9 218 // 0: outer left
219 // 1: middle left
220 // 2: inner
221 // 3: middle right
222 // 4: outer right
5c7f4665 223 iIdChamber = gMC->CurrentVolOffID(1,icChamber);
82bbf98a 224 if (iIdChamber == fIdChamber1)
851d3db9 225 cha = (hits[2] < 0 ? 0 : 4);
82bbf98a 226 else if (iIdChamber == fIdChamber2)
851d3db9 227 cha = (hits[2] < 0 ? 1 : 3);
82bbf98a 228 else if (iIdChamber == fIdChamber3)
851d3db9 229 cha = 2;
82bbf98a 230
851d3db9 231 // The plane number (0 - 5)
232 pla = icChamber - TMath::Nint((Float_t) (icChamber / 7)) * 6 - 1;
793ff80c 233 det = fGeometry->GetDetector(pla,cha,sec);
82bbf98a 234
851d3db9 235 new(lhits[fNhits++]) AliTRDhit(fIshunt
236 ,gAlice->CurrentTrack()
9d0b222b 237 ,det
793ff80c 238 ,hits
239 ,0);
d3f347ff 240
fe4da5cc 241 }
d3f347ff 242
fe4da5cc 243 }
d3f347ff 244
fe4da5cc 245}