1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
15 #include <Riostream.h>
17 #include <TGeoManager.h>
18 #include <TGeoVolume.h>
20 #include "AliITSsegmentationSDD.h"
21 #include "AliITSgeomSDD.h"
22 #include "AliITSresponseSDD.h"
24 /////////////////////////////////////////////////////////////////////////////
25 // Segmentation class for drift detectors //
27 // microcables microcables //
33 // 0 |----------------------|---------------------| 511 //
34 // | time-bins | time-bins | //
37 // X <_|_o____________________|___________________o_|__ //
39 // | e LEFT SIDE | RIGHT SIDE e | //
40 // | s CHANNEL 0 | CHANNEL 1 s | //
41 // | Xlocal > 0 | Xlocal < 0 | //
42 // 255 |----------------------|---------------------| 256 //
47 /////////////////////////////////////////////////////////////////////////////
51 const Float_t AliITSsegmentationSDD::fgkDxDefault = 35085.;
52 const Float_t AliITSsegmentationSDD::fgkDzDefault = 75264.;
53 const Float_t AliITSsegmentationSDD::fgkDyDefault = 300.;
54 const Float_t AliITSsegmentationSDD::fgkPitchDefault = 294.;
55 const Float_t AliITSsegmentationSDD::fgkClockDefault = 40.;
56 const Int_t AliITSsegmentationSDD::fgkHalfNanodesDefault = 256;
57 const Int_t AliITSsegmentationSDD::fgkNsamplesDefault = 256;
58 const Int_t AliITSsegmentationSDD::fgkNchipsPerHybrid = 4;
59 const Int_t AliITSsegmentationSDD::fgkNanodesPerChip = 64;
60 const Float_t AliITSsegmentationSDD::fgkCm2Micron = 10000.;
61 const Float_t AliITSsegmentationSDD::fgkMicron2Cm = 1.0E-04;
62 ClassImp(AliITSsegmentationSDD)
63 //----------------------------------------------------------------------
64 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom):
75 //______________________________________________________________________
76 AliITSsegmentationSDD::AliITSsegmentationSDD(Option_t *opt) : AliITSsegmentation(),
83 // Default constructor
85 if(strstr(opt,"TGeo")){
87 AliError("Geometry is not initialized\n");
91 v = gGeoManager->GetVolume("ITSsddSensitivL3");
93 AliWarning("TGeo volume ITSsddSensitivL3 not found (hint: use v11Hybrid geometry)\n Using hardwired default values");
96 TGeoBBox *s=(TGeoBBox*)v->GetShape();
97 SetDetSize(s->GetDX()*10000.,s->GetDZ()*20000.,s->GetDY()*20000.);
102 //______________________________________________________________________
103 void AliITSsegmentationSDD::Copy(TObject &obj) const {
104 // protected method. copy this to obj
105 AliITSsegmentation::Copy(obj);
106 ((AliITSsegmentationSDD& ) obj).fNsamples = fNsamples;
107 ((AliITSsegmentationSDD& ) obj).fNanodes = fNanodes;
108 ((AliITSsegmentationSDD& ) obj).fPitch = fPitch;
109 ((AliITSsegmentationSDD& ) obj).fTimeStep = fTimeStep;
110 ((AliITSsegmentationSDD& ) obj).fDriftSpeed = fDriftSpeed;
111 ((AliITSsegmentationSDD& ) obj).fSetDriftSpeed = fSetDriftSpeed;
114 //______________________________________________________________________
115 AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(const AliITSsegmentationSDD &source){
117 if(this==&source) return *this;
122 //____________________________________________________________________________
123 AliITSsegmentationSDD::AliITSsegmentationSDD(const AliITSsegmentationSDD &source) :
124 AliITSsegmentation(source),
135 //----------------------------------------------------------------------
136 void AliITSsegmentationSDD::Init(){
137 // Standard initilisation routine
138 fDriftSpeed=AliITSresponseSDD::DefaultDriftSpeed();
140 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
141 SetPadSize(fgkPitchDefault,fgkClockDefault);
142 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
144 //----------------------------------------------------------------------
145 void AliITSsegmentationSDD::InitFromGeom(AliITSgeom *geom){
146 // Inizialization from geometry
149 AliFatal("Pointer to ITS geometry class (AliITSgeom) is null\n");
152 AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (geom->GetShape(3,1,1));
154 fDz = 2.*fgkCm2Micron*gsdd->GetDz();
155 fDx = fgkCm2Micron*gsdd->GetDx();
156 fDy = 2.*fgkCm2Micron*gsdd->GetDy();
160 //----------------------------------------------------------------------
161 void AliITSsegmentationSDD::
162 Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]) const {
163 // returns neighbours for use in Cluster Finder routines and the like
165 if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
166 if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
168 Xlist[0]=Xlist[1]=iX;
169 if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
171 if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
173 if(iZ) Zlist[0]=iZ-1;
175 if (iZ < fNsamples) Zlist[1]=iZ+1;
177 Zlist[2]=Zlist[3]=iZ;
179 //----------------------------------------------------------------------
180 Float_t AliITSsegmentationSDD::GetAnodeFromLocal(Float_t xloc,Float_t zloc) const {
181 // returns anode coordinate (as float) starting from local coordinates
182 Float_t xAnode=zloc*fgkCm2Micron/fPitch;
183 if(xloc>0){ // left side (anodes 0-255, anode 0 at zloc<0)
184 xAnode+=(Float_t)fNanodes/4;
185 }else{ // right side (anodes 256-511, anode 0 at zloc>0)
186 xAnode=3*fNanodes/4-xAnode;
191 //----------------------------------------------------------------------
192 Float_t AliITSsegmentationSDD::GetLocalZFromAnode(Int_t nAnode) const{
193 // returns local Z coordinate from anode number (integer)
194 Float_t zAnode=(Float_t)nAnode+0.5;
195 return GetLocalZFromAnode(zAnode);
198 //----------------------------------------------------------------------
199 Float_t AliITSsegmentationSDD::GetLocalZFromAnode(Float_t zAnode) const{
200 // returns local Z coordinate from anode number (float)
202 if(zAnode<fNanodes/2){ // left side
203 zloc=(zAnode*fPitch-fDz/2)*fgkMicron2Cm;
206 zloc=-(zAnode*fPitch-fDz/2)*fgkMicron2Cm;
210 //----------------------------------------------------------------------
211 Int_t AliITSsegmentationSDD::GetChipFromChannel(Int_t ix, Int_t iz) const {
212 // returns chip number (in range 0-7) starting from channel number
213 if(iz>=fNanodes || iz<0 || ix>fNsamples){
214 AliError("Bad cell number");
217 Int_t theChip=iz/fgkNanodesPerChip;
220 //----------------------------------------------------------------------
221 Int_t AliITSsegmentationSDD::GetChipFromLocal(Float_t xloc, Float_t zloc) const {
222 // returns chip number (in range 0-7) starting from local coordinates
223 Float_t detsize=fDz*fgkMicron2Cm;
224 Float_t chipsize=detsize/(Float_t)fgkNchipsPerHybrid;
226 if(zloc<-0.01 || zloc>detsize+0.01){ // 100 micron tolerance around edges
227 AliError("Z local value out of sensitive SDD area");
230 Int_t iChip=int(zloc/chipsize);
232 if(zloc>=detsize) iChip=fgkNchipsPerHybrid-1;
233 if(iChip>=fgkNchipsPerHybrid || iChip<0){
234 AliError(Form("Bad chip number %d",iChip));
237 Int_t iSide=GetSideFromLocalX(xloc);
238 if(iSide==1) iChip=fgkNchipsPerHybrid-iChip+3; // i.e. 7-iChip
241 //----------------------------------------------------------------------
242 void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
243 Int_t &timebin,Int_t &anode) const {
244 // Returns cell coordinates (time sample,anode)
245 // for given real local coordinates (x,z)
247 // expects x, z in cm
249 Float_t driftpath=fDx-TMath::Abs(x*fgkCm2Micron);
250 timebin=(Int_t)(driftpath/fDriftSpeed/fTimeStep);
251 anode=(Int_t)GetAnodeFromLocal(x,z);
254 AliWarning("Drift speed not set: timebin is dummy");
258 //----------------------------------------------------------------------
259 void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
260 Float_t &x ,Float_t &z) const{
261 // Transform from cell to real local coordinates
262 // returns x, z in cm
264 // the +0.5 means that an # and time bin # should start from 0 !!!
265 // the +0.5 means that an # and time bin # should start from 0 !!!
267 Float_t driftpath=GetDriftTimeFromTb(timebin)*fDriftSpeed;
268 if (anode < fNanodes/2){ // left side, positive x
269 x=(fDx-driftpath)*fgkMicron2Cm;
270 }else{ // right side, negative x
271 x = -(fDx-driftpath)*fgkMicron2Cm;
273 z=GetLocalZFromAnode(anode);
276 AliWarning("Drift speed not set: x coord. is dummy");
279 //----------------------------------------------------------------------
280 void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z) const{
281 // Get anode and time bucket as floats - numbering from 0
283 // expects x, z in cm
287 Float_t driftpath=fDx-TMath::Abs(fgkCm2Micron*xloc);
288 x=driftpath/fDriftSpeed/fTimeStep;
289 if (xloc < 0) x = -x;
290 z=GetAnodeFromLocal(xloc,zloc);
293 AliWarning("Drift speed not set: x coord. is dummy");
296 //----------------------------------------------------------------------
297 void AliITSsegmentationSDD::Print(Option_t *opt) const {
298 // Print SDD segmentation Parameters
300 cout << "**************************************************" << endl;
301 cout << " Silicon Drift Detector Segmentation Parameters " << opt << endl;
302 cout << "**************************************************" << endl;
303 cout << "Number of Time Samples: " << fNsamples << endl;
304 cout << "Number of Anodes: " << fNanodes << endl;
305 cout << "Time Step (ns): " << fTimeStep << endl;
306 cout << "Anode Pitch (um): " << fPitch << endl;
307 cout << "Full Detector Width (x): " << fDx;
308 cout<<" (Default is "<<fgkDxDefault<<") "<<endl;
309 cout << "Half Detector Length (z): " << fDz;
310 cout<<" (Default is "<<fgkDzDefault<<") "<<endl;
311 cout << "Full Detector Thickness (y): " << fDy;
312 cout<<" (Default is "<<fgkDyDefault<<") "<<endl;
313 cout << "**************************************************" << endl;
317 //----------------------------------------------------------------------
318 void AliITSsegmentationSDD::PrintDefaultParameters() const {
319 // print SDD parameters defined as static const data members
321 cout << "**************************************************" << endl;
322 cout << " Silicon Drift Detector Segmentation Parameters " << endl;
323 cout << " Default values defined as static const data members"<< endl;
324 cout << " Actual values can be set with the relevant setters"<< endl;
325 cout << "**************************************************" << endl;
326 cout<<"fgkDxDefault = "<<fgkDxDefault<<endl;
327 cout<<"fgkDzDefault = "<<fgkDzDefault<<endl;
328 cout<<"fgkDyDefault = "<<fgkDyDefault<<endl;
329 cout<<"fgkPitchDefault = "<<fgkPitchDefault<<endl;
330 cout<<"fgkClockDefault = "<<fgkClockDefault<<endl;
331 cout<<"fgkHalfNanodesDefault = "<<fgkHalfNanodesDefault<<endl;
332 cout<<"fgkNsamplesDefault = "<<fgkNsamplesDefault<<endl;
333 cout << "**************************************************" << endl;
337 //______________________________________________________________________
338 Bool_t AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,
339 Int_t &ix,Int_t &iz) const {
340 // Transformation from Geant detector centered local coordinates (cm) to
341 // time bucket numbers ix and anode number iz.
343 // Float_t x detector local coordinate x in cm with respect to the
344 // center of the sensitive volume.
345 // Float_t z detector local coordinate z in cm with respect to the
346 // center of the sensitive volulme.
348 // Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
349 // Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
350 // A value of -1 for ix or iz indecates that this point is outside of the
351 // detector segmentation as defined.
355 ix = -1; // default values
356 iz = -1; // default values
357 dx = -fgkMicron2Cm*Dx(); // lower left edge in cm.
358 dz = -0.5*fgkMicron2Cm*Dz(); // lower left edge in cm.
360 AliWarning(Form("Input argument %f out of range (%f, %f)",x,dx,-dx));
361 return kFALSE; // outside of defined volume.
364 AliWarning(Form("Input argument %f out of range (%f, %f)",z,dz,-dz));
365 return kFALSE; // outside of defined volume.
367 GetPadIxz(x,z,ix,iz);
370 AliWarning("Drift speed not set: timebin is dummy");
373 return kTRUE; // Found ix and iz, return.
375 //______________________________________________________________________
376 void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
378 // Transformation from Detector time bucket and anode coordiantes to Geant
379 // detector centerd local coordinates (cm).
381 // Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
382 // Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
384 // Float_t x detector local coordinate x in cm with respect to the
385 // center of the sensitive volume.
386 // Float_t z detector local coordinate z in cm with respect to the
387 // center of the sensitive volulme.
388 // If ix and or iz is outside of the segmentation range a value of -Dx()
389 // or -0.5*Dz() is returned.
393 if(ix<0 || ix>=Npx()) {
394 AliWarning(Form("Input argument %d out of range (0, %d)",ix,Npx()));
395 return; // outside of detector
397 if(iz<0 || iz>=Npz()) {
398 AliWarning(Form("Input argument %d out of range (0, %d)",iz,Npz()));
399 return; // outside of detctor
401 GetPadCxz(ix,iz,x,z);
404 AliWarning("Drift speed not set: x coord. is dummy");
406 return; // Found x and z, return.