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>
19 #include "AliITSsegmentationSDD.h"
21 #include "AliITSgeom.h"
22 #include "AliITSgeomSDD.h"
24 #include "AliITSresponse.h"
26 ClassImp(AliITSsegmentationSDD)
27 //----------------------------------------------------------------------
28 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom,
29 AliITSresponse *resp){
32 fDriftSpeed=resp->DriftSpeed();
39 //______________________________________________________________________
40 AliITSsegmentationSDD::AliITSsegmentationSDD(){
41 // standard constructor
50 //----------------------------------------------------------------------
51 void AliITSsegmentationSDD::Init(){
52 // Standard initilisation routine
56 //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
58 AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
60 const Float_t kconv=10000.;
61 fDz = 2.*kconv*gsdd->GetDz();
62 fDx = kconv*gsdd->GetDx();
63 fDy = 2.*kconv*gsdd->GetDy();
66 //----------------------------------------------------------------------
67 void AliITSsegmentationSDD::
68 Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]){
69 // returns neighbours for use in Cluster Finder routines and the like
71 if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
72 if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
75 if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
77 if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
81 if (iZ < fNsamples) Zlist[1]=iZ+1;
85 //----------------------------------------------------------------------
86 void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
87 Int_t &timebin,Int_t &anode){
88 // Returns cell coordinates (time sample,anode) incremented by 1 !!!!!
89 // for given real local coordinates (x,z)
93 const Float_t kconv=10000; // cm->um
95 x *= kconv; // Convert to microns
96 z *= kconv; // Convert to microns
97 Int_t na = fNanodes/2;
98 Float_t driftpath=fDx-TMath::Abs(x);
99 timebin=(Int_t)(driftpath/fDriftSpeed/fTimeStep);
100 anode=(Int_t)(z/fPitch + na/2);
101 if (x > 0) anode += na;
107 //----------------------------------------------------------------------
108 void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
109 Float_t &x ,Float_t &z){
110 // Transform from cell to real local coordinates
111 // returns x, z in cm
113 // the +0.5 means that an # and time bin # should start from 0 !!!
114 const Float_t kconv=10000; // um->cm
115 // the +0.5 means that an # and time bin # should start from 0 !!!
117 Int_t na = fNanodes/2;
118 Float_t driftpath=(timebin+0.5)*fTimeStep*fDriftSpeed;
119 if (anode >= na) x=(fDx-driftpath)/kconv;
120 else x = -(fDx-driftpath)/kconv;
121 if (anode >= na) anode-=na;
122 z=((anode+0.5)*fPitch-fDz/2)/kconv;
125 //----------------------------------------------------------------------
126 void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z){
127 // Get anode and time bucket as floats - numbering from 0
129 // expects x, z in cm
131 const Float_t kconv=10000; // cm->um
134 Int_t na = fNanodes/2;
135 Float_t driftpath=fDx-TMath::Abs(kconv*x);
136 x=driftpath/fDriftSpeed/fTimeStep;
137 z=kconv*z/fPitch + (float)na/2;
141 //----------------------------------------------------------------------
142 void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l){
143 // returns local coordinates from global
146 //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
148 fGeom->GtoL(module,g,l);
150 //----------------------------------------------------------------------
151 void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g){
152 // return global coordinates from local
155 //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
158 fGeom->LtoG(module,l,g);
161 //----------------------------------------------------------------------
162 void AliITSsegmentationSDD::Print(Option_t *opt) const {
163 // Print SDD segmentation Parameters
165 cout << "**************************************************" << endl;
166 cout << " Silicon Drift Detector Segmentation Parameters " << endl;
167 cout << "**************************************************" << endl;
168 cout << "Number of Time Samples: " << fNsamples << endl;
169 cout << "Number of Anodes: " << fNanodes << endl;
170 cout << "Time Step (ns): " << fTimeStep << endl;
171 cout << "Anode Pitch (um): " << fPitch << endl;
172 cout << "Full Detector Width (x): " << fDx << endl;
173 cout << "Half Detector Length (z): " << fDz << endl;
174 cout << "Full Detector Thickness (y): " << fDy << endl;
175 cout << "**************************************************" << endl;
178 //______________________________________________________________________
180 //______________________________________________________________________
181 void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
182 // Transformation from Geant detector centered local coordinates (cm) to
183 // time bucket numbers ix and anode number iz.
185 // Float_t x detector local coordinate x in cm with respect to the
186 // center of the sensitive volume.
187 // Float_t z detector local coordinate z in cm with respect to the
188 // center of the sensitive volulme.
190 // Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
191 // Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
192 // A value of -1 for ix or iz indecates that this point is outside of the
193 // detector segmentation as defined.
194 // This segmentation geometry can be discribed as the following:
195 // {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
196 // res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the
197 // specific numbers will change not their layout.}
200 // 0 |----------------------|---------------------| 256
201 // | a time-bins | time-bins a |
203 // | o |___________________o_|__> X
207 // 255 |----------------------|---------------------| 511
212 const Float_t kconv = 1.0E-04; // converts microns to cm.
214 ix = -1; // default values
215 iz = -1; // default values
216 dx = -kconv*Dx(); // lower left edge in cm.
217 dz = -0.5*kconv*Dz(); // lower left edge in cm.
219 Warning("LocalToDet","input argument %f out of range (%f, %f)",x,dx,-dx);
220 return; // outside of defined volume.
223 Warning("LocalToDet","input argument %f out of range (%f, %f)",z,dz,-dz);
224 return; // outside of defined volume.
226 tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
227 if(x>0) dx = -(dx + x)/tb; // distance from + side in time bin units
228 else dx = (x - dx)/tb; // distance from - side in time bin units
229 dz = (z - dz)/(kconv*fPitch); // distance in z in anode pitch units
230 ix = (Int_t) dx; // time bin
231 iz = (Int_t) dz; // anode
232 if(x>0) iz += Npz()/2; // if x>0 then + side anodes values.
233 return; // Found ix and iz, return.
235 //______________________________________________________________________
236 void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z)
238 // Transformation from Detector time bucket and anode coordiantes to Geant
239 // detector centerd local coordinates (cm).
241 // Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
242 // Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
244 // Float_t x detector local coordinate x in cm with respect to the
245 // center of the sensitive volume.
246 // Float_t z detector local coordinate z in cm with respect to the
247 // center of the sensitive volulme.
248 // If ix and or iz is outside of the segmentation range a value of -Dx()
249 // or -0.5*Dz() is returned.
250 // This segmentation geometry can be discribed as the following:
251 // {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
252 // res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the
253 // specific numbers will change not their layout.}
256 // 0 |----------------------|---------------------| 256
257 // | a time-bins | time-bins a |
259 // | o |___________________o_|__> X
263 // 255 |----------------------|---------------------| 511
269 const Float_t kconv = 1.0E-04; // converts microns to cm.
271 if(iz>=Npz()/2) x = kconv*Dx(); // default value for +x side.
272 else x = -kconv*Dx(); // default value for -x side.
273 z = -0.5*kconv*Dz(); // default value.
274 if(ix<0 || ix>=Npx()) {
275 Warning("DetToLocal","input argument %d out of range (0, %d)",ix,Npx());
276 return; // outside of detector
278 if(iz<0 || iz>=Npz()) {
279 Warning("DetToLocal","input argument %d out of range (0, %d)",iz,Npz());
280 return; // outside of detctor
282 tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
283 if(iz>=Npz()/2) tb *= -1.0; // for +x side decrement frmo Dx().
284 for(i=0;i<ix;i++) x += tb; // sum up to cell ix-1
285 x += 0.5*tb; // add 1/2 of cell ix for center location.
286 if(iz>=Npz()/2) iz -=Npz()/2;// If +x side don't count anodes from -x side.
287 for(j=0;j<iz;j++) z += kconv*fPitch; // sum up cell iz-1
288 z += 0.5*kconv*fPitch; // add 1/2 of cell iz for center location.
289 return; // Found x and z, return.