Adding the AliAnalysisGUI class which is the main class that controls the GUI.
[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 "AliITSCalibration.h"
23#include "AliITSCalibrationSDD.h"
24#include "AliITSresponseSDD.h"
55d2c544 25//////////////////////////////////////////////////////
26// Segmentation class for //
27// drift detectors //
28// //
29//////////////////////////////////////////////////////
30
31const Float_t AliITSsegmentationSDD::fgkDxDefault = 35085.;
32const Float_t AliITSsegmentationSDD::fgkDzDefault = 75264.;
33const Float_t AliITSsegmentationSDD::fgkDyDefault = 300.;
34const Float_t AliITSsegmentationSDD::fgkPitchDefault = 294.;
35const Float_t AliITSsegmentationSDD::fgkClockDefault = 40.;
36const Int_t AliITSsegmentationSDD::fgkHalfNanodesDefault = 256;
37const Int_t AliITSsegmentationSDD::fgkNsamplesDefault = 256;
38
b0f5e3fc 39ClassImp(AliITSsegmentationSDD)
2a4239d3 40//----------------------------------------------------------------------
41AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom,
e56160b8 42 AliITSCalibration *resp):
43fNsamples(0),
44fNanodes(0),
45fPitch(0),
46fTimeStep(0),
47fDriftSpeed(0){
b0f5e3fc 48 // constructor
49 fGeom=geom;
fcf95fc7 50 AliITSCalibrationSDD* sp = (AliITSCalibrationSDD*)resp;
51 fDriftSpeed=sp->GetDriftSpeed();
b0f5e3fc 52 fCorr=0;
55d2c544 53 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
54 SetPadSize(fgkPitchDefault,fgkClockDefault);
55 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
b0f5e3fc 56
57}
2a4239d3 58//______________________________________________________________________
e56160b8 59AliITSsegmentationSDD::AliITSsegmentationSDD() : AliITSsegmentation(),
60fNsamples(0),
61fNanodes(0),
62fPitch(0),
63fTimeStep(0),
64fDriftSpeed(0){
55d2c544 65 // Default constructor
03898a57 66 fDriftSpeed=0;
55d2c544 67 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
68 SetPadSize(fgkPitchDefault,fgkClockDefault);
69 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
70
71}
b0f5e3fc 72
55d2c544 73//______________________________________________________________________
74void AliITSsegmentationSDD::Copy(TObject &obj) const {
75 // protected method. copy this to obj
76 AliITSsegmentation::Copy(obj);
77 ((AliITSsegmentationSDD& ) obj).fNsamples = fNsamples;
78 ((AliITSsegmentationSDD& ) obj).fNanodes = fNanodes;
79 ((AliITSsegmentationSDD& ) obj).fPitch = fPitch;
80 ((AliITSsegmentationSDD& ) obj).fTimeStep = fTimeStep;
81 ((AliITSsegmentationSDD& ) obj).fDriftSpeed = fDriftSpeed;
b0f5e3fc 82}
55d2c544 83
84//______________________________________________________________________
85AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(const AliITSsegmentationSDD &source){
86 // = operator
87 if(this==&source) return *this;
88 source.Copy(*this);
89 return *this;
90}
91
92//____________________________________________________________________________
93AliITSsegmentationSDD::AliITSsegmentationSDD(const AliITSsegmentationSDD &source) :
e56160b8 94 AliITSsegmentation(source),
95fNsamples(0),
96fNanodes(0),
97fPitch(0),
98fTimeStep(0),
99fDriftSpeed(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;
159
160}
2a4239d3 161//----------------------------------------------------------------------
162void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
55d2c544 163 Float_t &x ,Float_t &z) const{
b0f5e3fc 164 // Transform from cell to real local coordinates
b0f5e3fc 165 // returns x, z in cm
166
03898a57 167 // the +0.5 means that an # and time bin # should start from 0 !!!
b0f5e3fc 168 const Float_t kconv=10000; // um->cm
03898a57 169 // the +0.5 means that an # and time bin # should start from 0 !!!
b0f5e3fc 170
b0f5e3fc 171 Int_t na = fNanodes/2;
03898a57 172 Float_t driftpath=(timebin+0.5)*fTimeStep*fDriftSpeed;
b0f5e3fc 173 if (anode >= na) x=(fDx-driftpath)/kconv;
174 else x = -(fDx-driftpath)/kconv;
175 if (anode >= na) anode-=na;
03898a57 176 z=((anode+0.5)*fPitch-fDz/2)/kconv;
b0f5e3fc 177
178}
2a4239d3 179//----------------------------------------------------------------------
55d2c544 180void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z) const{
e8189707 181 // Get anode and time bucket as floats - numbering from 0
182
183 // expects x, z in cm
184
185 const Float_t kconv=10000; // cm->um
186
2a4239d3 187 Float_t x0=x;
2a4239d3 188 Int_t na = fNanodes/2;
e8189707 189 Float_t driftpath=fDx-TMath::Abs(kconv*x);
03898a57 190 x=driftpath/fDriftSpeed/fTimeStep;
2a4239d3 191 z=kconv*z/fPitch + (float)na/2;
192 if (x0 < 0) x = -x;
e8189707 193
194}
2a4239d3 195//----------------------------------------------------------------------
55d2c544 196void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l) const {
b0f5e3fc 197 // returns local coordinates from global
198 if(!fGeom) {
55d2c544 199 Fatal("GetLocal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
314ba410 200 return;
b0f5e3fc 201 }
202 fGeom->GtoL(module,g,l);
203}
2a4239d3 204//----------------------------------------------------------------------
55d2c544 205void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g) const {
b0f5e3fc 206 // return global coordinates from local
207 if(!fGeom) {
55d2c544 208 Fatal("GetGlobal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
b0f5e3fc 209 }
210
211 fGeom->LtoG(module,l,g);
212
213}
f5d698b9 214//----------------------------------------------------------------------
db93954b 215void AliITSsegmentationSDD::Print(Option_t *opt) const {
f5d698b9 216 // Print SDD segmentation Parameters
217
218 cout << "**************************************************" << endl;
ac74f489 219 cout << " Silicon Drift Detector Segmentation Parameters " << opt << endl;
f5d698b9 220 cout << "**************************************************" << endl;
221 cout << "Number of Time Samples: " << fNsamples << endl;
222 cout << "Number of Anodes: " << fNanodes << endl;
223 cout << "Time Step (ns): " << fTimeStep << endl;
224 cout << "Anode Pitch (um): " << fPitch << endl;
55d2c544 225 cout << "Full Detector Width (x): " << fDx;
226 cout<<" (Default is "<<fgkDxDefault<<") "<<endl;
227 cout << "Half Detector Length (z): " << fDz;
228 cout<<" (Default is "<<fgkDzDefault<<") "<<endl;
229 cout << "Full Detector Thickness (y): " << fDy;
230 cout<<" (Default is "<<fgkDyDefault<<") "<<endl;
f5d698b9 231 cout << "**************************************************" << endl;
232
233}
55d2c544 234
235//----------------------------------------------------------------------
236void AliITSsegmentationSDD::PrintDefaultParameters() const {
237 // print SDD parameters defined as static const data members
238
239 cout << "**************************************************" << endl;
240 cout << " Silicon Drift Detector Segmentation Parameters " << endl;
241 cout << " Default values defined as static const data members"<< endl;
242 cout << " Actual values can be set with the relevant setters"<< endl;
243 cout << "**************************************************" << endl;
244 cout<<"fgkDxDefault = "<<fgkDxDefault<<endl;
245 cout<<"fgkDzDefault = "<<fgkDzDefault<<endl;
246 cout<<"fgkDyDefault = "<<fgkDyDefault<<endl;
247 cout<<"fgkPitchDefault = "<<fgkPitchDefault<<endl;
248 cout<<"fgkClockDefault = "<<fgkClockDefault<<endl;
249 cout<<"fgkHalfNanodesDefault = "<<fgkHalfNanodesDefault<<endl;
250 cout<<"fgkNsamplesDefault = "<<fgkNsamplesDefault<<endl;
251 cout << "**************************************************" << endl;
252
253}
5752a110 254
255//______________________________________________________________________
aacedc3e 256Bool_t AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,
257 Int_t &ix,Int_t &iz) const {
5752a110 258// Transformation from Geant detector centered local coordinates (cm) to
259// time bucket numbers ix and anode number iz.
260// Input:
261// Float_t x detector local coordinate x in cm with respect to the
262// center of the sensitive volume.
263// Float_t z detector local coordinate z in cm with respect to the
264// center of the sensitive volulme.
265// Output:
266// Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
267// Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
268// A value of -1 for ix or iz indecates that this point is outside of the
269// detector segmentation as defined.
270// This segmentation geometry can be discribed as the following:
271// {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
272// res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the
273// specific numbers will change not their layout.}
274//
275// 0 191 0
276// 0 |----------------------|---------------------| 256
277// | a time-bins | time-bins a |
278// | n | n |
279// | o |___________________o_|__> X
280// | d | d |
281// | e | e |
282// | s | s |
283// 255 |----------------------|---------------------| 511
284// |
285// V
286// Z
287 Float_t dx,dz,tb;
288 const Float_t kconv = 1.0E-04; // converts microns to cm.
289
290 ix = -1; // default values
291 iz = -1; // default values
292 dx = -kconv*Dx(); // lower left edge in cm.
293 dz = -0.5*kconv*Dz(); // lower left edge in cm.
507cf1a7 294 if(x<dx || x>-dx) {
295 Warning("LocalToDet","input argument %f out of range (%f, %f)",x,dx,-dx);
aacedc3e 296 return kFALSE; // outside of defined volume.
507cf1a7 297 }
298 if(z<dz || z>-dz) {
299 Warning("LocalToDet","input argument %f out of range (%f, %f)",z,dz,-dz);
aacedc3e 300 return kFALSE; // outside of defined volume.
507cf1a7 301 }
03898a57 302 tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
5752a110 303 if(x>0) dx = -(dx + x)/tb; // distance from + side in time bin units
304 else dx = (x - dx)/tb; // distance from - side in time bin units
305 dz = (z - dz)/(kconv*fPitch); // distance in z in anode pitch units
306 ix = (Int_t) dx; // time bin
307 iz = (Int_t) dz; // anode
308 if(x>0) iz += Npz()/2; // if x>0 then + side anodes values.
aacedc3e 309 return kTRUE; // Found ix and iz, return.
5752a110 310}
311//______________________________________________________________________
55d2c544 312void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
5752a110 313{
314// Transformation from Detector time bucket and anode coordiantes to Geant
315// detector centerd local coordinates (cm).
316// Input:
317// Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
318// Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
319// Output:
320// Float_t x detector local coordinate x in cm with respect to the
321// center of the sensitive volume.
322// Float_t z detector local coordinate z in cm with respect to the
323// center of the sensitive volulme.
324// If ix and or iz is outside of the segmentation range a value of -Dx()
325// or -0.5*Dz() is returned.
326// This segmentation geometry can be discribed as the following:
327// {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
328// res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the
329// specific numbers will change not their layout.}
330//
331// 0 191 0
332// 0 |----------------------|---------------------| 256
333// | a time-bins | time-bins a |
334// | n | n |
335// | o |___________________o_|__> X
336// | d | d |
337// | e | e |
338// | s | s |
339// 255 |----------------------|---------------------| 511
340// |
341// V
342// Z
343 Int_t i,j;
344 Float_t tb;
345 const Float_t kconv = 1.0E-04; // converts microns to cm.
346
347 if(iz>=Npz()/2) x = kconv*Dx(); // default value for +x side.
348 else x = -kconv*Dx(); // default value for -x side.
349 z = -0.5*kconv*Dz(); // default value.
507cf1a7 350 if(ix<0 || ix>=Npx()) {
351 Warning("DetToLocal","input argument %d out of range (0, %d)",ix,Npx());
352 return; // outside of detector
353 }
354 if(iz<0 || iz>=Npz()) {
355 Warning("DetToLocal","input argument %d out of range (0, %d)",iz,Npz());
356 return; // outside of detctor
357 }
03898a57 358 tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
5752a110 359 if(iz>=Npz()/2) tb *= -1.0; // for +x side decrement frmo Dx().
360 for(i=0;i<ix;i++) x += tb; // sum up to cell ix-1
361 x += 0.5*tb; // add 1/2 of cell ix for center location.
362 if(iz>=Npz()/2) iz -=Npz()/2;// If +x side don't count anodes from -x side.
363 for(j=0;j<iz;j++) z += kconv*fPitch; // sum up cell iz-1
364 z += 0.5*kconv*fPitch; // add 1/2 of cell iz for center location.
365 return; // Found x and z, return.
366}