Clean-up of the class structure + coding conventions
[u/mrichter/AliRoot.git] / ITS / AliITSsegmentationSDD.cxx
CommitLineData
b0f5e3fc 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 **************************************************************************/
4ae5bbc4 15#include <Riostream.h>
b0f5e3fc 16#include <TMath.h>
17
b0f5e3fc 18#include "AliITSsegmentationSDD.h"
55d2c544 19// #include "AliITS.h"
314ba410 20#include "AliITSgeom.h"
d953664a 21#include "AliITSgeomSDD.h"
314ba410 22#include "AliITSresponse.h"
b0f5e3fc 23
55d2c544 24//////////////////////////////////////////////////////
25// Segmentation class for //
26// drift detectors //
27// //
28//////////////////////////////////////////////////////
29
30const Float_t AliITSsegmentationSDD::fgkDxDefault = 35085.;
31const Float_t AliITSsegmentationSDD::fgkDzDefault = 75264.;
32const Float_t AliITSsegmentationSDD::fgkDyDefault = 300.;
33const Float_t AliITSsegmentationSDD::fgkPitchDefault = 294.;
34const Float_t AliITSsegmentationSDD::fgkClockDefault = 40.;
35const Int_t AliITSsegmentationSDD::fgkHalfNanodesDefault = 256;
36const Int_t AliITSsegmentationSDD::fgkNsamplesDefault = 256;
37
b0f5e3fc 38ClassImp(AliITSsegmentationSDD)
2a4239d3 39//----------------------------------------------------------------------
40AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom,
41 AliITSresponse *resp){
b0f5e3fc 42 // constructor
43 fGeom=geom;
03898a57 44 fDriftSpeed=resp->DriftSpeed();
b0f5e3fc 45 fCorr=0;
55d2c544 46 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
47 SetPadSize(fgkPitchDefault,fgkClockDefault);
48 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
b0f5e3fc 49
50}
2a4239d3 51//______________________________________________________________________
55d2c544 52AliITSsegmentationSDD::AliITSsegmentationSDD() : AliITSsegmentation(){
53 // Default constructor
03898a57 54 fDriftSpeed=0;
55d2c544 55 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
56 SetPadSize(fgkPitchDefault,fgkClockDefault);
57 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
58
59}
b0f5e3fc 60
55d2c544 61//______________________________________________________________________
62void 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;
b0f5e3fc 70}
55d2c544 71
72//______________________________________________________________________
73AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(const AliITSsegmentationSDD &source){
74 // = operator
75 if(this==&source) return *this;
76 source.Copy(*this);
77 return *this;
78}
79
80//____________________________________________________________________________
81AliITSsegmentationSDD::AliITSsegmentationSDD(const AliITSsegmentationSDD &source) :
82 AliITSsegmentation(source){
83 // copy constructor
84 source.Copy(*this);
85}
86
2a4239d3 87//----------------------------------------------------------------------
b0f5e3fc 88void AliITSsegmentationSDD::Init(){
89 // Standard initilisation routine
90
e8189707 91 if(!fGeom) {
55d2c544 92 Fatal("Init","the pointer to the ITS geometry class (AliITSgeom) is null\n");
314ba410 93 return;
e8189707 94 }
b0f5e3fc 95 AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
96
97 const Float_t kconv=10000.;
98 fDz = 2.*kconv*gsdd->GetDz();
99 fDx = kconv*gsdd->GetDx();
100 fDy = 2.*kconv*gsdd->GetDy();
101}
102
2a4239d3 103//----------------------------------------------------------------------
b0f5e3fc 104void AliITSsegmentationSDD::
55d2c544 105Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]) const {
314ba410 106 // returns neighbours for use in Cluster Finder routines and the like
b0f5e3fc 107
e8189707 108 if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
109 if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
b0f5e3fc 110 *Nlist=4;
111 Xlist[0]=Xlist[1]=iX;
314ba410 112 if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
b0f5e3fc 113 else Xlist[2]=iX;
314ba410 114 if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
b0f5e3fc 115 else Xlist[3]=iX;
116 if(iZ) Zlist[0]=iZ-1;
117 else Zlist[0]=iZ;
118 if (iZ < fNsamples) Zlist[1]=iZ+1;
119 else Zlist[1]=iZ;
120 Zlist[2]=Zlist[3]=iZ;
b0f5e3fc 121}
2a4239d3 122//----------------------------------------------------------------------
123void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
55d2c544 124 Int_t &timebin,Int_t &anode) const {
03898a57 125// Returns cell coordinates (time sample,anode) incremented by 1 !!!!!
126// for given real local coordinates (x,z)
b0f5e3fc 127
128 // expects x, z in cm
129
130 const Float_t kconv=10000; // cm->um
131
f8d9a5b8 132 x *= kconv; // Convert to microns
133 z *= kconv; // Convert to microns
b0f5e3fc 134 Int_t na = fNanodes/2;
f8d9a5b8 135 Float_t driftpath=fDx-TMath::Abs(x);
03898a57 136 timebin=(Int_t)(driftpath/fDriftSpeed/fTimeStep);
f8d9a5b8 137 anode=(Int_t)(z/fPitch + na/2);
b0f5e3fc 138 if (x > 0) anode += na;
139
140 timebin+=1;
141 anode+=1;
142
143}
2a4239d3 144//----------------------------------------------------------------------
145void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
55d2c544 146 Float_t &x ,Float_t &z) const{
b0f5e3fc 147 // Transform from cell to real local coordinates
b0f5e3fc 148 // returns x, z in cm
149
03898a57 150 // the +0.5 means that an # and time bin # should start from 0 !!!
b0f5e3fc 151 const Float_t kconv=10000; // um->cm
03898a57 152 // the +0.5 means that an # and time bin # should start from 0 !!!
b0f5e3fc 153
b0f5e3fc 154 Int_t na = fNanodes/2;
03898a57 155 Float_t driftpath=(timebin+0.5)*fTimeStep*fDriftSpeed;
b0f5e3fc 156 if (anode >= na) x=(fDx-driftpath)/kconv;
157 else x = -(fDx-driftpath)/kconv;
158 if (anode >= na) anode-=na;
03898a57 159 z=((anode+0.5)*fPitch-fDz/2)/kconv;
b0f5e3fc 160
161}
2a4239d3 162//----------------------------------------------------------------------
55d2c544 163void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z) const{
e8189707 164 // Get anode and time bucket as floats - numbering from 0
165
166 // expects x, z in cm
167
168 const Float_t kconv=10000; // cm->um
169
2a4239d3 170 Float_t x0=x;
2a4239d3 171 Int_t na = fNanodes/2;
e8189707 172 Float_t driftpath=fDx-TMath::Abs(kconv*x);
03898a57 173 x=driftpath/fDriftSpeed/fTimeStep;
2a4239d3 174 z=kconv*z/fPitch + (float)na/2;
175 if (x0 < 0) x = -x;
e8189707 176
177}
2a4239d3 178//----------------------------------------------------------------------
55d2c544 179void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l) const {
b0f5e3fc 180 // returns local coordinates from global
181 if(!fGeom) {
55d2c544 182 Fatal("GetLocal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
314ba410 183 return;
b0f5e3fc 184 }
185 fGeom->GtoL(module,g,l);
186}
2a4239d3 187//----------------------------------------------------------------------
55d2c544 188void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g) const {
b0f5e3fc 189 // return global coordinates from local
190 if(!fGeom) {
55d2c544 191 Fatal("GetGlobal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
b0f5e3fc 192 }
193
194 fGeom->LtoG(module,l,g);
195
196}
f5d698b9 197//----------------------------------------------------------------------
db93954b 198void AliITSsegmentationSDD::Print(Option_t *opt) const {
f5d698b9 199 // Print SDD segmentation Parameters
200
201 cout << "**************************************************" << endl;
ac74f489 202 cout << " Silicon Drift Detector Segmentation Parameters " << opt << endl;
f5d698b9 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;
55d2c544 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;
f5d698b9 214 cout << "**************************************************" << endl;
215
216}
55d2c544 217
218//----------------------------------------------------------------------
219void AliITSsegmentationSDD::PrintDefaultParameters() const {
220 // print SDD parameters defined as static const data members
221
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;
235
236}
5752a110 237
238//______________________________________________________________________
55d2c544 239void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const {
5752a110 240// Transformation from Geant detector centered local coordinates (cm) to
241// time bucket numbers ix and anode number iz.
242// Input:
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.
247// Output:
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.}
256//
257// 0 191 0
258// 0 |----------------------|---------------------| 256
259// | a time-bins | time-bins a |
260// | n | n |
261// | o |___________________o_|__> X
262// | d | d |
263// | e | e |
264// | s | s |
265// 255 |----------------------|---------------------| 511
266// |
267// V
268// Z
269 Float_t dx,dz,tb;
270 const Float_t kconv = 1.0E-04; // converts microns to cm.
271
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.
507cf1a7 276 if(x<dx || x>-dx) {
277 Warning("LocalToDet","input argument %f out of range (%f, %f)",x,dx,-dx);
278 return; // outside of defined volume.
279 }
280 if(z<dz || z>-dz) {
281 Warning("LocalToDet","input argument %f out of range (%f, %f)",z,dz,-dz);
282 return; // outside of defined volume.
283 }
03898a57 284 tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
5752a110 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.
292}
293//______________________________________________________________________
55d2c544 294void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
5752a110 295{
296// Transformation from Detector time bucket and anode coordiantes to Geant
297// detector centerd local coordinates (cm).
298// Input:
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.
301// Output:
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.}
312//
313// 0 191 0
314// 0 |----------------------|---------------------| 256
315// | a time-bins | time-bins a |
316// | n | n |
317// | o |___________________o_|__> X
318// | d | d |
319// | e | e |
320// | s | s |
321// 255 |----------------------|---------------------| 511
322// |
323// V
324// Z
325 Int_t i,j;
326 Float_t tb;
327 const Float_t kconv = 1.0E-04; // converts microns to cm.
328
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.
507cf1a7 332 if(ix<0 || ix>=Npx()) {
333 Warning("DetToLocal","input argument %d out of range (0, %d)",ix,Npx());
334 return; // outside of detector
335 }
336 if(iz<0 || iz>=Npz()) {
337 Warning("DetToLocal","input argument %d out of range (0, %d)",iz,Npz());
338 return; // outside of detctor
339 }
03898a57 340 tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
5752a110 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.
348}