]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDv0.cxx
Using AliLog (F.Carminati)
[u/mrichter/AliRoot.git] / TRD / AliTRDv0.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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  Transition Radiation Detector version 0 -- fast simulator                //
21 //                                                                           //
22 //Begin_Html
23 /*
24 <img src="picts/AliTRDfullClass.gif">
25 */
26 //End_Html
27 //                                                                           //
28 //                                                                           //
29 ///////////////////////////////////////////////////////////////////////////////
30
31 #include <stdlib.h> 
32
33 #include <TLorentzVector.h>
34 #include <TMath.h>
35 #include <TRandom.h>
36 #include <TVector.h> 
37 #include <TVirtualMC.h>
38
39 #include "AliConst.h"
40 #include "AliRun.h"
41 #include "AliTRDgeometry.h"
42 #include "AliTRDhit.h"
43 #include "AliTRDv0.h"
44 #include "AliMC.h"
45
46 ClassImp(AliTRDv0)
47   
48 //_____________________________________________________________________________
49 AliTRDv0::AliTRDv0():AliTRD() 
50 {
51   //
52   // AliTRDv0 default constructor
53   //
54
55   fHitsOn     = 0;
56
57 }
58
59 //_____________________________________________________________________________
60 AliTRDv0::AliTRDv0(const char *name, const char *title) 
61          :AliTRD(name, title) 
62 {
63   //
64   // Standard constructor for Transition Radiation Detector version 0
65   //
66
67   fHitsOn     = 0;
68
69 }
70
71 //_____________________________________________________________________________
72 AliTRDv0::~AliTRDv0()
73 {
74   //
75   // AliTRDv0 destructor
76   //
77
78 }
79
80 //_____________________________________________________________________________
81 void AliTRDv0::CreateGeometry()
82 {
83   //
84   // Create the GEANT geometry for the Transition Radiation Detector - Version 0
85   // This version covers the full azimuth. 
86   //
87
88   // Check that FRAME is there otherwise we have no place where to put the TRD
89   AliModule* frame = gAlice->GetModule("FRAME");
90   if (!frame) return;
91
92   // Define the chambers
93   AliTRD::CreateGeometry();
94
95 }
96
97 //_____________________________________________________________________________
98 void AliTRDv0::CreateMaterials()
99 {
100   //
101   // Create materials for the Transition Radiation Detector
102   //
103
104   AliTRD::CreateMaterials();
105
106 }
107
108 //_____________________________________________________________________________
109 void AliTRDv0::Init() 
110 {
111   //
112   // Initialize Transition Radiation Detector after geometry is built
113   //
114
115   AliTRD::Init();
116
117   printf("          Fast simulator\n\n");
118   for (Int_t i = 0; i < 80; i++) printf("*");
119   printf("\n");
120   
121 }
122
123 //_____________________________________________________________________________
124 void AliTRDv0::StepManager()
125 {
126   //
127   // Procedure called at every step in the TRD
128   // Fast simulator. If switched on, a hit is produced when a track
129   // crosses the border between amplification region and pad plane.
130   //
131
132   Int_t   pla = 0; 
133   Int_t   cha = 0;
134   Int_t   sec = 0; 
135
136   Float_t hits[3];
137   Int_t   det;
138
139   TLorentzVector p;
140
141   // Use pad plane as sensitive volume
142   TString  cIdSens = "L";
143   TString  cIdCurrent;
144   Char_t   cIdChamber[3];
145            cIdChamber[2] = 0;
146
147   const Int_t kNplan = AliTRDgeometry::Nplan();
148
149   // Writing out hits enabled?
150   if (!(fHitsOn)) return;
151
152   // Use only charged tracks and count them only once per volume
153   if (gMC->TrackCharge()    && 
154       gMC->IsTrackEntering()) {
155     
156     // Check on sensitive volume
157     cIdCurrent = gMC->CurrentVolName();
158     if (cIdSens == cIdCurrent[1]) {
159
160       gMC->TrackPosition(p);
161       for (Int_t i = 0; i < 3; i++) hits[i] = p[i];
162
163       // The sector number (0 - 17)
164       // The numbering goes clockwise and starts at y = 0
165       Float_t phi = kRaddeg*TMath::ATan2(hits[0],hits[1]);
166       if (phi < 90.) 
167         phi = phi + 270.;
168       else
169         phi = phi -  90.;
170       sec = ((Int_t) (phi / 20));
171
172       // The plane and chamber number
173       cIdChamber[0] = cIdCurrent[2];
174       cIdChamber[1] = cIdCurrent[3];
175       Int_t idChamber = atoi(cIdChamber);
176       cha = ((Int_t) idChamber / kNplan);
177       pla = ((Int_t) idChamber % kNplan);
178       det = fGeometry->GetDetector(pla,cha,sec);
179
180       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),det,hits,0,kTRUE);       
181
182     }
183
184   }  
185
186 }