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