]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDv1.cxx
Introduction of the Copyright and cvs Log
[u/mrichter/AliRoot.git] / TRD / AliTRDv1.cxx
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
20 ///////////////////////////////////////////////////////////////////////////////
21 //                                                                           //
22 //  Transition Radiation Detector version 1 -- coarse simulation             //
23 //  This version has two detector arms, leaving the space in front of the    //
24 //  HMPID and PHOS empty                                                     //
25 //                                                                           //
26 //Begin_Html
27 /*
28 <img src="picts/AliTRDv1Class.gif">
29 */
30 //End_Html
31 //                                                                           //
32 //                                                                           //
33 ///////////////////////////////////////////////////////////////////////////////
34
35 #include <TMath.h>
36 #include <TRandom.h>
37 #include <TVector.h>
38
39 #include "AliTRDv1.h"
40 #include "AliRun.h"
41 #include "AliMC.h"
42 #include "AliConst.h"
43  
44 ClassImp(AliTRDv1)
45
46 //_____________________________________________________________________________
47 AliTRDv1::AliTRDv1(const char *name, const char *title) 
48          :AliTRD(name, title) 
49 {
50   //
51   // Standard constructor for the Transition Radiation Detector version 1
52   //
53
54   fIdSens     = 0;
55   fHitsOn     = 0;
56
57   fIdSpace1   = 0;
58   fIdSpace2   = 0;
59   fIdSpace3   = 0;
60
61   fIdChamber1 = 0;
62   fIdChamber2 = 0;
63   fIdChamber3 = 0;
64
65 }
66  
67 //_____________________________________________________________________________
68 void AliTRDv1::CreateGeometry()
69 {
70   //
71   // Create the GEANT geometry for the Transition Radiation Detector - Version 1
72   // This version covers only part of the azimuth. 
73   //
74   // Author:  Christoph Blume (C.Blume@gsi.de) 20/07/99 
75   //
76
77   Float_t xpos, ypos, zpos;
78
79   // Check that FRAME is there otherwise we have no place where to put the TRD
80   AliModule* FRAME = gAlice->GetModule("FRAME");
81   if (!FRAME) return;
82
83   // Define the chambers
84   AliTRD::CreateGeometry();
85
86   // Position the the TRD-sectors only in one TRD-volume in the spaceframe
87   xpos     = 0.;
88   ypos     = 0.;
89   zpos     = 0.;
90   gMC->Gspos("TRD ",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
91
92 }
93
94 //_____________________________________________________________________________
95 void AliTRDv1::CreateMaterials()
96 {
97   //
98   // Create materials for the Transition Radiation Detector version 1
99   //
100
101   AliTRD::CreateMaterials();
102
103 }
104
105 //_____________________________________________________________________________
106 void AliTRDv1::Init() 
107 {
108   //
109   // Initialise the Transition Radiation Detector after the geometry is built
110   //
111
112   AliTRD::Init();
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
130 }
131
132 //_____________________________________________________________________________
133 void AliTRDv1::StepManager() 
134 {
135   //
136   // Procedure called at every step in the TRD
137   // Fast simulator. If switched on, a hit is produced when a track
138   // crosses the border between amplification region and pad plane.
139   //
140
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];
151
152   TLorentzVector p;
153   TClonesArray  &lhits = *fHits;
154
155   // Writing out hits enabled?
156   if (!(fHitsOn)) return;
157
158   // Use only charged tracks and count them only once per volume
159   if (gMC->TrackCharge()    && 
160       gMC->IsTrackExiting()) {
161     
162     // Check on sensitive volume
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
174       // The sector number
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
182       // The chamber number 
183       //   1: outer left
184       //   2: middle left
185       //   3: inner
186       //   4: middle right
187       //   5: outer right
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)       
193         vol[1] = 3;
194
195       // The plane number
196       vol[2] = icChamber - TMath::Nint((Float_t) (icChamber / 7)) * 6;
197
198       new(lhits[fNhits++]) AliTRDhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
199
200     }
201
202   }  
203
204 }