]>
Commit | Line | Data |
---|---|---|
1d9af2d5 | 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 | /* $Id$ */ | |
17 | ||
18 | #include <TGeoManager.h> | |
19 | #include <TGeoVolume.h> | |
20 | #include <TGeoTube.h> | |
21 | #include <TVector3.h> | |
22 | #include <TMath.h> | |
23 | #include "AliGeomManager.h" | |
24 | #include "AliITSsegmentationUpgrade.h" | |
25 | #include "AliLog.h" | |
26 | #include <TFile.h> | |
1d9af2d5 | 27 | ////////////////////////////////////////////////////// |
28 | // Segmentation class for // | |
29 | // ITS upgrade // | |
30 | // // | |
31 | ////////////////////////////////////////////////////// | |
32 | ||
33 | ClassImp(AliITSsegmentationUpgrade) | |
34 | ||
35 | //_____________________________________________________________________________ | |
36 | ||
0ac80088 | 37 | AliITSsegmentationUpgrade::AliITSsegmentationUpgrade(): |
38 | TObject(), | |
1d9af2d5 | 39 | fCellSizeX(0), |
40 | fCellSizeZ(0), | |
0ac80088 | 41 | fNSectors(0), |
1d9af2d5 | 42 | fMinRadius(0), |
43 | fMaxRadius(0), | |
44 | fHalfLength(0) | |
45 | { | |
46 | ||
7dc6449a | 47 | AliDebug(2,"Default constructor is called"); |
1d9af2d5 | 48 | // Default constructor |
49 | ||
50 | if(!gGeoManager) AliGeomManager::LoadGeometry("geometry.root"); | |
51 | TFile *f=TFile::Open("Segmentation.root"); | |
52 | TArrayD *x=0; | |
53 | TArrayD *z=0; | |
0ac80088 | 54 | TArrayD *nS=0; |
55 | ||
1d9af2d5 | 56 | if(!f){ |
7dc6449a | 57 | AliError("Segmentation not available"); |
58 | return; | |
1d9af2d5 | 59 | }else { |
1d9af2d5 | 60 | x=(TArrayD*)f->Get("CellSizeX"); |
61 | z=(TArrayD*)f->Get("CellSizeZ"); | |
0ac80088 | 62 | nS=(TArrayD*)f->Get("nSectors"); |
1d9af2d5 | 63 | } |
64 | f->Close(); | |
65 | ||
66 | Int_t i=0; | |
6ea6235b | 67 | while(gGeoManager->GetVolume(Form("LayerSilicon%i",i))){ |
68 | TGeoVolume *vol = gGeoManager->GetVolume(Form("LayerSilicon%i",i)); | |
1d9af2d5 | 69 | if(!vol) { |
6ea6235b | 70 | AliInfo(Form("the volume %s has not been found... exiting!",Form("LayerSilicon%i",i))); |
1d9af2d5 | 71 | return; |
72 | } | |
0ac80088 | 73 | |
1d9af2d5 | 74 | TGeoTube *shape = (TGeoTube*)vol->GetShape(); |
75 | if(!shape) { | |
76 | AliInfo(Form("the volume %s has not shape defined... exiting!",vol->GetName())); | |
77 | return; | |
78 | } | |
0ac80088 | 79 | // AliInfo(Form(" volume index %i ", i)); |
1d9af2d5 | 80 | // setting the geometry parameters (needed for trasformations Global-Local) |
1d9af2d5 | 81 | fMaxRadius.Set(i+1); fMaxRadius.AddAt(shape->GetRmax(),i); |
82 | fMinRadius.Set(i+1); fMinRadius.AddAt(shape->GetRmin(),i); | |
83 | fHalfLength.Set(i+1); fHalfLength.AddAt(shape->GetDz(),i); | |
84 | fCellSizeX.Set(i+1); | |
85 | fCellSizeZ.Set(i+1); | |
86 | fCellSizeX.AddAt(x->At(i),i); | |
87 | fCellSizeZ.AddAt(z->At(i),i); | |
1d9af2d5 | 88 | i++; |
89 | } | |
0ac80088 | 90 | fNSectors = (Int_t)(nS->At(0)); |
91 | ||
1d9af2d5 | 92 | } |
1d9af2d5 | 93 | //_______________________________________________________________ |
0ac80088 | 94 | AliITSsegmentationUpgrade::AliITSsegmentationUpgrade(TArrayD radii, TArrayD widths, TArrayD Length): |
95 | TObject(), | |
1d9af2d5 | 96 | fCellSizeX(0), |
97 | fCellSizeZ(0), | |
0ac80088 | 98 | fNSectors(110), |
1d9af2d5 | 99 | fMinRadius(0), |
100 | fMaxRadius(0), | |
101 | fHalfLength(0) | |
102 | { | |
103 | for(Int_t i=0; i<radii.GetSize();i++){ | |
104 | fMaxRadius.Set(i+1); | |
105 | fMaxRadius.AddAt(radii.At(i)+widths.At(i),i); | |
106 | fMinRadius.Set(i+1); | |
107 | fMinRadius.AddAt(radii.At(i),i); | |
108 | fHalfLength.Set(i+1); | |
109 | fHalfLength.AddAt(Length.At(i),i); | |
110 | } | |
111 | } | |
112 | //_____________________________________________________________________________ | |
113 | void AliITSsegmentationUpgrade::SetSegmentation(Int_t ilayer, Double_t xsize, Double_t zsize){ | |
114 | ||
115 | // x/z size in microns | |
116 | if(fCellSizeX.GetSize()<ilayer+1) fCellSizeX.Set(ilayer+1); | |
117 | if(fCellSizeZ.GetSize()<ilayer+1) fCellSizeZ.Set(ilayer+1); | |
118 | AliDebug(10,Form("xsize %f zsize %f ilayer %i", xsize,zsize,ilayer)); | |
119 | fCellSizeX.AddAt(xsize,ilayer); | |
120 | fCellSizeZ.AddAt(zsize,ilayer); | |
121 | AliDebug(10,Form("fCellsizeX %f fCellSizeZ %f", fCellSizeX.At(ilayer), fCellSizeZ.At(ilayer))); | |
122 | } | |
123 | //_____________________________________________________________________________ | |
124 | void AliITSsegmentationUpgrade::SetFullSegmentation(TArrayD xsize, TArrayD zsize){ | |
125 | ||
126 | if(xsize.GetSize()!=zsize.GetSize())AliDebug(1,"Be Carefull Array Size Differ!!"); | |
127 | ||
128 | if(xsize.GetSize()!=fMaxRadius.GetSize())AliDebug(10,Form("Be Carefull Segmentation Array (%i) and Geometry Array Differ (%i)!!",xsize.GetSize(),fMaxRadius.GetSize())); | |
129 | ||
130 | for(Int_t ilayer=0; ilayer<fMaxRadius.GetSize(); ilayer++)SetSegmentation(ilayer, xsize.At(ilayer), zsize.At(ilayer)); | |
131 | } | |
132 | //_________________________________________________________________________________ | |
133 | void AliITSsegmentationUpgrade::GetSegmentation(Int_t ilayer, Double_t &xsize, Double_t &zsize ) const{ | |
134 | ||
135 | xsize = fCellSizeX.At(ilayer); | |
136 | zsize =fCellSizeZ.At(ilayer); | |
137 | } | |
138 | //_____________________________________________________________________________ | |
0ac80088 | 139 | Bool_t AliITSsegmentationUpgrade::GlobalToDet(Int_t ilayer, Double_t x,Double_t y,Double_t z,Double_t &xl,Double_t &zl) const{ |
1d9af2d5 | 140 | |
141 | ||
142 | if(TMath::Abs(z)>fHalfLength.At(ilayer)) return kFALSE; | |
143 | ||
144 | zl = z; | |
145 | Double_t xyproj= TMath::Sqrt(x*x+y*y); | |
146 | if(xyproj==0 || xyproj-0.001 > fMaxRadius.At(ilayer))return kFALSE; | |
147 | Double_t alpha= TMath::ATan2(y,x); | |
148 | if(x>0 && y<0)alpha=alpha+2.*(TMath::Pi()); | |
149 | if(x<0 && y<0)alpha=alpha+2.*(TMath::Pi()); | |
150 | xl = xyproj*alpha; | |
151 | ||
152 | return kTRUE; | |
153 | } | |
154 | //_____________________________________________________________________________ | |
155 | Bool_t AliITSsegmentationUpgrade::DetToGlobal(Int_t ilayer, Double_t xl,Double_t zl,Double_t &x,Double_t &y, Double_t &z) const { | |
156 | ||
157 | if(TMath::Abs(z)>fHalfLength.At(ilayer)) return kFALSE; | |
158 | z = zl; | |
159 | Double_t alpha = xl/fMaxRadius.At(ilayer); | |
160 | ||
161 | ||
162 | x = fMaxRadius.At(ilayer)*TMath::Cos(alpha); | |
163 | y = fMaxRadius.At(ilayer)*TMath::Sin(alpha); | |
164 | ||
1d9af2d5 | 165 | return kTRUE; |
166 | } | |
167 | //_______________________________________________________________________________ | |
168 | void AliITSsegmentationUpgrade::GetNpad(Int_t ilayer, Int_t &nx, Int_t &nz){ | |
169 | ||
170 | if(fCellSizeX.At(ilayer)==0)AliDebug(1,"Attention! Check your X Segmentation!!"); | |
171 | if(fCellSizeZ.At(ilayer)==0)AliDebug(1,"Attention! Check your Z Segmentation!!"); | |
172 | ||
173 | nx=(Int_t)(2.*TMath::Pi()*fMaxRadius.At(ilayer)/fCellSizeX.At(ilayer)); | |
174 | nz=(Int_t)(2.*fHalfLength.At(ilayer)/fCellSizeZ.At(ilayer)); | |
175 | ||
176 | } | |
177 | //________________________________________________________________________________ | |
9d092b87 | 178 | Int_t AliITSsegmentationUpgrade::GetNLayers(){ |
1d9af2d5 | 179 | |
180 | if(!gGeoManager) TGeoManager::Import("geometry.root"); | |
181 | ||
182 | Int_t nlay=0; | |
183 | ||
184 | for(Int_t ivol=0; ivol<gGeoManager->GetListOfVolumes()->GetEntries();ivol++){ | |
185 | TString volname = gGeoManager->GetListOfVolumes()->At(ivol)->GetName(); | |
186 | if(!volname.Contains("Silicon")) continue; | |
187 | ||
188 | nlay++; | |
189 | ||
190 | } | |
191 | ||
192 | return nlay; | |
193 | ||
194 | ||
195 | ||
196 | ||
197 | } | |
0ac80088 | 198 | //__________________________________________________________________________________ |
199 | Bool_t AliITSsegmentationUpgrade::DetToGlobal(Int_t ilayer, Int_t module, Double_t xl,Double_t zl,Double_t &x,Double_t &y, Double_t &z) const { | |
200 | if(module<0){ DetToGlobal(ilayer,xl,zl, x, y, z); | |
201 | return kTRUE; | |
202 | } | |
203 | ||
204 | if(TMath::Abs(z)>fHalfLength.At(ilayer)) return kFALSE; | |
205 | z = zl; | |
206 | Double_t alpha = (xl+module*(fMaxRadius.At(ilayer)*((TMath::Pi()*2)/fNSectors)))/fMaxRadius.At(ilayer); | |
207 | ||
208 | ||
209 | x = fMaxRadius.At(ilayer)*TMath::Cos(alpha); | |
210 | y = fMaxRadius.At(ilayer)*TMath::Sin(alpha); | |
211 | ||
212 | return kTRUE; | |
213 | } | |
214 | //_______________________________________________________________________________________________ | |
215 | Bool_t AliITSsegmentationUpgrade::GlobalToDet(Int_t ilayer, Double_t x,Double_t y,Double_t z,Double_t &xl,Double_t &zl,Int_t &module) const { | |
216 | if(module<0){ | |
217 | GlobalToDet(ilayer,x,y,z, xl, zl); | |
218 | return kTRUE; | |
219 | } | |
220 | ||
221 | if(TMath::Abs(z)>fHalfLength.At(ilayer)) return kFALSE; | |
222 | ||
223 | zl = z; | |
224 | ||
225 | Double_t xyproj= TMath::Sqrt(x*x+y*y); | |
226 | if(xyproj==0 || xyproj-0.001 > fMaxRadius.At(ilayer)){ | |
227 | return kFALSE; | |
228 | } | |
229 | Double_t alpha= TMath::ATan2(y,x); | |
230 | if(x>0 && y<0)alpha=alpha+2.*(TMath::Pi()); | |
231 | if(x<0 && y<0)alpha=alpha+2.*(TMath::Pi()); | |
232 | ||
233 | module = (Int_t)(alpha*(fNSectors/(TMath::Pi()*2))); | |
234 | Double_t alphaSect= module*((TMath::Pi()*2)/fNSectors); | |
235 | xl = xyproj*(alpha-alphaSect);//with respect the module | |
236 | //AliInfo(Form(" globtodet con modulo x,y,z = %f, %f, %f, alpha %f module %i alpha del modulo %f xlocal %f xlocal rispettp al modulo %f ", x,y,z,alpha,module, alphaSect, xyproj*alpha, xl)); | |
237 | return kTRUE; | |
238 | } | |
239 | //____________________________________________________________________________________________________ | |
240 | Bool_t AliITSsegmentationUpgrade::DetToPixID(Double_t xl, Double_t zl,Int_t layer, Int_t &nx, Int_t &nz) const { | |
241 | ||
242 | if(xl>fMaxRadius.At(layer)*(TMath::Pi()*2/fNSectors))return kFALSE; | |
243 | if(TMath::Abs(zl)>fHalfLength.At(layer)) return kFALSE; | |
244 | ||
245 | nx=(Int_t)(xl/fCellSizeX.At(layer)); | |
246 | //printf(" half %f \n ", fHalfLength.At(layer)); | |
247 | nz=(Int_t)((zl+fHalfLength.At(layer))/fCellSizeZ.At(layer)); | |
248 | return kTRUE; | |
249 | } | |
250 | //_________________________________________________________________________________________________________ | |
251 | Bool_t AliITSsegmentationUpgrade::DetToTrack2(Int_t layer,Int_t module, Double_t xl,Double_t zl, Double_t &ytr, Double_t &ztr)const { | |
252 | //sistema di tracciamento la x=0, y è la rphi rispetto al centro del modulo | |
253 | //sistema locale è la y=0 x è rphi rispetto all'inizio del modulo | |
254 | ||
255 | //voglio andare dalle locali alle tracciamento | |
256 | Double_t x=0.; | |
257 | Double_t y=0.; | |
258 | Double_t z=0.; | |
259 | // printf( " det to track xl %f zl %f \n ", xl, zl); | |
260 | ztr = zl; | |
261 | Bool_t ch=kFALSE; | |
262 | ch=DetToGlobal(layer,module,xl,zl,x,y,z); | |
263 | Double_t radius =fMaxRadius.At(layer); | |
264 | Double_t phiGrad; | |
265 | phiGrad=TMath::ATan2(y,x);//cluster phi angle (rad) | |
266 | if (phiGrad<0) phiGrad+=TMath::TwoPi();//from 0 to 360 | |
267 | else if (phiGrad>=TMath::TwoPi()) phiGrad-=TMath::TwoPi();// | |
268 | ||
269 | Double_t alpha= (module*(((TMath::Pi()*2)/fNSectors))+(((TMath::Pi()*2)/fNSectors)/2));//angle at the center of the ladder (rad) | |
270 | ||
271 | Double_t phiTrk= (phiGrad-alpha);// cluster angle in the rotated system (rad) | |
272 | ||
273 | ytr=radius*phiTrk; // tracking system coordinate: r*phi | |
274 | // AliInfo(Form( " det : x %f | track y %f, zeta %f ", xl, ytr,ztr)); | |
275 | return kTRUE; | |
276 | } | |
277 | //__________________________________________ | |
278 | Bool_t AliITSsegmentationUpgrade::DetToTrack(Int_t layer,Int_t module, Double_t xl,Double_t zl, Double_t &ytr, Double_t &ztr)const { | |
279 | //sistema di tracciamento la x=0, y è la rphi rispetto al centro del modulo | |
280 | //sistema locale è la y=0 x è rphi rispetto all'inizio del modulo | |
281 | ||
282 | //voglio andare dalle locali alle tracciamento | |
283 | ztr = zl; | |
284 | Double_t radius =fMaxRadius.At(layer); | |
285 | Double_t alphaloc = module*(TMath::Pi()*2)/fNSectors; //alpha di riferimento per il modulo locale in rad | |
286 | Double_t xlrif = alphaloc*radius;//xlocale di riferimento per questo modulo | |
287 | ||
288 | Double_t xlvera = xlrif + xl; // x locale vera rispetto a tutto il cilindro, per sapere a che angolo sto effettivamente | |
289 | ||
290 | Double_t alphaGlob = xlvera/radius; //in rad | |
291 | ||
292 | //da alpha vera posso ottenereinfo di tracciamento | |
293 | ||
294 | Double_t alpha_track= (module*(((TMath::Pi()*2)/fNSectors))+(((TMath::Pi()*2)/fNSectors)/2));//angle at the center of the ladder (rad) | |
295 | ||
296 | Double_t phiTrk= (alphaGlob-alpha_track);// cluster angle in the rotated system (rad) | |
297 | ||
298 | ytr=radius*phiTrk; // tracking system coordinate: r*phi | |
299 | // AliInfo(Form( " det : x %f | track y %f, zeta %f ", xl, ytr,ztr)); | |
300 | return kTRUE; | |
301 | } | |
302 | //_______________________ | |
303 | Int_t AliITSsegmentationUpgrade::GetModule(Double_t x,Double_t y)const{ | |
304 | ||
305 | ||
306 | Double_t alpha= TMath::ATan2(y,x); | |
307 | if(x>0 && y<0)alpha=alpha+2.*(TMath::Pi()); | |
308 | if(x<0 && y<0)alpha=alpha+2.*(TMath::Pi()); | |
309 | ||
310 | return GetModule(alpha); | |
311 | } | |
312 | //_______________________ | |
313 | Int_t AliITSsegmentationUpgrade::GetModule(Double_t phi) const { | |
314 | // | |
315 | // sector corresponding to that phi [0,2Pi] | |
316 | // | |
317 | ||
318 | Int_t module = -1; | |
319 | if(phi<0 || phi > TMath::TwoPi()) { | |
320 | AliError(Form("Phi is not within the acceptable range [0,2Pi] %f ",phi)); | |
321 | } | |
322 | else { | |
323 | module = (Int_t) (phi*((Double_t)fNSectors/(TMath::TwoPi()))); | |
324 | } | |
325 | ||
326 | return module; | |
327 | ||
328 | } | |
329 | //_______________________ | |
330 | Double_t AliITSsegmentationUpgrade::GetAlpha(Int_t module)const{ | |
331 | // | |
332 | // angle of the sector center | |
333 | // | |
334 | Double_t angle = TMath::DegToRad()*(360./fNSectors); | |
335 | return module*angle+0.5*angle; | |
336 | ||
337 | } | |
338 | ||
339 | ||
1d9af2d5 | 340 |