]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliITSsegmentationSDD.cxx
1085bb9a3b18382e6be2904814f331b67623a7c1
[u/mrichter/AliRoot.git] / 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 <TF1.h>
17 #include <TMath.h>
18
19 #include "AliITSsegmentationSDD.h"
20 #include "AliITS.h"
21 #include "AliITSgeom.h"
22 #include "AliRun.h"
23 #include "AliITSresponse.h"
24
25 ClassImp(AliITSsegmentationSDD)
26 //----------------------------------------------------------------------
27 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom,
28                                              AliITSresponse *resp){
29   // constructor
30    fGeom=geom;
31    fResponse=resp;
32    fCorr=0;
33    SetDetSize();
34    SetPadSize();
35    SetNPads();
36
37 }
38 //______________________________________________________________________
39 AliITSsegmentationSDD::AliITSsegmentationSDD(){
40   // standard constructor
41    fGeom=0;
42    fResponse=0;  
43    fCorr=0;
44    SetDetSize();
45    SetPadSize();
46    SetNPads();
47
48 }
49 //______________________________________________________________________
50 AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(AliITSsegmentationSDD 
51                                                         &source){
52   // Operator =
53   if(this==&source) return *this;
54   this->fNsamples = source.fNsamples;
55   this->fNanodes  = source.fNanodes;
56   this->fPitch    = source.fPitch;
57   this->fTimeStep = source.fTimeStep;
58   this->fDx       = source.fDx;
59   this->fDz       = source.fDz;
60   this->fDy       = source.fDy;
61   this->fCorr     = new TF1(*(source.fCorr));
62   this->fGeom     = source.fGeom; // Just copy the pointer
63   this->fResponse = source.fResponse; //Just copy the pointer
64   return *this;
65 }
66 //______________________________________________________________________
67 AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSsegmentationSDD &source){
68   // Copy constructor
69    *this = source;
70 }
71 //----------------------------------------------------------------------
72 void AliITSsegmentationSDD::Init(){
73   // Standard initilisation routine
74
75    if(!fGeom) {
76      return;
77      //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
78    }
79    AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
80
81    const Float_t kconv=10000.;
82    fDz = 2.*kconv*gsdd->GetDz();
83    fDx = kconv*gsdd->GetDx();
84    fDy = 2.*kconv*gsdd->GetDy();
85 }
86
87 //----------------------------------------------------------------------
88 void AliITSsegmentationSDD::
89 Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]){
90   // returns neighbours for use in Cluster Finder routines and the like
91
92     if(iX >= fNanodes) printf("iX > fNanodes %d %d\n",iX,fNanodes);
93     if(iZ >= fNsamples) printf("iZ > fNsamples %d %d\n",iZ,fNsamples);
94     *Nlist=4;
95     Xlist[0]=Xlist[1]=iX;
96     if(iX && (iX != fNanodes/2)) Xlist[2]=iX-1;
97     else Xlist[2]=iX;
98     if ((iX !=fNanodes/2 -1) && (iX != fNanodes)) Xlist[3]=iX+1;
99     else Xlist[3]=iX;
100     if(iZ) Zlist[0]=iZ-1;
101     else Zlist[0]=iZ;
102     if (iZ < fNsamples) Zlist[1]=iZ+1;
103     else Zlist[1]=iZ;
104     Zlist[2]=Zlist[3]=iZ;
105 }
106 //----------------------------------------------------------------------
107 void AliITSsegmentationSDD::GetPadIxz(Float_t x,Float_t z,
108                                       Int_t &timebin,Int_t &anode){
109 // Returns cell coordinates (time sample,anode) for given real local
110 // coordinates (x,z)
111
112     // expects x, z in cm
113
114     const Float_t kconv=10000;  // cm->um
115
116     Float_t speed=fResponse->DriftSpeed();
117     Int_t na = fNanodes/2;
118     Float_t driftpath=fDx-TMath::Abs(kconv*x);
119     timebin=(Int_t)(driftpath/speed/fTimeStep);
120     anode=(Int_t)(kconv*z/fPitch) + na/2;
121     if (x > 0) anode += na;
122
123     timebin+=1;
124     anode+=1;
125
126 }
127 //----------------------------------------------------------------------
128 void AliITSsegmentationSDD::GetPadCxz(Int_t timebin,Int_t anode,
129                                       Float_t &x ,Float_t &z){
130     // Transform from cell to real local coordinates
131     // returns x, z in cm
132
133     const Float_t kconv=10000;  // um->cm
134
135     Float_t speed=fResponse->DriftSpeed();
136     Int_t na = fNanodes/2;
137     Float_t driftpath=(timebin+1)*fTimeStep*speed;
138     if (anode >= na) x=(fDx-driftpath)/kconv;
139     else x = -(fDx-driftpath)/kconv;
140     if (anode >= na) anode-=na;
141     z=((anode+1)*fPitch-fDz/2)/kconv;
142
143 }
144 //----------------------------------------------------------------------
145 void AliITSsegmentationSDD::GetPadTxz(Float_t &x,Float_t &z){
146     // Get anode and time bucket as floats - numbering from 0
147
148     // expects x, z in cm
149
150     const Float_t kconv=10000;  // cm->um
151
152     Float_t x0=x;
153     Float_t speed=fResponse->DriftSpeed();
154     Int_t na = fNanodes/2;
155     Float_t driftpath=fDx-TMath::Abs(kconv*x);
156     x=driftpath/speed/fTimeStep;
157     z=kconv*z/fPitch + (float)na/2;
158     if (x0 < 0) x = -x;
159
160 }
161 //----------------------------------------------------------------------
162 void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l){
163   // returns local coordinates from global
164     if(!fGeom) {
165         return;
166         //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
167     }
168     fGeom->GtoL(module,g,l);
169 }
170 //----------------------------------------------------------------------
171 void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g){
172   // return global coordinates from local
173     if(!fGeom) {
174         return;
175         //fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
176     }
177
178     fGeom->LtoG(module,l,g);
179
180 }