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>
35 #include <TGeoMatrix.h>
37 // --- Standard library ---
39 // --- AliRoot header files ---
41 #include "AliPHOSGeometry.h"
42 #include "AliPHOSEMCAGeometry.h"
43 #include "AliPHOSRecPoint.h"
45 ClassImp(AliPHOSGeometry)
47 // these initialisations are needed for a singleton
48 AliPHOSGeometry * AliPHOSGeometry::fgGeom = 0 ;
49 Bool_t AliPHOSGeometry::fgInit = kFALSE ;
51 //____________________________________________________________________________
52 AliPHOSGeometry::AliPHOSGeometry() :
56 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)
68 : AliPHOSGeoUtils(rhs),
71 fIPtoUpperCPVsurface(rhs.fIPtoUpperCPVsurface),
72 fCrystalShift(rhs.fCrystalShift),
73 fCryCellShift(rhs.fCryCellShift),
76 Fatal("cpy ctor", "not implemented") ;
79 //____________________________________________________________________________
80 AliPHOSGeometry::AliPHOSGeometry(const Text_t* name, const Text_t* title)
81 : AliPHOSGeoUtils(name, title),
84 fIPtoUpperCPVsurface(0),
89 // ctor only for internal usage (singleton)
94 //____________________________________________________________________________
95 AliPHOSGeometry::~AliPHOSGeometry(void)
99 if (fRotMatrixArray) fRotMatrixArray->Delete() ;
100 if (fRotMatrixArray) delete fRotMatrixArray ;
101 if (fPHOSAngle ) delete[] fPHOSAngle ;
104 //____________________________________________________________________________
105 void AliPHOSGeometry::Init(void)
107 // Initializes the PHOS parameters :
108 // IHEP is the Protvino CPV (cathode pad chambers)
115 fPHOSAngle = new Float_t[fNModules] ;
117 Float_t * emcParams = fGeometryEMCA->GetEMCParams() ;
119 fPHOSParams[0] = TMath::Max((Double_t)fGeometryCPV->GetCPVBoxSize(0)/2.,
120 (Double_t)(emcParams[0] - (emcParams[1]-emcParams[0])*
121 fGeometryCPV->GetCPVBoxSize(1)/2/emcParams[3]));
122 fPHOSParams[1] = emcParams[1] ;
123 fPHOSParams[2] = TMath::Max((Double_t)emcParams[2], (Double_t)fGeometryCPV->GetCPVBoxSize(2)/2.);
124 fPHOSParams[3] = emcParams[3] + fGeometryCPV->GetCPVBoxSize(1)/2. ;
126 fIPtoUpperCPVsurface = fGeometryEMCA->GetIPtoOuterCoverDistance() - fGeometryCPV->GetCPVBoxSize(1) ;
128 //calculate offset to crystal surface
129 Float_t * inthermo = fGeometryEMCA->GetInnerThermoHalfSize() ;
130 Float_t * strip = fGeometryEMCA->GetStripHalfSize() ;
131 Float_t* splate = fGeometryEMCA->GetSupportPlateHalfSize();
132 Float_t * crystal = fGeometryEMCA->GetCrystalHalfSize() ;
133 Float_t * pin = fGeometryEMCA->GetAPDHalfSize() ;
134 Float_t * preamp = fGeometryEMCA->GetPreampHalfSize() ;
135 fCrystalShift=-inthermo[1]+strip[1]+splate[1]+crystal[1]-fGeometryEMCA->GetAirGapLed()/2.+pin[1]+preamp[1] ;
136 fCryCellShift=crystal[1]-(fGeometryEMCA->GetAirGapLed()-2*pin[1]-2*preamp[1])/2;
139 for ( index = 0; index < fNModules; index++ )
140 fPHOSAngle[index] = 0.0 ; // Module position angles are set in CreateGeometry()
142 fRotMatrixArray = new TObjArray(fNModules) ;
144 // Geometry parameters are calculated
147 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
148 Float_t r = GetIPtoOuterCoverDistance() + fPHOSParams[3] - GetCPVBoxSize(1) ;
149 for (Int_t iModule=0; iModule<fNModules; iModule++) {
150 fModuleCenter[iModule][0] = r * TMath::Sin(fPHOSAngle[iModule] / kRADDEG );
151 fModuleCenter[iModule][1] =-r * TMath::Cos(fPHOSAngle[iModule] / kRADDEG );
152 fModuleCenter[iModule][2] = 0.;
154 fModuleAngle[iModule][0][0] = 90;
155 fModuleAngle[iModule][0][1] = fPHOSAngle[iModule];
156 fModuleAngle[iModule][1][0] = 0;
157 fModuleAngle[iModule][1][1] = 0;
158 fModuleAngle[iModule][2][0] = 90;
159 fModuleAngle[iModule][2][1] = 270 + fPHOSAngle[iModule];
164 //____________________________________________________________________________
165 AliPHOSGeometry * AliPHOSGeometry::GetInstance()
167 // Returns the pointer of the unique instance; singleton specific
169 return static_cast<AliPHOSGeometry *>( fgGeom ) ;
172 //____________________________________________________________________________
173 AliPHOSGeometry * AliPHOSGeometry::GetInstance(const Text_t* name, const Text_t* title)
175 // Returns the pointer of the unique instance
176 // Creates it with the specified options (name, title) if it does not exist yet
178 AliPHOSGeometry * rv = 0 ;
180 if ( strcmp(name,"") == 0 )
183 fgGeom = new AliPHOSGeometry(name, title) ;
185 rv = (AliPHOSGeometry * ) fgGeom ;
194 if ( strcmp(fgGeom->GetName(), name) != 0 )
195 ::Error("GetInstance", "Current geometry is %s. You cannot call %s",
196 fgGeom->GetName(), name) ;
198 rv = (AliPHOSGeometry *) fgGeom ;
203 //____________________________________________________________________________
204 void AliPHOSGeometry::SetPHOSAngles()
206 // Calculates the position of the PHOS modules in ALICE global coordinate system
209 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
210 Float_t pphi = 2 * TMath::ATan( GetOuterBoxSize(0) / ( 2.0 * GetIPtoUpperCPVsurface() ) ) ;
213 AliError(Form("PHOS modules overlap!\n pphi = %f fAngle = %f",
219 for( Int_t i = 1; i <= fNModules ; i++ ) {
220 Float_t angle = pphi * ( i - fNModules / 2.0 - 0.5 ) ;
221 fPHOSAngle[i-1] = - angle ;
224 //____________________________________________________________________________
225 void AliPHOSGeometry::GetGlobal(const AliRecPoint* , TVector3 & ) const
227 AliFatal(Form("Please use GetGlobalPHOS(recPoint,gpos) instead of GetGlobal!"));
230 //____________________________________________________________________________
231 void AliPHOSGeometry::GetGlobalPHOS(const AliPHOSRecPoint* recPoint, TVector3 & gpos) const
233 // Calculates the coordinates of a RecPoint and the error matrix in the ALICE global coordinate system
235 const AliPHOSRecPoint * tmpPHOS = recPoint ;
236 TVector3 localposition ;
238 tmpPHOS->GetLocalPosition(gpos) ;
241 AliFatal("Geo manager not initialized\n");
243 //construct module name
246 if(tmpPHOS->IsEmc()){
247 sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",tmpPHOS->GetPHOSMod()) ;
248 // sprintf(path,"/ALIC_1/PHOS_%d",tmpPHOS->GetPHOSMod()) ;
252 sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",tmpPHOS->GetPHOSMod()) ;
253 dy= GetCPVBoxSize(1)/2. ; //center of CPV module
255 Double_t pos[3]={gpos.X(),gpos.Y()-dy,gpos.Z()} ;
257 pos[2]=-pos[2] ; //Opposite z directions in EMC matrix and local frame!!!
259 //now apply possible shifts and rotations
260 if (!gGeoManager->cd(path)){
261 AliFatal("Geo manager can not find path \n");
263 TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
265 m->LocalToMaster(pos,posC);
268 AliFatal("Geo matrixes are not loaded \n") ;
270 gpos.SetXYZ(posC[0],posC[1],posC[2]) ;
273 //____________________________________________________________________________
275 void AliPHOSGeometry::GetModuleCenter(TVector3& center,
279 // Returns a position of the center of the CPV or EMC module
280 // in ideal (not misaligned) geometry
282 if (strcmp(det,"CPV") == 0) rDet = GetIPtoCPVDistance ();
283 else if (strcmp(det,"EMC") == 0) rDet = GetIPtoCrystalSurface();
285 AliFatal(Form("Wrong detector name %s",det));
287 Float_t angle = GetPHOSAngle(module); // (40,20,0,-20,-40) degrees
288 angle *= TMath::Pi()/180;
289 angle += 3*TMath::Pi()/2.;
290 center.SetXYZ(rDet*TMath::Cos(angle), rDet*TMath::Sin(angle), 0.);