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