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