1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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.
27 // -- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC "KI" & SUBATECH)
29 // --- ROOT system ---
32 #include "TRotation.h"
33 #include "TParticle.h"
34 #include <TGeoManager.h>
36 // --- Standard library ---
38 // --- AliRoot header files ---
40 #include "AliPHOSGeometry.h"
41 #include "AliPHOSEMCAGeometry.h"
42 #include "AliPHOSRecPoint.h"
44 ClassImp(AliPHOSGeometry)
46 // these initialisations are needed for a singleton
47 AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ;
48 Bool_t AliPHOSGeometry::fgInit = kFALSE ;
50 //____________________________________________________________________________
51 AliPHOSGeometry::AliPHOSGeometry() :
55 fIPtoUpperCPVsurface(0),
62 // must be kept public for root persistency purposes, but should never be called by the outside world
66 //____________________________________________________________________________
67 AliPHOSGeometry::AliPHOSGeometry(const AliPHOSGeometry & rhs)
69 fNModules(rhs.fNModules),
72 fIPtoUpperCPVsurface(rhs.fIPtoUpperCPVsurface),
78 Fatal("cpy ctor", "not implemented") ;
81 //____________________________________________________________________________
82 AliPHOSGeometry::AliPHOSGeometry(const Text_t* name, const Text_t* title)
83 : AliGeometry(name, title),
87 fIPtoUpperCPVsurface(0),
93 // ctor only for internal usage (singleton)
97 //____________________________________________________________________________
98 AliPHOSGeometry::~AliPHOSGeometry(void)
102 if (fRotMatrixArray) fRotMatrixArray->Delete() ;
103 if (fRotMatrixArray) delete fRotMatrixArray ;
104 if (fPHOSAngle ) delete[] fPHOSAngle ;
107 //____________________________________________________________________________
108 void AliPHOSGeometry::Init(void)
110 // Initializes the PHOS parameters :
111 // IHEP is the Protvino CPV (cathode pad chambers)
113 TString test(GetName()) ;
114 if (test != "IHEP" && test != "noCPV") {
115 AliFatal(Form("%s is not a known geometry (choose among IHEP)",
124 fGeometryEMCA = new AliPHOSEMCAGeometry();
126 fGeometryCPV = new AliPHOSCPVGeometry ();
128 fGeometrySUPP = new AliPHOSSupportGeometry();
130 fPHOSAngle = new Float_t[fNModules] ;
132 Float_t * emcParams = fGeometryEMCA->GetEMCParams() ;
134 fPHOSParams[0] = TMath::Max((Double_t)fGeometryCPV->GetCPVBoxSize(0)/2.,
135 (Double_t)(emcParams[0] - (emcParams[1]-emcParams[0])*
136 fGeometryCPV->GetCPVBoxSize(1)/2/emcParams[3]));
137 fPHOSParams[1] = emcParams[1] ;
138 fPHOSParams[2] = TMath::Max((Double_t)emcParams[2], (Double_t)fGeometryCPV->GetCPVBoxSize(2)/2.);
139 fPHOSParams[3] = emcParams[3] + fGeometryCPV->GetCPVBoxSize(1)/2. ;
141 fIPtoUpperCPVsurface = fGeometryEMCA->GetIPtoOuterCoverDistance() - fGeometryCPV->GetCPVBoxSize(1) ;
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;
154 for ( index = 0; index < fNModules; index++ )
155 fPHOSAngle[index] = 0.0 ; // Module position angles are set in CreateGeometry()
157 fRotMatrixArray = new TObjArray(fNModules) ;
159 // Geometry parameters are calculated
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.;
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];
179 //____________________________________________________________________________
180 AliPHOSGeometry * AliPHOSGeometry::GetInstance()
182 // Returns the pointer of the unique instance; singleton specific
184 return static_cast<AliPHOSGeometry *>( fgGeom ) ;
187 //____________________________________________________________________________
188 AliPHOSGeometry * AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t* title)
190 // Returns the pointer of the unique instance
191 // Creates it with the specified options (name, title) if it does not exist yet
193 AliPHOSGeometry * rv = 0 ;
195 if ( strcmp(name,"") == 0 )
198 fgGeom = new AliPHOSGeometry(name, title) ;
200 rv = (AliPHOSGeometry * ) fgGeom ;
209 if ( strcmp(fgGeom->GetName(), name) != 0 )
210 ::Error("GetInstance", "Current geometry is %s. You cannot call %s",
211 fgGeom->GetName(), name) ;
213 rv = (AliPHOSGeometry *) fgGeom ;
218 //____________________________________________________________________________
219 void AliPHOSGeometry::SetPHOSAngles()
221 // Calculates the position of the PHOS modules in ALICE global coordinate system
224 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
225 Float_t pphi = 2 * TMath::ATan( GetOuterBoxSize(0) / ( 2.0 * GetIPtoUpperCPVsurface() ) ) ;
228 AliError(Form("PHOS modules overlap!\n pphi = %f fAngle = %f",
234 for( Int_t i = 1; i <= fNModules ; i++ ) {
235 Float_t angle = pphi * ( i - fNModules / 2.0 - 0.5 ) ;
236 fPHOSAngle[i-1] = - angle ;
240 //____________________________________________________________________________
241 Bool_t AliPHOSGeometry::AbsToRelNumbering(Int_t AbsId, Int_t * relid) const
243 // Converts the absolute numbering into the following array
244 // relid[0] = PHOS Module number 1:fNModules
245 // relid[1] = 0 if PbW04
247 // relid[2] = Row number inside a PHOS module
248 // relid[3] = Column number inside a PHOS module
253 Int_t phosmodulenumber = (Int_t)TMath:: Ceil( id / GetNCristalsInModule() ) ;
255 if ( phosmodulenumber > GetNModules() ) { // it is a CPV pad
257 id -= GetNPhi() * GetNZ() * GetNModules() ;
258 Float_t nCPV = GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() ;
259 relid[0] = (Int_t) TMath::Ceil( id / nCPV ) ;
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() ) ;
265 else { // it is a PW04 crystal
267 relid[0] = phosmodulenumber ;
269 id -= ( phosmodulenumber - 1 ) * GetNPhi() * GetNZ() ;
270 relid[2] = (Int_t)TMath::Ceil( id / GetNZ() ) ;
271 relid[3] = (Int_t)( id - ( relid[2] - 1 ) * GetNZ() ) ;
275 //____________________________________________________________________________
276 void AliPHOSGeometry::GetGlobal(const AliRecPoint* recPoint, TVector3 & gpos) const
278 AliFatal(Form("Please use GetGlobalPHOS(recPoint,gpos) instead of GetGlobal!"));
281 //____________________________________________________________________________
282 void AliPHOSGeometry::GetGlobalPHOS(const AliPHOSRecPoint* recPoint, TVector3 & gpos) const
284 // Calculates the coordinates of a RecPoint and the error matrix in the ALICE global coordinate system
286 const AliPHOSRecPoint * tmpPHOS = recPoint ;
287 TVector3 localposition ;
289 tmpPHOS->GetLocalPosition(gpos) ;
292 AliFatal("Geo manager not initialized\n");
294 //construct module name
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()) ;
299 // sprintf(path,"/ALIC_1/PHOS_%d",tmpPHOS->GetPHOSMod()) ;
303 sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",tmpPHOS->GetPHOSMod()) ;
304 dy= GetCPVBoxSize(1)/2. ; //center of CPV module
306 Double_t pos[3]={gpos.X(),gpos.Y()-dy,gpos.Z()} ;
308 pos[2]=-pos[2] ; //Opposite z directions in EMC matrix and local frame!!!
310 //now apply possible shifts and rotations
311 if (!gGeoManager->cd(path)){
312 AliFatal("Geo manager can not find path \n");
314 TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
316 m->LocalToMaster(pos,posC);
319 AliFatal("Geo matrixes are not loaded \n") ;
321 gpos.SetXYZ(posC[0],posC[1],posC[2]) ;
324 //____________________________________________________________________________
325 void AliPHOSGeometry::ImpactOnEmc(Double_t * vtx, Double_t theta, Double_t phi,
326 Int_t & moduleNumber, Double_t & z, Double_t & x) const
328 // calculates the impact coordinates on PHOS of a neutral particle
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)) ;
331 TVector3 v(vtx[0],vtx[1],vtx[2]) ;
334 AliFatal("Geo manager not initialized\n");
337 for(Int_t imod=1; imod<=GetNModules() ; imod++){
338 //create vector from (0,0,0) to center of crystal surface of imod module
339 Double_t tmp[3]={0.,-fCrystalShift,0.} ;
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");
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) ;
352 continue ; //momentum directed FROM module
353 Double_t fr = (n.Mag2()-n.Dot(v))/direction ;
354 //Calculate direction in module plain
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 ;
361 x=TMath::Sign(n.Pt(),n.X()) ;
371 //____________________________________________________________________________
372 Bool_t AliPHOSGeometry::Impact(const TParticle * particle) const
374 // Tells if a particle enters PHOS
376 Int_t moduleNumber=0;
377 Double_t vtx[3]={particle->Vx(),particle->Vy(),particle->Vz()} ;
379 ImpactOnEmc(vtx,particle->Theta(),particle->Phi(),moduleNumber,z,x);
385 //____________________________________________________________________________
386 Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t & AbsId) const
388 // Converts the relative numbering into the absolute numbering
390 // AbsId = from 1 to fNModules * fNPhi * fNZ
392 // AbsId = from N(total PHOS crystals) + 1
393 // to NCPVModules * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ
397 if ( relid[1] == 0 ) { // it is a Phos crystal
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
403 else { // it is a CPV pad
404 AbsId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate EMCA crystals from CPV pads
405 + ( relid[0] - 1 ) * GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() // the pads offset of PHOS modules
406 + ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() // the pads offset of a CPV row
407 + relid[3] ; // the column number
413 //____________________________________________________________________________
414 void AliPHOSGeometry::RelPosInAlice(Int_t id, TVector3 & pos ) const
416 // Converts the absolute numbering into the global ALICE coordinate system
419 AliFatal("Geo manager not initialized\n");
424 AbsToRelNumbering(id , relid) ;
426 //construct module name
428 if(relid[1]==0){ //this is EMC
430 Double_t ps[3]= {0.0,-fCryCellShift,0.}; //Position incide the crystal
431 Double_t psC[3]={0.0,0.0,0.}; //Global position
433 //Shift and possibly apply misalignment corrections
434 Int_t nCellsInStrip=fGeometryEMCA->GetNCellsXInStrip() ;
435 Int_t strip=1+(relid[3]-1)/fGeometryEMCA->GetNCellsZInStrip()+((relid[2]-1)/nCellsInStrip)*fGeometryEMCA->GetNStripZ() ;
436 Int_t cell=fGeometryEMCA->GetNCellsZInStrip()*(1+(relid[2]-1)%nCellsInStrip)-(relid[3]-1)%fGeometryEMCA->GetNCellsZInStrip() ;
437 sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d/PCEL_%d",
438 relid[0],strip,cell) ;
439 if (!gGeoManager->cd(path)){
440 AliFatal("Geo manager can not find path \n");
442 TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
443 if (m) m->LocalToMaster(ps,psC);
445 AliFatal("Geo matrixes are not loaded \n") ;
447 pos.SetXYZ(psC[0],psC[1],-psC[2]) ;
450 //first calculate position with respect to CPV plain
451 Int_t row = relid[2] ; //offset along x axis
452 Int_t column = relid[3] ; //offset along z axis
453 Double_t ps[3]= {0.0,GetCPVBoxSize(1)/2.,0.}; //Position on top of CPV
454 Double_t psC[3]={0.0,0.0,0.}; //Global position
455 pos[0] = - ( GetNumberOfCPVPadsPhi()/2. - row - 0.5 ) * GetPadSizePhi() ; // position of pad with respect
456 pos[2] = - ( GetNumberOfCPVPadsZ() /2. - column - 0.5 ) * GetPadSizeZ() ; // of center of PHOS module
458 //now apply possible shifts and rotations
459 sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",relid[0]) ;
460 if (!gGeoManager->cd(path)){
461 AliFatal("Geo manager can not find path \n");
463 TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
464 if (m) m->LocalToMaster(ps,psC);
466 AliFatal("Geo matrixes are not loaded \n") ;
468 pos.SetXYZ(psC[0],psC[1],-psC[2]) ;
472 //____________________________________________________________________________
473 void AliPHOSGeometry::RelPosToAbsId(Int_t module, Double_t x, Double_t z, Int_t & AbsId) const
475 // converts local PHOS-module (x, z) coordinates to absId
477 //find Global position
479 AliFatal("Geo manager not initialized\n");
483 sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",module) ;
484 Double_t lpos[3]={x,0.0,z} ;
485 Double_t gpos[3]={0.,0.,0.} ;
486 if (!gGeoManager->cd(path)){
487 AliFatal("Geo manager can not find path \n");
489 TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
490 if (m) m->LocalToMaster(lpos,gpos);
492 AliFatal("Geo matrixes are not loaded \n") ;
494 gGeoManager->FindNode(gpos[0],gpos[1],gpos[2]) ;
495 //Check that path contains PSTR and extract strip number
496 TString cpath(gGeoManager->GetPath()) ;
497 Int_t indx = cpath.Index("PCEL") ;
498 if(indx==-1){ //for the few events when particle hits between srips use ideal geometry
501 relid[2] = static_cast<Int_t>(TMath::Ceil( x/ GetCellStep() + GetNPhi() / 2.) );
502 relid[3] = static_cast<Int_t>(TMath::Ceil(-z/ GetCellStep() + GetNZ() / 2.) ) ;
503 if(relid[2]<1)relid[2]=1 ;
504 if(relid[3]<1)relid[3]=1 ;
505 if(relid[2]>GetNPhi())relid[2]=GetNPhi() ;
506 if(relid[3]>GetNZ())relid[3]=GetNZ() ;
509 Int_t indx2 = cpath.Index("/",indx) ;
511 indx2=cpath.Length() ;
512 TString cell=cpath(indx+5,indx2-indx-5) ;
513 Int_t icell=cell.Atoi() ;
514 indx = cpath.Index("PSTR") ;
515 indx2 = cpath.Index("/",indx) ;
516 TString strip=cpath(indx+5,indx2-indx-5) ;
517 Int_t iStrip = strip.Atoi() ;
520 Int_t raw = fGeometryEMCA->GetNCellsXInStrip()*((iStrip-1)/fGeometryEMCA->GetNStripZ()) +
521 1 + (icell-1)/fGeometryEMCA->GetNCellsZInStrip() ;
522 Int_t col = fGeometryEMCA->GetNCellsZInStrip()*(1+(iStrip-1)%fGeometryEMCA->GetNStripZ()) -
523 (icell-1)%fGeometryEMCA->GetNCellsZInStrip() ;
524 if(col==0) col=GetNZ() ;
529 RelToAbsNumbering(relid,AbsId) ;
532 //____________________________________________________________________________
533 void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) const
535 // Converts the relative numbering into the local PHOS-module (x, z) coordinates
536 // Note: sign of z differs from that in the previous version (Yu.Kharlov, 12 Oct 2000)
540 AliFatal("Geo manager not initialized\n");
542 //construct module name
544 if(relid[1]==0){ //this is PHOS
546 // Calculations using ideal geometry (obsolete)
547 // x = - ( GetNPhi()/2. - relid[2] + 0.5 ) * GetCellStep() ; // position of Xtal with respect
548 // z = - ( GetNZ() /2. - relid[3] + 0.5 ) * GetCellStep() ; // of center of PHOS module
550 Double_t pos[3]= {0.0,0.0,0.}; //Position incide the crystal (Y coordinalte is not important)
551 Double_t posC[3]={0.0,0.0,0.}; //Global position
553 //Shift and possibly apply misalignment corrections
554 Int_t nCellsInStrip=fGeometryEMCA->GetNCellsXInStrip() ;
555 Int_t strip=1+(relid[3]-1)/fGeometryEMCA->GetNCellsZInStrip()+((relid[2]-1)/nCellsInStrip)*fGeometryEMCA->GetNStripZ() ;
556 Int_t sellRaw = (relid[2]-1)%nCellsInStrip ;
557 Int_t cell=fGeometryEMCA->GetNCellsZInStrip()*(sellRaw+1) -(relid[3]-1)%fGeometryEMCA->GetNCellsZInStrip() ;
558 sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d/PCEL_%d",
559 relid[0],strip,cell) ;
560 if (!gGeoManager->cd(path)){
561 AliFatal("Geo manager can not find path \n");
563 TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
564 if (m) m->LocalToMaster(pos,posC);
566 AliFatal("Geo matrixes are not loaded \n") ;
568 //Return to PHOS local system
569 Double_t posL[3]={posC[0],posC[1],posC[2]};
570 sprintf(path,"/ALIC_1/PHOS_%d",relid[0]) ;
571 if (!gGeoManager->cd(path)){
572 AliFatal("Geo manager can not find path \n");
574 TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix();
575 if (mPHOS) mPHOS->MasterToLocal(posC,posL);
577 AliFatal("Geo matrixes are not loaded \n") ;
579 //printf("old: x=%f, z=%f \n",x,z);
582 //printf("Geo: x=%f, z=%f \n",x,z);
586 //first calculate position with respect to CPV plain
587 Int_t row = relid[2] ; //offset along x axis
588 Int_t column = relid[3] ; //offset along z axis
589 Double_t pos[3]= {0.0,0.0,0.}; //Position incide the CPV printed circuit
590 Double_t posC[3]={0.0,0.0,0.}; //Global position
591 pos[0] = - ( GetNumberOfCPVPadsPhi()/2. - row - 0.5 ) * GetPadSizePhi() ; // position of pad with respect
592 pos[2] = - ( GetNumberOfCPVPadsZ() /2. - column - 0.5 ) * GetPadSizeZ() ; // of center of PHOS module
594 //now apply possible shifts and rotations
595 sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",relid[0]) ;
596 if (!gGeoManager->cd(path)){
597 AliFatal("Geo manager can not find path \n");
599 TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
600 if (m) m->LocalToMaster(pos,posC);
602 AliFatal("Geo matrixes are not loaded \n") ;
604 //Return to PHOS local system
605 Double_t posL[3]={0.,0.,0.,} ;
606 sprintf(path,"/ALIC_1/PHOS_%d",relid[0]) ;
607 if (!gGeoManager->cd(path)){
608 AliFatal("Geo manager can not find path \n");
610 TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix();
611 if (mPHOS) mPHOS->MasterToLocal(posC,posL);
613 AliFatal("Geo matrixes are not loaded \n") ;
623 //____________________________________________________________________________
625 void AliPHOSGeometry::GetModuleCenter(TVector3& center,
629 // Returns a position of the center of the CPV or EMC module
630 // in ideal (not misaligned) geometry
632 if (strcmp(det,"CPV") == 0) rDet = GetIPtoCPVDistance ();
633 else if (strcmp(det,"EMC") == 0) rDet = GetIPtoCrystalSurface();
635 AliFatal(Form("Wrong detector name %s",det));
637 Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees
638 angle *= TMath::Pi()/180;
639 angle += 3*TMath::Pi()/2.;
640 center.SetXYZ(rDet*TMath::Cos(angle), rDet*TMath::Sin(angle), 0.);
643 //____________________________________________________________________________
645 void AliPHOSGeometry::Global2Local(TVector3& localPosition,
646 const TVector3& globalPosition,
649 // Transforms a global position of the rec.point to the local coordinate system
650 //Return to PHOS local system
651 Double_t posG[3]={globalPosition.X(),globalPosition.Y(),globalPosition.Z()} ;
652 Double_t posL[3]={0.,0.,0.} ;
654 sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",module) ;
655 // sprintf(path,"/ALIC_1/PHOS_%d",module) ;
656 if (!gGeoManager->cd(path)){
657 AliFatal("Geo manager can not find path \n");
659 TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix();
660 if (mPHOS) mPHOS->MasterToLocal(posG,posL);
662 AliFatal("Geo matrixes are not loaded \n") ;
664 localPosition.SetXYZ(posL[0],posL[1]+fCrystalShift,-posL[2]) ;
667 Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees
668 angle *= TMath::Pi()/180;
669 angle += 3*TMath::Pi()/2.;
670 localPosition = globalPosition;
671 localPosition.RotateZ(-angle);
674 //____________________________________________________________________________
675 void AliPHOSGeometry::Local2Global(Int_t mod, Float_t x, Float_t z,
676 TVector3& globalPosition) const
679 sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",mod) ;
680 // sprintf(path,"/ALIC_1/PHOS_%d",mod) ;
681 if (!gGeoManager->cd(path)){
682 AliFatal("Geo manager can not find path \n");
684 Double_t posL[3]={x,-fCrystalShift,-z} ; //Only for EMC!!!
686 TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix();
688 mPHOS->LocalToMaster(posL,posG);
691 AliFatal("Geo matrixes are not loaded \n") ;
693 globalPosition.SetXYZ(posG[0],posG[1],posG[2]) ;
695 //____________________________________________________________________________
696 void AliPHOSGeometry::GetIncidentVector(const TVector3 &vtx, Int_t module, Float_t x,Float_t z, TVector3 &vInc) const {
697 //Calculates vector pointing from vertex to current poisition in module local frame
698 //Note that PHOS local system and ALICE global have opposite z directions
700 Global2Local(vInc,vtx,module) ;
701 vInc.SetXYZ(vInc.X()+x,vInc.Y(),vInc.Z()+z) ;