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