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 "AliITSDriftSpeedSDD.h"
23 /////////////////////////////////////////////////////////////////////////////
24 // Segmentation class for drift detectors //
26 // microcables microcables //
32 // 0 |----------------------|---------------------| 511 //
33 // | time-bins | time-bins | //
36 // X <_|_o____________________|___________________o_|__ //
38 // | e LEFT SIDE | RIGHT SIDE e | //
39 // | s CHANNEL 0 | CHANNEL 1 s | //
40 // | Xlocal > 0 | Xlocal < 0 | //
41 // 255 |----------------------|---------------------| 256 //
46 /////////////////////////////////////////////////////////////////////////////
50 const Float_t AliITSsegmentationSDD::fgkDxDefault = 35085.;
51 const Float_t AliITSsegmentationSDD::fgkDzDefault = 75264.;
52 const Float_t AliITSsegmentationSDD::fgkDyDefault = 300.;
53 const Float_t AliITSsegmentationSDD::fgkPitchDefault = 294.;
54 const Float_t AliITSsegmentationSDD::fgkClockDefault = 40.;
55 const Int_t AliITSsegmentationSDD::fgkHalfNanodesDefault = 256;
56 const Int_t AliITSsegmentationSDD::fgkNsamplesDefault = 256;
57 const Int_t AliITSsegmentationSDD::fgkNchipsPerHybrid = 4;
58 const Int_t AliITSsegmentationSDD::fgkNanodesPerChip = 64;
59 const Float_t AliITSsegmentationSDD::fgkCm2Micron = 10000.;
60 const Float_t AliITSsegmentationSDD::fgkMicron2Cm = 1.0E-04;
61 ClassImp(AliITSsegmentationSDD)
63 //______________________________________________________________________
64 AliITSsegmentationSDD::AliITSsegmentationSDD(Option_t *opt) : AliITSsegmentation(),
71 // Default constructor
73 if(strstr(opt,"TGeo")){
75 AliError("Geometry is not initialized\n");
79 v = gGeoManager->GetVolume("ITSsddSensitivL3");
81 AliWarning("TGeo volume ITSsddSensitivL3 not found (hint: use v11Hybrid geometry)\n Using hardwired default values");
84 TGeoBBox *s=(TGeoBBox*)v->GetShape();
85 SetDetSize(s->GetDX()*10000.,s->GetDZ()*20000.,s->GetDY()*20000.);
90 //______________________________________________________________________
91 void AliITSsegmentationSDD::Copy(TObject &obj) const {
92 // protected method. copy this to obj
93 AliITSsegmentation::Copy(obj);
94 ((AliITSsegmentationSDD& ) obj).fNsamples = fNsamples;
95 ((AliITSsegmentationSDD& ) obj).fNanodes = fNanodes;
96 ((AliITSsegmentationSDD& ) obj).fPitch = fPitch;
97 ((AliITSsegmentationSDD& ) obj).fTimeStep = fTimeStep;
98 ((AliITSsegmentationSDD& ) obj).fDriftSpeed = fDriftSpeed;
99 ((AliITSsegmentationSDD& ) obj).fSetDriftSpeed = fSetDriftSpeed;
102 //______________________________________________________________________
103 AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(const AliITSsegmentationSDD &source){
105 if(this==&source) return *this;
110 //____________________________________________________________________________
111 AliITSsegmentationSDD::AliITSsegmentationSDD(const AliITSsegmentationSDD &source) :
112 AliITSsegmentation(source),
123 //----------------------------------------------------------------------
124 void AliITSsegmentationSDD::Init(){
125 // Standard initilisation routine
126 fDriftSpeed=AliITSDriftSpeedSDD::DefaultDriftSpeed();
128 SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
129 SetPadSize(fgkPitchDefault,fgkClockDefault);
130 SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
133 //----------------------------------------------------------------------
134 void AliITSsegmentationSDD::
135 Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]) const {
136 // returns neighbours for use in Cluster Finder routines and the like
138 if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
139 if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
141 Xlist[0]=Xlist[1]=iX;
142 if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
144 if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
146 if(iZ) Zlist[0]=iZ-1;
148 if (iZ < fNsamples) Zlist[1]=iZ+1;
150 Zlist[2]=Zlist[3]=iZ;
152 //----------------------------------------------------------------------
153 Float_t AliITSsegmentationSDD::GetAnodeFromLocal(Float_t xloc,Float_t zloc) const {
154 // returns anode coordinate (as float) starting from local coordinates
155 Float_t xAnode=zloc*fgkCm2Micron/fPitch;
156 if(xloc>0){ // left side (anodes 0-255, anode 0 at zloc<0)
157 xAnode+=(Float_t)fNanodes/4;
158 }else{ // right side (anodes 256-511, anode 0 at zloc>0)
159 xAnode=3*fNanodes/4-xAnode;
164 //----------------------------------------------------------------------
165 Float_t AliITSsegmentationSDD::GetLocalZFromAnode(Int_t nAnode) const{
166 // returns local Z coordinate from anode number (integer)
167 Float_t zAnode=(Float_t)nAnode+0.5;
168 return GetLocalZFromAnode(zAnode);
171 //----------------------------------------------------------------------
172 Float_t AliITSsegmentationSDD::GetLocalZFromAnode(Float_t zAnode) const{
173 // returns local Z coordinate from anode number (float)
175 if(zAnode<fNanodes/2){ // left side
176 zloc=(zAnode*fPitch-fDz/2)*fgkMicron2Cm;
179 zloc=-(zAnode*fPitch-fDz/2)*fgkMicron2Cm;
183 //----------------------------------------------------------------------
184 Int_t AliITSsegmentationSDD::GetChipFromChannel(Int_t ix, Int_t iz) const {
185 // returns chip number (in range 0-7) starting from channel number
186 if(iz>=fNanodes || iz<0 || ix>fNsamples){
187 AliError("Bad cell number");
190 Int_t theChip=iz/fgkNanodesPerChip;
193 //----------------------------------------------------------------------
194 Int_t AliITSsegmentationSDD::GetChipFromLocal(Float_t xloc, Float_t zloc) const {
195 // returns chip number (in range 0-7) starting from local coordinates
196 Float_t detsize=fDz*fgkMicron2Cm;
197 Float_t chipsize=detsize/(Float_t)fgkNchipsPerHybrid;
199 if(zloc<-0.01 || zloc>detsize+0.01){ // 100 micron tolerance around edges
200 AliError("Z local value out of sensitive SDD area");
203 Int_t iChip=int(zloc/chipsize);
205 if(zloc>=detsize) iChip=fgkNchipsPerHybrid-1;
206 if(iChip>=fgkNchipsPerHybrid || iChip<0){
207 AliError(Form("Bad chip number %d",iChip));
210 Int_t iSide=GetSideFromLocalX(xloc);
211 if(iSide==1) iChip=fgkNchipsPerHybrid-iChip+3; // i.e. 7-iChip
214 //----------------------------------------------------------------------
215 Int_t AliITSsegmentationSDD::GetChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, Float_t xmin, Float_t xmax) const {
216 // returns the numbers of the chips that read channels in a given region
217 // of the module defined in local coordinates by zmin-zmax, xmin-max
220 Float_t zminDet=-fDz*fgkMicron2Cm/2.;
221 Float_t zmaxDet=fDz*fgkMicron2Cm/2.;
222 if(zmin<zminDet) zmin=zminDet;
223 if(zmax>zmaxDet) zmax=zmaxDet;
224 Float_t xminDet=-fDx*fgkMicron2Cm;
225 Float_t xmaxDet=fDx*fgkMicron2Cm;
226 if(xmin<xminDet) xmin=xminDet;
227 if(xmax>xmaxDet) xmax=xmaxDet;
228 Int_t n1=GetChipFromLocal(xmin,zmin);
231 Int_t n2=GetChipFromLocal(xmin,zmax);
233 Int_t imin=TMath::Min(n1,n2);
234 Int_t imax=TMath::Max(n1,n2);
235 for(Int_t ichip=imin; ichip<=imax; ichip++){
236 if(ichip==n1) continue;
237 array[nChipInW]=ichip;
241 Int_t n3=GetChipFromLocal(xmax,zmin);
245 Int_t n4=GetChipFromLocal(xmax,zmax);
247 Int_t imin=TMath::Min(n3,n4);
248 Int_t imax=TMath::Max(n3,n4);
249 for(Int_t ichip=imin; ichip<=imax; ichip++){
250 if(ichip==n3) continue;
251 array[nChipInW]=ichip;
258 //----------------------------------------------------------------------
259 void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
260 Int_t &timebin,Int_t &anode) const {
261 // Returns cell coordinates (time sample,anode)
262 // for given real local coordinates (x,z)
264 // expects x, z in cm
266 Float_t driftpath=fDx-TMath::Abs(x*fgkCm2Micron);
267 timebin=(Int_t)(driftpath/fDriftSpeed/fTimeStep);
268 anode=(Int_t)GetAnodeFromLocal(x,z);
271 AliWarning("Drift speed not set: timebin is dummy");
275 //----------------------------------------------------------------------
276 void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
277 Float_t &x ,Float_t &z) const{
278 // Transform from cell to real local coordinates
279 // returns x, z in cm
281 // the +0.5 means that an # and time bin # should start from 0 !!!
282 // the +0.5 means that an # and time bin # should start from 0 !!!
284 Float_t driftpath=GetDriftTimeFromTb(timebin)*fDriftSpeed;
285 if (anode < fNanodes/2){ // left side, positive x
286 x=(fDx-driftpath)*fgkMicron2Cm;
287 }else{ // right side, negative x
288 x = -(fDx-driftpath)*fgkMicron2Cm;
290 z=GetLocalZFromAnode(anode);
293 AliWarning("Drift speed not set: x coord. is dummy");
296 //----------------------------------------------------------------------
297 void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z) const{
298 // Get anode and time bucket as floats - numbering from 0
300 // expects x, z in cm
304 Float_t driftpath=fDx-TMath::Abs(fgkCm2Micron*xloc);
305 x=driftpath/fDriftSpeed/fTimeStep;
306 if (xloc < 0) x = -x;
307 z=GetAnodeFromLocal(xloc,zloc);
310 AliWarning("Drift speed not set: x coord. is dummy");
313 //----------------------------------------------------------------------
314 void AliITSsegmentationSDD::Print(Option_t *opt) const {
315 // Print SDD segmentation Parameters
317 cout << "**************************************************" << endl;
318 cout << " Silicon Drift Detector Segmentation Parameters " << opt << endl;
319 cout << "**************************************************" << endl;
320 cout << "Number of Time Samples: " << fNsamples << endl;
321 cout << "Number of Anodes: " << fNanodes << endl;
322 cout << "Time Step (ns): " << fTimeStep << endl;
323 cout << "Anode Pitch (um): " << fPitch << endl;
324 cout << "Full Detector Width (x): " << fDx;
325 cout<<" (Default is "<<fgkDxDefault<<") "<<endl;
326 cout << "Half Detector Length (z): " << fDz;
327 cout<<" (Default is "<<fgkDzDefault<<") "<<endl;
328 cout << "Full Detector Thickness (y): " << fDy;
329 cout<<" (Default is "<<fgkDyDefault<<") "<<endl;
330 cout << "**************************************************" << endl;
334 //----------------------------------------------------------------------
335 void AliITSsegmentationSDD::PrintDefaultParameters() const {
336 // print SDD parameters defined as static const data members
338 cout << "**************************************************" << endl;
339 cout << " Silicon Drift Detector Segmentation Parameters " << endl;
340 cout << " Default values defined as static const data members"<< endl;
341 cout << " Actual values can be set with the relevant setters"<< endl;
342 cout << "**************************************************" << endl;
343 cout<<"fgkDxDefault = "<<fgkDxDefault<<endl;
344 cout<<"fgkDzDefault = "<<fgkDzDefault<<endl;
345 cout<<"fgkDyDefault = "<<fgkDyDefault<<endl;
346 cout<<"fgkPitchDefault = "<<fgkPitchDefault<<endl;
347 cout<<"fgkClockDefault = "<<fgkClockDefault<<endl;
348 cout<<"fgkHalfNanodesDefault = "<<fgkHalfNanodesDefault<<endl;
349 cout<<"fgkNsamplesDefault = "<<fgkNsamplesDefault<<endl;
350 cout << "**************************************************" << endl;
354 //______________________________________________________________________
355 Bool_t AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,
356 Int_t &ix,Int_t &iz) const {
357 // Transformation from Geant detector centered local coordinates (cm) to
358 // time bucket numbers ix and anode number iz.
360 // Float_t x detector local coordinate x in cm with respect to the
361 // center of the sensitive volume.
362 // Float_t z detector local coordinate z in cm with respect to the
363 // center of the sensitive volulme.
365 // Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
366 // Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
367 // A value of -1 for ix or iz indecates that this point is outside of the
368 // detector segmentation as defined.
372 ix = -1; // default values
373 iz = -1; // default values
374 dx = -fgkMicron2Cm*Dx(); // lower left edge in cm.
375 dz = -0.5*fgkMicron2Cm*Dz(); // lower left edge in cm.
377 AliWarning(Form("Input argument %f out of range (%f, %f)",x,dx,-dx));
378 return kFALSE; // outside of defined volume.
381 AliWarning(Form("Input argument %f out of range (%f, %f)",z,dz,-dz));
382 return kFALSE; // outside of defined volume.
384 GetPadIxz(x,z,ix,iz);
387 AliWarning("Drift speed not set: timebin is dummy");
390 return kTRUE; // Found ix and iz, return.
392 //______________________________________________________________________
393 void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
395 // Transformation from Detector time bucket and anode coordiantes to Geant
396 // detector centerd local coordinates (cm).
398 // Int_t ix detector x time coordinate. Has the range 0<=ix<fNsamples.
399 // Int_t iz detector z anode coordinate. Has the range 0<=iz<fNandoes.
401 // Float_t x detector local coordinate x in cm with respect to the
402 // center of the sensitive volume.
403 // Float_t z detector local coordinate z in cm with respect to the
404 // center of the sensitive volulme.
405 // If ix and or iz is outside of the segmentation range a value of -Dx()
406 // or -0.5*Dz() is returned.
410 if(ix<0 || ix>=Npx()) {
411 AliWarning(Form("Input argument %d out of range (0, %d)",ix,Npx()));
412 return; // outside of detector
414 if(iz<0 || iz>=Npz()) {
415 AliWarning(Form("Input argument %d out of range (0, %d)",iz,Npz()));
416 return; // outside of detctor
418 GetPadCxz(ix,iz,x,z);
421 AliWarning("Drift speed not set: x coord. is dummy");
423 return; // Found x and z, return.