]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSsegmentationSDD.cxx
Added AliMpStringObjMap, AliMpDEIterator, AliMpDEManager, AliMpSegFactory
[u/mrichter/AliRoot.git] / ITS / AliITSsegmentationSDD.cxx
index 12779f136304737373648862fe224f740e8f0cce..34d559f86ddf298f5da535e2ac1d1292f6ffabac 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-#include <iostream.h>
-#include <iomanip.h>
-#include <fstream.h>
-#include <TF1.h>
+#include <Riostream.h>
 #include <TMath.h>
 
 #include "AliITSsegmentationSDD.h"
-#include "AliITS.h"
+// #include "AliITS.h"
 #include "AliITSgeom.h"
 #include "AliITSgeomSDD.h"
-#include "AliRun.h"
 #include "AliITSresponse.h"
 
+//////////////////////////////////////////////////////
+// Segmentation class for                           //
+// drift detectors                                  //
+//                                                  //
+//////////////////////////////////////////////////////
+
+const Float_t AliITSsegmentationSDD::fgkDxDefault = 35085.;
+const Float_t AliITSsegmentationSDD::fgkDzDefault = 75264.;
+const Float_t AliITSsegmentationSDD::fgkDyDefault = 300.;
+const Float_t AliITSsegmentationSDD::fgkPitchDefault = 294.;
+const Float_t AliITSsegmentationSDD::fgkClockDefault = 40.;
+const Int_t AliITSsegmentationSDD::fgkHalfNanodesDefault = 256; 
+const Int_t AliITSsegmentationSDD::fgkNsamplesDefault = 256;
+
 ClassImp(AliITSsegmentationSDD)
 //----------------------------------------------------------------------
 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom,
@@ -33,29 +43,54 @@ AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom,
    fGeom=geom;
    fDriftSpeed=resp->DriftSpeed();
    fCorr=0;
-   SetDetSize();
-   SetPadSize();
-   SetNPads();
+   SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
+   SetPadSize(fgkPitchDefault,fgkClockDefault);
+   SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
 
 }
 //______________________________________________________________________
-AliITSsegmentationSDD::AliITSsegmentationSDD(){
-  // standard constructor
-   fGeom=0;
+AliITSsegmentationSDD::AliITSsegmentationSDD() : AliITSsegmentation(){
+  // Default constructor
    fDriftSpeed=0;  
-   fCorr=0;
-   SetDetSize();
-   SetPadSize();
-   SetNPads();
+   SetDetSize(fgkDxDefault,fgkDzDefault,fgkDyDefault);
+   SetPadSize(fgkPitchDefault,fgkClockDefault);
+   SetNPads(fgkHalfNanodesDefault,fgkNsamplesDefault);
+
+}
+
+//______________________________________________________________________
+void AliITSsegmentationSDD::Copy(TObject &obj) const {
+  // protected method. copy this to obj
+  AliITSsegmentation::Copy(obj);
+  ((AliITSsegmentationSDD& ) obj).fNsamples = fNsamples;
+  ((AliITSsegmentationSDD& ) obj).fNanodes = fNanodes;
+  ((AliITSsegmentationSDD& ) obj).fPitch = fPitch;
+  ((AliITSsegmentationSDD& ) obj).fTimeStep = fTimeStep;
+  ((AliITSsegmentationSDD& ) obj).fDriftSpeed = fDriftSpeed;
+}
+
+//______________________________________________________________________
+AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(const AliITSsegmentationSDD &source){
+   // = operator
+   if(this==&source) return *this;
+   source.Copy(*this);
+   return *this;
+}
 
+//____________________________________________________________________________
+AliITSsegmentationSDD::AliITSsegmentationSDD(const AliITSsegmentationSDD &source) :
+    AliITSsegmentation(source){
+  // copy constructor
+  source.Copy(*this);
 }
+
 //----------------------------------------------------------------------
 void AliITSsegmentationSDD::Init(){
   // Standard initilisation routine
 
    if(!fGeom) {
+     Fatal("Init","the pointer to the ITS geometry class (AliITSgeom) is null\n");
      return;
-     //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
    }
    AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
 
@@ -67,7 +102,7 @@ void AliITSsegmentationSDD::Init(){
 
 //----------------------------------------------------------------------
 void AliITSsegmentationSDD::
-Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]){
+Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]) const {
   // returns neighbours for use in Cluster Finder routines and the like
 
     if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
@@ -86,7 +121,7 @@ Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]){
 }
 //----------------------------------------------------------------------
 void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
