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