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 "AliITSCalibration.h"
23 #include "AliITSCalibrationSDD.h"
24 #include "AliITSresponseSDD.h"
25 //////////////////////////////////////////////////////
26 // Segmentation class for //
29 //////////////////////////////////////////////////////
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;
39 ClassImp(AliITSsegmentationSDD)
40 //----------------------------------------------------------------------
41 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom,
42 AliITSCalibration *resp){
45 AliITSCalibrationSDD* sp = (AliITSCalibrationSDD*)resp;
46 fDriftSpeed=sp->GetDriftSpeed();
48 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
49 SetPadSize(fgkPitchDefault,fgkClockDefault);
50 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
53 //______________________________________________________________________
54 AliITSsegmentationSDD::AliITSsegmentationSDD() : AliITSsegmentation(){
55 // Default constructor
57 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
58 SetPadSize(fgkPitchDefault,fgkClockDefault);
59 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
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;
74 //______________________________________________________________________
75 AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(const AliITSsegmentationSDD &source){
77 if(this==&source) return *this;
82 //____________________________________________________________________________
83 AliITSsegmentationSDD::AliITSsegmentationSDD(const AliITSsegmentationSDD &source) :
84 AliITSsegmentation(source){
89 //----------------------------------------------------------------------
90 void AliITSsegmentationSDD::Init(){
91 // Standard initilisation routine
94 Fatal("Init","the pointer to the ITS geometry class (AliITSgeom) is null\n");
97 AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
99 const Float_t kconv=10000.;
100 fDz = 2.*kconv*gsdd->GetDz();
101 fDx = kconv*gsdd->GetDx();
102 fDy = 2.*kconv*gsdd->GetDy();
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
110 if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
111 if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
113 Xlist[0]=Xlist[1]=iX;
114 if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
116 if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
118 if(iZ) Zlist[0]=iZ-1;
120 if (iZ < fNsamples) Zlist[1]=iZ+1;
122 Zlist[2]=Zlist[3]=iZ;
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)
130 // expects x, z in cm
132 const Float_t kconv=10000; // cm->um
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;
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
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 !!!
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;
164 //----------------------------------------------------------------------
165 void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z) const{
166 // Get anode and time bucket as floats - numbering from 0
168 // expects x, z in cm
170 const Float_t kconv=10000; // cm->um
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;
180 //----------------------------------------------------------------------
181 void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l) const {
182 // returns local coordinates from global
184 Fatal("GetLocal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
187 fGeom->GtoL(module,g,l);
189 //----------------------------------------------------------------------
190 void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g) const {
191 // return global coordinates from local
193 Fatal("GetGlobal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
196 fGeom->LtoG(module,l,g);
199 //----------------------------------------------------------------------
200 void AliITSsegmentationSDD::Print(Option_t *opt) const {
201 // Print SDD segmentation Parameters
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;
220 //----------------------------------------------------------------------
221 void AliITSsegmentationSDD::PrintDefaultParameters() const {
222 // print SDD parameters defined as static const data members
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;
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.
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.
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.}
261 // 0 |----------------------|---------------------| 256
262 // | a time-bins | time-bins a |
264 // | o |___________________o_|__> X
268 // 255 |----------------------|---------------------| 511
273 const Float_t kconv = 1.0E-04; // converts microns to cm.
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.
280 Warning("LocalToDet","input argument %f out of range (%f, %f)",x,dx,-dx);
281 return kFALSE; // outside of defined volume.
284 Warning("LocalToDet","input argument %f out of range (%f, %f)",z,dz,-dz);
285 return kFALSE; // outside of defined volume.
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.
296 //______________________________________________________________________
297 void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
299 // Transformation from Detector time bucket and anode coordiantes to Geant
300 // detector centerd local coordinates (cm).
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.
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.}
317 // 0 |----------------------|---------------------| 256
318 // | a time-bins | time-bins a |
320 // | o |___________________o_|__> X
324 // 255 |----------------------|---------------------| 511
330 const Float_t kconv = 1.0E-04; // converts microns to cm.
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
339 if(iz<0 || iz>=Npz()) {
340 Warning("DetToLocal","input argument %d out of range (0, %d)",iz,Npz());
341 return; // outside of detctor
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.