]>
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 | // |
710f859a | 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" |
d15a28e7 | 34 | |
35 | // --- Standard library --- | |
36 | ||
d15a28e7 | 37 | // --- AliRoot header files --- |
38 | ||
39 | #include "AliPHOSGeometry.h" | |
468794ea | 40 | #include "AliPHOSEMCAGeometry.h" |
710f859a | 41 | #include "AliPHOSRecPoint.h" |
d15a28e7 | 42 | |
9ec91567 | 43 | ClassImp(AliPHOSGeometry) ; |
d15a28e7 | 44 | |
a4e98857 | 45 | // these initialisations are needed for a singleton |
9ec91567 | 46 | AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ; |
282c5906 | 47 | Bool_t AliPHOSGeometry::fgInit = kFALSE ; |
9ec91567 | 48 | |
e957fea8 | 49 | //____________________________________________________________________________ |
50 | AliPHOSGeometry::AliPHOSGeometry() { | |
51 | // default ctor | |
52 | // must be kept public for root persistency purposes, but should never be called by the outside world | |
53 | fPHOSAngle = 0 ; | |
54 | fGeometryEMCA = 0 ; | |
55 | fGeometrySUPP = 0 ; | |
56 | fGeometryCPV = 0 ; | |
57 | fgGeom = 0 ; | |
58 | fRotMatrixArray = 0 ; | |
59 | } | |
60 | ||
d15a28e7 | 61 | //____________________________________________________________________________ |
62 | AliPHOSGeometry::~AliPHOSGeometry(void) | |
63 | { | |
b2a60966 | 64 | // dtor |
65 | ||
52a36ffd | 66 | if (fRotMatrixArray) fRotMatrixArray->Delete() ; |
67 | if (fRotMatrixArray) delete fRotMatrixArray ; | |
fa0bc588 | 68 | if (fPHOSAngle ) delete[] fPHOSAngle ; |
52a36ffd | 69 | } |
52a36ffd | 70 | //____________________________________________________________________________ |
71 | ||
72 | void AliPHOSGeometry::Init(void) | |
73 | { | |
a4e98857 | 74 | // Initializes the PHOS parameters : |
75 | // IHEP is the Protvino CPV (cathode pad chambers) | |
710f859a | 76 | |
809cd394 | 77 | TString test(GetName()) ; |
22b8277f | 78 | if (test != "IHEP" ) { |
79 | Fatal("Init", "%s is not a known geometry (choose among IHEP)", test.Data() ) ; | |
809cd394 | 80 | } |
81 | ||
710f859a | 82 | fgInit = kTRUE ; |
83 | ||
84 | fNModules = 5; | |
85 | fAngle = 20; | |
86 | ||
87 | fGeometryEMCA = new AliPHOSEMCAGeometry(); | |
88 | ||
89 | fGeometryCPV = new AliPHOSCPVGeometry (); | |
90 | ||
91 | fGeometrySUPP = new AliPHOSSupportGeometry(); | |
92 | ||
93 | fPHOSAngle = new Float_t[fNModules] ; | |
94 | ||
95 | Float_t * emcParams = fGeometryEMCA->GetEMCParams() ; | |
96 | ||
581e32d4 | 97 | fPHOSParams[0] = TMath::Max((Double_t)fGeometryCPV->GetCPVBoxSize(0)/2., |
a83b6179 | 98 | (Double_t)(emcParams[0] - (emcParams[1]-emcParams[0])* |
99 | fGeometryCPV->GetCPVBoxSize(1)/2/emcParams[3])); | |
710f859a | 100 | fPHOSParams[1] = emcParams[1] ; |
581e32d4 | 101 | fPHOSParams[2] = TMath::Max((Double_t)emcParams[2], (Double_t)fGeometryCPV->GetCPVBoxSize(2)/2.); |
710f859a | 102 | fPHOSParams[3] = emcParams[3] + fGeometryCPV->GetCPVBoxSize(1)/2. ; |
103 | ||
104 | fIPtoUpperCPVsurface = fGeometryEMCA->GetIPtoOuterCoverDistance() - fGeometryCPV->GetCPVBoxSize(1) ; | |
105 | ||
106 | Int_t index ; | |
107 | for ( index = 0; index < fNModules; index++ ) | |
52a36ffd | 108 | fPHOSAngle[index] = 0.0 ; // Module position angles are set in CreateGeometry() |
710f859a | 109 | |
110 | this->SetPHOSAngles() ; | |
111 | fRotMatrixArray = new TObjArray(fNModules) ; | |
112 | ||
52a36ffd | 113 | } |
114 | ||
115 | //____________________________________________________________________________ | |
116 | AliPHOSGeometry * AliPHOSGeometry::GetInstance() | |
117 | { | |
a4e98857 | 118 | // Returns the pointer of the unique instance; singleton specific |
119 | ||
809cd394 | 120 | return static_cast<AliPHOSGeometry *>( fgGeom ) ; |
52a36ffd | 121 | } |
122 | ||
123 | //____________________________________________________________________________ | |
124 | AliPHOSGeometry * AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t* title) | |
125 | { | |
126 | // Returns the pointer of the unique instance | |
a4e98857 | 127 | // Creates it with the specified options (name, title) if it does not exist yet |
128 | ||
52a36ffd | 129 | AliPHOSGeometry * rv = 0 ; |
130 | if ( fgGeom == 0 ) { | |
131 | if ( strcmp(name,"") == 0 ) | |
132 | rv = 0 ; | |
133 | else { | |
134 | fgGeom = new AliPHOSGeometry(name, title) ; | |
135 | if ( fgInit ) | |
136 | rv = (AliPHOSGeometry * ) fgGeom ; | |
137 | else { | |
138 | rv = 0 ; | |
139 | delete fgGeom ; | |
140 | fgGeom = 0 ; | |
141 | } | |
142 | } | |
143 | } | |
144 | else { | |
21cd0c07 | 145 | if ( strcmp(fgGeom->GetName(), name) != 0 ) |
146 | ::Error("GetInstance", "Current geometry is %s. You cannot call %s", fgGeom->GetName(), name) ; | |
52a36ffd | 147 | else |
148 | rv = (AliPHOSGeometry *) fgGeom ; | |
149 | } | |
150 | return rv ; | |
151 | } | |
4697edca | 152 | |
52a36ffd | 153 | //____________________________________________________________________________ |
154 | void AliPHOSGeometry::SetPHOSAngles() | |
155 | { | |
a4e98857 | 156 | // Calculates the position of the PHOS modules in ALICE global coordinate system |
52a36ffd | 157 | |
a8c47ab6 | 158 | Double_t const kRADDEG = 180.0 / TMath::Pi() ; |
710f859a | 159 | Float_t pphi = 2 * TMath::ATan( GetOuterBoxSize(0) / ( 2.0 * GetIPtoUpperCPVsurface() ) ) ; |
52a36ffd | 160 | pphi *= kRADDEG ; |
710f859a | 161 | if (pphi > fAngle){ |
21cd0c07 | 162 | Error("SetPHOSAngles", "PHOS modules overlap!\n pphi = %f fAngle = %f", pphi, fAngle); |
710f859a | 163 | |
164 | } | |
ed4205d8 | 165 | pphi = fAngle; |
52a36ffd | 166 | |
167 | for( Int_t i = 1; i <= fNModules ; i++ ) { | |
ed4205d8 | 168 | Float_t angle = pphi * ( i - fNModules / 2.0 - 0.5 ) ; |
52a36ffd | 169 | fPHOSAngle[i-1] = - angle ; |
170 | } | |
d15a28e7 | 171 | } |
172 | ||
173 | //____________________________________________________________________________ | |
fc7e2f43 | 174 | Bool_t AliPHOSGeometry::AbsToRelNumbering(Int_t AbsId, Int_t * relid) const |
d15a28e7 | 175 | { |
b2a60966 | 176 | // Converts the absolute numbering into the following array/ |
177 | // relid[0] = PHOS Module number 1:fNModules | |
178 | // relid[1] = 0 if PbW04 | |
710f859a | 179 | // = -1 if CPV |
180 | // relid[2] = Row number inside a PHOS module | |
181 | // relid[3] = Column number inside a PHOS module | |
d15a28e7 | 182 | |
183 | Bool_t rv = kTRUE ; | |
92862013 | 184 | Float_t id = AbsId ; |
d15a28e7 | 185 | |
710f859a | 186 | Int_t phosmodulenumber = (Int_t)TMath:: Ceil( id / GetNCristalsInModule() ) ; |
d15a28e7 | 187 | |
710f859a | 188 | if ( phosmodulenumber > GetNModules() ) { // it is a CPV pad |
189 | ||
190 | id -= GetNPhi() * GetNZ() * GetNModules() ; | |
191 | Float_t nCPV = GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() ; | |
192 | relid[0] = (Int_t) TMath::Ceil( id / nCPV ) ; | |
193 | relid[1] = -1 ; | |
194 | id -= ( relid[0] - 1 ) * nCPV ; | |
195 | relid[2] = (Int_t) TMath::Ceil( id / GetNumberOfCPVPadsZ() ) ; | |
196 | relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() ) ; | |
d15a28e7 | 197 | } |
710f859a | 198 | else { // it is a PW04 crystal |
d15a28e7 | 199 | |
92862013 | 200 | relid[0] = phosmodulenumber ; |
201 | relid[1] = 0 ; | |
202 | id -= ( phosmodulenumber - 1 ) * GetNPhi() * GetNZ() ; | |
710f859a | 203 | relid[2] = (Int_t)TMath::Ceil( id / GetNZ() ) ; |
204 | relid[3] = (Int_t)( id - ( relid[2] - 1 ) * GetNZ() ) ; | |
d15a28e7 | 205 | } |
206 | return rv ; | |
207 | } | |
52a36ffd | 208 | |
9f616d61 | 209 | //____________________________________________________________________________ |
fc7e2f43 | 210 | void AliPHOSGeometry::EmcModuleCoverage(Int_t mod, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt) const |
9f616d61 | 211 | { |
a4e98857 | 212 | // calculates the angular coverage in theta and phi of one EMC (=PHOS) module |
9f616d61 | 213 | |
214 | Double_t conv ; | |
cf0c2bc1 | 215 | if ( opt == Radian() ) |
9f616d61 | 216 | conv = 1. ; |
cf0c2bc1 | 217 | else if ( opt == Degre() ) |
9f616d61 | 218 | conv = 180. / TMath::Pi() ; |
219 | else { | |
21cd0c07 | 220 | Warning("EmcModuleCoverage", "%s unknown option; result in radian", opt) ; |
9f616d61 | 221 | conv = 1. ; |
222 | } | |
223 | ||
710f859a | 224 | Float_t phi = GetPHOSAngle(mod) * (TMath::Pi() / 180.) ; |
225 | Float_t y0 = GetIPtoCrystalSurface() ; | |
88cb7938 | 226 | Float_t * strip = fGeometryEMCA->GetStripHalfSize() ; |
227 | Float_t x0 = fGeometryEMCA->GetNStripX()*strip[0] ; | |
228 | Float_t z0 = fGeometryEMCA->GetNStripZ()*strip[2] ; | |
229 | Double_t angle = TMath::ATan( x0 / y0 ) ; | |
710f859a | 230 | phi = phi + 1.5 * TMath::Pi() ; // to follow the convention of the particle generator(PHOS is between 220 and 320 deg.) |
92862013 | 231 | Double_t max = phi - angle ; |
232 | Double_t min = phi + angle ; | |
233 | pM = TMath::Max(max, min) * conv ; | |
234 | pm = TMath::Min(max, min) * conv ; | |
9f616d61 | 235 | |
88cb7938 | 236 | angle = TMath::ATan( z0 / y0 ) ; |
92862013 | 237 | max = TMath::Pi() / 2. + angle ; // to follow the convention of the particle generator(PHOS is at 90 deg.) |
238 | min = TMath::Pi() / 2. - angle ; | |
239 | tM = TMath::Max(max, min) * conv ; | |
240 | tm = TMath::Min(max, min) * conv ; | |
9f616d61 | 241 | |
242 | } | |
243 | ||
244 | //____________________________________________________________________________ | |
7b7c1533 | 245 | void AliPHOSGeometry::EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t * opt) const |
9f616d61 | 246 | { |
a4e98857 | 247 | // calculates the angular coverage in theta and phi of a single crystal in a EMC(=PHOS) module |
9f616d61 | 248 | |
249 | Double_t conv ; | |
cf0c2bc1 | 250 | if ( opt == Radian() ) |
9f616d61 | 251 | conv = 1. ; |
cf0c2bc1 | 252 | else if ( opt == Degre() ) |
9f616d61 | 253 | conv = 180. / TMath::Pi() ; |
254 | else { | |
21cd0c07 | 255 | Warning("EmcXtalCoverage", "%s unknown option; result in radian", opt) ; |
9f616d61 | 256 | conv = 1. ; |
257 | } | |
258 | ||
710f859a | 259 | Float_t y0 = GetIPtoCrystalSurface() ; |
92862013 | 260 | theta = 2 * TMath::ATan( GetCrystalSize(2) / (2 * y0) ) * conv ; |
261 | phi = 2 * TMath::ATan( GetCrystalSize(0) / (2 * y0) ) * conv ; | |
9f616d61 | 262 | } |
263 | ||
264 | ||
265 | //____________________________________________________________________________ | |
4c7fd00f | 266 | void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos, TMatrix & /*gmat*/) const |
d15a28e7 | 267 | { |
a4e98857 | 268 | // Calculates the coordinates of a RecPoint and the error matrix in the ALICE global coordinate system |
b2a60966 | 269 | |
d15a28e7 | 270 | AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ; |
92862013 | 271 | TVector3 localposition ; |
d15a28e7 | 272 | |
273 | tmpPHOS->GetLocalPosition(gpos) ; | |
274 | ||
275 | ||
276 | if ( tmpPHOS->IsEmc() ) // it is a EMC crystal | |
710f859a | 277 | { gpos.SetY( - GetIPtoCrystalSurface()) ; |
d15a28e7 | 278 | |
279 | } | |
280 | else | |
710f859a | 281 | { // it is a CPV |
282 | gpos.SetY(- GetIPtoUpperCPVsurface() ) ; | |
d15a28e7 | 283 | } |
284 | ||
92862013 | 285 | Float_t phi = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ; |
a8c47ab6 | 286 | Double_t const kRADDEG = 180.0 / TMath::Pi() ; |
92862013 | 287 | Float_t rphi = phi / kRADDEG ; |
d15a28e7 | 288 | |
92862013 | 289 | TRotation rot ; |
290 | rot.RotateZ(-rphi) ; // a rotation around Z by angle | |
d15a28e7 | 291 | |
92862013 | 292 | TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame |
293 | gpos.Transform(rot) ; // rotate the baby | |
6ad0bfa0 | 294 | |
d15a28e7 | 295 | } |
296 | ||
297 | //____________________________________________________________________________ | |
5cda30f6 | 298 | void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos) const |
d15a28e7 | 299 | { |
a4e98857 | 300 | // Calculates the coordinates of a RecPoint in the ALICE global coordinate system |
b2a60966 | 301 | |
d15a28e7 | 302 | AliPHOSRecPoint * tmpPHOS = (AliPHOSRecPoint *) RecPoint ; |
92862013 | 303 | TVector3 localposition ; |
d15a28e7 | 304 | tmpPHOS->GetLocalPosition(gpos) ; |
305 | ||
306 | ||
307 | if ( tmpPHOS->IsEmc() ) // it is a EMC crystal | |
710f859a | 308 | { gpos.SetY( - GetIPtoCrystalSurface() ) ; |
d15a28e7 | 309 | } |
310 | else | |
710f859a | 311 | { // it is a CPV |
312 | gpos.SetY(- GetIPtoUpperCPVsurface() ) ; | |
d15a28e7 | 313 | } |
314 | ||
92862013 | 315 | Float_t phi = GetPHOSAngle( tmpPHOS->GetPHOSMod()) ; |
a8c47ab6 | 316 | Double_t const kRADDEG = 180.0 / TMath::Pi() ; |
92862013 | 317 | Float_t rphi = phi / kRADDEG ; |
d15a28e7 | 318 | |
92862013 | 319 | TRotation rot ; |
320 | rot.RotateZ(-rphi) ; // a rotation around Z by angle | |
d15a28e7 | 321 | |
92862013 | 322 | TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame |
323 | gpos.Transform(rot) ; // rotate the baby | |
d15a28e7 | 324 | } |
325 | ||
326 | //____________________________________________________________________________ | |
aa35fc01 | 327 | void AliPHOSGeometry::ImpactOnEmc(Double_t theta, Double_t phi, Int_t & moduleNumber, Double_t & z, Double_t & x) const |
d15a28e7 | 328 | { |
a4e98857 | 329 | // calculates the impact coordinates on PHOS of a neutral particle |
330 | // emitted in the direction theta and phi in the ALICE global coordinate system | |
d15a28e7 | 331 | |
52a36ffd | 332 | // searches for the PHOS EMC module |
aa35fc01 | 333 | |
334 | moduleNumber = 0 ; | |
52a36ffd | 335 | Double_t tm, tM, pm, pM ; |
336 | Int_t index = 1 ; | |
aa35fc01 | 337 | while ( moduleNumber == 0 && index <= GetNModules() ) { |
52a36ffd | 338 | EmcModuleCoverage(index, tm, tM, pm, pM) ; |
88cb7938 | 339 | if ( (theta >= tm && theta <= tM) && (phi >= pm && phi <= pM ) ) |
aa35fc01 | 340 | moduleNumber = index ; |
52a36ffd | 341 | index++ ; |
d15a28e7 | 342 | } |
aa35fc01 | 343 | if ( moduleNumber != 0 ) { |
344 | Float_t phi0 = GetPHOSAngle(moduleNumber) * (TMath::Pi() / 180.) + 1.5 * TMath::Pi() ; | |
710f859a | 345 | Float_t y0 = GetIPtoCrystalSurface() ; |
88cb7938 | 346 | Double_t angle = phi - phi0; |
52a36ffd | 347 | x = y0 * TMath::Tan(angle) ; |
348 | angle = theta - TMath::Pi() / 2 ; | |
349 | z = y0 * TMath::Tan(angle) ; | |
d15a28e7 | 350 | } |
d15a28e7 | 351 | } |
352 | ||
aa35fc01 | 353 | //____________________________________________________________________________ |
354 | void AliPHOSGeometry::ImpactOnEmc(TVector3 vec, Int_t & moduleNumber, Double_t & z, Double_t & x) const | |
355 | { | |
356 | // calculates the impact coordinates on PHOS of a neutral particle | |
357 | // emitted in the direction theta and phi in the ALICE global coordinate system | |
358 | // searches for the PHOS EMC module | |
359 | ||
360 | TParticle p ; | |
361 | p.SetMomentum(vec.X(), vec.Y(), vec.Z(), 0.) ; | |
362 | ||
363 | ImpactOnEmc(p, moduleNumber, z, x) ; | |
364 | } | |
365 | ||
366 | //____________________________________________________________________________ | |
367 | void AliPHOSGeometry::ImpactOnEmc(TParticle p, Int_t & moduleNumber, Double_t & z, Double_t & x) const | |
368 | { | |
369 | // calculates the impact coordinates on PHOS of a neutral particle | |
370 | // emitted in the direction theta and phi in the ALICE global coordinate system | |
371 | ||
372 | // searches for the PHOS EMC module | |
373 | Double_t theta = p.Theta() ; | |
374 | Double_t phi = p.Phi() ; | |
375 | ||
376 | ImpactOnEmc(theta, phi, moduleNumber, z, x) ; | |
377 | } | |
378 | ||
e957fea8 | 379 | //____________________________________________________________________________ |
1c9d8212 | 380 | Bool_t AliPHOSGeometry::Impact(const TParticle * particle) const |
381 | { | |
e957fea8 | 382 | // Tells if a particle enters PHOS |
383 | Bool_t in=kFALSE; | |
384 | Int_t moduleNumber=0; | |
1c9d8212 | 385 | Double_t z,x; |
e957fea8 | 386 | ImpactOnEmc(particle->Theta(),particle->Phi(),moduleNumber,z,x); |
387 | if(moduleNumber) | |
388 | in=kTRUE; | |
389 | else | |
390 | in=kFALSE; | |
391 | return in; | |
1c9d8212 | 392 | } |
393 | ||
d15a28e7 | 394 | //____________________________________________________________________________ |
7b7c1533 | 395 | Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t & AbsId) const |
d15a28e7 | 396 | { |
b2a60966 | 397 | // Converts the relative numbering into the absolute numbering |
ed4205d8 | 398 | // EMCA crystals: |
399 | // AbsId = from 1 to fNModules * fNPhi * fNZ | |
ed4205d8 | 400 | // CPV pad: |
401 | // AbsId = from N(total PHOS crystals) + 1 | |
402 | // to NCPVModules * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ | |
d15a28e7 | 403 | |
404 | Bool_t rv = kTRUE ; | |
710f859a | 405 | |
406 | if ( relid[1] == 0 ) { // it is a Phos crystal | |
52a36ffd | 407 | AbsId = |
710f859a | 408 | ( relid[0] - 1 ) * GetNPhi() * GetNZ() // the offset of PHOS modules |
409 | + ( relid[2] - 1 ) * GetNZ() // the offset along phi | |
410 | + relid[3] ; // the offset along z | |
d15a28e7 | 411 | } |
710f859a | 412 | else { // it is a CPV pad |
413 | AbsId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate EMCA crystals from CPV pads | |
414 | + ( relid[0] - 1 ) * GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() // the pads offset of PHOS modules | |
415 | + ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() // the pads offset of a CPV row | |
52a36ffd | 416 | + relid[3] ; // the column number |
417 | } | |
418 | ||
d15a28e7 | 419 | return rv ; |
420 | } | |
421 | ||
422 | //____________________________________________________________________________ | |
423 | ||
fc7e2f43 | 424 | void AliPHOSGeometry::RelPosInAlice(Int_t id, TVector3 & pos ) const |
d15a28e7 | 425 | { |
a4e98857 | 426 | // Converts the absolute numbering into the global ALICE coordinate system |
b2a60966 | 427 | |
ed4205d8 | 428 | |
429 | Int_t relid[4] ; | |
430 | ||
431 | AbsToRelNumbering(id , relid) ; | |
432 | ||
433 | Int_t phosmodule = relid[0] ; | |
434 | ||
435 | Float_t y0 = 0 ; | |
436 | ||
710f859a | 437 | if ( relid[1] == 0 ) // it is a PbW04 crystal |
438 | y0 = - GetIPtoCrystalSurface() ; | |
439 | else | |
440 | y0 = - GetIPtoUpperCPVsurface() ; | |
441 | ||
ed4205d8 | 442 | Float_t x, z ; |
443 | RelPosInModule(relid, x, z) ; | |
444 | ||
445 | pos.SetX(x) ; | |
446 | pos.SetZ(z) ; | |
710f859a | 447 | pos.SetY(y0) ; |
ed4205d8 | 448 | |
449 | Float_t phi = GetPHOSAngle( phosmodule) ; | |
a8c47ab6 | 450 | Double_t const kRADDEG = 180.0 / TMath::Pi() ; |
ed4205d8 | 451 | Float_t rphi = phi / kRADDEG ; |
452 | ||
453 | TRotation rot ; | |
454 | rot.RotateZ(-rphi) ; // a rotation around Z by angle | |
455 | ||
456 | TRotation dummy = rot.Invert() ; // to transform from original frame to rotate frame | |
457 | ||
458 | pos.Transform(rot) ; // rotate the baby | |
d15a28e7 | 459 | } |
460 | ||
461 | //____________________________________________________________________________ | |
842988a5 | 462 | void AliPHOSGeometry::RelPosToAbsId(const Int_t module, const Double_t x, const Double_t z, Int_t & AbsId) const |
463 | { | |
464 | // converts local PHOS-module (x, z) coordinates to absId | |
465 | Int_t relid[4] ; | |
466 | relid[0] = module ; | |
467 | relid[1] = 0 ; | |
468 | relid[2] = static_cast<Int_t>(TMath::Ceil( x/ GetCellStep() + GetNPhi() / 2.) ); | |
469 | relid[3] = static_cast<Int_t>(TMath::Ceil(-z/ GetCellStep() + GetNZ() / 2.) ) ; | |
470 | ||
471 | RelToAbsNumbering(relid,AbsId) ; | |
472 | } | |
473 | ||
474 | //____________________________________________________________________________ | |
7b7c1533 | 475 | void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) const |
d15a28e7 | 476 | { |
b2a60966 | 477 | // Converts the relative numbering into the local PHOS-module (x, z) coordinates |
52a36ffd | 478 | // Note: sign of z differs from that in the previous version (Yu.Kharlov, 12 Oct 2000) |
b2a60966 | 479 | |
786222b3 | 480 | Int_t row = relid[2] ; //offset along x axis |
481 | Int_t column = relid[3] ; //offset along z axis | |
d15a28e7 | 482 | |
ed4205d8 | 483 | |
66c3e8ff | 484 | if ( relid[1] == 0 ) { // its a PbW04 crystal |
485 | x = - ( GetNPhi()/2. - row + 0.5 ) * GetCellStep() ; // position of Xtal with respect | |
4a76d472 | 486 | z = - ( GetNZ() /2. - column + 0.5 ) * GetCellStep() ; // of center of PHOS module |
52a36ffd | 487 | } |
488 | else { | |
710f859a | 489 | x = - ( GetNumberOfCPVPadsPhi()/2. - row - 0.5 ) * GetPadSizePhi() ; // position of pad with respect |
4a76d472 | 490 | z = - ( GetNumberOfCPVPadsZ() /2. - column - 0.5 ) * GetPadSizeZ() ; // of center of PHOS module |
52a36ffd | 491 | } |
2f3366b6 | 492 | } |
aa0b9641 | 493 | |
494 | //____________________________________________________________________________ | |
495 | ||
bfc17d18 | 496 | TVector3 AliPHOSGeometry::GetModuleCenter(char *det, Int_t module) const |
aa0b9641 | 497 | { |
bfc17d18 | 498 | // Returns a position of the center of the CPV or EMC module |
1504ac47 | 499 | Float_t rDet = 0.; |
e77bb310 | 500 | if (strcmp(det,"CPV") == 0) rDet = GetIPtoCPVDistance (); |
501 | else if (strcmp(det,"EMC") == 0) rDet = GetIPtoCrystalSurface(); | |
bfc17d18 | 502 | else Fatal("GetModuleCenter","Wrong detector name %s",det); |
503 | ||
395f4eea | 504 | Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees |
505 | angle *= TMath::Pi()/180; | |
506 | angle += 3*TMath::Pi()/2.; | |
bfc17d18 | 507 | return TVector3(rDet*TMath::Cos(angle), rDet*TMath::Sin(angle), 0.); |
aa0b9641 | 508 | } |
509 | ||
510 | //____________________________________________________________________________ | |
511 | ||
bfc17d18 | 512 | TVector3 AliPHOSGeometry::Global2Local(TVector3 globalPosition, Int_t module) const |
aa0b9641 | 513 | { |
bfc17d18 | 514 | // Transforms a global position of the rec.point to the local coordinate system |
395f4eea | 515 | Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees |
516 | angle *= TMath::Pi()/180; | |
517 | angle += 3*TMath::Pi()/2.; | |
aa0b9641 | 518 | globalPosition.RotateZ(-angle); |
395f4eea | 519 | return TVector3(globalPosition.Y(),globalPosition.X(),globalPosition.Z()); |
aa0b9641 | 520 | } |