]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSsegmentationSDD.cxx
New ITS code for new structure and simulations.
[u/mrichter/AliRoot.git] / ITS / AliITSsegmentationSDD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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
16 #include <TMath.h>
17
18 #include "AliITSgeom.h"
19 #include "AliITSsegmentationSDD.h"
20 #include "AliITS.h"
21 #include "AliRun.h"
22
23 class AliITS;
24
25 ClassImp(AliITSsegmentationSDD)
26 //------------------------------
27 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom, AliITSresponse *resp){
28   // constructor
29    fGeom=geom;
30    fResponse=resp;
31    fCorr=0;
32    SetDetSize();
33    SetCellSize();
34    SetNCells();
35
36 }
37 //_____________________________________________________________________________
38 AliITSsegmentationSDD::AliITSsegmentationSDD(){
39    fGeom=0;
40    fResponse=0;  
41    fCorr=0;
42    SetDetSize();
43    SetCellSize();
44    SetNCells();
45
46 }
47 //_____________________________________________________________________________
48 AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(AliITSsegmentationSDD &source){
49   // Operator =
50   if(this==&source) return *this;
51   this->fNsamples = source.fNsamples;
52   this->fNanodes  = source.fNanodes;
53   this->fPitch    = source.fPitch;
54   this->fTimeStep = source.fTimeStep;
55   this->fDx       = source.fDx;
56   this->fDz       = source.fDz;
57   this->fDy       = source.fDy;
58   this->fCorr     = new TF1(*(source.fCorr));
59   this->fGeom     = source.fGeom; // Just copy the pointer
60   this->fResponse = source.fResponse; //Just copy the pointer
61   return *this;
62 }
63 //___________________________________________________________________________
64 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSsegmentationSDD &source){
65   // Copy constructor
66    *this = source;
67 }
68 //------------------------------
69 void AliITSsegmentationSDD::Init(){
70   // Standard initilisation routine
71
72    AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
73
74    const Float_t kconv=10000.;
75    fDz = 2.*kconv*gsdd->GetDz();
76    fDx = kconv*gsdd->GetDx();
77    fDy = 2.*kconv*gsdd->GetDy();
78 }
79
80 //------------------------------
81 void AliITSsegmentationSDD::
82 Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[4], Int_t Zlist[4]){
83   // returns neighbers for use in Cluster Finder routines and the like
84
85     *Nlist=4;
86     Xlist[0]=Xlist[1]=iX;
87     if(iX) Xlist[2]=iX-1;
88     else Xlist[2]=iX;
89     if (iX < fNanodes) Xlist[3]=iX+1;
90     else Xlist[3]=iX;
91     if(iZ) Zlist[0]=iZ-1;
92     else Zlist[0]=iZ;
93     if (iZ < fNsamples) Zlist[1]=iZ+1;
94     else Zlist[1]=iZ;
95     Zlist[2]=Zlist[3]=iZ;
96
97 }
98 //------------------------------
99 void AliITSsegmentationSDD::GetCellIxz(Float_t &x,Float_t &z,Int_t &timebin,Int_t &anode){
100 //  Returns cell coordinates (time sample,anode) for given real local coordinates (x,z)
101
102     // expects x, z in cm
103
104     const Float_t kconv=10000;  // cm->um
105
106     Float_t speed=fResponse->DriftSpeed();
107     Int_t na = fNanodes/2;
108     Float_t driftpath=fDx-TMath::Abs(kconv*x);
109     timebin=(Int_t)(driftpath/speed/fTimeStep);
110     anode=(Int_t)(kconv*z/fPitch + na/2);
111     if (x > 0) anode += na;
112
113     timebin+=1;
114     anode+=1;
115
116 }
117
118 //------------------------------
119 void AliITSsegmentationSDD::GetCellCxz(Int_t timebin,Int_t anode,Float_t &x ,Float_t &z){
120     // Transform from cell to real local coordinates
121   
122     // returns x, z in cm
123
124     const Float_t kconv=10000;  // um->cm
125
126     Float_t speed=fResponse->DriftSpeed();
127     Int_t na = fNanodes/2;
128     Float_t driftpath=(timebin+1)*fTimeStep*speed;
129     if (anode >= na) x=(fDx-driftpath)/kconv;
130     else x = -(fDx-driftpath)/kconv;
131     if (anode >= na) anode-=na;
132     z=((anode+1)*fPitch-fDz/2)/kconv;
133
134 }
135
136 //------------------------------
137 void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l){
138   // returns local coordinates from global
139     if(!fGeom) {
140         fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
141     }
142     fGeom->GtoL(module,g,l);
143 }
144 //------------------------------
145 void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g){
146   // return global coordinates from local
147     if(!fGeom) {
148         fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
149     }
150
151     fGeom->LtoG(module,l,g);
152
153 }