]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSsegmentationSDD.cxx
Temporarily change the number of charge injection points to
[u/mrichter/AliRoot.git] / ITS / AliITSsegmentationSDD.cxx
index 456dd0ddc6fd6a58f6be4599e3477947126ab2d5..1ac4229d2a83c8f35a1e30f83604f514bf4458c7 100644 (file)
  **************************************************************************/
 #include <Riostream.h>
 #include <TMath.h>
-
+#include <TGeoManager.h>
+#include <TGeoVolume.h>
+#include <TGeoBBox.h>
 #include "AliITSsegmentationSDD.h"
-#include "AliITSgeomSDD.h"
-#include "AliITSresponseSDD.h"
+#include "AliITSDriftSpeedSDD.h"
 
 /////////////////////////////////////////////////////////////////////////////
 // Segmentation class for drift detectors                                  //
@@ -44,6 +45,8 @@
 //                               Z                                         //
 /////////////////////////////////////////////////////////////////////////////
 
+/* $Id$ */
+
 const Float_t AliITSsegmentationSDD::fgkDxDefault = 35085.;
 const Float_t AliITSsegmentationSDD::fgkDzDefault = 75264.;
 const Float_t AliITSsegmentationSDD::fgkDyDefault = 300.;
@@ -51,27 +54,17 @@ const Float_t AliITSsegmentationSDD::fgkPitchDefault = 294.;
 const Float_t AliITSsegmentationSDD::fgkClockDefault = 40.;
 const Int_t AliITSsegmentationSDD::fgkHalfNanodesDefault = 256; 
 const Int_t AliITSsegmentationSDD::fgkNsamplesDefault = 256;
+const Int_t AliITSsegmentationSDD::fgkNchipsPerHybrid = 4;
+const Int_t AliITSsegmentationSDD::fgkNanodesPerChip = 64;
 const Float_t AliITSsegmentationSDD::fgkCm2Micron = 10000.;
 const Float_t AliITSsegmentationSDD::fgkMicron2Cm = 1.0E-04;
+
+using std::endl;
+using std::cout;
 ClassImp(AliITSsegmentationSDD)
-//----------------------------------------------------------------------
-AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom):
-AliITSsegmentation(geom),
-fNsamples(0),
-fNanodes(0),
-fPitch(0),
-fTimeStep(0),
-fDriftSpeed(0),
-fSetDriftSpeed(0){
-  // constructor
-   fDriftSpeed=AliITSresponseSDD::DefaultDriftSpeed();
-   fCorr=0;
-   SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
-   SetPadSize(fgkPitchDefault,fgkClockDefault);
-   SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
-}
+
 //______________________________________________________________________
-AliITSsegmentationSDD::AliITSsegmentationSDD() : AliITSsegmentation(),
+AliITSsegmentationSDD::AliITSsegmentationSDD(Option_t *opt) : AliITSsegmentation(),
 fNsamples(0),
 fNanodes(0),
 fPitch(0),
@@ -79,10 +72,22 @@ fTimeStep(0),
 fDriftSpeed(0),
 fSetDriftSpeed(0){
   // Default constructor
-   fDriftSpeed=0;  
-   SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
-   SetPadSize(fgkPitchDefault,fgkClockDefault);
-   SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
+  Init();
+  if(strstr(opt,"TGeo")){
+    if(!gGeoManager){
+      AliError("Geometry is not initialized\n");
+      return;
+    }
+    TGeoVolume *v=NULL;
+    v = gGeoManager->GetVolume("ITSsddSensitivL3");
+    if(!v){
+      AliWarning("TGeo volume ITSsddSensitivL3 not found (hint: use v11Hybrid geometry)\n Using hardwired default values"); 
+    }
+    else {
+      TGeoBBox *s=(TGeoBBox*)v->GetShape();
+      SetDetSize(s->GetDX()*10000.,s->GetDZ()*20000.,s->GetDY()*20000.);
+    }
+  }
 }
 
 //______________________________________________________________________
