]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSsegmentationSDD.cxx
32c8f34a21d4eb931299f8515df0fc57a2583226
[u/mrichter/AliRoot.git] / ITS / AliITSsegmentationSDD.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 #include <Riostream.h>
16 #include <TMath.h>
17
18 #include "AliITSsegmentationSDD.h"
19 // #include "AliITS.h"
20 #include "AliITSgeom.h"
21 #include "AliITSgeomSDD.h"
22 #include "AliITSresponse.h"
23
24 //////////////////////////////////////////////////////
25 // Segmentation class for                           //
26 // drift detectors                                  //
27 //                                                  //
28 //////////////////////////////////////////////////////
29
30 const Float_t AliITSsegmentationSDD::fgkDxDefault = 35085.;
31 const Float_t AliITSsegmentationSDD::fgkDzDefault = 75264.;
32 const Float_t AliITSsegmentationSDD::fgkDyDefault = 300.;
33 const Float_t AliITSsegmentationSDD::fgkPitchDefault = 294.;
34 const Float_t AliITSsegmentationSDD::fgkClockDefault = 40.;
35 const Int_t AliITSsegmentationSDD::fgkHalfNanodesDefault = 256; 
36 const Int_t AliITSsegmentationSDD::fgkNsamplesDefault = 256;
37
38 ClassImp(AliITSsegmentationSDD)
39 //----------------------------------------------------------------------
40 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom,
41                                              AliITSresponse *resp){
42   // constructor
43    fGeom=geom;
44    fDriftSpeed=resp->DriftSpeed();
45    fCorr=0;
46    SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
47    SetPadSize(fgkPitchDefault,fgkClockDefault);
48    SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
49
50 }
51 //______________________________________________________________________
52 AliITSsegmentationSDD::AliITSsegmentationSDD() : AliITSsegmentation(){
53   // Default constructor
54    fDriftSpeed=0;  
55    SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
56    SetPadSize(fgkPitchDefault,fgkClockDefault);
57    SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
58
59 }
60
61 //______________________________________________________________________
62 void AliITSsegmentationSDD::Copy(TObject &obj) const {
63   // protected method. copy this to obj
64   AliITSsegmentation::Copy(obj);
65   ((AliITSsegmentationSDD& ) obj).fNsamples = fNsamples;
66   ((AliITSsegmentationSDD& ) obj).fNanodes = fNanodes;
67   ((AliITSsegmentationSDD& ) obj).fPitch = fPitch;
68   ((AliITSsegmentationSDD& ) obj).fTimeStep = fTimeStep;
69   ((AliITSsegmentationSDD& ) obj).fDriftSpeed = fDriftSpeed;
70 }
71
72 //______________________________________________________________________
73 AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(const AliITSsegmentationSDD &source){
74    // = operator
75    if(this==&source) return *this;
76    source.Copy(*this);
77    return *this;
78 }
79
80 //____________________________________________________________________________
81 AliITSsegmentationSDD::AliITSsegmentationSDD(const AliITSsegmentationSDD &source) :
82     AliITSsegmentation(source){
83   // copy constructor
84   source.Copy(*this);
85 }
86
87 //----------------------------------------------------------------------
88 void AliITSsegmentationSDD::Init(){
89   // Standard initilisation routine
90
91    if(!fGeom) {
92      Fatal("Init","the pointer to the ITS geometry class (AliITSgeom) is null\n");
93      return;
94    }
95    AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
96
97    const Float_t kconv=10000.;
98    fDz = 2.*kconv*gsdd->GetDz();
99    fDx = kconv*gsdd->GetDx();
100    fDy = 2.*kconv*gsdd->GetDy();
101 }
102
103 //----------------------------------------------------------------------
104 void AliITSsegmentationSDD::
105 Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]) const {
106   // returns neighbours for use in Cluster Finder routines and the like
107
108     if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
109     if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
110     *Nlist=4;
111     Xlist[0]=Xlist[1]=iX;
112     if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
113     else Xlist[2]=iX;
114     if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
115     else Xlist[3]=iX;
116     if(iZ) Zlist[0]=iZ-1;
117     else Zlist[0]=iZ;
118     if (iZ < fNsamples) Zlist[1]=iZ+1;
119     else Zlist[1]=iZ;
120     Zlist[2]=Zlist[3]=iZ;
121 }
122 //----------------------------------------------------------------------
123 void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
124                                       Int_t &timebin,Int_t &anode) const {
125 // Returns cell coordinates (time sample,anode) incremented by 1 !!!!! 
126 // for given real local coordinates (x,z)
127
128     // expects x, z in cm
129
130     const Float_t kconv=10000;  // cm->um
131
132     x *= kconv; // Convert to microns
133     z *= kconv; // Convert to microns
134     Int_t na = fNanodes/2;
135     Float_t driftpath=fDx-TMath::Abs(x);
136     timebin=(Int_t)(driftpath/fDriftSpeed/fTimeStep);
137     anode=(Int_t)(z/fPitch + na/2);
138     if (x > 0) anode += na;
139
140     timebin+=1;
141     anode+=1;
142
143 }
144 //----------------------------------------------------------------------
145 void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
146                                       Float_t &x ,Float_t &z) const{
147     // Transform from cell to real local coordinates
148     // returns x, z in cm
149
150   // the +0.5 means that an # and time bin # should start from 0 !!! 
151     const Float_t kconv=10000;  // um->cm
152   // the +0.5 means that an # and time bin # should start from 0 !!! 
153
154     Int_t na = fNanodes/2;
155     Float_t driftpath=(timebin+0.5)*fTimeStep*fDriftSpeed;
156     if (anode >= na) x=(fDx-driftpath)/kconv;
157     else x = -(fDx-driftpath)/kconv;
158     if (anode >= na) anode-=na;
159     z=((anode+0.5)*fPitch-fDz/2)/kconv;
160
161 }
162 //----------------------------------------------------------------------
163 void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z) const{
164     // Get anode and time bucket as floats - numbering from 0
165
166     // expects x, z in cm
167
168     const Float_t kconv=10000;  // cm->um
169
170     Float_t x0=x;
171     Int_t na = fNanodes/2;
172     Float_t driftpath=fDx-TMath::Abs(kconv*x);
173     x=driftpath/fDriftSpeed/fTimeStep;
174     z=kconv*z/fPitch + (float)na/2;
175     if (x0 < 0) x = -x;
176
177 }
178 //----------------------------------------------------------------------
179 void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l) const {
180   // returns local coordinates from global
181     if(!fGeom) {
182       Fatal("GetLocal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
183         return;
184     }
185     fGeom->GtoL(module,g,l);
186 }
187 //----------------------------------------------------------------------
188 void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g) const {
189   // return global coordinates from local
190     if(!fGeom) {
191       Fatal("GetGlobal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
192     }
193
194     fGeom->LtoG(module,l,g);
195
196 }
197 //----------------------------------------------------------------------
198 void AliITSsegmentationSDD::Print(Option_t *opt) const {
199   // Print SDD segmentation Parameters
200
201    cout << "**************************************************" << endl;
202    cout << "  Silicon Drift Detector Segmentation Parameters  " << opt << endl;
203    cout << "**************************************************" << endl;
204    cout << "Number of Time Samples: " << fNsamples << endl;
205    cout << "Number of Anodes: " << fNanodes << endl;
206    cout << "Time Step (ns): " << fTimeStep << endl;
207    cout << "Anode Pitch (um): " << fPitch << endl;
208    cout << "Full Detector Width     (x): " << fDx;
209    cout<<" (Default is "<<fgkDxDefault<<") "<<endl;
210    cout << "Half Detector Length    (z): " << fDz;
211    cout<<" (Default is "<<fgkDzDefault<<") "<<endl;
212    cout << "Full Detector Thickness (y): " << fDy;
213    cout<<" (Default is "<<fgkDyDefault<<") "<<endl;
214    cout << "**************************************************" << endl;
215
216 }
217
218 //----------------------------------------------------------------------
219 void AliITSsegmentationSDD::PrintDefaultParameters() const {
220   // print SDD parameters defined as static const data members
221
222   cout << "**************************************************" << endl;
223   cout << "  Silicon Drift Detector Segmentation Parameters  " << endl;
224   cout << " Default values defined as static const data members"<< endl;
225   cout << " Actual values can be set with the relevant setters"<< endl; 
226   cout << "**************************************************" << endl;
227   cout<<"fgkDxDefault = "<<fgkDxDefault<<endl;
228   cout<<"fgkDzDefault = "<<fgkDzDefault<<endl;
229   cout<<"fgkDyDefault = "<<fgkDyDefault<<endl;
230   cout<<"fgkPitchDefault = "<<fgkPitchDefault<<endl;
231   cout<<"fgkClockDefault = "<<fgkClockDefault<<endl;
232   cout<<"fgkHalfNanodesDefault = "<<fgkHalfNanodesDefault<<endl;
233   cout<<"fgkNsamplesDefault = "<<fgkNsamplesDefault<<endl;
234   cout << "**************************************************" << endl;
235
236 }
237
238 //______________________________________________________________________
239 void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const {
240 // Transformation from Geant detector centered local coordinates (cm) to
241 // time bucket numbers ix and anode number iz.
242 // Input:
243 // Float_t   x      detector local coordinate x in cm with respect to the
244 //                  center of the sensitive volume.
245 // Float_t   z      detector local coordinate z in cm with respect to the
246 //                  center of the sensitive volulme.
247 // Output:
248 // Int_t    ix      detector x time coordinate. Has the range 0<=ix<fNsamples.
249 // Int_t    iz      detector z anode coordinate. Has the range 0<=iz<fNandoes.
250 //   A value of -1 for ix or iz indecates that this point is outside of the
251 // detector segmentation as defined.
252 //     This segmentation geometry can be discribed as the following:
253 // {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
254 //  res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the 
255 //  specific numbers will change not their layout.}
256 //
257 //        0                     191                    0
258 //      0 |----------------------|---------------------| 256
259 //        | a     time-bins      |     time-bins     a |
260 //        | n                    |                   n |
261 //        | o                    |___________________o_|__> X
262 //        | d                    |                   d |
263 //        | e                    |                   e |
264 //        | s                    |                   s |
265 //    255 |----------------------|---------------------| 511
266 //                               |
267 //                               V
268 //                               Z
269     Float_t dx,dz,tb;
270     const Float_t kconv = 1.0E-04; // converts microns to cm.
271
272     ix = -1; // default values
273     iz = -1; // default values
274     dx = -kconv*Dx(); // lower left edge in cm.
275     dz = -0.5*kconv*Dz(); // lower left edge in cm.
276     if(x<dx || x>-dx) {
277       Warning("LocalToDet","input argument %f out of range (%f, %f)",x,dx,-dx);
278       return; // outside of defined volume.
279     }
280     if(z<dz || z>-dz) {
281       Warning("LocalToDet","input argument %f out of range (%f, %f)",z,dz,-dz);
282       return; // outside of defined volume.
283     }
284     tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
285     if(x>0) dx = -(dx + x)/tb; // distance from + side in time bin units
286     else dx = (x - dx)/tb;     // distance from - side in time bin units
287     dz = (z - dz)/(kconv*fPitch); // distance in z in anode pitch units
288     ix = (Int_t) dx;   // time bin
289     iz = (Int_t) dz;   // anode
290     if(x>0) iz += Npz()/2; // if x>0 then + side anodes values.
291     return; // Found ix and iz, return.
292 }
293 //______________________________________________________________________
294 void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
295 {
296 // Transformation from Detector time bucket and anode coordiantes to Geant 
297 // detector centerd local coordinates (cm).
298 // Input:
299 // Int_t    ix      detector x time coordinate. Has the range 0<=ix<fNsamples.
300 // Int_t    iz      detector z anode coordinate. Has the range 0<=iz<fNandoes.
301 // Output:
302 // Float_t   x      detector local coordinate x in cm with respect to the
303 //                  center of the sensitive volume.
304 // Float_t   z      detector local coordinate z in cm with respect to the
305 //                  center of the sensitive volulme.
306 // If ix and or iz is outside of the segmentation range a value of -Dx()
307 // or -0.5*Dz() is returned.
308 //     This segmentation geometry can be discribed as the following:
309 // {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
310 //  res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the 
311 //  specific numbers will change not their layout.}
312 //
313 //        0                     191                    0
314 //      0 |----------------------|---------------------| 256
315 //        | a     time-bins      |     time-bins     a |
316 //        | n                    |                   n |
317 //        | o                    |___________________o_|__> X
318 //        | d                    |                   d |
319 //        | e                    |                   e |
320 //        | s                    |                   s |
321 //    255 |----------------------|---------------------| 511
322 //                               |
323 //                               V
324 //                               Z
325     Int_t i,j;
326     Float_t tb;
327     const Float_t kconv = 1.0E-04; // converts microns to cm.
328
329     if(iz>=Npz()/2) x = kconv*Dx(); // default value for +x side.
330     else x = -kconv*Dx(); // default value for -x side.
331     z = -0.5*kconv*Dz(); // default value.
332     if(ix<0 || ix>=Npx()) {
333       Warning("DetToLocal","input argument %d out of range (0, %d)",ix,Npx());
334       return; // outside of detector
335     }
336     if(iz<0 || iz>=Npz()) {
337       Warning("DetToLocal","input argument %d out of range (0, %d)",iz,Npz());
338      return; // outside of detctor
339     }
340     tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
341     if(iz>=Npz()/2) tb *= -1.0; // for +x side decrement frmo Dx().
342     for(i=0;i<ix;i++) x += tb; // sum up to cell ix-1
343     x += 0.5*tb; // add 1/2 of cell ix for center location.
344     if(iz>=Npz()/2) iz -=Npz()/2;// If +x side don't count anodes from -x side.
345     for(j=0;j<iz;j++) z += kconv*fPitch; // sum up cell iz-1
346     z += 0.5*kconv*fPitch; // add 1/2 of cell iz for center location.
347     return; // Found x and z, return.
348 }