]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSsegmentationSSD.cxx
Nano change. Warning message corrected.
[u/mrichter/AliRoot.git] / ITS / AliITSsegmentationSSD.cxx
index 6dba076dadee1be13b91c4f2c2acbe58f1ea9f80..e572d3a10a06b2b145a091b5ae97f1c68b07c3f0 100644 (file)
@@ -17,6 +17,9 @@
 
 #include <Riostream.h>
 #include <TMath.h>
+#include <TGeoManager.h>
+#include <TGeoVolume.h>
+#include <TGeoBBox.h>
 #include "AliITSsegmentationSSD.h"
 
 //////////////////////////////////////////////////////
@@ -29,23 +32,59 @@ const Float_t AliITSsegmentationSSD::fgkDzDefault = 40000.;
 const Float_t AliITSsegmentationSSD::fgkDyDefault = 300.;
 const Float_t AliITSsegmentationSSD::fgkPitchDefault = 95.;
 const Int_t AliITSsegmentationSSD::fgkNstripsDefault = 768;
+const Int_t AliITSsegmentationSSD::fgkNchipsPerSide = 6;
+const Int_t AliITSsegmentationSSD::fgkNstripsPerChip = 128;
 
 ClassImp(AliITSsegmentationSSD)
-AliITSsegmentationSSD::AliITSsegmentationSSD(): AliITSsegmentation(){
+AliITSsegmentationSSD::AliITSsegmentationSSD(Option_t *opt): AliITSsegmentation(),
+fNstrips(0),
+fStereoP(0),
+fStereoN(0),
+fPitch(0),
+fStereoPl5(0),
+fStereoNl5(0),
+fStereoPl6(0),
+fStereoNl6(0),
+fLayer(0){
     // default constructor
+    SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
+    SetPadSize(fgkPitchDefault,0.);
+    SetNPads(fgkNstripsDefault,0);
+    SetAngles();
+  if(strstr(opt,"TGeo")){
+    if(!gGeoManager){
+      AliError("Geometry is not initialized\n");
+      return;
+    }
+    TGeoVolume *v=NULL;
+    v = gGeoManager->GetVolume("ITSssdSensitivL5");
+    if(!v){
+      AliWarning("TGeo volumeITSssdSensitivL5  not found (hint: use v11Hybrid geometry)\n Using hardwired default values"); 
+    }
+    else {
+      TGeoBBox *s=(TGeoBBox*)v->GetShape();
+      SetDetSize(s->GetDX()*20000.,s->GetDZ()*20000.,s->GetDY()*20000.);
+    }
+  }
 }
 //----------------------------------------------------------------------
-AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom){
+AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom):
+AliITSsegmentation(geom),
+fNstrips(0),
+fStereoP(0),
+fStereoN(0),
+fPitch(0),
+fStereoPl5(0),
+fStereoNl5(0),
+fStereoPl6(0),
+fStereoNl6(0),
+fLayer(0){
     // constuctor
-    fGeom = geom;
-    fCorr = 0;
     SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
     SetPadSize(fgkPitchDefault,0.);
     SetNPads(fgkNstripsDefault,0);
     SetAngles();
-    fLayer = 0;
 }
