Made Getters const
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackingSector.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 Revision 1.1.2.2  2000/10/04 16:34:58  cblume
19 Replace include files by forward declarations
20
21 Revision 1.1.2.1  2000/09/22 14:47:52  cblume
22 Add the tracking code
23
24 */                        
25                                 
26 #include <TObject.h>
27
28 #include "AliRun.h"
29
30 #include "AliTRD.h" 
31 #include "AliTRDconst.h"
32 #include "AliTRDgeometry.h" 
33 #include "AliTRDcluster.h" 
34 #include "AliTRDtimeBin.h" 
35
36 #include "AliTRDtrackingSector.h" 
37
38
39 ClassImp(AliTRDtrackingSector) 
40
41 //_______________________________________________________
42
43 AliTRDtrackingSector::~AliTRDtrackingSector()
44 {
45   //
46   // Destructor
47   //
48
49   delete[] fTimeBin;
50
51 }
52
53 //_______________________________________________________
54 AliTRDtimeBin &AliTRDtrackingSector::operator[](Int_t i)
55 {
56   //
57   // Index operator 
58   //
59
60   return *(fTimeBin+i);
61
62 }
63
64 //_______________________________________________________
65
66 void AliTRDtrackingSector::SetUp()
67
68
69   AliTRD *TRD = (AliTRD*) gAlice->GetDetector("TRD");
70   fGeom = TRD->GetGeometry();
71
72   fTimeBinSize = fGeom->GetTimeBinSize();
73
74   fN = kNplan * (Int_t(kDrThick/fTimeBinSize) + 1);
75
76   fTimeBin = new AliTRDtimeBin[fN]; 
77
78 }
79
80 //______________________________________________________
81
82 Double_t AliTRDtrackingSector::GetX(Int_t l) const
83 {
84   if( (l<0) || (l>fN-1)) {
85     fprintf(stderr,"AliTRDtrackingSector::GetX: TimeBin index is out of range !\n");
86     return -99999.;
87   }
88   else { 
89     
90     Int_t tb_per_plane = fN/kNplan;
91     Int_t plane = l/tb_per_plane;
92     Int_t time_slice = l%(Int_t(kDrThick/fTimeBinSize) + 1);
93
94     Float_t t0 = fGeom->GetTime0(plane);
95     Double_t x = t0 + time_slice * fTimeBinSize;
96
97     //    cerr<<"plane, tb, x = "<<plane<<","<<time_slice<<","<<x<<endl;
98
99     return x;
100   }
101 }
102
103 //______________________________________________________
104
105 Double_t AliTRDtrackingSector::GetMaxY(Int_t l) const 
106
107
108   if((l<(fN-1)) && (l>-1)) { 
109     Int_t tb_per_plane = fN/kNplan;
110     Int_t plane = l/tb_per_plane;
111     return fGeom->GetChamberWidth(plane); 
112   }
113   else {
114     fprintf(stderr,
115     "AliTRDtrackingSector::GetMaxY: TimeBin index is out of range !\n");
116     if(l<0) return fGeom->GetChamberWidth(0);
117     else return fGeom->GetChamberWidth(kNplan-1);
118   }
119 }
120
121 //______________________________________________________
122
123 Int_t AliTRDtrackingSector::GetTimeBinNumber(Double_t x) const
124 {
125   Float_t r_out = fGeom->GetTime0(kNplan-1) + kDrThick; 
126   Float_t r_in = fGeom->GetTime0(0);
127   //  cerr<<"GetTimeBinNumber: r_in,r_out = "<<r_in<<","<<r_out<<endl;
128
129   if(x >= r_out) return fN-1;
130   if(x <= r_in) return 0;
131
132   Float_t gap = fGeom->GetTime0(1) - fGeom->GetTime0(0);
133   //  cerr<<"GetTimeBinNumber: gap = "<<gap<<endl;
134
135   Int_t plane = Int_t((x - r_in + fTimeBinSize/2)/gap);
136   //  cerr<<"GetTimeBinNumber: plane="<<plane<<endl;
137
138   Int_t local_tb = Int_t((x-fGeom->GetTime0(plane))/fTimeBinSize + 0.5);
139   //  cerr<<"GetTimeBinNumber: local_tb="<<local_tb<<endl;
140
141   Int_t time_bin = plane * (Int_t(kDrThick/fTimeBinSize) + 1) + local_tb;
142   //  cerr<<"GetTimeBinNumber: time_bin = "<<time_bin<<endl;
143   
144
145   return time_bin;
146 }
147
148 //______________________________________________________
149
150 Int_t AliTRDtrackingSector::GetTimeBin(Int_t det, Int_t local_tb) const 
151 {
152   Int_t plane = fGeom->GetPlane(det);
153
154   Int_t time_bin = plane * (Int_t(kDrThick/fTimeBinSize) + 1) + local_tb;  
155   return time_bin;
156 }
157