9#include "EmcRecGeoSvc/EmcRecROOTGeo.h"
10#include "EmcRecGeoSvc/EmcRecCrystal.h"
11#include "ROOTGeo/EmcROOTGeo.h"
12#include "CLHEP/Vector/Rotation.h"
14#include <TGeoManager.h>
32 if(!gGeoManager) gGeoManager =
new TGeoManager(
"BesGeo",
"Bes geometry");
38 for (
int part = 0; part < fEmcROOTGeo->
GetPartNb(); part++) {
39 for (
int phi = 0; phi < fEmcROOTGeo->
GetPhiNb(part); phi++) {
40 for (
int theta = 0; theta < fEmcROOTGeo->
GetThetaNb(part); theta++) {
41 TGeoPhysicalNode *crystalPhysicalNode
44 TGeoArb8 *arb = (TGeoArb8*)crystalPhysicalNode->GetShape();
48 pRot = crystalPhysicalNode->GetMatrix()->GetRotationMatrix();
49 Hep3Vector rotX(pRot[0], pRot[3], pRot[6]);
50 Hep3Vector rotY(pRot[1], pRot[4], pRot[7]);
51 Hep3Vector rotZ(pRot[2], pRot[5], pRot[8]);
52 HepRotation rotateCrystalToGlobal(rotX, rotY, rotZ);
55 Hep3Vector rotTX(pRot[0], pRot[1], pRot[2]);
56 Hep3Vector rotTY(pRot[3], pRot[4], pRot[5]);
57 Hep3Vector rotTZ(pRot[6], pRot[7], pRot[8]);
58 HepRotation rotateGlobalToCrystal(rotTX, rotTY, rotTZ);
61 pTrans = crystalPhysicalNode->GetMatrix()->GetTranslation();
62 Hep3Vector translateCrystalToGlobal(pTrans[0], pTrans[1], pTrans[2]);
65 for(
int i=0;i<8;i++) {
67 fPnt[i] = Hep3Vector(arb->GetVertices()[i*2],
68 arb->GetVertices()[i*2+1],
71 fPnt[i] = Hep3Vector(arb->GetVertices()[i*2],
72 arb->GetVertices()[i*2+1],
76 fPnt[i] *= rotateCrystalToGlobal;
77 fPnt[i] += translateCrystalToGlobal;
96 for(
int i=0;i<8;i++) {
97 aCrystal.
Set(i,fPnt[i]);
102 for(
int i=0;i<8;i++) {
108 aCrystal.
Set(i,fPnt[i]);
118 if(theta>=30&&theta<32) {
123 int newTheta, newPhi;
128 aCrystal.
Set(0,tempCrystal.
Get(0));
129 aCrystal.
Set(1,fPnt[0]);
130 aCrystal.
Set(2,fPnt[1]);
131 aCrystal.
Set(3,tempCrystal.
Get(2));
132 aCrystal.
Set(4,tempCrystal.
Get(3));
133 aCrystal.
Set(5,tempCrystal.
Get(4));
134 aCrystal.
Set(6,fPnt[4]);
135 aCrystal.
Set(7,fPnt[5]);
136 aCrystal.
Set(8,tempCrystal.
Get(6));
137 aCrystal.
Set(9,tempCrystal.
Get(7));
150 const int part,
const int theta,
const int phi)
155 m_crystalMap[id]=aCrystal;
157 int newTheta, newPhi;
160 m_crystalMap[id]=aCrystal;
166 return m_crystalMap.find(
id)->second;
180 const int theta,
const int phi,
int& newTheta,
int& newPhi)
183 if((sector>=0)&&(sector<3))
187 if((theta>=0)&&(theta<4))
190 newPhi = (sector-3)*4+theta;
192 else if((theta>=4)&&(theta<8))
195 newPhi = (sector-3)*4+theta-4;
197 else if((theta>=8)&&(theta<13))
200 newPhi = (sector-3)*5+theta-8;
202 else if((theta>=13)&&(theta<18))
205 newPhi = (sector-3)*5+theta-13;
207 else if((theta>=18)&&(theta<24))
210 newPhi = (sector-3)*6+theta-18;
212 else if((theta>=24)&&(theta<30))
215 newPhi = (sector-3)*6+theta-24;
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
static unsigned int getBARREL()
int GetPartNb()
Get number of part;.
int GetPhiNb(int part)
Get number of phi on part;.
void SetPhysicalNode()
Set the pointers to the physical nodes;.
int GetThetaNb(int part)
Get number of theta on part;.
TGeoPhysicalNode * GetPhysicalCrystal(int part, int phi, int theta)
Get crystal physical node;.
HepPoint3D Center() const
HepPoint3D Get(int index) const
HepPoint3D FrontCenter() const
void Set(int index, const HepPoint3D &aPoint)
void ComputeThetaPhi(const int part, const int theta, const int phi, int &newTheta, int &newPhi)
void FillCrystalMap(EmcRecCrystal &, const int, const int, const int)
EmcRecCrystal GetCrystal(const Identifier &id) const
HepPoint3D GetCFrontCenter(const Identifier &id) const
HepPoint3D GetCCenter(const Identifier &id) const