]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSsegmentationSDD.cxx
Posible memory leak fixed. Changes AliITSpList destructor. Not clear if
[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 **************************************************************************/
04436464 15#include <iomanip.h>
16#include <fstream.h>
1ca7869b 17#include <TF1.h>
b0f5e3fc 18#include <TMath.h>
19
b0f5e3fc 20#include "AliITSsegmentationSDD.h"
21#include "AliITS.h"
314ba410 22#include "AliITSgeom.h"
d953664a 23#include "AliITSgeomSDD.h"
b0f5e3fc 24#include "AliRun.h"
314ba410 25#include "AliITSresponse.h"
b0f5e3fc 26
b0f5e3fc 27ClassImp(AliITSsegmentationSDD)
2a4239d3 28//----------------------------------------------------------------------
29AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom,
30 AliITSresponse *resp){
b0f5e3fc 31 // constructor
32 fGeom=geom;
03898a57 33 fDriftSpeed=resp->DriftSpeed();
b0f5e3fc 34 fCorr=0;
35 SetDetSize();
e8189707 36 SetPadSize();
37 SetNPads();
b0f5e3fc 38
39}
2a4239d3 40//______________________________________________________________________
b0f5e3fc 41AliITSsegmentationSDD::AliITSsegmentationSDD(){
e8189707 42 // standard constructor
b0f5e3fc 43 fGeom=0;
03898a57 44 fDriftSpeed=0;
b0f5e3fc 45 fCorr=0;
46 SetDetSize();
e8189707 47 SetPadSize();
48 SetNPads();
b0f5e3fc 49
50}
2a4239d3 51//----------------------------------------------------------------------
b0f5e3fc 52void AliITSsegmentationSDD::Init(){
53 // Standard initilisation routine
54
e8189707 55 if(!fGeom) {
314ba410 56 return;
57 //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
e8189707 58 }
b0f5e3fc 59 AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
60
61 const Float_t kconv=10000.;
62 fDz = 2.*kconv*gsdd->GetDz();
63 fDx = kconv*gsdd->GetDx();
64 fDy = 2.*kconv*gsdd->GetDy();
65}
66
2a4239d3 67//----------------------------------------------------------------------
b0f5e3fc 68void AliITSsegmentationSDD::
314ba410 69Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]){
70 // returns neighbours for use in Cluster Finder routines and the like
b0f5e3fc 71
e8189707 72 if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
73 if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
b0f5e3fc 74 *Nlist=4;
75 Xlist[0]=Xlist[1]=iX;
314ba410 76 if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
b0f5e3fc 77 else Xlist[2]=iX;
314ba410 78 if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
b0f5e3fc 79 else Xlist[3]=iX;
80 if(iZ) Zlist[0]=iZ-1;
81 else Zlist[0]=iZ;
82 if (iZ < fNsamples) Zlist[1]=iZ+1;
83 else Zlist[1]=iZ;
84 Zlist[2]=Zlist[3]=iZ;
b0f5e3fc 85}
2a4239d3 86//----------------------------------------------------------------------
87void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
88 Int_t &timebin,Int_t &anode){
03898a57 89// Returns cell coordinates (time sample,anode) incremented by 1 !!!!!
90// for given real local coordinates (x,z)
b0f5e3fc 91
92 // expects x, z in cm
93
94 const Float_t kconv=10000; // cm->um
95
b0f5e3fc 96 Int_t na = fNanodes/2;
97 Float_t driftpath=fDx-TMath::Abs(kconv*x);
03898a57 98 timebin=(Int_t)(driftpath/fDriftSpeed/fTimeStep);
99 anode=(Int_t)(kconv*(z/fPitch + na/2));
b0f5e3fc 100 if (x > 0) anode += na;
101
102 timebin+=1;
103 anode+=1;
104
105}
2a4239d3 106//----------------------------------------------------------------------
107void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
108 Float_t &x ,Float_t &z){
b0f5e3fc 109 // Transform from cell to real local coordinates
b0f5e3fc 110 // returns x, z in cm
111
03898a57 112 // the +0.5 means that an # and time bin # should start from 0 !!!
b0f5e3fc 113 const Float_t kconv=10000; // um->cm
03898a57 114 // the +0.5 means that an # and time bin # should start from 0 !!!
b0f5e3fc 115
b0f5e3fc 116 Int_t na = fNanodes/2;
03898a57 117 Float_t driftpath=(timebin+0.5)*fTimeStep*fDriftSpeed;
b0f5e3fc 118 if (anode >= na) x=(fDx-driftpath)/kconv;
119 else x = -(fDx-driftpath)/kconv;
120 if (anode >= na) anode-=na;
03898a57 121 z=((anode+0.5)*fPitch-fDz/2)/kconv;
b0f5e3fc 122
123}
2a4239d3 124//----------------------------------------------------------------------
e8189707 125void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z){
126 // Get anode and time bucket as floats - numbering from 0
127
128 // expects x, z in cm
129
130 const Float_t kconv=10000; // cm->um
131
2a4239d3 132 Float_t x0=x;
2a4239d3 133 Int_t na = fNanodes/2;
e8189707 134 Float_t driftpath=fDx-TMath::Abs(kconv*x);
03898a57 135 x=driftpath/fDriftSpeed/fTimeStep;
2a4239d3 136 z=kconv*z/fPitch + (float)na/2;
137 if (x0 < 0) x = -x;
e8189707 138
139}
2a4239d3 140//----------------------------------------------------------------------
b0f5e3fc 141void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l){
142 // returns local coordinates from global
143 if(!fGeom) {
314ba410 144 return;
145 //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
b0f5e3fc 146 }
147 fGeom->GtoL(module,g,l);
148}
2a4239d3 149//----------------------------------------------------------------------
b0f5e3fc 150void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g){
151 // return global coordinates from local
152 if(!fGeom) {
314ba410 153 return;
154 //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
b0f5e3fc 155 }
156
157 fGeom->LtoG(module,l,g);
158
159}
f5d698b9 160//----------------------------------------------------------------------
db93954b 161void AliITSsegmentationSDD::Print(Option_t *opt) const {
f5d698b9 162 // Print SDD segmentation Parameters
163
164 cout << "**************************************************" << endl;
165 cout << " Silicon Drift Detector Segmentation Parameters " << endl;
166 cout << "**************************************************" << endl;
167 cout << "Number of Time Samples: " << fNsamples << endl;
168 cout << "Number of Anodes: " << fNanodes << endl;
169 cout << "Time Step (ns): " << fTimeStep << endl;
170 cout << "Anode Pitch (um): " << fPitch << endl;
171 cout << "Full Detector Width (x): " << fDx << endl;
172 cout << "Half Detector Length (z): " << fDz << endl;
173 cout << "Full Detector Thickness (y): " << fDy << endl;
174 cout << "**************************************************" << endl;
175
176}
5752a110 177//______________________________________________________________________
178
179//______________________________________________________________________
180void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
181// Transformation from Geant detector centered local coordinates (cm) to
182// time bucket numbers ix and anode number iz.
183// Input:
184// Float_t x detector local coordinate x in cm with respect to the
185// center of the sensitive volume.
186// Float_t z detector local coordinate z in cm with respect to the
187// center of the sensitive volulme.
188// Output:
189// Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
190// Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
191// A value of -1 for ix or iz indecates that this point is outside of the
192// detector segmentation as defined.
193// This segmentation geometry can be discribed as the following:
194// {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
195// res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the
196// specific numbers will change not their layout.}
197//
198// 0 191 0
199// 0 |----------------------|---------------------| 256
200// | a time-bins | time-bins a |
201// | n | n |
202// | o |___________________o_|__> X
203// | d | d |
204// | e | e |
205// | s | s |
206// 255 |----------------------|---------------------| 511
207// |
208// V
209// Z
210 Float_t dx,dz,tb;
211 const Float_t kconv = 1.0E-04; // converts microns to cm.
212
213 ix = -1; // default values
214 iz = -1; // default values
215 dx = -kconv*Dx(); // lower left edge in cm.
216 dz = -0.5*kconv*Dz(); // lower left edge in cm.
217 if(x<dx || x>-dx) return; // outside of defined volume.
218 if(z<dz || z>-dz) return; // outside of defined volume.
03898a57 219 tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
5752a110 220 if(x>0) dx = -(dx + x)/tb; // distance from + side in time bin units
221 else dx = (x - dx)/tb; // distance from - side in time bin units
222 dz = (z - dz)/(kconv*fPitch); // distance in z in anode pitch units
223 ix = (Int_t) dx; // time bin
224 iz = (Int_t) dz; // anode
225 if(x>0) iz += Npz()/2; // if x>0 then + side anodes values.
226 return; // Found ix and iz, return.
227}
228//______________________________________________________________________
229void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z)
230{
231// Transformation from Detector time bucket and anode coordiantes to Geant
232// detector centerd local coordinates (cm).
233// Input:
234// Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
235// Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
236// Output:
237// Float_t x detector local coordinate x in cm with respect to the
238// center of the sensitive volume.
239// Float_t z detector local coordinate z in cm with respect to the
240// center of the sensitive volulme.
241// If ix and or iz is outside of the segmentation range a value of -Dx()
242// or -0.5*Dz() is returned.
243// This segmentation geometry can be discribed as the following:
244// {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
245// res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the
246// specific numbers will change not their layout.}
247//
248// 0 191 0
249// 0 |----------------------|---------------------| 256
250// | a time-bins | time-bins a |
251// | n | n |
252// | o |___________________o_|__> X
253// | d | d |
254// | e | e |
255// | s | s |
256// 255 |----------------------|---------------------| 511
257// |
258// V
259// Z
260 Int_t i,j;
261 Float_t tb;
262 const Float_t kconv = 1.0E-04; // converts microns to cm.
263
264 if(iz>=Npz()/2) x = kconv*Dx(); // default value for +x side.
265 else x = -kconv*Dx(); // default value for -x side.
266 z = -0.5*kconv*Dz(); // default value.
267 if(ix<0 || ix>=Npx()) return; // outside of detector
268 if(iz<0 || iz>=Npz()) return; // outside of detctor
03898a57 269 tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
5752a110 270 if(iz>=Npz()/2) tb *= -1.0; // for +x side decrement frmo Dx().
271 for(i=0;i<ix;i++) x += tb; // sum up to cell ix-1
272 x += 0.5*tb; // add 1/2 of cell ix for center location.
273 if(iz>=Npz()/2) iz -=Npz()/2;// If +x side don't count anodes from -x side.
274 for(j=0;j<iz;j++) z += kconv*fPitch; // sum up cell iz-1
275 z += 0.5*kconv*fPitch; // add 1/2 of cell iz for center location.
276 return; // Found x and z, return.
277}