]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDv0.cxx
Added protections against using the wrong version of FRAME
[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$
ab76897d 18Revision 1.10 1999/09/29 09:24:35 fca
19Introduction of the Copyright and cvs Log
20
4c039060 21*/
22
fe4da5cc 23///////////////////////////////////////////////////////////////////////////////
24// //
25// Transition Radiation Detector version 0 -- coarse simulation //
26// //
27//Begin_Html
28/*
1439f98e 29<img src="picts/AliTRDv0Class.gif">
fe4da5cc 30*/
31//End_Html
32// //
33// //
34///////////////////////////////////////////////////////////////////////////////
35
ab76897d 36#include <stdlib.h>
37
fe4da5cc 38#include <TMath.h>
39#include <TRandom.h>
40#include <TVector.h>
fe4da5cc 41
fe4da5cc 42#include "AliTRDv0.h"
43#include "AliRun.h"
44#include "AliMC.h"
45#include "AliConst.h"
46
47ClassImp(AliTRDv0)
48
49//_____________________________________________________________________________
50AliTRDv0::AliTRDv0(const char *name, const char *title)
51 :AliTRD(name, title)
52{
53 //
54 // Standard constructor for Transition Radiation Detector version 0
55 //
82bbf98a 56
57 fIdSens = 0;
58 fHitsOn = 0;
59
60 fIdSpace1 = 0;
61 fIdSpace2 = 0;
62 fIdSpace3 = 0;
63
64 fIdChamber1 = 0;
65 fIdChamber2 = 0;
66 fIdChamber3 = 0;
67
fe4da5cc 68}
69
70//_____________________________________________________________________________
71void AliTRDv0::CreateGeometry()
72{
73 //
82bbf98a 74 // Create the GEANT geometry for the Transition Radiation Detector - Version 0
75 // This version covers the full azimuth.
d3f347ff 76 //
82bbf98a 77 // Author: Christoph Blume (C.Blume@gsi.de) 20/07/99
d3f347ff 78 //
79
82bbf98a 80 Float_t xpos, ypos, zpos;
d3f347ff 81
82bbf98a 82 // Check that FRAME is there otherwise we have no place where to put the TRD
83 AliModule* FRAME = gAlice->GetModule("FRAME");
84 if (!FRAME) return;
fe4da5cc 85
82bbf98a 86 // Define the chambers
87 AliTRD::CreateGeometry();
fe4da5cc 88
82bbf98a 89 // Position the the TRD-sectors in all TRD-volumes in the spaceframe
90 xpos = 0.;
91 ypos = 0.;
92 zpos = 0.;
93 gMC->Gspos("TRD ",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
94 gMC->Gspos("TRD ",2,"BTR2",xpos,ypos,zpos,0,"ONLY");
95 gMC->Gspos("TRD ",3,"BTR3",xpos,ypos,zpos,0,"ONLY");
d3f347ff 96
fe4da5cc 97}
98
99//_____________________________________________________________________________
100void AliTRDv0::CreateMaterials()
101{
102 //
103 // Create materials for the Transition Radiation Detector
104 //
82bbf98a 105
fe4da5cc 106 AliTRD::CreateMaterials();
82bbf98a 107
fe4da5cc 108}
109
110//_____________________________________________________________________________
111void AliTRDv0::Init()
112{
113 //
114 // Initialise Transition Radiation Detector after geometry is built
115 //
82bbf98a 116
fe4da5cc 117 AliTRD::Init();
82bbf98a 118
ab76897d 119 printf("**************************************"
120 " TRD "
121 "**************************************\n");
122 printf("\n Version 0 of TRD initialing, "
123 "symmetric TRD\n\n");
124
125 //
126 // Check that FRAME is there otherwise we have no place where to
127 // put TRD
128 AliModule* FRAME=gAlice->GetModule("FRAME");
129 if(!FRAME) {
130 Error("Ctor","TRD needs FRAME to be present\n");
131 exit(1);
132 } else
133 if(FRAME->IsVersion()!=1) {
134 Error("Ctor","FRAME version 1 needed with this version of TRD\n");
135 exit(1);
136 }
137
82bbf98a 138 for (Int_t i = 0; i < 80; i++) printf("*");
139 printf("\n");
140
141 // Identifier of the sensitive volume (amplification region)
142 fIdSens = gMC->VolId("UL06");
143
144 // Identifier of the TRD-spaceframe volumina
145 fIdSpace1 = gMC->VolId("B028");
146 fIdSpace2 = gMC->VolId("B029");
147 fIdSpace3 = gMC->VolId("B030");
148
149 // Identifier of the TRD-driftchambers
150 fIdChamber1 = gMC->VolId("UCIO");
151 fIdChamber2 = gMC->VolId("UCIM");
152 fIdChamber3 = gMC->VolId("UCII");
153
ab76897d 154 printf("**************************************"
155 " TRD "
156 "**************************************\n");
fe4da5cc 157}
158
159//_____________________________________________________________________________
160void AliTRDv0::StepManager()
161{
162 //
163 // Procedure called at every step in the TRD
82bbf98a 164 // Fast simulator. If switched on, a hit is produced when a track
165 // crosses the border between amplification region and pad plane.
fe4da5cc 166 //
167
82bbf98a 168 Int_t vol[3];
169 Int_t iIdSens, icSens;
170 Int_t iIdSpace, icSpace;
171 Int_t iIdChamber, icChamber;
172
173 Int_t secMap1[10] = { 3, 7, 8, 9, 10, 11, 2, 1, 18, 17 };
174 Int_t secMap2[ 5] = { 16, 15, 14, 13, 12 };
175 Int_t secMap3[ 3] = { 5, 6, 4 };
176
177 Float_t hits[4];
fe4da5cc 178
0a6d8768 179 TLorentzVector p;
82bbf98a 180 TClonesArray &lhits = *fHits;
fe4da5cc 181
82bbf98a 182 // Writing out hits enabled?
183 if (!(fHitsOn)) return;
fe4da5cc 184
fe4da5cc 185 // Use only charged tracks and count them only once per volume
82bbf98a 186 if (gMC->TrackCharge() &&
187 gMC->IsTrackExiting()) {
fe4da5cc 188
189 // Check on sensitive volume
82bbf98a 190 iIdSens = gMC->CurrentVolID(icSens);
191 if (iIdSens == fIdSens) {
192
193 gMC->TrackPosition(p);
194 for (Int_t i = 0; i < 3; i++) hits[i] = p[i];
195 // No charge created
196 hits[3] = 0;
197
198 iIdSpace = gMC->CurrentVolOffID(4,icSpace );
199 iIdChamber = gMC->CurrentVolOffID(1,icChamber);
200
fe4da5cc 201 // The sector number
82bbf98a 202 if (iIdSpace == fIdSpace1)
203 vol[0] = secMap1[icSpace-1];
204 else if (iIdSpace == fIdSpace2)
205 vol[0] = secMap2[icSpace-1];
206 else if (iIdSpace == fIdSpace3)
207 vol[0] = secMap3[icSpace-1];
208
d3f347ff 209 // The chamber number
210 // 1: outer left
82bbf98a 211 // 2: middle left
d3f347ff 212 // 3: inner
82bbf98a 213 // 4: middle right
d3f347ff 214 // 5: outer right
82bbf98a 215 if (iIdChamber == fIdChamber1)
216 vol[1] = (hits[2] < 0 ? 1 : 5);
217 else if (iIdChamber == fIdChamber2)
218 vol[1] = (hits[2] < 0 ? 2 : 4);
219 else if (iIdChamber == fIdChamber3)
d3f347ff 220 vol[1] = 3;
82bbf98a 221
fe4da5cc 222 // The plane number
82bbf98a 223 vol[2] = icChamber - TMath::Nint((Float_t) (icChamber / 7)) * 6;
224
225 new(lhits[fNhits++]) AliTRDhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
d3f347ff 226
fe4da5cc 227 }
d3f347ff 228
fe4da5cc 229 }
d3f347ff 230
fe4da5cc 231}