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 **************************************************************************/
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){
39 //______________________________________________________________________
40 AliITSsegmentationSDD::AliITSsegmentationSDD(){
41 // standard constructor
50 //______________________________________________________________________
51 AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(AliITSsegmentationSDD
54 if(this==&source) return *this;
55 this->fNsamples = source.fNsamples;
56 this->fNanodes = source.fNanodes;
57 this->fPitch = source.fPitch;
58 this->fTimeStep = source.fTimeStep;
59 this->fDx = source.fDx;
60 this->fDz = source.fDz;
61 this->fDy = source.fDy;
62 this->fCorr = new TF1(*(source.fCorr));
63 this->fGeom = source.fGeom; // Just copy the pointer
64 this->fResponse = source.fResponse; //Just copy the pointer
67 //______________________________________________________________________
68 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSsegmentationSDD &source){
72 //----------------------------------------------------------------------
73 void AliITSsegmentationSDD::Init(){
74 // Standard initilisation routine
78 //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
80 AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
82 const Float_t kconv=10000.;
83 fDz = 2.*kconv*gsdd->GetDz();
84 fDx = kconv*gsdd->GetDx();
85 fDy = 2.*kconv*gsdd->GetDy();
88 //----------------------------------------------------------------------
89 void AliITSsegmentationSDD::
90 Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]){
91 // returns neighbours for use in Cluster Finder routines and the like
93 if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
94 if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
97 if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
99 if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
101 if(iZ) Zlist[0]=iZ-1;
103 if (iZ < fNsamples) Zlist[1]=iZ+1;
105 Zlist[2]=Zlist[3]=iZ;
107 //----------------------------------------------------------------------
108 void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
109 Int_t &timebin,Int_t &anode){
110 // Returns cell coordinates (time sample,anode) for given real local
113 // expects x, z in cm
115 const Float_t kconv=10000; // cm->um
117 Float_t speed=fResponse->DriftSpeed();
118 Int_t na = fNanodes/2;
119 Float_t driftpath=fDx-TMath::Abs(kconv*x);
120 timebin=(Int_t)(driftpath/speed/fTimeStep);
121 anode=(Int_t)(kconv*z/fPitch) + na/2;
122 if (x > 0) anode += na;
128 //----------------------------------------------------------------------
129 void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
130 Float_t &x ,Float_t &z){
131 // Transform from cell to real local coordinates
132 // returns x, z in cm
134 const Float_t kconv=10000; // um->cm
136 Float_t speed=fResponse->DriftSpeed();
137 Int_t na = fNanodes/2;
138 Float_t driftpath=(timebin+1)*fTimeStep*speed;
139 if (anode >= na) x=(fDx-driftpath)/kconv;
140 else x = -(fDx-driftpath)/kconv;
141 if (anode >= na) anode-=na;
142 z=((anode+1)*fPitch-fDz/2)/kconv;
145 //----------------------------------------------------------------------
146 void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z){
147 // Get anode and time bucket as floats - numbering from 0
149 // expects x, z in cm
151 const Float_t kconv=10000; // cm->um
154 Float_t speed=fResponse->DriftSpeed();
155 Int_t na = fNanodes/2;
156 Float_t driftpath=fDx-TMath::Abs(kconv*x);
157 x=driftpath/speed/fTimeStep;
158 z=kconv*z/fPitch + (float)na/2;
162 //----------------------------------------------------------------------
163 void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l){
164 // returns local coordinates from global
167 //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
169 fGeom->GtoL(module,g,l);
171 //----------------------------------------------------------------------
172 void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g){
173 // return global coordinates from local
176 //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
179 fGeom->LtoG(module,l,g);
182 //----------------------------------------------------------------------
183 void AliITSsegmentationSDD::Print(){
184 // Print SDD segmentation Parameters
186 cout << "**************************************************" << endl;
187 cout << " Silicon Drift Detector Segmentation Parameters " << endl;
188 cout << "**************************************************" << endl;
189 cout << "Number of Time Samples: " << fNsamples << endl;
190 cout << "Number of Anodes: " << fNanodes << endl;
191 cout << "Time Step (ns): " << fTimeStep << endl;
192 cout << "Anode Pitch (um): " << fPitch << endl;
193 cout << "Full Detector Width (x): " << fDx << endl;
194 cout << "Half Detector Length (z): " << fDz << endl;
195 cout << "Full Detector Thickness (y): " << fDy << endl;
196 cout << "**************************************************" << endl;
199 //______________________________________________________________________
201 //______________________________________________________________________
202 void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
203 // Transformation from Geant detector centered local coordinates (cm) to
204 // time bucket numbers ix and anode number iz.
206 // Float_t x detector local coordinate x in cm with respect to the
207 // center of the sensitive volume.
208 // Float_t z detector local coordinate z in cm with respect to the
209 // center of the sensitive volulme.
211 // Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
212 // Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
213 // A value of -1 for ix or iz indecates that this point is outside of the
214 // detector segmentation as defined.
215 // This segmentation geometry can be discribed as the following:
216 // {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
217 // res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the
218 // specific numbers will change not their layout.}
221 // 0 |----------------------|---------------------| 256
222 // | a time-bins | time-bins a |
224 // | o |___________________o_|__> X
228 // 255 |----------------------|---------------------| 511
233 const Float_t kconv = 1.0E-04; // converts microns to cm.
235 ix = -1; // default values
236 iz = -1; // default values
237 dx = -kconv*Dx(); // lower left edge in cm.
238 dz = -0.5*kconv*Dz(); // lower left edge in cm.
239 if(x<dx || x>-dx) return; // outside of defined volume.
240 if(z<dz || z>-dz) return; // outside of defined volume.
241 tb = fResponse->DriftSpeed()*fTimeStep*kconv; // compute size of time bin.
242 if(x>0) dx = -(dx + x)/tb; // distance from + side in time bin units
243 else dx = (x - dx)/tb; // distance from - side in time bin units
244 dz = (z - dz)/(kconv*fPitch); // distance in z in anode pitch units
245 ix = (Int_t) dx; // time bin
246 iz = (Int_t) dz; // anode
247 if(x>0) iz += Npz()/2; // if x>0 then + side anodes values.
248 return; // Found ix and iz, return.
250 //______________________________________________________________________
251 void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z)
253 // Transformation from Detector time bucket and anode coordiantes to Geant
254 // detector centerd local coordinates (cm).
256 // Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
257 // Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
259 // Float_t x detector local coordinate x in cm with respect to the
260 // center of the sensitive volume.
261 // Float_t z detector local coordinate z in cm with respect to the
262 // center of the sensitive volulme.
263 // If ix and or iz is outside of the segmentation range a value of -Dx()
264 // or -0.5*Dz() is returned.
265 // This segmentation geometry can be discribed as the following:
266 // {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
267 // res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the
268 // specific numbers will change not their layout.}
271 // 0 |----------------------|---------------------| 256
272 // | a time-bins | time-bins a |
274 // | o |___________________o_|__> X
278 // 255 |----------------------|---------------------| 511
284 const Float_t kconv = 1.0E-04; // converts microns to cm.
286 if(iz>=Npz()/2) x = kconv*Dx(); // default value for +x side.
287 else x = -kconv*Dx(); // default value for -x side.
288 z = -0.5*kconv*Dz(); // default value.
289 if(ix<0 || ix>=Npx()) return; // outside of detector
290 if(iz<0 || iz>=Npz()) return; // outside of detctor
291 tb = fResponse->DriftSpeed()*fTimeStep*kconv; // compute size of time bin.
292 if(iz>=Npz()/2) tb *= -1.0; // for +x side decrement frmo Dx().
293 for(i=0;i<ix;i++) x += tb; // sum up to cell ix-1
294 x += 0.5*tb; // add 1/2 of cell ix for center location.
295 if(iz>=Npz()/2) iz -=Npz()/2;// If +x side don't count anodes from -x side.
296 for(j=0;j<iz;j++) z += kconv*fPitch; // sum up cell iz-1
297 z += 0.5*kconv*fPitch; // add 1/2 of cell iz for center location.
298 return; // Found x and z, return.