-                                     Int_t &timebin,Int_t &anode){
+                                     Int_t &timebin,Int_t &anode) const {
 // Returns cell coordinates (time sample,anode) incremented by 1 !!!!! 
 // for given real local coordinates (x,z)
 
@@ -94,10 +129,12 @@ void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
 
     const Float_t kconv=10000;  // cm->um
 
+    x *= kconv; // Convert to microns
+    z *= kconv; // Convert to microns
     Int_t na = fNanodes/2;
-    Float_t driftpath=fDx-TMath::Abs(kconv*x);
+    Float_t driftpath=fDx-TMath::Abs(x);
     timebin=(Int_t)(driftpath/fDriftSpeed/fTimeStep);
-    anode=(Int_t)(kconv*z/fPitch + na/2));
+    anode=(Int_t)(z/fPitch + na/2);
     if (x > 0) anode += na;
 
     timebin+=1;
@@ -106,7 +143,7 @@ void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
 }
 //----------------------------------------------------------------------
 void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
-                                     Float_t &x ,Float_t &z){
+                                     Float_t &x ,Float_t &z) const{
     // Transform from cell to real local coordinates
     // returns x, z in cm
 
@@ -123,7 +160,7 @@ void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
 
 }
 //----------------------------------------------------------------------
-void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z){
+void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z) const{
     // Get anode and time bucket as floats - numbering from 0
 
     // expects x, z in cm
@@ -139,20 +176,19 @@ void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z){
 
 }
 //----------------------------------------------------------------------
