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