]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSsegmentationSDD.cxx
Modified ASCII output to equalize baselines
[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"
fcf95fc7 22#include "AliITSresponseSDD.h"
55d2c544 23//////////////////////////////////////////////////////
24// Segmentation class for //
25// drift detectors //
26// //
27//////////////////////////////////////////////////////
28
29const Float_t AliITSsegmentationSDD::fgkDxDefault = 35085.;
30const Float_t AliITSsegmentationSDD::fgkDzDefault = 75264.;
31const Float_t AliITSsegmentationSDD::fgkDyDefault = 300.;
32const Float_t AliITSsegmentationSDD::fgkPitchDefault = 294.;
33const Float_t AliITSsegmentationSDD::fgkClockDefault = 40.;
34const Int_t AliITSsegmentationSDD::fgkHalfNanodesDefault = 256;
35const Int_t AliITSsegmentationSDD::fgkNsamplesDefault = 256;
36
b0f5e3fc 37ClassImp(AliITSsegmentationSDD)
2a4239d3 38//----------------------------------------------------------------------
4952f440 39AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom):
e56160b8 40fNsamples(0),
41fNanodes(0),
42fPitch(0),
43fTimeStep(0),
4952f440 44fDriftSpeed(0),
45fSetDriftSpeed(0){
b0f5e3fc 46 // constructor
47 fGeom=geom;
4952f440 48 fDriftSpeed=AliITSresponseSDD::DefaultDriftSpeed();
b0f5e3fc 49 fCorr=0;
55d2c544 50 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
51 SetPadSize(fgkPitchDefault,fgkClockDefault);
52 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
b0f5e3fc 53
54}
2a4239d3 55//______________________________________________________________________
e56160b8 56AliITSsegmentationSDD::AliITSsegmentationSDD() : AliITSsegmentation(),
57fNsamples(0),
58fNanodes(0),
59fPitch(0),
60fTimeStep(0),
4952f440 61fDriftSpeed(0),
62fSetDriftSpeed(0){
55d2c544 63 // Default constructor
03898a57 64 fDriftSpeed=0;
55d2c544 65 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
66 SetPadSize(fgkPitchDefault,fgkClockDefault);
67 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
68
69}
b0f5e3fc 70
55d2c544 71//______________________________________________________________________
72void AliITSsegmentationSDD::Copy(TObject &obj) const {
73 // protected method. copy this to obj
74 AliITSsegmentation::Copy(obj);
75 ((AliITSsegmentationSDD& ) obj).fNsamples = fNsamples;
76 ((AliITSsegmentationSDD& ) obj).fNanodes = fNanodes;
77 ((AliITSsegmentationSDD& ) obj).fPitch = fPitch;
78 ((AliITSsegmentationSDD& ) obj).fTimeStep = fTimeStep;
79 ((AliITSsegmentationSDD& ) obj).fDriftSpeed = fDriftSpeed;
4952f440 80 ((AliITSsegmentationSDD& ) obj).fSetDriftSpeed = fSetDriftSpeed;
b0f5e3fc 81}
55d2c544 82
83//______________________________________________________________________
84AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(const AliITSsegmentationSDD &source){
85 // = operator
86 if(this==&source) return *this;
87 source.Copy(*this);
88 return *this;
89}
90
91//____________________________________________________________________________
92AliITSsegmentationSDD::AliITSsegmentationSDD(const AliITSsegmentationSDD &source) :
e56160b8 93 AliITSsegmentation(source),
94fNsamples(0),
95fNanodes(0),
96fPitch(0),
97fTimeStep(0),
4952f440 98fDriftSpeed(0),
99fSetDriftSpeed(0){
55d2c544 100 // copy constructor
101 source.Copy(*this);
102}
103
2a4239d3 104//----------------------------------------------------------------------
b0f5e3fc 105void AliITSsegmentationSDD::Init(){
106 // Standard initilisation routine
107
e8189707 108 if(!fGeom) {
55d2c544 109 Fatal("Init","the pointer to the ITS geometry class (AliITSgeom) is null\n");
314ba410 110 return;
e8189707 111 }
b0f5e3fc 112 AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
113
114 const Float_t kconv=10000.;
115 fDz = 2.*kconv*gsdd->GetDz();
116 fDx = kconv*gsdd->GetDx();
117 fDy = 2.*kconv*gsdd->GetDy();
118}
119
2a4239d3 120//----------------------------------------------------------------------
b0f5e3fc 121void AliITSsegmentationSDD::
55d2c544 122Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]) const {
314ba410 123 // returns neighbours for use in Cluster Finder routines and the like
b0f5e3fc 124
e8189707 125 if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
126 if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
b0f5e3fc 127 *Nlist=4;
128 Xlist[0]=Xlist[1]=iX;
314ba410 129 if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
b0f5e3fc 130 else Xlist[2]=iX;
314ba410 131 if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
b0f5e3fc 132 else Xlist[3]=iX;
133 if(iZ) Zlist[0]=iZ-1;
134 else Zlist[0]=iZ;
135 if (iZ < fNsamples) Zlist[1]=iZ+1;
136 else Zlist[1]=iZ;
137 Zlist[2]=Zlist[3]=iZ;
b0f5e3fc 138}
2a4239d3 139//----------------------------------------------------------------------
140void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
55d2c544 141 Int_t &timebin,Int_t &anode) const {
03898a57 142// Returns cell coordinates (time sample,anode) incremented by 1 !!!!!
143// for given real local coordinates (x,z)
b0f5e3fc 144
145 // expects x, z in cm
146
147 const Float_t kconv=10000; // cm->um
148
f8d9a5b8 149 x *= kconv; // Convert to microns
150 z *= kconv; // Convert to microns
b0f5e3fc 151 Int_t na = fNanodes/2;
f8d9a5b8 152 Float_t driftpath=fDx-TMath::Abs(x);
03898a57 153 timebin=(Int_t)(driftpath/fDriftSpeed/fTimeStep);
f8d9a5b8 154 anode=(Int_t)(z/fPitch + na/2);
b0f5e3fc 155 if (x > 0) anode += na;
156
157 timebin+=1;
158 anode+=1;
4952f440 159 if(!fSetDriftSpeed){
160 timebin=-999;
161 Warning("GetPadIxz","Drift speed not set: timebin is dummy");
162 }
b0f5e3fc 163
164}
2a4239d3 165//----------------------------------------------------------------------
166void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
55d2c544 167 Float_t &x ,Float_t &z) const{
b0f5e3fc 168 // Transform from cell to real local coordinates
b0f5e3fc 169 // returns x, z in cm
170
03898a57 171 // the +0.5 means that an # and time bin # should start from 0 !!!
b0f5e3fc 172 const Float_t kconv=10000; // um->cm
03898a57 173 // the +0.5 means that an # and time bin # should start from 0 !!!
b0f5e3fc 174
b0f5e3fc 175 Int_t na = fNanodes/2;
03898a57 176 Float_t driftpath=(timebin+0.5)*fTimeStep*fDriftSpeed;
b0f5e3fc 177 if (anode >= na) x=(fDx-driftpath)/kconv;
178 else x = -(fDx-driftpath)/kconv;
179 if (anode >= na) anode-=na;
03898a57 180 z=((anode+0.5)*fPitch-fDz/2)/kconv;
4952f440 181 if(!fSetDriftSpeed){
182 x=-9999.;
183 Warning("GetPadCxz","Drift speed not set: x coord. is dummy");
184 }
b0f5e3fc 185
186}
2a4239d3 187//----------------------------------------------------------------------
55d2c544 188void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z) const{
e8189707 189 // Get anode and time bucket as floats - numbering from 0
190
191 // expects x, z in cm
192
193 const Float_t kconv=10000; // cm->um
194
2a4239d3 195 Float_t x0=x;
2a4239d3 196 Int_t na = fNanodes/2;
e8189707 197 Float_t driftpath=fDx-TMath::Abs(kconv*x);
03898a57 198 x=driftpath/fDriftSpeed/fTimeStep;
2a4239d3 199 z=kconv*z/fPitch + (float)na/2;
200 if (x0 < 0) x = -x;
4952f440 201 if(!fSetDriftSpeed){
202 x=-9999.;
203 Warning("GetPadTxz","Drift speed not set: x coord. is dummy");
204 }
e8189707 205}
2a4239d3 206//----------------------------------------------------------------------
55d2c544 207void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l) const {
b0f5e3fc 208 // returns local coordinates from global
209 if(!fGeom) {
55d2c544 210 Fatal("GetLocal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
314ba410 211 return;
b0f5e3fc 212 }
213 fGeom->GtoL(module,g,l);
214}
2a4239d3 215//----------------------------------------------------------------------
55d2c544 216void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g) const {
b0f5e3fc 217 // return global coordinates from local
218 if(!fGeom) {
55d2c544 219 Fatal("GetGlobal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
b0f5e3fc 220 }
221
222 fGeom->LtoG(module,l,g);
223
224}
f5d698b9 225//----------------------------------------------------------------------
db93954b 226void AliITSsegmentationSDD::Print(Option_t *opt) const {
f5d698b9 227 // Print SDD segmentation Parameters
228
229 cout << "**************************************************" << endl;
ac74f489 230 cout << " Silicon Drift Detector Segmentation Parameters " << opt << endl;
f5d698b9 231 cout << "**************************************************" << endl;
232 cout << "Number of Time Samples: " << fNsamples << endl;
233 cout << "Number of Anodes: " << fNanodes << endl;
234 cout << "Time Step (ns): " << fTimeStep << endl;
235 cout << "Anode Pitch (um): " << fPitch << endl;
55d2c544 236 cout << "Full Detector Width (x): " << fDx;
237 cout<<" (Default is "<<fgkDxDefault<<") "<<endl;
238 cout << "Half Detector Length (z): " << fDz;
239 cout<<" (Default is "<<fgkDzDefault<<") "<<endl;
240 cout << "Full Detector Thickness (y): " << fDy;
241 cout<<" (Default is "<<fgkDyDefault<<") "<<endl;
f5d698b9 242 cout << "**************************************************" << endl;
243
244}
55d2c544 245
246//----------------------------------------------------------------------
247void AliITSsegmentationSDD::PrintDefaultParameters() const {
248 // print SDD parameters defined as static const data members
249
250 cout << "**************************************************" << endl;
251 cout << " Silicon Drift Detector Segmentation Parameters " << endl;
252 cout << " Default values defined as static const data members"<< endl;
253 cout << " Actual values can be set with the relevant setters"<< endl;
254 cout << "**************************************************" << endl;
255 cout<<"fgkDxDefault = "<<fgkDxDefault<<endl;
256 cout<<"fgkDzDefault = "<<fgkDzDefault<<endl;
257 cout<<"fgkDyDefault = "<<fgkDyDefault<<endl;
258 cout<<"fgkPitchDefault = "<<fgkPitchDefault<<endl;
259 cout<<"fgkClockDefault = "<<fgkClockDefault<<endl;
260 cout<<"fgkHalfNanodesDefault = "<<fgkHalfNanodesDefault<<endl;
261 cout<<"fgkNsamplesDefault = "<<fgkNsamplesDefault<<endl;
262 cout << "**************************************************" << endl;
263
264}
5752a110 265
266//______________________________________________________________________
aacedc3e 267Bool_t AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,
268 Int_t &ix,Int_t &iz) const {
5752a110 269// Transformation from Geant detector centered local coordinates (cm) to
270// time bucket numbers ix and anode number iz.
271// Input:
272// Float_t x detector local coordinate x in cm with respect to the
273// center of the sensitive volume.
274// Float_t z detector local coordinate z in cm with respect to the
275// center of the sensitive volulme.
276// Output:
277// Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
278// Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
279// A value of -1 for ix or iz indecates that this point is outside of the
280// detector segmentation as defined.
281// This segmentation geometry can be discribed as the following:
282// {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
283// res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the
284// specific numbers will change not their layout.}
285//
286// 0 191 0
287// 0 |----------------------|---------------------| 256
288// | a time-bins | time-bins a |
289// | n | n |
290// | o |___________________o_|__> X
291// | d | d |
292// | e | e |
293// | s | s |
294// 255 |----------------------|---------------------| 511
295// |
296// V
297// Z
298 Float_t dx,dz,tb;
299 const Float_t kconv = 1.0E-04; // converts microns to cm.
300
301 ix = -1; // default values
302 iz = -1; // default values
303 dx = -kconv*Dx(); // lower left edge in cm.
304 dz = -0.5*kconv*Dz(); // lower left edge in cm.
507cf1a7 305 if(x<dx || x>-dx) {
306 Warning("LocalToDet","input argument %f out of range (%f, %f)",x,dx,-dx);
aacedc3e 307 return kFALSE; // outside of defined volume.
507cf1a7 308 }
309 if(z<dz || z>-dz) {
310 Warning("LocalToDet","input argument %f out of range (%f, %f)",z,dz,-dz);
aacedc3e 311 return kFALSE; // outside of defined volume.
507cf1a7 312 }
03898a57 313 tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
5752a110 314 if(x>0) dx = -(dx + x)/tb; // distance from + side in time bin units
315 else dx = (x - dx)/tb; // distance from - side in time bin units
316 dz = (z - dz)/(kconv*fPitch); // distance in z in anode pitch units
317 ix = (Int_t) dx; // time bin
318 iz = (Int_t) dz; // anode
319 if(x>0) iz += Npz()/2; // if x>0 then + side anodes values.
4952f440 320 if(!fSetDriftSpeed){
321 tb=-999;
322 Warning("LocalToDet","Drift speed not set: timebin is dummy");
323 return kFALSE;
324 }
aacedc3e 325 return kTRUE; // Found ix and iz, return.
5752a110 326}
327//______________________________________________________________________
55d2c544 328void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
5752a110 329{
330// Transformation from Detector time bucket and anode coordiantes to Geant
331// detector centerd local coordinates (cm).
332// Input:
333// Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
334// Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
335// Output:
336// Float_t x detector local coordinate x in cm with respect to the
337// center of the sensitive volume.
338// Float_t z detector local coordinate z in cm with respect to the
339// center of the sensitive volulme.
340// If ix and or iz is outside of the segmentation range a value of -Dx()
341// or -0.5*Dz() is returned.
342// This segmentation geometry can be discribed as the following:
343// {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
344// res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the
345// specific numbers will change not their layout.}
346//
347// 0 191 0
348// 0 |----------------------|---------------------| 256
349// | a time-bins | time-bins a |
350// | n | n |
351// | o |___________________o_|__> X
352// | d | d |
353// | e | e |
354// | s | s |
355// 255 |----------------------|---------------------| 511
356// |
357// V
358// Z
359 Int_t i,j;
360 Float_t tb;
361 const Float_t kconv = 1.0E-04; // converts microns to cm.
362
363 if(iz>=Npz()/2) x = kconv*Dx(); // default value for +x side.
364 else x = -kconv*Dx(); // default value for -x side.
365 z = -0.5*kconv*Dz(); // default value.
507cf1a7 366 if(ix<0 || ix>=Npx()) {
367 Warning("DetToLocal","input argument %d out of range (0, %d)",ix,Npx());
368 return; // outside of detector
369 }
370 if(iz<0 || iz>=Npz()) {
371 Warning("DetToLocal","input argument %d out of range (0, %d)",iz,Npz());
372 return; // outside of detctor
373 }
03898a57 374 tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
5752a110 375 if(iz>=Npz()/2) tb *= -1.0; // for +x side decrement frmo Dx().
376 for(i=0;i<ix;i++) x += tb; // sum up to cell ix-1
377 x += 0.5*tb; // add 1/2 of cell ix for center location.
378 if(iz>=Npz()/2) iz -=Npz()/2;// If +x side don't count anodes from -x side.
379 for(j=0;j<iz;j++) z += kconv*fPitch; // sum up cell iz-1
380 z += 0.5*kconv*fPitch; // add 1/2 of cell iz for center location.
4952f440 381 if(!fSetDriftSpeed){
382 x=-9999.;
383 Warning("LocalToDet","Drift speed not set: x coord. is dummy");
384 }
5752a110 385 return; // Found x and z, return.
386}