-
 //______________________________________________________________________
 void AliITSsegmentationSSD::Copy(TObject &obj) const {
   // protected method. copy this to obj
@@ -75,7 +114,16 @@ AliITSsegmentationSSD& AliITSsegmentationSSD::operator=(
 }
 //______________________________________________________________________
 AliITSsegmentationSSD::AliITSsegmentationSSD(const AliITSsegmentationSSD &source):
-    AliITSsegmentation(source){
+    AliITSsegmentation(source),
+fNstrips(0),
+fStereoP(0),
+fStereoN(0),
+fPitch(0),
+fStereoPl5(0),
+fStereoNl5(0),
+fStereoPl6(0),
+fStereoNl6(0),
+fLayer(0){
     // copy constructor
   source.Copy(*this);
 }
@@ -104,7 +152,7 @@ void AliITSsegmentationSSD::SetLayer(Int_t l){
   //set fLayer data member (only 5 or 6 are allowed)
     if (l==5) fLayer =5;
     if (l==6) fLayer =6;
-    if((l!=5) && (l!=6))Error("SetLayer","Layer can be 5 or 6, not %d",l);
+    if((l!=5) && (l!=6))AliError(Form("Layer can be 5 or 6, not %d",l));
 }
 //----------------------------------------------------------------------
 void AliITSsegmentationSSD::GetPadTxz(Float_t &x,Float_t &z) const{
@@ -235,19 +283,24 @@ Bool_t AliITSsegmentationSSD::LocalToDet(Float_t x,Float_t z,
                      |00/
                      |0/
     */
-    const Double_t kconst = 1.0E-04; // convert microns to cm.
-
-    x /= kconst;  // convert to microns
-    z /= kconst;  // convert to microns
-    this->GetPadTxz(x,z);
-
-    // first for P side
-    iP = (Int_t) x;
-    if(iP<0 || iP>=fNstrips) iP=-1; // strip number must be in range.
-    // Now for N side)
-    iN = (Int_t) z;
-    if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range.
-    return kTRUE;
+  Float_t dx,dz;
+  const Double_t kconst = 1.0E-04; // convert microns to cm.
+  dx = 0.5*kconst*Dx();
+  dz = 0.5*kconst*Dz();
+  if( (x<-dx) || (x>dx) ) { iP=-1; return kTRUE; } // outside x range.
+  if( (z<-dz) || (z>dz) ) { iN=-1; return kTRUE; } // outside z range.
+  
+  x /= kconst;  // convert to microns
+  z /= kconst;  // convert to microns
+  this->GetPadTxz(x,z);
+  
+  // first for P side
+  iP = (Int_t) x;
+  if(iP<0 || iP>=fNstrips) iP=-1; // strip number must be in range.
+  // Now for N side)
+  iN = (Int_t) z;
+  if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range.
+  return kTRUE;
 }
 //----------------------------------------------------------------------
 void AliITSsegmentationSSD::DetToLocal(Int_t ix,Int_t iPN,
@@ -383,6 +436,43 @@ Bool_t AliITSsegmentationSSD::GetCrossing(Int_t iP,Int_t iN,
     return kTRUE;
 }
 
+//----------------------------------------------------------------------
+Int_t AliITSsegmentationSSD::GetChipFromChannel(Int_t ix, Int_t iz) const {
+  // returns chip number (in range 0-11) starting from channel number
+
+  if( (iz>=fgkNstripsDefault) || (iz<0) || (ix<0) || (ix>1) ) {
+    AliError("Bad cell number");
+    return -1;
+  }
+  
+  if(ix==1) iz = 1535-iz;
+  Int_t theChip =iz/fgkNstripsPerChip;
+  return theChip;
+
+}
+//----------------------------------------------------------------------
+Int_t AliITSsegmentationSSD::GetChipFromLocal(Float_t xloc, Float_t zloc) const
+{
+  // returns chip numbers starting from local coordinates
+  // The two Nside chip number and Pside chip number are 
+  // coded as chip=Nchip*10+Pchip
+
+  Int_t iP=0;
+  Int_t iN=0;
+  if (!LocalToDet(xloc,zloc,iP,iN) || 
+      (iP<0) || (iP>=fNstrips) || (iN<0) || (iN>=fNstrips) ) {
+    AliWarning("Bad local coordinate");
+    return -1;
+  }
+
+  Int_t iChip = GetChipFromChannel(0,iP);
+  iChip += 10*GetChipFromChannel(1,iN); // add Nside
+
+  return iChip;
+
+}
+//
+
 //----------------------------------------------------------------------
 void AliITSsegmentationSSD::PrintDefaultParameters() const {
 // Print default values for parameters.