]>
Commit | Line | Data |
---|---|---|
70a0fabe | 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: AliPHOSGeometry.cxx 25590 2008-05-06 07:09:11Z prsnko $ */ | |
17 | ||
18 | //_________________________________________________________________________ | |
19 | // Geometry class for PHOS : singleton | |
20 | // PHOS consists of the electromagnetic calorimeter (EMCA) | |
21 | // and a charged particle veto either in the Subatech's version (PPSD) | |
22 | // or in the IHEP's one (CPV). | |
23 | // The EMCA/PPSD/CPV modules are parametrized so that any configuration | |
24 | // can be easily implemented | |
25 | // The title is used to identify the version of CPV used. | |
26 | // | |
27 | // -- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC "KI" & SUBATECH) | |
28 | ||
29 | // --- ROOT system --- | |
30 | ||
31 | #include "TVector3.h" | |
32 | #include "TParticle.h" | |
33 | #include <TGeoManager.h> | |
34 | #include <TGeoMatrix.h> | |
35 | ||
36 | // --- Standard library --- | |
37 | ||
38 | // --- AliRoot header files --- | |
39 | #include "AliPHOSEMCAGeometry.h" | |
40 | #include "AliPHOSCPVGeometry.h" | |
41 | #include "AliPHOSGeoUtils.h" | |
42 | ||
43 | ClassImp(AliPHOSGeoUtils) | |
44 | ||
45 | //____________________________________________________________________________ | |
46 | AliPHOSGeoUtils::AliPHOSGeoUtils(): | |
47 | fNModules(0),fNCristalsInModule(0),fNPhi(0),fNZ(0), | |
48 | fNumberOfCPVPadsPhi(0),fNumberOfCPVPadsZ(0), | |
49 | fNCellsXInStrip(0),fNCellsZInStrip(0),fNStripZ(0), | |
50 | fCrystalShift(0.),fCryCellShift(0.),fCellStep(0.), | |
51 | fPadSizePhi(0.),fPadSizeZ(0.),fCPVBoxSizeY(0.) | |
52 | ||
53 | { | |
54 | // default ctor | |
55 | // must be kept public for root persistency purposes, but should never be called by the outside world | |
56 | } | |
57 | ||
58 | //____________________________________________________________________________ | |
59 | AliPHOSGeoUtils::AliPHOSGeoUtils(const AliPHOSGeoUtils & rhs) | |
60 | : TNamed(rhs), | |
61 | fNModules(0),fNCristalsInModule(0),fNPhi(0),fNZ(0), | |
62 | fNumberOfCPVPadsPhi(0),fNumberOfCPVPadsZ(0), | |
63 | fNCellsXInStrip(0),fNCellsZInStrip(0),fNStripZ(0), | |
64 | fCrystalShift(0.),fCryCellShift(0.),fCellStep(0.), | |
65 | fPadSizePhi(0.),fPadSizeZ(0.),fCPVBoxSizeY(0.) | |
66 | { | |
67 | Fatal("cpy ctor", "not implemented") ; | |
68 | } | |
69 | ||
70 | //____________________________________________________________________________ | |
71 | AliPHOSGeoUtils::AliPHOSGeoUtils(const Text_t* name, const Text_t* title) | |
72 | : TNamed(name, title), | |
73 | fNModules(0),fNCristalsInModule(0),fNPhi(0),fNZ(0), | |
74 | fNumberOfCPVPadsPhi(0),fNumberOfCPVPadsZ(0), | |
75 | fNCellsXInStrip(0),fNCellsZInStrip(0),fNStripZ(0), | |
76 | fCrystalShift(0.),fCryCellShift(0.),fCellStep(0.), | |
77 | fPadSizePhi(0.),fPadSizeZ(0.),fCPVBoxSizeY(0.) | |
78 | { | |
79 | // ctor only for normal usage | |
80 | Init() ; | |
81 | } | |
82 | ||
83 | //____________________________________________________________________________ | |
84 | AliPHOSGeoUtils & AliPHOSGeoUtils::operator = (const AliPHOSGeoUtils & /*rvalue*/) { | |
85 | Init() ; | |
86 | return *this ; | |
87 | } | |
88 | ||
89 | //____________________________________________________________________________ | |
90 | AliPHOSGeoUtils::~AliPHOSGeoUtils(void) | |
91 | { | |
92 | // dtor | |
93 | } | |
94 | //____________________________________________________________________________ | |
95 | Bool_t AliPHOSGeoUtils::AbsToRelNumbering(Int_t absId, Int_t * relid) const | |
96 | { | |
97 | // Converts the absolute numbering into the following array | |
98 | // relid[0] = PHOS Module number 1:fNModules | |
99 | // relid[1] = 0 if PbW04 | |
100 | // = -1 if CPV | |
101 | // relid[2] = Row number inside a PHOS module | |
102 | // relid[3] = Column number inside a PHOS module | |
103 | ||
104 | Float_t id = absId ; | |
105 | ||
106 | Int_t phosmodulenumber = (Int_t)TMath:: Ceil( id / fNCristalsInModule ) ; | |
107 | ||
108 | if ( phosmodulenumber > fNModules ) { // it is a CPV pad | |
109 | ||
110 | id -= fNPhi * fNZ * fNModules ; | |
111 | Float_t nCPV = fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ ; | |
112 | relid[0] = (Int_t) TMath::Ceil( id / nCPV ) ; | |
113 | relid[1] = -1 ; | |
114 | id -= ( relid[0] - 1 ) * nCPV ; | |
115 | relid[2] = (Int_t) TMath::Ceil( id / fNumberOfCPVPadsZ ) ; | |
116 | relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * fNumberOfCPVPadsZ ) ; | |
117 | } | |
118 | else { // it is a PW04 crystal | |
119 | ||
120 | relid[0] = phosmodulenumber ; | |
121 | relid[1] = 0 ; | |
122 | id -= ( phosmodulenumber - 1 ) * fNPhi * fNZ ; | |
123 | relid[2] = (Int_t)TMath::Ceil( id / fNZ ) ; | |
124 | relid[3] = (Int_t)( id - ( relid[2] - 1 ) * fNZ ) ; | |
125 | } | |
126 | return kTRUE ; | |
127 | } | |
128 | //____________________________________________________________________________ | |
129 | Bool_t AliPHOSGeoUtils::RelToAbsNumbering(const Int_t * relid, Int_t & absId) const | |
130 | { | |
131 | // Converts the relative numbering into the absolute numbering | |
132 | // EMCA crystals: | |
133 | // absId = from 1 to fNModules * fNPhi * fNZ | |
134 | // CPV pad: | |
135 | // absId = from N(total PHOS crystals) + 1 | |
136 | // to NCPVModules * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ | |
137 | ||
138 | if ( relid[1] == 0 ) { // it is a Phos crystal | |
139 | absId = | |
140 | ( relid[0] - 1 ) * fNPhi * fNZ // the offset of PHOS modules | |
141 | + ( relid[2] - 1 ) * fNZ // the offset along phi | |
142 | + relid[3] ; // the offset along z | |
143 | } | |
144 | else { // it is a CPV pad | |
145 | absId = fNPhi * fNZ * fNModules // the offset to separate EMCA crystals from CPV pads | |
146 | + ( relid[0] - 1 ) * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ // the pads offset of PHOS modules | |
147 | + ( relid[2] - 1 ) * fNumberOfCPVPadsZ // the pads offset of a CPV row | |
148 | + relid[3] ; // the column number | |
149 | } | |
150 | ||
151 | return kTRUE ; | |
152 | } | |
153 | ||
154 | //____________________________________________________________________________ | |
155 | void AliPHOSGeoUtils::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) const | |
156 | { | |
157 | // Converts the relative numbering into the local PHOS-module (x, z) coordinates | |
158 | ||
159 | if (!gGeoManager){ | |
160 | printf("Geo manager not initialized\n"); | |
161 | abort() ; | |
162 | } | |
163 | //construct module name | |
164 | char path[100] ; | |
165 | if(relid[1]==0){ //this is PHOS | |
166 | ||
167 | Double_t pos[3]= {0.0,-fCryCellShift,0.}; //Position incide the crystal | |
168 | Double_t posC[3]={0.0,0.0,0.}; //Global position | |
169 | ||
170 | //Shift and possibly apply misalignment corrections | |
171 | Int_t strip=1+((Int_t) TMath::Ceil((Double_t)relid[2]/fNCellsXInStrip))*fNStripZ- | |
172 | (Int_t) TMath::Ceil((Double_t)relid[3]/fNCellsZInStrip) ; | |
173 | Int_t cellraw= relid[3]%fNCellsZInStrip ; | |
174 | if(cellraw==0)cellraw=fNCellsZInStrip ; | |
175 | Int_t cell= ((relid[2]-1)%fNCellsXInStrip)*fNCellsZInStrip + cellraw ; | |
176 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d/PCEL_%d", | |
177 | relid[0],strip,cell) ; | |
178 | if (!gGeoManager->cd(path)){ | |
179 | printf("Geo manager can not find path \n"); | |
180 | abort() ; | |
181 | } | |
182 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
183 | if (m) m->LocalToMaster(pos,posC); | |
184 | else{ | |
185 | printf("Geo matrixes are not loaded \n") ; | |
186 | abort() ; | |
187 | } | |
188 | //Return to PHOS local system | |
189 | Double_t posL[3]={posC[0],posC[1],posC[2]}; | |
190 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",relid[0]) ; | |
191 | // sprintf(path,"/ALIC_1/PHOS_%d",relid[0]) ; | |
192 | if (!gGeoManager->cd(path)){ | |
193 | printf("Geo manager can not find path \n"); | |
194 | abort(); | |
195 | } | |
196 | TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix(); | |
197 | if (mPHOS) mPHOS->MasterToLocal(posC,posL); | |
198 | else{ | |
199 | printf("Geo matrixes are not loaded \n") ; | |
200 | abort() ; | |
201 | } | |
202 | x=posL[0] ; | |
203 | z=-posL[2]; | |
204 | return ; | |
205 | } | |
206 | else{//CPV | |
207 | //first calculate position with respect to CPV plain | |
208 | Int_t row = relid[2] ; //offset along x axis | |
209 | Int_t column = relid[3] ; //offset along z axis | |
210 | Double_t pos[3]= {0.0,0.0,0.}; //Position incide the CPV printed circuit | |
211 | Double_t posC[3]={0.0,0.0,0.}; //Global position | |
212 | pos[0] = - ( fNumberOfCPVPadsPhi/2. - row - 0.5 ) * fPadSizePhi ; // position of pad with respect | |
213 | pos[2] = - ( fNumberOfCPVPadsZ /2. - column - 0.5 ) * fPadSizeZ ; // of center of PHOS module | |
214 | ||
215 | //now apply possible shifts and rotations | |
216 | sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",relid[0]) ; | |
217 | if (!gGeoManager->cd(path)){ | |
218 | printf("Geo manager can not find path \n"); | |
219 | abort() ; | |
220 | } | |
221 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
222 | if (m) m->LocalToMaster(pos,posC); | |
223 | else{ | |
224 | printf("Geo matrixes are not loaded \n") ; | |
225 | abort() ; | |
226 | } | |
227 | //Return to PHOS local system | |
228 | Double_t posL[3]={0.,0.,0.,} ; | |
229 | sprintf(path,"/ALIC_1/PHOS_%d",relid[0]) ; | |
230 | if (!gGeoManager->cd(path)){ | |
231 | printf("Geo manager can not find path \n"); | |
232 | abort() ; | |
233 | } | |
234 | TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix(); | |
235 | if (mPHOS) mPHOS->MasterToLocal(posC,posL); | |
236 | else{ | |
237 | printf("Geo matrixes are not loaded \n") ; | |
238 | abort() ; | |
239 | } | |
240 | x=posL[0] ; | |
241 | z=posL[1]; | |
242 | return ; | |
243 | ||
244 | } | |
245 | ||
246 | } | |
247 | //____________________________________________________________________________ | |
248 | void AliPHOSGeoUtils::RelPosToAbsId(Int_t module, Double_t x, Double_t z, Int_t & absId) const | |
249 | { | |
250 | // converts local PHOS-module (x, z) coordinates to absId | |
251 | ||
252 | //find Global position | |
253 | if (!gGeoManager){ | |
254 | printf("Geo manager not initialized\n"); | |
255 | abort() ; | |
256 | } | |
257 | Double_t posL[3]={x,-fCrystalShift,-z} ; //Only for EMC!!! | |
258 | Double_t posG[3] ; | |
259 | char path[100] ; | |
260 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",module) ; | |
261 | if (!gGeoManager->cd(path)){ | |
262 | printf("Geo manager can not find path \n"); | |
263 | abort() ; | |
264 | } | |
265 | TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix(); | |
266 | if (mPHOS){ | |
267 | mPHOS->LocalToMaster(posL,posG); | |
268 | } | |
269 | else{ | |
270 | printf("Geo matrixes are not loaded \n") ; | |
271 | abort() ; | |
272 | } | |
273 | ||
274 | Int_t relid[4] ; | |
275 | gGeoManager->FindNode(posG[0],posG[1],posG[2]) ; | |
276 | //Check that path contains PSTR and extract strip number | |
277 | TString cpath(gGeoManager->GetPath()) ; | |
278 | Int_t indx = cpath.Index("PCEL") ; | |
279 | if(indx==-1){ //for the few events when particle hits between srips use ideal geometry | |
280 | relid[0] = module ; | |
281 | relid[1] = 0 ; | |
282 | relid[2] = static_cast<Int_t>(TMath::Ceil( x/ fCellStep + fNPhi / 2.) ); | |
283 | relid[3] = static_cast<Int_t>(TMath::Ceil(-z/ fCellStep + fNZ / 2.) ) ; | |
284 | if(relid[2]<1)relid[2]=1 ; | |
285 | if(relid[3]<1)relid[3]=1 ; | |
286 | if(relid[2]>fNPhi)relid[2]=fNPhi ; | |
287 | if(relid[3]>fNZ)relid[3]=fNZ ; | |
288 | RelToAbsNumbering(relid,absId) ; | |
289 | } | |
290 | else{ | |
291 | Int_t indx2 = cpath.Index("/",indx) ; | |
292 | if(indx2==-1) | |
293 | indx2=cpath.Length() ; | |
294 | TString cell=cpath(indx+5,indx2-indx-5) ; | |
295 | Int_t icell=cell.Atoi() ; | |
296 | indx = cpath.Index("PSTR") ; | |
297 | indx2 = cpath.Index("/",indx) ; | |
298 | TString strip=cpath(indx+5,indx2-indx-5) ; | |
299 | Int_t iStrip = strip.Atoi() ; | |
300 | ||
301 | Int_t row = fNStripZ - (iStrip - 1) % (fNStripZ) ; | |
302 | Int_t col = (Int_t) TMath::Ceil((Double_t) iStrip/(fNStripZ)) -1 ; | |
303 | ||
304 | // Absid for 8x2-strips. Looks nice :) | |
305 | absId = (module-1)*fNCristalsInModule + | |
306 | row * 2 + (col*fNCellsXInStrip + (icell - 1) / 2)*fNZ - (icell & 1 ? 1 : 0); | |
307 | ||
308 | } | |
309 | ||
310 | } | |
311 | ||
312 | //____________________________________________________________________________ | |
313 | void AliPHOSGeoUtils::RelPosToRelId(Int_t module, Double_t x, Double_t z, Int_t * relId) const | |
314 | { | |
315 | //Evaluates RelId of the crystall with given coordinates | |
316 | ||
317 | Int_t absId ; | |
318 | RelPosToAbsId(module, x,z,absId) ; | |
319 | AbsToRelNumbering(absId,relId) ; | |
320 | } | |
321 | ||
322 | //____________________________________________________________________________ | |
323 | void AliPHOSGeoUtils::RelPosInAlice(Int_t id, TVector3 & pos ) const | |
324 | { | |
325 | // Converts the absolute numbering into the global ALICE coordinate system | |
326 | ||
327 | if (!gGeoManager){ | |
328 | printf("Geo manager not initialized\n"); | |
329 | abort(); | |
330 | } | |
331 | ||
332 | Int_t relid[4] ; | |
333 | ||
334 | AbsToRelNumbering(id , relid) ; | |
335 | ||
336 | //construct module name | |
337 | char path[100] ; | |
338 | if(relid[1]==0){ //this is EMC | |
339 | ||
340 | Double_t ps[3]= {0.0,-fCryCellShift,0.}; //Position incide the crystal | |
341 | Double_t psC[3]={0.0,0.0,0.}; //Global position | |
342 | ||
343 | //Shift and possibly apply misalignment corrections | |
344 | Int_t strip=1+((Int_t) TMath::Ceil((Double_t)relid[2]/fNCellsXInStrip))*fNStripZ- | |
345 | (Int_t) TMath::Ceil((Double_t)relid[3]/fNCellsZInStrip) ; | |
346 | Int_t cellraw= relid[3]%fNCellsZInStrip ; | |
347 | if(cellraw==0)cellraw=fNCellsZInStrip ; | |
348 | Int_t cell= ((relid[2]-1)%fNCellsXInStrip)*fNCellsZInStrip + cellraw ; | |
349 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d/PCEL_%d", | |
350 | relid[0],strip,cell) ; | |
351 | if (!gGeoManager->cd(path)){ | |
352 | printf("Geo manager can not find path \n"); | |
353 | abort() ; | |
354 | } | |
355 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
356 | if (m) m->LocalToMaster(ps,psC); | |
357 | else{ | |
358 | printf("Geo matrixes are not loaded \n") ; | |
359 | abort() ; | |
360 | } | |
361 | pos.SetXYZ(psC[0],psC[1],psC[2]) ; | |
362 | } | |
363 | else{ | |
364 | //first calculate position with respect to CPV plain | |
365 | Int_t row = relid[2] ; //offset along x axis | |
366 | Int_t column = relid[3] ; //offset along z axis | |
367 | Double_t ps[3]= {0.0,fCPVBoxSizeY/2.,0.}; //Position on top of CPV | |
368 | Double_t psC[3]={0.0,0.0,0.}; //Global position | |
369 | pos[0] = - ( fNumberOfCPVPadsPhi/2. - row - 0.5 ) * fPadSizePhi ; // position of pad with respect | |
370 | pos[2] = - ( fNumberOfCPVPadsZ /2. - column - 0.5 ) * fPadSizeZ ; // of center of PHOS module | |
371 | ||
372 | //now apply possible shifts and rotations | |
373 | sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",relid[0]) ; | |
374 | if (!gGeoManager->cd(path)){ | |
375 | printf("Geo manager can not find path \n"); | |
376 | abort(); | |
377 | } | |
378 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
379 | if (m) m->LocalToMaster(ps,psC); | |
380 | else{ | |
381 | printf("Geo matrixes are not loaded \n") ; | |
382 | abort() ; | |
383 | } | |
384 | pos.SetXYZ(psC[0],psC[1],-psC[2]) ; | |
385 | } | |
386 | } | |
387 | ||
388 | //____________________________________________________________________________ | |
389 | void AliPHOSGeoUtils::Local2Global(Int_t mod, Float_t x, Float_t z, | |
390 | TVector3& globalPosition) const | |
391 | { | |
392 | char path[100] ; | |
393 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",mod) ; | |
394 | if (!gGeoManager->cd(path)){ | |
395 | printf("Geo manager can not find path \n"); | |
396 | abort() ; | |
397 | } | |
398 | Double_t posL[3]={x,-fCrystalShift,-z} ; //Only for EMC!!! | |
399 | Double_t posG[3] ; | |
400 | TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix(); | |
401 | if (mPHOS){ | |
402 | mPHOS->LocalToMaster(posL,posG); | |
403 | } | |
404 | else{ | |
405 | printf("Geo matrixes are not loaded \n") ; | |
406 | abort() ; | |
407 | } | |
408 | globalPosition.SetXYZ(posG[0],posG[1],posG[2]) ; | |
409 | } | |
410 | //____________________________________________________________________________ | |
411 | void AliPHOSGeoUtils::Global2Local(TVector3& localPosition, | |
412 | const TVector3& globalPosition, | |
413 | Int_t module) const | |
414 | { | |
415 | // Transforms a global position to the local coordinate system | |
416 | // of the module | |
417 | //Return to PHOS local system | |
418 | Double_t posG[3]={globalPosition.X(),globalPosition.Y(),globalPosition.Z()} ; | |
419 | Double_t posL[3]={0.,0.,0.} ; | |
420 | char path[100] ; | |
421 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",module) ; | |
422 | if (!gGeoManager->cd(path)){ | |
423 | printf("Geo manager can not find path \n"); | |
424 | abort() ; | |
425 | } | |
426 | TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix(); | |
427 | if (mPHOS) mPHOS->MasterToLocal(posG,posL); | |
428 | else{ | |
429 | printf("Geo matrixes are not loaded \n") ; | |
430 | abort() ; | |
431 | } | |
432 | localPosition.SetXYZ(posL[0],posL[1]+fCrystalShift,-posL[2]) ; | |
433 | ||
f4aea312 | 434 | } |
435 | //____________________________________________________________________________ | |
436 | Bool_t AliPHOSGeoUtils::GlobalPos2RelId(TVector3 & global, Int_t * relId){ | |
437 | //Converts position in global ALICE coordinates to relId | |
438 | //returns false if x,z coordinates are beyond PHOS | |
439 | //distande to PHOS surface is NOT calculated | |
440 | TVector3 loc ; | |
441 | for(Int_t mod=1; mod<fNModules; mod++){ | |
442 | Global2Local(loc,global,mod) ; | |
443 | //If in Acceptance | |
444 | if((TMath::Abs(loc.Z())<fXtlArrSize[2]) && (TMath::Abs(loc.X())<fXtlArrSize[0])){ | |
445 | RelPosToRelId(mod,loc.X(),loc.Z(),relId); | |
446 | return kTRUE ; | |
447 | } | |
448 | } | |
449 | return kFALSE ; | |
450 | ||
70a0fabe | 451 | } |
452 | //____________________________________________________________________________ | |
453 | Bool_t AliPHOSGeoUtils::ImpactOnEmc(const TParticle * particle, | |
454 | Int_t & moduleNumber, Double_t & z, Double_t & x) const | |
455 | { | |
456 | // Tells if a particle enters PHOS and evaluates hit position | |
457 | Double_t vtx[3]={particle->Vx(),particle->Vy(),particle->Vz()} ; | |
458 | return ImpactOnEmc(vtx,particle->Theta(),particle->Phi(),moduleNumber,z,x); | |
459 | } | |
460 | ||
461 | //____________________________________________________________________________ | |
462 | Bool_t AliPHOSGeoUtils::ImpactOnEmc(const Double_t * vtx, Double_t theta, Double_t phi, | |
463 | Int_t & moduleNumber, Double_t & z, Double_t & x) const | |
464 | { | |
465 | // calculates the impact coordinates on PHOS of a neutral particle | |
466 | // emitted in the vertex vtx[3] with direction vec(p) in the ALICE global coordinate system | |
467 | TVector3 p(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ; | |
468 | return ImpactOnEmc(vtx,p,moduleNumber,z,x) ; | |
469 | ||
470 | } | |
471 | //____________________________________________________________________________ | |
472 | Bool_t AliPHOSGeoUtils::ImpactOnEmc(const Double_t * vtx, const TVector3 &p, | |
473 | Int_t & moduleNumber, Double_t & z, Double_t & x) const | |
474 | { | |
475 | // calculates the impact coordinates on PHOS of a neutral particle | |
476 | // emitted in the vertex vtx[3] with direction theta and phi in the ALICE global coordinate system | |
477 | TVector3 v(vtx[0],vtx[1],vtx[2]) ; | |
478 | ||
479 | if (!gGeoManager){ | |
480 | printf("Geo manager not initialized\n"); | |
481 | abort() ; | |
482 | return kFALSE ; | |
483 | } | |
484 | ||
485 | for(Int_t imod=1; imod<=fNModules ; imod++){ | |
486 | //create vector from (0,0,0) to center of crystal surface of imod module | |
487 | Double_t tmp[3]={0.,-fCrystalShift,0.} ; | |
488 | ||
489 | char path[100] ; | |
490 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",imod) ; | |
491 | if (!gGeoManager->cd(path)){ | |
492 | printf("Geo manager can not find path \n"); | |
493 | abort() ; | |
494 | return kFALSE ; | |
495 | } | |
496 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
497 | Double_t posG[3]={0.,0.,0.} ; | |
498 | if (m) m->LocalToMaster(tmp,posG); | |
499 | TVector3 n(posG[0],posG[1],posG[2]) ; | |
500 | Double_t direction=n.Dot(p) ; | |
501 | if(direction<=0.) | |
502 | continue ; //momentum directed FROM module | |
503 | Double_t fr = (n.Mag2()-n.Dot(v))/direction ; | |
504 | //Calculate direction in module plain | |
505 | n-=v+fr*p ; | |
506 | n*=-1. ; | |
507 | if(TMath::Abs(TMath::Abs(n.Z())<fXtlArrSize[2]) && n.Pt()<fXtlArrSize[0]){ | |
508 | moduleNumber = imod ; | |
509 | z=n.Z() ; | |
510 | x=TMath::Sign(n.Pt(),n.X()) ; | |
511 | //no need to return to local system since we calcilated distance from module center | |
512 | //and tilts can not be significant. | |
513 | return kTRUE ; | |
514 | } | |
515 | } | |
516 | //Not in acceptance | |
517 | x=0; z=0 ; | |
518 | moduleNumber=0 ; | |
519 | return kFALSE ; | |
520 | ||
521 | } | |
522 | ||
523 | //____________________________________________________________________________ | |
524 | void AliPHOSGeoUtils::Init(void){ | |
525 | //Reads geometry parameters from dedicated classes | |
526 | ||
527 | AliPHOSEMCAGeometry emcGeom ; | |
528 | ||
529 | fNModules = 5; | |
530 | fNPhi = emcGeom.GetNPhi() ; | |
531 | fNZ = emcGeom.GetNZ() ; | |
532 | fNCristalsInModule = fNPhi*fNZ ; | |
533 | fNCellsXInStrip= emcGeom.GetNCellsXInStrip() ; | |
534 | fNCellsZInStrip= emcGeom.GetNCellsZInStrip() ; | |
535 | fNStripZ = emcGeom.GetNStripZ() ; | |
536 | fXtlArrSize[0]=emcGeom.GetInnerThermoHalfSize()[0] ; //Wery close to the zise of the Xtl set | |
537 | fXtlArrSize[1]=emcGeom.GetInnerThermoHalfSize()[1] ; //Wery close to the zise of the Xtl set | |
538 | fXtlArrSize[2]=emcGeom.GetInnerThermoHalfSize()[2] ; //Wery close to the zise of the Xtl set | |
539 | ||
540 | //calculate offset to crystal surface | |
541 | Float_t * inthermo = emcGeom.GetInnerThermoHalfSize() ; | |
542 | Float_t * strip = emcGeom.GetStripHalfSize() ; | |
543 | Float_t* splate = emcGeom.GetSupportPlateHalfSize(); | |
544 | Float_t * crystal = emcGeom.GetCrystalHalfSize() ; | |
545 | Float_t * pin = emcGeom.GetAPDHalfSize() ; | |
546 | Float_t * preamp = emcGeom.GetPreampHalfSize() ; | |
547 | fCrystalShift=-inthermo[1]+strip[1]+splate[1]+crystal[1]-emcGeom.GetAirGapLed()/2.+pin[1]+preamp[1] ; | |
548 | fCryCellShift=crystal[1]-(emcGeom.GetAirGapLed()-2*pin[1]-2*preamp[1])/2; | |
549 | fCellStep = 2.*emcGeom.GetAirCellHalfSize()[0] ; | |
550 | ||
551 | AliPHOSCPVGeometry cpvGeom ; | |
552 | ||
553 | fNumberOfCPVPadsPhi = cpvGeom.GetNumberOfCPVPadsPhi() ; | |
554 | fNumberOfCPVPadsZ = cpvGeom.GetNumberOfCPVPadsZ() ; | |
555 | fPadSizePhi = cpvGeom.GetCPVPadSizePhi() ; | |
556 | fPadSizeZ = cpvGeom.GetCPVPadSizeZ() ; | |
557 | fCPVBoxSizeY= cpvGeom.GetCPVBoxSize(1) ; | |
558 | } |