@@ -120,17 +125,12 @@ fSetDriftSpeed(0){
 
 //----------------------------------------------------------------------
 void AliITSsegmentationSDD::Init(){
-  // Standard initilisation routine
-
-   if(!fGeom) {
-     AliFatal("Pointer to ITS geometry class (AliITSgeom) is null\n");
-     return;
-   }
-   AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
-
-   fDz = 2.*fgkCm2Micron*gsdd->GetDz();
-   fDx = fgkCm2Micron*gsdd->GetDx();
-   fDy = 2.*fgkCm2Micron*gsdd->GetDy();
+// Standard initilisation routine
+   fDriftSpeed=AliITSDriftSpeedSDD::DefaultDriftSpeed();
+   fCorr=0;
+   SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
+   SetPadSize(fgkPitchDefault,fgkClockDefault);
+   SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
 }
 
 //----------------------------------------------------------------------
@@ -184,6 +184,81 @@ Float_t AliITSsegmentationSDD::GetLocalZFromAnode(Float_t zAnode) const{
   return zloc;
 }
 //----------------------------------------------------------------------
+Int_t AliITSsegmentationSDD::GetChipFromChannel(Int_t ix, Int_t iz) const {
+  // returns chip number (in range 0-7) starting from channel number
+  if(iz>=fNanodes  || iz<0 || ix>fNsamples){
+    AliError("Bad cell number");
+    return -1;
+  }
+  Int_t theChip=iz/fgkNanodesPerChip;
+  return theChip;
+}
+//----------------------------------------------------------------------
+Int_t AliITSsegmentationSDD::GetChipFromLocal(Float_t xloc, Float_t zloc) const {  
+  // returns chip number (in range 0-7) starting from local coordinates
+  Float_t detsize=fDz*fgkMicron2Cm;
+  Float_t chipsize=detsize/(Float_t)fgkNchipsPerHybrid;
+  zloc+=detsize/2.;
+  if(zloc<-0.01 || zloc>detsize+0.01){ // 100 micron tolerance around edges
+    AliError("Z local value out of sensitive SDD area");
+    return -1;
+  }
+  Int_t iChip=int(zloc/chipsize);
+  if(zloc<0.) iChip=0;  
+  if(zloc>=detsize) iChip=fgkNchipsPerHybrid-1;
+  if(iChip>=fgkNchipsPerHybrid || iChip<0){ 
+    AliError(Form("Bad chip number %d",iChip));
+    return -1;
+  }
+  Int_t iSide=GetSideFromLocalX(xloc);
+  if(iSide==1) iChip=fgkNchipsPerHybrid-iChip+3;   // i.e. 7-iChip
+  return iChip;
+}
+//----------------------------------------------------------------------
+Int_t AliITSsegmentationSDD::GetChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, Float_t xmin, Float_t xmax) const {
+  // returns the numbers of the chips that read channels in a given region
+  // of the module defined in local coordinates by zmin-zmax, xmin-max
+
+  Int_t nChipInW = 0;
+  Float_t zminDet=-fDz*fgkMicron2Cm/2.;
+  Float_t zmaxDet=fDz*fgkMicron2Cm/2.;
+  if(zmin<zminDet) zmin=zminDet;
+  if(zmax>zmaxDet) zmax=zmaxDet;
+  Float_t xminDet=-fDx*fgkMicron2Cm;
+  Float_t xmaxDet=fDx*fgkMicron2Cm;
+  if(xmin<xminDet) xmin=xminDet;
+  if(xmax>xmaxDet) xmax=xmaxDet;
+  Int_t n1=GetChipFromLocal(xmin,zmin);
+  array[nChipInW]=n1;
+  nChipInW++;
+  Int_t n2=GetChipFromLocal(xmin,zmax);
+  if(n2!=n1){
+    Int_t imin=TMath::Min(n1,n2);
+    Int_t imax=TMath::Max(n1,n2);
+    for(Int_t ichip=imin; ichip<=imax; ichip++){
+      if(ichip==n1) continue;
+      array[nChipInW]=ichip;
+      nChipInW++;    
+    }
+  }
+  Int_t n3=GetChipFromLocal(xmax,zmin);
+  if(n3!=n1){
+    array[nChipInW]=n3;
+    nChipInW++;
+    Int_t n4=GetChipFromLocal(xmax,zmax);
+    if(n4!=n3){
+      Int_t imin=TMath::Min(n3,n4);
+      Int_t imax=TMath::Max(n3,n4);
+      for(Int_t ichip=imin; ichip<=imax; ichip++){
+       if(ichip==n3) continue;
+       array[nChipInW]=ichip;
+       nChipInW++;    
+      }
+    }
+  }
+  return nChipInW;
+}
+//----------------------------------------------------------------------
 void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
                                      Int_t &timebin,Int_t &anode) const {
 // Returns cell coordinates (time sample,anode)