1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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>
18 #include "AliITSsegmentationSDD.h"
19 // #include "AliITS.h"
20 #include "AliITSgeom.h"
21 #include "AliITSgeomSDD.h"
22 #include "AliITSresponse.h"
24 //////////////////////////////////////////////////////
25 // Segmentation class for //
28 //////////////////////////////////////////////////////
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;
38 ClassImp(AliITSsegmentationSDD)
39 //----------------------------------------------------------------------
40 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom,
41 AliITSresponse *resp){
44 fDriftSpeed=resp->DriftSpeed();
46 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
47 SetPadSize(fgkPitchDefault,fgkClockDefault);
48 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
51 //______________________________________________________________________
52 AliITSsegmentationSDD::AliITSsegmentationSDD() : AliITSsegmentation(){
53 // Default constructor
55 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
56 SetPadSize(fgkPitchDefault,fgkClockDefault);
57 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
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;
72 //______________________________________________________________________
73 AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(const AliITSsegmentationSDD &source){
75 if(this==&source) return *this;
80 //____________________________________________________________________________
81 AliITSsegmentationSDD::AliITSsegmentationSDD(const AliITSsegmentationSDD &source) :
82 AliITSsegmentation(source){
87 //----------------------------------------------------------------------
88 void AliITSsegmentationSDD::Init(){
89 // Standard initilisation routine
92 Fatal("Init","the pointer to the ITS geometry class (AliITSgeom) is null\n");
95 AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
97 const Float_t kconv=10000.;
98 fDz = 2.*kconv*gsdd->GetDz();
99 fDx = kconv*gsdd->GetDx();
100 fDy = 2.*kconv*gsdd->GetDy();
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
108 if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
109 if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
111 Xlist[0]=Xlist[1]=iX;
112 if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
114 if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
116 if(iZ) Zlist[0]=iZ-1;
118 if (iZ < fNsamples) Zlist[1]=iZ+1;
120 Zlist[2]=Zlist[3]=iZ;
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)
128 // expects x, z in cm
130 const Float_t kconv=10000; // cm->um
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;
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
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 !!!
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;
162 //----------------------------------------------------------------------
163 void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z) const{
164 // Get anode and time bucket as floats - numbering from 0
166 // expects x, z in cm
168 const Float_t kconv=10000; // cm->um
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;
178 //----------------------------------------------------------------------
179 void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l) const {
180 // returns local coordinates from global
182 Fatal("GetLocal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
185 fGeom->GtoL(module,g,l);
187 //----------------------------------------------------------------------
188 void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g) const {
189 // return global coordinates from local
191 Fatal("GetGlobal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
194 fGeom->LtoG(module,l,g);
197 //----------------------------------------------------------------------
198 void AliITSsegmentationSDD::Print(Option_t *opt) const {
199 // Print SDD segmentation Parameters
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;
218 //----------------------------------------------------------------------
219 void AliITSsegmentationSDD::PrintDefaultParameters() const {
220 // print SDD parameters defined as static const data members
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;
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.
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.
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.}
258 // 0 |----------------------|---------------------| 256
259 // | a time-bins | time-bins a |
261 // | o |___________________o_|__> X
265 // 255 |----------------------|---------------------| 511
270 const Float_t kconv = 1.0E-04; // converts microns to cm.
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.
277 Warning("LocalToDet","input argument %f out of range (%f, %f)",x,dx,-dx);
278 return; // outside of defined volume.
281 Warning("LocalToDet","input argument %f out of range (%f, %f)",z,dz,-dz);
282 return; // outside of defined volume.
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.
293 //______________________________________________________________________
294 void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
296 // Transformation from Detector time bucket and anode coordiantes to Geant
297 // detector centerd local coordinates (cm).
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.
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.}
314 // 0 |----------------------|---------------------| 256
315 // | a time-bins | time-bins a |
317 // | o |___________________o_|__> X
321 // 255 |----------------------|---------------------| 511
327 const Float_t kconv = 1.0E-04; // converts microns to cm.
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
336 if(iz<0 || iz>=Npz()) {
337 Warning("DetToLocal","input argument %d out of range (0, %d)",iz,Npz());
338 return; // outside of detctor
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.