-void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l){
+void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l) const {
   // returns local coordinates from global
     if(!fGeom) {
+      Fatal("GetLocal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
         return;
-        //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
     }
     fGeom->GtoL(module,g,l);
 }
 //----------------------------------------------------------------------
-void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g){
+void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g) const {
   // return global coordinates from local
     if(!fGeom) {
-        return;
-        //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
+      Fatal("GetGlobal","the pointer to the ITS geometry class (AliITSgeom) is null\n");
     }
 
     fGeom->LtoG(module,l,g);
@@ -163,22 +199,45 @@ void AliITSsegmentationSDD::Print(Option_t *opt) const {
   // Print SDD segmentation Parameters
 
    cout << "**************************************************" << endl;
-   cout << "  Silicon Drift Detector Segmentation Parameters  " << endl;
+   cout << "  Silicon Drift Detector Segmentation Parameters  " << opt << endl;
    cout << "**************************************************" << endl;
    cout << "Number of Time Samples: " << fNsamples << endl;
    cout << "Number of Anodes: " << fNanodes << endl;
    cout << "Time Step (ns): " << fTimeStep << endl;
    cout << "Anode Pitch (um): " << fPitch << endl;
-   cout << "Full Detector Width     (x): " << fDx << endl;
-   cout << "Half Detector Length    (z): " << fDz << endl;
-   cout << "Full Detector Thickness (y): " << fDy << endl;
+   cout << "Full Detector Width     (x): " << fDx;
+   cout<<" (Default is "<<fgkDxDefault<<") "<<endl;
+   cout << "Half Detector Length    (z): " << fDz;
+   cout<<" (Default is "<<fgkDzDefault<<") "<<endl;
+   cout << "Full Detector Thickness (y): " << fDy;
+   cout<<" (Default is "<<fgkDyDefault<<") "<<endl;
    cout << "**************************************************" << endl;
 
 }
-//______________________________________________________________________
+
+//----------------------------------------------------------------------
+void AliITSsegmentationSDD::PrintDefaultParameters() const {
+  // print SDD parameters defined as static const data members
+
+  cout << "**************************************************" << endl;
+  cout << "  Silicon Drift Detector Segmentation Parameters  " << endl;
+  cout << " Default values defined as static const data members"<< endl;
+  cout << " Actual values can be set with the relevant setters"<< endl; 
+  cout << "**************************************************" << endl;
+  cout<<"fgkDxDefault = "<<fgkDxDefault<<endl;
+  cout<<"fgkDzDefault = "<<fgkDzDefault<<endl;
+  cout<<"fgkDyDefault = "<<fgkDyDefault<<endl;
+  cout<<"fgkPitchDefault = "<<fgkPitchDefault<<endl;
+  cout<<"fgkClockDefault = "<<fgkClockDefault<<endl;
+  cout<<"fgkHalfNanodesDefault = "<<fgkHalfNanodesDefault<<endl;
+  cout<<"fgkNsamplesDefault = "<<fgkNsamplesDefault<<endl;
+  cout << "**************************************************" << endl;
+
+}
 
 //______________________________________________________________________
-void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
+Bool_t AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,
+                                         Int_t &ix,Int_t &iz) const {
 // Transformation from Geant detector centered local coordinates (cm) to
 // time bucket numbers ix and anode number iz.
 // Input:
@@ -215,8 +274,14 @@ void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
     iz = -1; // default values
     dx = -kconv*Dx(); // lower left edge in cm.
     dz = -0.5*kconv*Dz(); // lower left edge in cm.
-    if(x<dx || x>-dx) return; // outside of defined volume.
-    if(z<dz || z>-dz) return; // outside of defined volume.
+    if(x<dx || x>-dx) {
+      Warning("LocalToDet","input argument %f out of range (%f, %f)",x,dx,-dx);
+      return kFALSE; // outside of defined volume.
+    }
+    if(z<dz || z>-dz) {
+      Warning("LocalToDet","input argument %f out of range (%f, %f)",z,dz,-dz);
+      return kFALSE; // outside of defined volume.
+    }
     tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
     if(x>0) dx = -(dx + x)/tb; // distance from + side in time bin units
     else dx = (x - dx)/tb;     // distance from - side in time bin units
@@ -224,10 +289,10 @@ void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
     ix = (Int_t) dx;   // time bin
     iz = (Int_t) dz;   // anode
     if(x>0) iz += Npz()/2; // if x>0 then + side anodes values.
-    return; // Found ix and iz, return.
+    return kTRUE; // Found ix and iz, return.
 }
 //______________________________________________________________________
-void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z)
+void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
 {
 // Transformation from Detector time bucket and anode coordiantes to Geant 
 // detector centerd local coordinates (cm).
@@ -265,8 +330,14 @@ void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z)
     if(iz>=Npz()/2) x = kconv*Dx(); // default value for +x side.
     else x = -kconv*Dx(); // default value for -x side.
     z = -0.5*kconv*Dz(); // default value.
-    if(ix<0 || ix>=Npx()) return; // outside of detector
-    if(iz<0 || iz>=Npz()) return; // outside of detctor
+    if(ix<0 || ix>=Npx()) {
+      Warning("DetToLocal","input argument %d out of range (0, %d)",ix,Npx());
+      return; // outside of detector
+    }
+    if(iz<0 || iz>=Npz()) {
+      Warning("DetToLocal","input argument %d out of range (0, %d)",iz,Npz());
+     return; // outside of detctor
+    }
     tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin.
     if(iz>=Npz()/2) tb *= -1.0; // for +x side decrement frmo Dx().
     for(i=0;i<ix;i++) x += tb; // sum up to cell ix-1