]>
Commit | Line | Data |
---|---|---|
d15a28e7 | 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 | ||
b2a60966 | 16 | /* $Id$ */ |
17 | ||
d15a28e7 | 18 | //_________________________________________________________________________ |
b2a60966 | 19 | // Geometry class for PHOS : singleton |
a3dfe79c | 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. | |
b2a60966 | 26 | // |
05d33a3d | 27 | // -- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC "KI" & SUBATECH) |
d15a28e7 | 28 | |
29 | // --- ROOT system --- | |
30 | ||
31 | #include "TVector3.h" | |
32 | #include "TRotation.h" | |
e957fea8 | 33 | #include "TParticle.h" |
91daaf24 | 34 | #include <TGeoManager.h> |
d15a28e7 | 35 | |
36 | // --- Standard library --- | |
37 | ||
d15a28e7 | 38 | // --- AliRoot header files --- |
351dd634 | 39 | #include "AliLog.h" |
d15a28e7 | 40 | #include "AliPHOSGeometry.h" |
468794ea | 41 | #include "AliPHOSEMCAGeometry.h" |
710f859a | 42 | #include "AliPHOSRecPoint.h" |
d15a28e7 | 43 | |
925e6570 | 44 | ClassImp(AliPHOSGeometry) |
d15a28e7 | 45 | |
a4e98857 | 46 | // these initialisations are needed for a singleton |
05d33a3d | 47 | AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ; |
48 | Bool_t AliPHOSGeometry::fgInit = kFALSE ; | |
9ec91567 | 49 | |
e957fea8 | 50 | //____________________________________________________________________________ |
3663622c | 51 | AliPHOSGeometry::AliPHOSGeometry() : |
52 | fNModules(0), | |
53 | fAngle(0.f), | |
54 | fPHOSAngle(0), | |
55 | fIPtoUpperCPVsurface(0), | |
56 | fRotMatrixArray(0), | |
57 | fGeometryEMCA(0), | |
58 | fGeometryCPV(0), | |
59 | fGeometrySUPP(0) | |
60 | { | |
e957fea8 | 61 | // default ctor |
62 | // must be kept public for root persistency purposes, but should never be called by the outside world | |
e957fea8 | 63 | fgGeom = 0 ; |
e957fea8 | 64 | } |
65 | ||
3663622c | 66 | //____________________________________________________________________________ |
67 | AliPHOSGeometry::AliPHOSGeometry(const AliPHOSGeometry & rhs) | |
68 | : AliGeometry(rhs), | |
69 | fNModules(rhs.fNModules), | |
70 | fAngle(rhs.fAngle), | |
71 | fPHOSAngle(0), | |
72 | fIPtoUpperCPVsurface(rhs.fIPtoUpperCPVsurface), | |
73 | fRotMatrixArray(0), | |
74 | fGeometryEMCA(0), | |
75 | fGeometryCPV(0), | |
76 | fGeometrySUPP(0) | |
77 | { | |
78 | Fatal("cpy ctor", "not implemented") ; | |
79 | } | |
80 | ||
91daaf24 | 81 | //____________________________________________________________________________ |
3663622c | 82 | AliPHOSGeometry::AliPHOSGeometry(const Text_t* name, const Text_t* title) |
83 | : AliGeometry(name, title), | |
84 | fNModules(0), | |
85 | fAngle(0.f), | |
86 | fPHOSAngle(0), | |
87 | fIPtoUpperCPVsurface(0), | |
88 | fRotMatrixArray(0), | |
89 | fGeometryEMCA(0), | |
90 | fGeometryCPV(0), | |
91 | fGeometrySUPP(0) | |
92 | { | |
93 | // ctor only for internal usage (singleton) | |
94 | Init() ; | |
95 | } | |
96 | ||
d15a28e7 | 97 | //____________________________________________________________________________ |
98 | AliPHOSGeometry::~AliPHOSGeometry(void) | |
99 | { | |
b2a60966 | 100 | // dtor |
101 | ||
52a36ffd | 102 | if (fRotMatrixArray) fRotMatrixArray->Delete() ; |
103 | if (fRotMatrixArray) delete fRotMatrixArray ; | |
fa0bc588 | 104 | if (fPHOSAngle ) delete[] fPHOSAngle ; |
52a36ffd | 105 | } |
52a36ffd | 106 | |
91daaf24 | 107 | //____________________________________________________________________________ |
52a36ffd | 108 | void AliPHOSGeometry::Init(void) |
109 | { | |
a4e98857 | 110 | // Initializes the PHOS parameters : |
111 | // IHEP is the Protvino CPV (cathode pad chambers) | |
710f859a | 112 | |
809cd394 | 113 | TString test(GetName()) ; |
9d1b528b | 114 | if (test != "IHEP" && test != "noCPV") { |
351dd634 | 115 | AliFatal(Form("%s is not a known geometry (choose among IHEP)", |
116 | test.Data() )) ; | |
809cd394 | 117 | } |
118 | ||
710f859a | 119 | fgInit = kTRUE ; |
05d33a3d | 120 | |
85698486 | 121 | fNModules = 5; |
122 | fAngle = 20; | |
05d33a3d | 123 | |
710f859a | 124 | fGeometryEMCA = new AliPHOSEMCAGeometry(); |
125 | ||
126 | fGeometryCPV = new AliPHOSCPVGeometry (); | |
127 | ||
128 | fGeometrySUPP = new AliPHOSSupportGeometry(); | |
129 | ||
130 | fPHOSAngle = new Float_t[fNModules] ; | |
131 | ||
132 | Float_t * emcParams = fGeometryEMCA->GetEMCParams() ; | |
133 | ||
581e32d4 | 134 | fPHOSParams[0] = TMath::Max((Double_t)fGeometryCPV->GetCPVBoxSize(0)/2., |
a83b6179 | 135 | (Double_t)(emcParams[0] - (emcParams[1]-emcParams[0])* |
136 | fGeometryCPV->GetCPVBoxSize(1)/2/emcParams[3])); | |
710f859a | 137 | fPHOSParams[1] = emcParams[1] ; |
581e32d4 | 138 | fPHOSParams[2] = TMath::Max((Double_t)emcParams[2], (Double_t)fGeometryCPV->GetCPVBoxSize(2)/2.); |
710f859a | 139 | fPHOSParams[3] = emcParams[3] + fGeometryCPV->GetCPVBoxSize(1)/2. ; |
140 | ||
141 | fIPtoUpperCPVsurface = fGeometryEMCA->GetIPtoOuterCoverDistance() - fGeometryCPV->GetCPVBoxSize(1) ; | |
8e20650f | 142 | |
143 | //calculate offset to crystal surface | |
144 | Float_t * inthermo = fGeometryEMCA->GetInnerThermoHalfSize() ; | |
145 | Float_t * strip = fGeometryEMCA->GetStripHalfSize() ; | |
146 | Float_t* splate = fGeometryEMCA->GetSupportPlateHalfSize(); | |
147 | Float_t * crystal = fGeometryEMCA->GetCrystalHalfSize() ; | |
148 | Float_t * pin = fGeometryEMCA->GetAPDHalfSize() ; | |
149 | Float_t * preamp = fGeometryEMCA->GetPreampHalfSize() ; | |
150 | fCrystalShift=-inthermo[1]+strip[1]+splate[1]+crystal[1]-fGeometryEMCA->GetAirGapLed()/2.+pin[1]+preamp[1] ; | |
151 | fCryCellShift=crystal[1]-(fGeometryEMCA->GetAirGapLed()-2*pin[1]-2*preamp[1])/2; | |
152 | ||
710f859a | 153 | Int_t index ; |
154 | for ( index = 0; index < fNModules; index++ ) | |
52a36ffd | 155 | fPHOSAngle[index] = 0.0 ; // Module position angles are set in CreateGeometry() |
710f859a | 156 | |
710f859a | 157 | fRotMatrixArray = new TObjArray(fNModules) ; |
05d33a3d | 158 | |
85698486 | 159 | // Geometry parameters are calculated |
160 | ||
161 | SetPHOSAngles(); | |
162 | Double_t const kRADDEG = 180.0 / TMath::Pi() ; | |
163 | Float_t r = GetIPtoOuterCoverDistance() + fPHOSParams[3] - GetCPVBoxSize(1) ; | |
164 | for (Int_t iModule=0; iModule<fNModules; iModule++) { | |
165 | fModuleCenter[iModule][0] = r * TMath::Sin(fPHOSAngle[iModule] / kRADDEG ); | |
166 | fModuleCenter[iModule][1] =-r * TMath::Cos(fPHOSAngle[iModule] / kRADDEG ); | |
167 | fModuleCenter[iModule][2] = 0.; | |
168 | ||
169 | fModuleAngle[iModule][0][0] = 90; | |
170 | fModuleAngle[iModule][0][1] = fPHOSAngle[iModule]; | |
171 | fModuleAngle[iModule][1][0] = 0; | |
172 | fModuleAngle[iModule][1][1] = 0; | |
173 | fModuleAngle[iModule][2][0] = 90; | |
174 | fModuleAngle[iModule][2][1] = 270 + fPHOSAngle[iModule]; | |
05d33a3d | 175 | } |
176 | ||
52a36ffd | 177 | } |
178 | ||
179 | //____________________________________________________________________________ | |
180 | AliPHOSGeometry * AliPHOSGeometry::GetInstance() | |
181 | { | |
a4e98857 | 182 | // Returns the pointer of the unique instance; singleton specific |
183 | ||
809cd394 | 184 | return static_cast<AliPHOSGeometry *>( fgGeom ) ; |
52a36ffd | 185 | } |
186 | ||
187 | //____________________________________________________________________________ | |
188 | AliPHOSGeometry * AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t* title) | |
189 | { | |
190 | // Returns the pointer of the unique instance | |
a4e98857 | 191 | // Creates it with the specified options (name, title) if it does not exist yet |
192 | ||
52a36ffd | 193 | AliPHOSGeometry * rv = 0 ; |
194 | if ( fgGeom == 0 ) { | |
195 | if ( strcmp(name,"") == 0 ) | |
196 | rv = 0 ; | |
197 | else { | |
198 | fgGeom = new AliPHOSGeometry(name, title) ; | |
199 | if ( fgInit ) | |
200 | rv = (AliPHOSGeometry * ) fgGeom ; | |
201 | else { | |
202 | rv = 0 ; | |
203 | delete fgGeom ; | |
204 | fgGeom = 0 ; | |
205 | } | |
206 | } | |
207 | } | |
208 | else { | |
21cd0c07 | 209 | if ( strcmp(fgGeom->GetName(), name) != 0 ) |
351dd634 | 210 | ::Error("GetInstance", "Current geometry is %s. You cannot call %s", |
211 | fgGeom->GetName(), name) ; | |
52a36ffd | 212 | else |
213 | rv = (AliPHOSGeometry *) fgGeom ; | |
214 | } | |
215 | return rv ; | |
216 | } | |
4697edca | 217 | |
52a36ffd | 218 | //____________________________________________________________________________ |
219 | void AliPHOSGeometry::SetPHOSAngles() | |
220 | { | |
a4e98857 | 221 | // Calculates the position of the PHOS modules in ALICE global coordinate system |
91daaf24 | 222 | // in ideal geometry |
52a36ffd | 223 | |
a8c47ab6 | 224 | Double_t const kRADDEG = 180.0 / TMath::Pi() ; |
710f859a | 225 | Float_t pphi = 2 * TMath::ATan( GetOuterBoxSize(0) / ( 2.0 * GetIPtoUpperCPVsurface() ) ) ; |
52a36ffd | 226 | pphi *= kRADDEG ; |
710f859a | 227 | if (pphi > fAngle){ |
351dd634 | 228 | AliError(Form("PHOS modules overlap!\n pphi = %f fAngle = %f", |
229 | pphi, fAngle)); | |
710f859a | 230 | |
231 | } | |
ed4205d8 | 232 | pphi = fAngle; |
52a36ffd | 233 | |
234 | for( Int_t i = 1; i <= fNModules ; i++ ) { | |
ed4205d8 | 235 | Float_t angle = pphi * ( i - fNModules / 2.0 - 0.5 ) ; |
52a36ffd | 236 | fPHOSAngle[i-1] = - angle ; |
237 | } | |
d15a28e7 | 238 | } |
239 | ||
240 | //____________________________________________________________________________ | |
fd6f5ab1 | 241 | Bool_t AliPHOSGeometry::AbsToRelNumbering(Int_t absId, Int_t * relid) const |
d15a28e7 | 242 | { |
91daaf24 | 243 | // Converts the absolute numbering into the following array |
b2a60966 | 244 | // relid[0] = PHOS Module number 1:fNModules |
245 | // relid[1] = 0 if PbW04 | |
710f859a | 246 | // = -1 if CPV |
247 | // relid[2] = Row number inside a PHOS module | |
248 | // relid[3] = Column number inside a PHOS module | |
d15a28e7 | 249 | |
250 | Bool_t rv = kTRUE ; | |
fd6f5ab1 | 251 | Float_t id = absId ; |
d15a28e7 | 252 | |
710f859a | 253 | Int_t phosmodulenumber = (Int_t)TMath:: Ceil( id / GetNCristalsInModule() ) ; |
d15a28e7 | 254 | |
710f859a | 255 | if ( phosmodulenumber > GetNModules() ) { // it is a CPV pad |
256 | ||
257 | id -= GetNPhi() * GetNZ() * GetNModules() ; | |
258 | Float_t nCPV = GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() ; | |
259 | relid[0] = (Int_t) TMath::Ceil( id / nCPV ) ; | |
260 | relid[1] = -1 ; | |
261 | id -= ( relid[0] - 1 ) * nCPV ; | |
262 | relid[2] = (Int_t) TMath::Ceil( id / GetNumberOfCPVPadsZ() ) ; | |
263 | relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() ) ; | |
d15a28e7 | 264 | } |
710f859a | 265 | else { // it is a PW04 crystal |
d15a28e7 | 266 | |
92862013 | 267 | relid[0] = phosmodulenumber ; |
268 | relid[1] = 0 ; | |
269 | id -= ( phosmodulenumber - 1 ) * GetNPhi() * GetNZ() ; | |
710f859a | 270 | relid[2] = (Int_t)TMath::Ceil( id / GetNZ() ) ; |
271 | relid[3] = (Int_t)( id - ( relid[2] - 1 ) * GetNZ() ) ; | |
d15a28e7 | 272 | } |
273 | return rv ; | |
274 | } | |
9f616d61 | 275 | //____________________________________________________________________________ |
91daaf24 | 276 | void AliPHOSGeometry::GetGlobal(const AliRecPoint* recPoint, TVector3 & gpos) const |
9ee9f78d | 277 | { |
278 | AliFatal(Form("Please use GetGlobalPHOS(recPoint,gpos) instead of GetGlobal!")); | |
279 | } | |
280 | ||
281 | //____________________________________________________________________________ | |
282 | void AliPHOSGeometry::GetGlobalPHOS(const AliPHOSRecPoint* recPoint, TVector3 & gpos) const | |
d15a28e7 | 283 | { |
a4e98857 | 284 | // Calculates the coordinates of a RecPoint and the error matrix in the ALICE global coordinate system |
b2a60966 | 285 | |
9ee9f78d | 286 | const AliPHOSRecPoint * tmpPHOS = recPoint ; |
92862013 | 287 | TVector3 localposition ; |
d15a28e7 | 288 | |
289 | tmpPHOS->GetLocalPosition(gpos) ; | |
290 | ||
91daaf24 | 291 | if (!gGeoManager){ |
292 | AliFatal("Geo manager not initialized\n"); | |
d15a28e7 | 293 | } |
91daaf24 | 294 | //construct module name |
295 | char path[100] ; | |
296 | Double_t dy ; | |
297 | if(tmpPHOS->IsEmc()){ | |
298 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",tmpPHOS->GetPHOSMod()) ; | |
8e20650f | 299 | // sprintf(path,"/ALIC_1/PHOS_%d",tmpPHOS->GetPHOSMod()) ; |
300 | dy=fCrystalShift ; | |
d15a28e7 | 301 | } |
91daaf24 | 302 | else{ |
303 | sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",tmpPHOS->GetPHOSMod()) ; | |
304 | dy= GetCPVBoxSize(1)/2. ; //center of CPV module | |
305 | } | |
306 | Double_t pos[3]={gpos.X(),gpos.Y()-dy,gpos.Z()} ; | |
8e20650f | 307 | if(tmpPHOS->IsEmc()) |
308 | pos[2]=-pos[2] ; //Opposite z directions in EMC matrix and local frame!!! | |
91daaf24 | 309 | Double_t posC[3]; |
310 | //now apply possible shifts and rotations | |
311 | if (!gGeoManager->cd(path)){ | |
312 | AliFatal("Geo manager can not find path \n"); | |
313 | } | |
314 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
8e20650f | 315 | if (m){ |
316 | m->LocalToMaster(pos,posC); | |
317 | } | |
91daaf24 | 318 | else{ |
319 | AliFatal("Geo matrixes are not loaded \n") ; | |
320 | } | |
8e20650f | 321 | gpos.SetXYZ(posC[0],posC[1],posC[2]) ; |
7b51037f | 322 | |
aa35fc01 | 323 | } |
aa35fc01 | 324 | //____________________________________________________________________________ |
91daaf24 | 325 | void AliPHOSGeometry::ImpactOnEmc(Double_t * vtx, Double_t theta, Double_t phi, |
326 | Int_t & moduleNumber, Double_t & z, Double_t & x) const | |
aa35fc01 | 327 | { |
328 | // calculates the impact coordinates on PHOS of a neutral particle | |
91daaf24 | 329 | // emitted in the vertex vtx[3] with direction theta and phi in the ALICE global coordinate system |
330 | TVector3 p(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ; | |
022ee411 | 331 | TVector3 v(vtx[0],vtx[1],vtx[2]) ; |
aa35fc01 | 332 | |
91daaf24 | 333 | if (!gGeoManager){ |
334 | AliFatal("Geo manager not initialized\n"); | |
335 | } | |
336 | ||
337 | for(Int_t imod=1; imod<=GetNModules() ; imod++){ | |
338 | //create vector from (0,0,0) to center of crystal surface of imod module | |
8e20650f | 339 | Double_t tmp[3]={0.,-fCrystalShift,0.} ; |
91daaf24 | 340 | |
341 | char path[100] ; | |
342 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",imod) ; | |
343 | if (!gGeoManager->cd(path)){ | |
344 | AliFatal("Geo manager can not find path \n"); | |
345 | } | |
346 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
347 | Double_t posG[3]={0.,0.,0.} ; | |
348 | if (m) m->LocalToMaster(tmp,posG); | |
349 | TVector3 n(posG[0],posG[1],-posG[2]) ; | |
350 | Double_t direction=n.Dot(p) ; | |
351 | if(direction<=0.) | |
352 | continue ; //momentum directed FROM module | |
19c8ddd0 | 353 | Double_t fr = (n.Mag2()-n.Dot(v))/direction ; |
91daaf24 | 354 | //Calculate direction in module plain |
19c8ddd0 | 355 | n-=v+fr*p ; |
91daaf24 | 356 | n*=-1. ; |
357 | Float_t * sz = fGeometryEMCA->GetInnerThermoHalfSize() ; //Wery close to the zise of the Xtl set | |
358 | if(TMath::Abs(TMath::Abs(n.Z())<sz[2]) && n.Pt()<sz[0]){ | |
359 | moduleNumber = imod ; | |
360 | z=n.Z() ; | |
361 | x=TMath::Sign(n.Pt(),n.X()) ; | |
362 | return ; | |
363 | } | |
364 | } | |
365 | //Not in acceptance | |
366 | x=0; z=0 ; | |
367 | moduleNumber=0 ; | |
aa35fc01 | 368 | |
aa35fc01 | 369 | } |
370 | ||
e957fea8 | 371 | //____________________________________________________________________________ |
1c9d8212 | 372 | Bool_t AliPHOSGeometry::Impact(const TParticle * particle) const |
373 | { | |
e957fea8 | 374 | // Tells if a particle enters PHOS |
375 | Bool_t in=kFALSE; | |
376 | Int_t moduleNumber=0; | |
91daaf24 | 377 | Double_t vtx[3]={particle->Vx(),particle->Vy(),particle->Vz()} ; |
1c9d8212 | 378 | Double_t z,x; |
91daaf24 | 379 | ImpactOnEmc(vtx,particle->Theta(),particle->Phi(),moduleNumber,z,x); |
380 | if(moduleNumber!=0) | |
e957fea8 | 381 | in=kTRUE; |
e957fea8 | 382 | return in; |
1c9d8212 | 383 | } |
384 | ||
d15a28e7 | 385 | //____________________________________________________________________________ |
fd6f5ab1 | 386 | Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t & absId) const |
d15a28e7 | 387 | { |
b2a60966 | 388 | // Converts the relative numbering into the absolute numbering |
ed4205d8 | 389 | // EMCA crystals: |
fd6f5ab1 | 390 | // absId = from 1 to fNModules * fNPhi * fNZ |
ed4205d8 | 391 | // CPV pad: |
fd6f5ab1 | 392 | // absId = from N(total PHOS crystals) + 1 |
ed4205d8 | 393 | // to NCPVModules * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ |
d15a28e7 | 394 | |
395 | Bool_t rv = kTRUE ; | |
710f859a | 396 | |
397 | if ( relid[1] == 0 ) { // it is a Phos crystal | |
fd6f5ab1 | 398 | absId = |
710f859a | 399 | ( relid[0] - 1 ) * GetNPhi() * GetNZ() // the offset of PHOS modules |
400 | + ( relid[2] - 1 ) * GetNZ() // the offset along phi | |
401 | + relid[3] ; // the offset along z | |
d15a28e7 | 402 | } |
710f859a | 403 | else { // it is a CPV pad |
fd6f5ab1 | 404 | absId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate EMCA crystals from CPV pads |
710f859a | 405 | + ( relid[0] - 1 ) * GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() // the pads offset of PHOS modules |
406 | + ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() // the pads offset of a CPV row | |
52a36ffd | 407 | + relid[3] ; // the column number |
408 | } | |
409 | ||
d15a28e7 | 410 | return rv ; |
411 | } | |
412 | ||
413 | //____________________________________________________________________________ | |
fc7e2f43 | 414 | void AliPHOSGeometry::RelPosInAlice(Int_t id, TVector3 & pos ) const |
d15a28e7 | 415 | { |
a4e98857 | 416 | // Converts the absolute numbering into the global ALICE coordinate system |
b2a60966 | 417 | |
91daaf24 | 418 | if (!gGeoManager){ |
419 | AliFatal("Geo manager not initialized\n"); | |
420 | } | |
ed4205d8 | 421 | |
91daaf24 | 422 | Int_t relid[4] ; |
ed4205d8 | 423 | |
91daaf24 | 424 | AbsToRelNumbering(id , relid) ; |
ed4205d8 | 425 | |
91daaf24 | 426 | //construct module name |
427 | char path[100] ; | |
428 | if(relid[1]==0){ //this is EMC | |
429 | ||
8e20650f | 430 | Double_t ps[3]= {0.0,-fCryCellShift,0.}; //Position incide the crystal |
91daaf24 | 431 | Double_t psC[3]={0.0,0.0,0.}; //Global position |
432 | ||
433 | //Shift and possibly apply misalignment corrections | |
fd6f5ab1 | 434 | Int_t nCellsXInStrip=fGeometryEMCA->GetNCellsXInStrip() ; |
435 | Int_t nCellsZInStrip=fGeometryEMCA->GetNCellsZInStrip() ; | |
436 | Int_t strip=1+((Int_t) TMath::Ceil((Double_t)relid[2]/nCellsXInStrip))*fGeometryEMCA->GetNStripZ()- | |
437 | (Int_t) TMath::Ceil((Double_t)relid[3]/nCellsZInStrip) ; | |
438 | Int_t cellraw= relid[3]%nCellsZInStrip ; | |
439 | if(cellraw==0)cellraw=nCellsZInStrip ; | |
440 | Int_t cell= ((relid[2]-1)%nCellsXInStrip)*nCellsZInStrip + cellraw ; | |
91daaf24 | 441 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d/PCEL_%d", |
442 | relid[0],strip,cell) ; | |
443 | if (!gGeoManager->cd(path)){ | |
444 | AliFatal("Geo manager can not find path \n"); | |
445 | } | |
446 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
447 | if (m) m->LocalToMaster(ps,psC); | |
448 | else{ | |
449 | AliFatal("Geo matrixes are not loaded \n") ; | |
450 | } | |
fd6f5ab1 | 451 | pos.SetXYZ(psC[0],psC[1],psC[2]) ; |
91daaf24 | 452 | } |
453 | else{ | |
454 | //first calculate position with respect to CPV plain | |
455 | Int_t row = relid[2] ; //offset along x axis | |
456 | Int_t column = relid[3] ; //offset along z axis | |
457 | Double_t ps[3]= {0.0,GetCPVBoxSize(1)/2.,0.}; //Position on top of CPV | |
458 | Double_t psC[3]={0.0,0.0,0.}; //Global position | |
459 | pos[0] = - ( GetNumberOfCPVPadsPhi()/2. - row - 0.5 ) * GetPadSizePhi() ; // position of pad with respect | |
460 | pos[2] = - ( GetNumberOfCPVPadsZ() /2. - column - 0.5 ) * GetPadSizeZ() ; // of center of PHOS module | |
461 | ||
462 | //now apply possible shifts and rotations | |
463 | sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",relid[0]) ; | |
464 | if (!gGeoManager->cd(path)){ | |
465 | AliFatal("Geo manager can not find path \n"); | |
466 | } | |
467 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
468 | if (m) m->LocalToMaster(ps,psC); | |
469 | else{ | |
470 | AliFatal("Geo matrixes are not loaded \n") ; | |
471 | } | |
472 | pos.SetXYZ(psC[0],psC[1],-psC[2]) ; | |
473 | } | |
d15a28e7 | 474 | } |
475 | ||
476 | //____________________________________________________________________________ | |
fd6f5ab1 | 477 | void AliPHOSGeometry::RelPosToAbsId(Int_t module, Double_t x, Double_t z, Int_t & absId) const |
842988a5 | 478 | { |
479 | // converts local PHOS-module (x, z) coordinates to absId | |
91daaf24 | 480 | |
481 | //find Global position | |
482 | if (!gGeoManager){ | |
483 | AliFatal("Geo manager not initialized\n"); | |
484 | } | |
fd6f5ab1 | 485 | Double_t posL[3]={x,-fCrystalShift,-z} ; //Only for EMC!!! |
486 | Double_t posG[3] ; | |
91daaf24 | 487 | char path[100] ; |
488 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",module) ; | |
91daaf24 | 489 | if (!gGeoManager->cd(path)){ |
fd6f5ab1 | 490 | AliFatal("Geo manager can not find path \n"); |
491 | } | |
492 | TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix(); | |
493 | if (mPHOS){ | |
494 | mPHOS->LocalToMaster(posL,posG); | |
91daaf24 | 495 | } |
91daaf24 | 496 | else{ |
497 | AliFatal("Geo matrixes are not loaded \n") ; | |
498 | } | |
fd6f5ab1 | 499 | |
500 | Int_t relid[4] ; | |
501 | gGeoManager->FindNode(posG[0],posG[1],posG[2]) ; | |
91daaf24 | 502 | //Check that path contains PSTR and extract strip number |
503 | TString cpath(gGeoManager->GetPath()) ; | |
504 | Int_t indx = cpath.Index("PCEL") ; | |
505 | if(indx==-1){ //for the few events when particle hits between srips use ideal geometry | |
506 | relid[0] = module ; | |
507 | relid[1] = 0 ; | |
508 | relid[2] = static_cast<Int_t>(TMath::Ceil( x/ GetCellStep() + GetNPhi() / 2.) ); | |
509 | relid[3] = static_cast<Int_t>(TMath::Ceil(-z/ GetCellStep() + GetNZ() / 2.) ) ; | |
510 | if(relid[2]<1)relid[2]=1 ; | |
511 | if(relid[3]<1)relid[3]=1 ; | |
512 | if(relid[2]>GetNPhi())relid[2]=GetNPhi() ; | |
513 | if(relid[3]>GetNZ())relid[3]=GetNZ() ; | |
fd6f5ab1 | 514 | RelToAbsNumbering(relid,absId) ; |
91daaf24 | 515 | } |
516 | else{ | |
517 | Int_t indx2 = cpath.Index("/",indx) ; | |
518 | if(indx2==-1) | |
519 | indx2=cpath.Length() ; | |
520 | TString cell=cpath(indx+5,indx2-indx-5) ; | |
521 | Int_t icell=cell.Atoi() ; | |
522 | indx = cpath.Index("PSTR") ; | |
523 | indx2 = cpath.Index("/",indx) ; | |
524 | TString strip=cpath(indx+5,indx2-indx-5) ; | |
525 | Int_t iStrip = strip.Atoi() ; | |
fd6f5ab1 | 526 | |
527 | Int_t row = fGeometryEMCA->GetNStripZ() - (iStrip - 1) % (fGeometryEMCA->GetNStripZ()) ; | |
528 | Int_t col = (Int_t) TMath::Ceil((Double_t) iStrip/(fGeometryEMCA->GetNStripZ())) -1 ; | |
529 | ||
530 | // Absid for 8x2-strips. Looks nice :) | |
531 | absId = (module-1)*GetNCristalsInModule() + | |
532 | row * 2 + (col*fGeometryEMCA->GetNCellsXInStrip() + (icell - 1) / 2)*GetNZ() - (icell & 1 ? 1 : 0); | |
533 | ||
91daaf24 | 534 | } |
535 | ||
842988a5 | 536 | } |
537 | ||
538 | //____________________________________________________________________________ | |
7b7c1533 | 539 | void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) const |
d15a28e7 | 540 | { |
b2a60966 | 541 | // Converts the relative numbering into the local PHOS-module (x, z) coordinates |
52a36ffd | 542 | // Note: sign of z differs from that in the previous version (Yu.Kharlov, 12 Oct 2000) |
b2a60966 | 543 | |
d15a28e7 | 544 | |
91daaf24 | 545 | if (!gGeoManager){ |
546 | AliFatal("Geo manager not initialized\n"); | |
547 | } | |
548 | //construct module name | |
549 | char path[100] ; | |
550 | if(relid[1]==0){ //this is PHOS | |
551 | ||
552 | // Calculations using ideal geometry (obsolete) | |
553 | // x = - ( GetNPhi()/2. - relid[2] + 0.5 ) * GetCellStep() ; // position of Xtal with respect | |
554 | // z = - ( GetNZ() /2. - relid[3] + 0.5 ) * GetCellStep() ; // of center of PHOS module | |
555 | ||
fd6f5ab1 | 556 | Double_t pos[3]= {0.0,-fCryCellShift,0.}; //Position incide the crystal |
91daaf24 | 557 | Double_t posC[3]={0.0,0.0,0.}; //Global position |
558 | ||
559 | //Shift and possibly apply misalignment corrections | |
fd6f5ab1 | 560 | Int_t nCellsXInStrip=fGeometryEMCA->GetNCellsXInStrip() ; |
561 | Int_t nCellsZInStrip=fGeometryEMCA->GetNCellsZInStrip() ; | |
562 | // Int_t strip=1+(relid[3]-1)/fGeometryEMCA->GetNCellsZInStrip()+((relid[2]-1)/nCellsInStrip)*fGeometryEMCA->GetNStripZ() ; | |
563 | Int_t strip=1+((Int_t) TMath::Ceil((Double_t)relid[2]/nCellsXInStrip))*fGeometryEMCA->GetNStripZ()- | |
564 | (Int_t) TMath::Ceil((Double_t)relid[3]/nCellsZInStrip) ; | |
565 | Int_t cellraw= relid[3]%nCellsZInStrip ; | |
566 | if(cellraw==0)cellraw=nCellsZInStrip ; | |
567 | Int_t cell= ((relid[2]-1)%nCellsXInStrip)*nCellsZInStrip + cellraw ; | |
91daaf24 | 568 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d/PCEL_%d", |
569 | relid[0],strip,cell) ; | |
570 | if (!gGeoManager->cd(path)){ | |
571 | AliFatal("Geo manager can not find path \n"); | |
572 | } | |
573 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
574 | if (m) m->LocalToMaster(pos,posC); | |
575 | else{ | |
576 | AliFatal("Geo matrixes are not loaded \n") ; | |
577 | } | |
578 | //Return to PHOS local system | |
579 | Double_t posL[3]={posC[0],posC[1],posC[2]}; | |
580 | sprintf(path,"/ALIC_1/PHOS_%d",relid[0]) ; | |
581 | if (!gGeoManager->cd(path)){ | |
582 | AliFatal("Geo manager can not find path \n"); | |
583 | } | |
584 | TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix(); | |
585 | if (mPHOS) mPHOS->MasterToLocal(posC,posL); | |
586 | else{ | |
587 | AliFatal("Geo matrixes are not loaded \n") ; | |
588 | } | |
fd6f5ab1 | 589 | //printf("RelPosInMod: posL=[%f,%f,%f]\n",posL[0],posL[1],posL[2]) ; |
91daaf24 | 590 | //printf("old: x=%f, z=%f \n",x,z); |
591 | x=posL[0] ; | |
fd6f5ab1 | 592 | z=posL[1]; |
91daaf24 | 593 | return ; |
594 | } | |
595 | else{//CPV | |
596 | //first calculate position with respect to CPV plain | |
597 | Int_t row = relid[2] ; //offset along x axis | |
598 | Int_t column = relid[3] ; //offset along z axis | |
599 | Double_t pos[3]= {0.0,0.0,0.}; //Position incide the CPV printed circuit | |
600 | Double_t posC[3]={0.0,0.0,0.}; //Global position | |
601 | pos[0] = - ( GetNumberOfCPVPadsPhi()/2. - row - 0.5 ) * GetPadSizePhi() ; // position of pad with respect | |
602 | pos[2] = - ( GetNumberOfCPVPadsZ() /2. - column - 0.5 ) * GetPadSizeZ() ; // of center of PHOS module | |
603 | ||
604 | //now apply possible shifts and rotations | |
605 | sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",relid[0]) ; | |
606 | if (!gGeoManager->cd(path)){ | |
607 | AliFatal("Geo manager can not find path \n"); | |
608 | } | |
609 | TGeoHMatrix *m = gGeoManager->GetCurrentMatrix(); | |
610 | if (m) m->LocalToMaster(pos,posC); | |
611 | else{ | |
612 | AliFatal("Geo matrixes are not loaded \n") ; | |
613 | } | |
614 | //Return to PHOS local system | |
615 | Double_t posL[3]={0.,0.,0.,} ; | |
616 | sprintf(path,"/ALIC_1/PHOS_%d",relid[0]) ; | |
617 | if (!gGeoManager->cd(path)){ | |
618 | AliFatal("Geo manager can not find path \n"); | |
619 | } | |
620 | TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix(); | |
621 | if (mPHOS) mPHOS->MasterToLocal(posC,posL); | |
622 | else{ | |
623 | AliFatal("Geo matrixes are not loaded \n") ; | |
624 | } | |
625 | x=posL[0] ; | |
626 | z=posL[1]; | |
627 | return ; | |
628 | ||
52a36ffd | 629 | } |
91daaf24 | 630 | |
2f3366b6 | 631 | } |
aa0b9641 | 632 | |
633 | //____________________________________________________________________________ | |
634 | ||
7b51037f | 635 | void AliPHOSGeometry::GetModuleCenter(TVector3& center, |
636 | const char *det, | |
637 | Int_t module) const | |
aa0b9641 | 638 | { |
bfc17d18 | 639 | // Returns a position of the center of the CPV or EMC module |
91daaf24 | 640 | // in ideal (not misaligned) geometry |
1504ac47 | 641 | Float_t rDet = 0.; |
e77bb310 | 642 | if (strcmp(det,"CPV") == 0) rDet = GetIPtoCPVDistance (); |
643 | else if (strcmp(det,"EMC") == 0) rDet = GetIPtoCrystalSurface(); | |
351dd634 | 644 | else |
645 | AliFatal(Form("Wrong detector name %s",det)); | |
bfc17d18 | 646 | |
395f4eea | 647 | Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees |
648 | angle *= TMath::Pi()/180; | |
649 | angle += 3*TMath::Pi()/2.; | |
7b51037f | 650 | center.SetXYZ(rDet*TMath::Cos(angle), rDet*TMath::Sin(angle), 0.); |
aa0b9641 | 651 | } |
652 | ||
653 | //____________________________________________________________________________ | |
654 | ||
7b51037f | 655 | void AliPHOSGeometry::Global2Local(TVector3& localPosition, |
656 | const TVector3& globalPosition, | |
657 | Int_t module) const | |
aa0b9641 | 658 | { |
bfc17d18 | 659 | // Transforms a global position of the rec.point to the local coordinate system |
91daaf24 | 660 | //Return to PHOS local system |
8e20650f | 661 | Double_t posG[3]={globalPosition.X(),globalPosition.Y(),globalPosition.Z()} ; |
91daaf24 | 662 | Double_t posL[3]={0.,0.,0.} ; |
663 | char path[100] ; | |
753b19cd | 664 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",module) ; |
665 | // sprintf(path,"/ALIC_1/PHOS_%d",module) ; | |
91daaf24 | 666 | if (!gGeoManager->cd(path)){ |
667 | AliFatal("Geo manager can not find path \n"); | |
668 | } | |
669 | TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix(); | |
670 | if (mPHOS) mPHOS->MasterToLocal(posG,posL); | |
671 | else{ | |
672 | AliFatal("Geo matrixes are not loaded \n") ; | |
673 | } | |
8e20650f | 674 | localPosition.SetXYZ(posL[0],posL[1]+fCrystalShift,-posL[2]) ; |
91daaf24 | 675 | |
676 | /* | |
395f4eea | 677 | Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees |
678 | angle *= TMath::Pi()/180; | |
679 | angle += 3*TMath::Pi()/2.; | |
7b51037f | 680 | localPosition = globalPosition; |
681 | localPosition.RotateZ(-angle); | |
91daaf24 | 682 | */ |
683 | } | |
684 | //____________________________________________________________________________ | |
685 | void AliPHOSGeometry::Local2Global(Int_t mod, Float_t x, Float_t z, | |
686 | TVector3& globalPosition) const | |
687 | { | |
688 | char path[100] ; | |
689 | sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",mod) ; | |
8e20650f | 690 | // sprintf(path,"/ALIC_1/PHOS_%d",mod) ; |
91daaf24 | 691 | if (!gGeoManager->cd(path)){ |
692 | AliFatal("Geo manager can not find path \n"); | |
693 | } | |
8e20650f | 694 | Double_t posL[3]={x,-fCrystalShift,-z} ; //Only for EMC!!! |
91daaf24 | 695 | Double_t posG[3] ; |
696 | TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix(); | |
8e20650f | 697 | if (mPHOS){ |
698 | mPHOS->LocalToMaster(posL,posG); | |
699 | } | |
91daaf24 | 700 | else{ |
701 | AliFatal("Geo matrixes are not loaded \n") ; | |
702 | } | |
8e20650f | 703 | globalPosition.SetXYZ(posG[0],posG[1],posG[2]) ; |
91daaf24 | 704 | } |
705 | //____________________________________________________________________________ | |
407d15b3 | 706 | void AliPHOSGeometry::GetIncidentVector(const TVector3 &vtx, Int_t module, Float_t x,Float_t z, TVector3 &vInc) const { |
91daaf24 | 707 | //Calculates vector pointing from vertex to current poisition in module local frame |
022ee411 | 708 | //Note that PHOS local system and ALICE global have opposite z directions |
91daaf24 | 709 | |
753b19cd | 710 | Global2Local(vInc,vtx,module) ; |
8e20650f | 711 | vInc.SetXYZ(vInc.X()+x,vInc.Y(),vInc.Z()+z) ; |
aa0b9641 | 712 | } |