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 **************************************************************************/
16 /* $Id: AliPHOSGeometry.cxx 25590 2008-05-06 07:09:11Z prsnko $ */
18 //_________________________________________________________________________
19 // Geometry class for PHOS
20 // PHOS consists of the electromagnetic calorimeter (EMCA)
21 // and a charged particle veto (CPV)
22 // The EMCA/CPV modules are parametrized so that any configuration
23 // can be easily implemented
24 // The title is used to identify the version of CPV used.
26 // -- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC "KI" & SUBATECH)
28 // --- ROOT system ---
30 #include "TClonesArray.h"
32 #include "TParticle.h"
33 #include <TGeoManager.h>
34 #include <TGeoMatrix.h>
36 // --- Standard library ---
38 // --- AliRoot header files ---
40 #include "AliPHOSEMCAGeometry.h"
41 #include "AliPHOSCPVGeometry.h"
42 #include "AliPHOSSupportGeometry.h"
43 #include "AliPHOSGeoUtils.h"
45 ClassImp(AliPHOSGeoUtils)
47 //____________________________________________________________________________
48 AliPHOSGeoUtils::AliPHOSGeoUtils():
49 fGeometryEMCA(0x0),fGeometryCPV(0x0),fGeometrySUPP(0x0),
50 fNModules(0),fNCristalsInModule(0),fNPhi(0),fNZ(0),
51 fNumberOfCPVPadsPhi(0),fNumberOfCPVPadsZ(0),
52 fNCellsXInStrip(0),fNCellsZInStrip(0),fNStripZ(0),
53 fCrystalShift(0.),fCryCellShift(0.),fCryStripShift(0.),fCellStep(0.),
54 fPadSizePhi(0.),fPadSizeZ(0.),fCPVBoxSizeY(0.),fMisalArray(0x0)
58 // must be kept public for root persistency purposes, but should never be called by the outside world
64 for(Int_t mod=0; mod<5; mod++){
66 for(Int_t istrip=0; istrip<224; istrip++)
67 fStripMatrix[mod][istrip]=0 ;
74 //____________________________________________________________________________
75 AliPHOSGeoUtils::AliPHOSGeoUtils(const AliPHOSGeoUtils & rhs)
77 fGeometryEMCA(0x0),fGeometryCPV(0x0),fGeometrySUPP(0x0),
78 fNModules(0),fNCristalsInModule(0),fNPhi(0),fNZ(0),
79 fNumberOfCPVPadsPhi(0),fNumberOfCPVPadsZ(0),
80 fNCellsXInStrip(0),fNCellsZInStrip(0),fNStripZ(0),
81 fCrystalShift(0.),fCryCellShift(0.),fCryStripShift(0.),fCellStep(0.),
82 fPadSizePhi(0.),fPadSizeZ(0.),fCPVBoxSizeY(0.),fMisalArray(0x0)
84 Fatal("cpy ctor", "not implemented") ;
85 for(Int_t mod=0; mod<5; mod++){
87 for(Int_t istrip=0; istrip<224; istrip++)
88 fStripMatrix[mod][istrip]=0 ;
94 //____________________________________________________________________________
95 AliPHOSGeoUtils::AliPHOSGeoUtils(const Text_t* name, const Text_t* title)
96 : TNamed(name, title),
97 fGeometryEMCA(0x0),fGeometryCPV(0x0),fGeometrySUPP(0x0),
98 fNModules(0),fNCristalsInModule(0),fNPhi(0),fNZ(0),
99 fNumberOfCPVPadsPhi(0),fNumberOfCPVPadsZ(0),
100 fNCellsXInStrip(0),fNCellsZInStrip(0),fNStripZ(0),
101 fCrystalShift(0.),fCryCellShift(0.),fCryStripShift(0.),fCellStep(0.),
102 fPadSizePhi(0.),fPadSizeZ(0.),fCPVBoxSizeY(0.),fMisalArray(0x0)
104 // ctor only for normal usage
106 fGeometryEMCA = new AliPHOSEMCAGeometry() ;
107 fGeometryCPV = new AliPHOSCPVGeometry() ;
108 fGeometrySUPP = new AliPHOSSupportGeometry() ;
111 fNPhi = fGeometryEMCA->GetNPhi() ;
112 fNZ = fGeometryEMCA->GetNZ() ;
113 fNCristalsInModule = fNPhi*fNZ ;
114 fNCellsXInStrip= fGeometryEMCA->GetNCellsXInStrip() ;
115 fNCellsZInStrip= fGeometryEMCA->GetNCellsZInStrip() ;
116 fNStripZ = fGeometryEMCA->GetNStripZ() ;
117 fXtlArrSize[0]=fGeometryEMCA->GetInnerThermoHalfSize()[0] ; //Wery close to the zise of the Xtl set
118 fXtlArrSize[1]=fGeometryEMCA->GetInnerThermoHalfSize()[1] ; //Wery close to the zise of the Xtl set
119 fXtlArrSize[2]=fGeometryEMCA->GetInnerThermoHalfSize()[2] ; //Wery close to the zise of the Xtl set
121 //calculate offset to crystal surface
122 const Float_t * inthermo = fGeometryEMCA->GetInnerThermoHalfSize() ;
123 const Float_t * strip = fGeometryEMCA->GetStripHalfSize() ;
124 const Float_t * splate = fGeometryEMCA->GetSupportPlateHalfSize();
125 const Float_t * crystal = fGeometryEMCA->GetCrystalHalfSize() ;
126 const Float_t * pin = fGeometryEMCA->GetAPDHalfSize() ;
127 const Float_t * preamp = fGeometryEMCA->GetPreampHalfSize() ;
128 fCrystalShift=-inthermo[1]+strip[1]+splate[1]+crystal[1]-fGeometryEMCA->GetAirGapLed()/2.+pin[1]+preamp[1] ;
129 fCryCellShift=crystal[1]-(fGeometryEMCA->GetAirGapLed()-2*pin[1]-2*preamp[1])/2;
130 fCryStripShift=fCryCellShift+splate[1] ;
131 fCellStep = 2.*fGeometryEMCA->GetAirCellHalfSize()[0] ;
133 fNumberOfCPVPadsPhi = fGeometryCPV->GetNumberOfCPVPadsPhi() ;
134 fNumberOfCPVPadsZ = fGeometryCPV->GetNumberOfCPVPadsZ() ;
135 fPadSizePhi = fGeometryCPV->GetCPVPadSizePhi() ;
136 fPadSizeZ = fGeometryCPV->GetCPVPadSizeZ() ;
137 fCPVBoxSizeY= fGeometryCPV->GetCPVBoxSize(1) ;
139 for(Int_t mod=0; mod<5; mod++){
141 for(Int_t istrip=0; istrip<224; istrip++)
142 fStripMatrix[mod][istrip]=0 ;
149 //____________________________________________________________________________
150 AliPHOSGeoUtils & AliPHOSGeoUtils::operator = (const AliPHOSGeoUtils & /*rvalue*/) {
152 Fatal("assignment operator", "not implemented") ;
156 //____________________________________________________________________________
157 AliPHOSGeoUtils::~AliPHOSGeoUtils(void)
161 delete fGeometryEMCA; fGeometryEMCA = 0 ;
164 delete fGeometryCPV; fGeometryCPV=0 ;
167 delete fGeometrySUPP ; fGeometrySUPP=0 ;
170 delete fMisalArray; fMisalArray=0 ;
173 for(Int_t mod=0; mod<5; mod++){
174 delete fEMCMatrix[mod] ;
175 for(Int_t istrip=0; istrip<224; istrip++)
176 delete fStripMatrix[mod][istrip];
177 delete fCPVMatrix[mod];
178 delete fPHOSMatrix[mod];
181 //____________________________________________________________________________
182 Bool_t AliPHOSGeoUtils::AbsToRelNumbering(Int_t absId, Int_t * relid) const
184 // Converts the absolute numbering into the following array
185 // relid[0] = PHOS Module number 1:fNModules
186 // relid[1] = 0 if PbW04
188 // relid[2] = Row number inside a PHOS module
189 // relid[3] = Column number inside a PHOS module
193 Int_t phosmodulenumber = (Int_t)TMath:: Ceil( id / fNCristalsInModule ) ;
195 if ( phosmodulenumber > fNModules ) { // it is a CPV pad
197 id -= fNPhi * fNZ * fNModules ;
198 Float_t nCPV = fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ ;
199 relid[0] = (Int_t) TMath::Ceil( id / nCPV ) ;
201 id -= ( relid[0] - 1 ) * nCPV ;
202 relid[2] = (Int_t) TMath::Ceil( id / fNumberOfCPVPadsZ ) ;
203 relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * fNumberOfCPVPadsZ ) ;
205 else { // it is a PW04 crystal
207 relid[0] = phosmodulenumber ;
209 id -= ( phosmodulenumber - 1 ) * fNPhi * fNZ ;
210 relid[2] = (Int_t)TMath::Ceil( id / fNZ ) ;
211 relid[3] = (Int_t)( id - ( relid[2] - 1 ) * fNZ ) ;
215 //____________________________________________________________________________
216 Bool_t AliPHOSGeoUtils::RelToAbsNumbering(const Int_t * relid, Int_t & absId) const
218 // Converts the relative numbering into the absolute numbering
220 // absId = from 1 to fNModules * fNPhi * fNZ
222 // absId = from N(total PHOS crystals) + 1
223 // to NCPVModules * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ
225 if ( relid[1] == 0 ) { // it is a Phos crystal
227 ( relid[0] - 1 ) * fNPhi * fNZ // the offset of PHOS modules
228 + ( relid[2] - 1 ) * fNZ // the offset along phi
229 + relid[3] ; // the offset along z
231 else { // it is a CPV pad
232 absId = fNPhi * fNZ * fNModules // the offset to separate EMCA crystals from CPV pads
233 + ( relid[0] - 1 ) * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ // the pads offset of PHOS modules
234 + ( relid[2] - 1 ) * fNumberOfCPVPadsZ // the pads offset of a CPV row
235 + relid[3] ; // the column number
241 //____________________________________________________________________________
242 void AliPHOSGeoUtils::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) const
244 // Converts the relative numbering into the local PHOS-module (x, z) coordinates
246 if(relid[1]==0){ //this is PHOS
248 Double_t pos[3]= {0.0,-fCryCellShift,0.}; //Position incide the crystal
249 Double_t posC[3]={0.0,0.0,0.}; //Global position
251 //Shift and possibly apply misalignment corrections
252 Int_t strip=1+((Int_t) TMath::Ceil((Double_t)relid[2]/fNCellsXInStrip))*fNStripZ-
253 (Int_t) TMath::Ceil((Double_t)relid[3]/fNCellsZInStrip) ;
254 pos[0]=((relid[2]-1)%fNCellsXInStrip-fNCellsXInStrip/2+0.5)*fCellStep ;
255 pos[2]=(-(relid[3]-1)%fNCellsZInStrip+fNCellsZInStrip/2-0.5)*fCellStep ;
257 Int_t mod = relid[0] ;
258 const TGeoHMatrix * m2 = GetMatrixForStrip(mod, strip) ;
259 m2->LocalToMaster(pos,posC);
261 //Return to PHOS local system
262 Double_t posL2[3]={posC[0],posC[1],posC[2]};
263 const TGeoHMatrix *mPHOS2 = GetMatrixForModule(mod) ;
264 mPHOS2->MasterToLocal(posC,posL2);
270 //first calculate position with respect to CPV plain
271 Int_t row = relid[2] ; //offset along x axis
272 Int_t column = relid[3] ; //offset along z axis
273 Double_t pos[3]= {0.0,0.0,0.}; //Position incide the CPV printed circuit
274 Double_t posC[3]={0.0,0.0,0.}; //Global position
275 pos[0] = - ( fNumberOfCPVPadsPhi/2. - row - 0.5 ) * fPadSizePhi ; // position of pad with respect
276 pos[2] = - ( fNumberOfCPVPadsZ /2. - column - 0.5 ) * fPadSizeZ ; // of center of PHOS module
278 //now apply possible shifts and rotations
279 const TGeoHMatrix *m = GetMatrixForCPV(relid[0]) ;
280 m->LocalToMaster(pos,posC);
281 //Return to PHOS local system
282 Double_t posL[3]={0.,0.,0.,} ;
283 const TGeoHMatrix *mPHOS = GetMatrixForPHOS(relid[0]) ;
284 mPHOS->MasterToLocal(posC,posL);
292 //____________________________________________________________________________
293 void AliPHOSGeoUtils::RelPosToAbsId(Int_t module, Double_t x, Double_t z, Int_t & absId) const
295 // converts local PHOS-module (x, z) coordinates to absId
297 //Calculate AbsId using ideal geometry. Should be sufficient for primary particles calculation
298 //(the only place where this method used currently)
299 Int_t relid[4]={module,0,1,1} ;
300 relid[2] = static_cast<Int_t>(TMath::Ceil( x/ fCellStep + fNPhi / 2.) );
301 relid[3] = fNZ+1-static_cast<Int_t>(TMath::Ceil(-z/ fCellStep + fNZ / 2.) ) ;
302 if(relid[2]<1)relid[2]=1 ;
303 if(relid[3]<1)relid[3]=1 ;
304 if(relid[2]>fNPhi)relid[2]=fNPhi ;
305 if(relid[3]>fNZ)relid[3]=fNZ ;
306 RelToAbsNumbering(relid,absId) ;
309 //find Global position
311 printf("Geo manager not initialized\n");
314 Double_t posL[3]={x,-fCrystalShift,-z} ; //Only for EMC!!!
317 sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",module) ;
318 if (!gGeoManager->cd(path)){
319 printf("Geo manager can not find path \n");
322 TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix();
324 mPHOS->LocalToMaster(posL,posG);
327 printf("Geo matrixes are not loaded \n") ;
332 gGeoManager->FindNode(posG[0],posG[1],posG[2]) ;
333 //Check that path contains PSTR and extract strip number
334 TString cpath(gGeoManager->GetPath()) ;
335 Int_t indx = cpath.Index("PCEL") ;
336 if(indx==-1){ //for the few events when particle hits between srips use ideal geometry
339 relid[2] = static_cast<Int_t>(TMath::Ceil( x/ fCellStep + fNPhi / 2.) );
340 relid[3] = static_cast<Int_t>(TMath::Ceil(-z/ fCellStep + fNZ / 2.) ) ;
341 if(relid[2]<1)relid[2]=1 ;
342 if(relid[3]<1)relid[3]=1 ;
343 if(relid[2]>fNPhi)relid[2]=fNPhi ;
344 if(relid[3]>fNZ)relid[3]=fNZ ;
345 RelToAbsNumbering(relid,absId) ;
348 Int_t indx2 = cpath.Index("/",indx) ;
350 indx2=cpath.Length() ;
351 TString cell=cpath(indx+5,indx2-indx-5) ;
352 Int_t icell=cell.Atoi() ;
353 indx = cpath.Index("PSTR") ;
354 indx2 = cpath.Index("/",indx) ;
355 TString strip=cpath(indx+5,indx2-indx-5) ;
356 Int_t iStrip = strip.Atoi() ;
358 Int_t row = fNStripZ - (iStrip - 1) % (fNStripZ) ;
359 Int_t col = (Int_t) TMath::Ceil((Double_t) iStrip/(fNStripZ)) -1 ;
361 // Absid for 8x2-strips. Looks nice :)
362 absId = (module-1)*fNCristalsInModule +
363 row * 2 + (col*fNCellsXInStrip + (icell - 1) / 2)*fNZ - (icell & 1 ? 1 : 0);
370 //____________________________________________________________________________
371 void AliPHOSGeoUtils::RelPosToRelId(Int_t module, Double_t x, Double_t z, Int_t * relId) const
373 //Evaluates RelId of the crystall with given coordinates
376 RelPosToAbsId(module, x,z,absId) ;
377 AbsToRelNumbering(absId,relId) ;
380 //____________________________________________________________________________
381 void AliPHOSGeoUtils::RelPosInAlice(Int_t id, TVector3 & pos ) const
383 // Converts the absolute numbering into the global ALICE coordinate system
386 AliFatal("Geo manager not initialized\n");
391 AbsToRelNumbering(id , relid) ;
393 //construct module name
394 if(relid[1]==0){ //this is EMC
396 Double_t ps[3]= {0.0,-fCryStripShift,0.}; //Position incide the crystal
397 Double_t psC[3]={0.0,0.0,0.}; //Global position
399 //Shift and possibly apply misalignment corrections
400 Int_t strip=1+((Int_t) TMath::Ceil((Double_t)relid[2]/fNCellsXInStrip))*fNStripZ-
401 (Int_t) TMath::Ceil((Double_t)relid[3]/fNCellsZInStrip) ;
402 ps[0]=((relid[2]-1)%fNCellsXInStrip-fNCellsXInStrip/2+0.5)*fCellStep ;
403 ps[2]=(-(relid[3]-1)%fNCellsZInStrip+fNCellsZInStrip/2-0.5)*fCellStep ;
405 Int_t mod = relid[0] ;
406 const TGeoHMatrix * m2 = GetMatrixForStrip(mod, strip) ;
407 m2->LocalToMaster(ps,psC);
408 pos.SetXYZ(psC[0],psC[1],psC[2]) ;
412 //first calculate position with respect to CPV plain
413 Int_t row = relid[2] ; //offset along x axis
414 Int_t column = relid[3] ; //offset along z axis
415 Double_t ps[3]= {0.0,fCPVBoxSizeY/2.,0.}; //Position on top of CPV
416 Double_t psC[3]={0.0,0.0,0.}; //Global position
417 pos[0] = - ( fNumberOfCPVPadsPhi/2. - row - 0.5 ) * fPadSizePhi ; // position of pad with respect
418 pos[2] = - ( fNumberOfCPVPadsZ /2. - column - 0.5 ) * fPadSizeZ ; // of center of PHOS module
420 //now apply possible shifts and rotations
421 const TGeoHMatrix *m = GetMatrixForCPV(relid[0]) ;
422 m->LocalToMaster(ps,psC);
423 pos.SetXYZ(psC[0],psC[1],-psC[2]) ;
427 //____________________________________________________________________________
428 void AliPHOSGeoUtils::Local2Global(Int_t mod, Float_t x, Float_t z,
429 TVector3& globalPosition) const
431 Double_t posL[3]={x,-fCrystalShift,-z} ; //Only for EMC!!!
433 const TGeoHMatrix *mPHOS = GetMatrixForModule(mod) ;
434 mPHOS->LocalToMaster(posL,posG);
435 globalPosition.SetXYZ(posG[0],posG[1],posG[2]) ;
437 //____________________________________________________________________________
438 void AliPHOSGeoUtils::Global2Local(TVector3& localPosition,
439 const TVector3& globalPosition,
442 // Transforms a global position to the local coordinate system
444 //Return to PHOS local system
445 Double_t posG[3]={globalPosition.X(),globalPosition.Y(),globalPosition.Z()} ;
446 Double_t posL[3]={0.,0.,0.} ;
447 const TGeoHMatrix *mPHOS = GetMatrixForModule(module) ;
449 mPHOS->MasterToLocal(posG,posL);
450 localPosition.SetXYZ(posL[0],posL[1]+fCrystalShift,-posL[2]) ;
453 localPosition.SetXYZ(999.,999.,999.) ; //module does not exist in given configuration
457 //____________________________________________________________________________
458 Bool_t AliPHOSGeoUtils::GlobalPos2RelId(TVector3 & global, Int_t * relId){
459 //Converts position in global ALICE coordinates to relId
460 //returns false if x,z coordinates are beyond PHOS
461 //distande to PHOS surface is NOT calculated
463 for(Int_t mod=1; mod<=fNModules; mod++){
464 Global2Local(loc,global,mod) ;
466 if((TMath::Abs(loc.Z())<fXtlArrSize[2]) && (TMath::Abs(loc.X())<fXtlArrSize[0])){
467 RelPosToRelId(mod,loc.X(),loc.Z(),relId);
474 //____________________________________________________________________________
475 Bool_t AliPHOSGeoUtils::ImpactOnEmc(const TParticle * particle,
476 Int_t & moduleNumber, Double_t & z, Double_t & x) const
478 // Tells if a particle enters PHOS and evaluates hit position
479 Double_t vtx[3]={particle->Vx(),particle->Vy(),particle->Vz()} ;
480 return ImpactOnEmc(vtx,particle->Theta(),particle->Phi(),moduleNumber,z,x);
483 //____________________________________________________________________________
484 Bool_t AliPHOSGeoUtils::ImpactOnEmc(const Double_t * vtx, Double_t theta, Double_t phi,
485 Int_t & moduleNumber, Double_t & z, Double_t & x) const
487 // calculates the impact coordinates on PHOS of a neutral particle
488 // emitted in the vertex vtx[3] with direction vec(p) in the ALICE global coordinate system
489 TVector3 p(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ;
490 return ImpactOnEmc(vtx,p,moduleNumber,z,x) ;
493 //____________________________________________________________________________
494 Bool_t AliPHOSGeoUtils::ImpactOnEmc(const Double_t * vtx, const TVector3 &p,
495 Int_t & moduleNumber, Double_t & z, Double_t & x) const
497 // calculates the impact coordinates on PHOS of a neutral particle
498 // emitted in the vertex vtx[3] with direction theta and phi in the ALICE global coordinate system
499 TVector3 v(vtx[0],vtx[1],vtx[2]) ;
501 for(Int_t imod=1; imod<=fNModules ; imod++){
502 //create vector from (0,0,0) to center of crystal surface of imod module
503 Double_t tmp[3]={0.,-fCrystalShift,0.} ;
505 const TGeoHMatrix *m = GetMatrixForModule(imod) ;
506 if(!m) //module does not exist in given configuration
508 Double_t posG[3]={0.,0.,0.} ;
509 m->LocalToMaster(tmp,posG);
510 TVector3 n(posG[0],posG[1],posG[2]) ;
511 Double_t direction=n.Dot(p) ;
513 continue ; //momentum directed FROM module
514 Double_t fr = (n.Mag2()-n.Dot(v))/direction ;
515 //Calculate direction in module plain
518 if(TMath::Abs(TMath::Abs(n.Z())<fXtlArrSize[2]) && n.Pt()<fXtlArrSize[0]){
519 moduleNumber = imod ;
521 x=TMath::Sign(n.Pt(),n.X()) ;
522 //no need to return to local system since we calcilated distance from module center
523 //and tilts can not be significant.
533 //____________________________________________________________________________
534 void AliPHOSGeoUtils::GetIncidentVector(const TVector3 &vtx, Int_t module, Float_t x,Float_t z, TVector3 &vInc) const {
535 //Calculates vector pointing from vertex to current poisition in module local frame
536 //Note that PHOS local system and ALICE global have opposite z directions
538 Global2Local(vInc,vtx,module) ;
539 vInc.SetXYZ(vInc.X()+x,vInc.Y(),vInc.Z()+z) ;
541 //____________________________________________________________________________
542 const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForModule(Int_t mod)const {
543 //Provides shift-rotation matrix for module mod
545 //If GeoManager exists, take matrixes from it
548 snprintf(path,255,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",mod) ;
549 // sprintf(path,"/ALIC_1/PHOS_%d",relid[0]) ;
550 if (!gGeoManager->cd(path)){
551 AliWarning(Form("Geo manager can not find path %s \n",path));
554 return gGeoManager->GetCurrentMatrix();
556 if(fEMCMatrix[mod-1]){
557 return fEMCMatrix[mod-1] ;
560 // AliWarning("Can not find PHOS misalignment matrixes\n") ;
561 // AliWarning("Either import TGeoManager from geometry.root or \n");
562 // AliWarning("read stored matrixes from AliESD Header: \n") ;
563 // AliWarning("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
568 //____________________________________________________________________________
569 const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForStrip(Int_t mod, Int_t strip)const {
570 //Provides shift-rotation matrix for strip unit of the module mod
572 //If GeoManager exists, take matrixes from it
575 snprintf(path,255,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d",mod,strip) ;
576 if (!gGeoManager->cd(path)){
577 AliWarning(Form("Geo manager can not find path %s \n",path));
580 return gGeoManager->GetCurrentMatrix();
582 if(fStripMatrix[mod-1][strip-1]){
583 return fStripMatrix[mod-1][strip-1] ;
586 AliWarning("Can not find PHOS misalignment matrixes\n") ;
587 AliWarning("Either import TGeoManager from geometry.root or \n");
588 AliWarning("read stored matrixes from AliESD Header: \n") ;
589 AliWarning("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
594 //____________________________________________________________________________
595 const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForCPV(Int_t mod)const {
596 //Provides shift-rotation matrix for CPV of the module mod
598 //If GeoManager exists, take matrixes from it
601 //now apply possible shifts and rotations
602 snprintf(path,255,"/ALIC_1/PHOS_%d/PCPV_1",mod) ;
603 if (!gGeoManager->cd(path)){
604 AliWarning(Form("Geo manager can not find path %s \n",path));
607 return gGeoManager->GetCurrentMatrix();
609 if(fCPVMatrix[mod-1]){
610 return fCPVMatrix[mod-1] ;
613 AliWarning("Can not find PHOS misalignment matrixes\n") ;
614 AliWarning("Either import TGeoManager from geometry.root or \n");
615 AliWarning("read stored matrixes from AliESD Header: \n") ;
616 AliWarning("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
621 //____________________________________________________________________________
622 const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForPHOS(Int_t mod)const {
623 //Provides shift-rotation matrix for PHOS (EMC+CPV)
625 //If GeoManager exists, take matrixes from it
629 snprintf(path,255,"/ALIC_1/PHOS_%d",mod) ;
631 if (!gGeoManager->cd(path)){
632 AliWarning(Form("Geo manager can not find path %s \n",path));
635 return gGeoManager->GetCurrentMatrix();
637 if(fPHOSMatrix[mod-1]){
638 return fPHOSMatrix[mod-1] ;
641 AliWarning("Can not find PHOS misalignment matrixes\n") ;
642 AliWarning("Either import TGeoManager from geometry.root or \n");
643 AliWarning("read stored matrixes from AliESD Header: \n") ;
644 AliWarning("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
649 //____________________________________________________________________________
650 void AliPHOSGeoUtils::SetMisalMatrix(const TGeoHMatrix * m, Int_t mod){
651 //Fills pointers to geo matrixes
653 if(fPHOSMatrix[mod]){ //have been set already. Can not be changed any more
656 if(m==NULL) //Matrix for non-existing modules? Remain zero, no need to re-set
658 fPHOSMatrix[mod]= new TGeoHMatrix(*m) ;
660 //Calculate maxtrices for PTII
662 fMisalArray = new TClonesArray("TGeoHMatrix",1120+10) ;
663 Int_t nr = fMisalArray->GetEntriesFast() ;
664 Double_t rotEMC[9]={1.,0.,0.,0.,0.,-1.,0.,1.,0.} ;
665 const Float_t * inthermo = fGeometryEMCA->GetInnerThermoHalfSize() ;
666 const Float_t * strip = fGeometryEMCA->GetStripHalfSize() ;
667 const Float_t * covparams = fGeometryEMCA->GetAlCoverParams() ;
668 const Float_t * warmcov = fGeometryEMCA->GetWarmAlCoverHalfSize() ;
669 Float_t z = fGeometryCPV->GetCPVBoxSize(1) / 2. - warmcov[2] + covparams[3]-inthermo[1] ;
670 Double_t locTII[3]={0.,0.,z} ;
671 Double_t globTII[3] ;
673 if (fEMCMatrix[mod] == NULL)
674 fEMCMatrix[mod] = new((*fMisalArray)[nr])TGeoHMatrix() ;
676 fEMCMatrix[mod]->SetRotation(rotEMC) ;
677 fEMCMatrix[mod]->MultiplyLeft(fPHOSMatrix[mod]) ;
678 fPHOSMatrix[mod]->LocalToMaster(locTII,globTII) ;
679 fEMCMatrix[mod]->SetTranslation(globTII) ;
681 //Now calculate ideal matrixes for strip misalignment.
682 //For the moment we can not store them in ESDHeader
684 Double_t loc[3]={0.,inthermo[1] - strip[1],0.} ;
688 for(Int_t irow = 0; irow < fGeometryEMCA->GetNStripX(); irow ++){
689 loc[0] = (2*irow + 1 - fGeometryEMCA->GetNStripX())* strip[0] ;
690 for(Int_t icol = 0; icol < fGeometryEMCA->GetNStripZ(); icol ++){
691 loc[2] = (2*icol + 1 - fGeometryEMCA->GetNStripZ()) * strip[2] ;
692 fEMCMatrix[mod]->LocalToMaster(loc,glob) ;
693 if (fStripMatrix[mod][istrip] == NULL)
694 fStripMatrix[mod][istrip] = new((*fMisalArray)[nr])TGeoHMatrix(*(fEMCMatrix[mod])) ; //Use same rotation as PHOS module
696 fStripMatrix[mod][istrip]->SetTranslation(glob) ;
701 //Now calculate CPV matrixes
702 const Float_t * emcParams = fGeometryEMCA->GetEMCParams() ;
703 Double_t globCPV[3] ;
704 Double_t locCPV[3]={0.,0.,- emcParams[3]} ;
705 Double_t rot[9]={1.,0.,0.,0.,0.,1.,0.,-1.,0.} ;
707 if (fCPVMatrix[mod] == NULL)
708 fCPVMatrix[mod] = new((*fMisalArray)[nr])TGeoHMatrix() ;
710 fCPVMatrix[mod]->SetRotation(rot) ;
711 fCPVMatrix[mod]->MultiplyLeft(fPHOSMatrix[mod]) ;
712 fCPVMatrix[mod]->ReflectY(kFALSE) ;
713 fPHOSMatrix[mod]->LocalToMaster(locCPV,globCPV) ;
714 fCPVMatrix[mod]->SetTranslation(globCPV) ;