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