24 {
25 if ( !gGeoManager ) gGeoManager = new TGeoManager( "BesGeo", "Bes geometry" );
26
27 EmcROOTGeo* fEmcROOTGeo = new EmcROOTGeo();
29
30
31 for (
int part = 0; part < fEmcROOTGeo->
GetPartNb(); part++ )
32 {
33 for (
int phi = 0; phi < fEmcROOTGeo->
GetPhiNb( part ); phi++ )
34 {
35 for (
int theta = 0; theta < fEmcROOTGeo->
GetThetaNb( part ); theta++ )
36 {
37 TGeoPhysicalNode* crystalPhysicalNode =
39
40 TGeoArb8* arb = (TGeoArb8*)crystalPhysicalNode->GetShape();
41
42
43 double* pRot;
44 pRot = crystalPhysicalNode->GetMatrix()->GetRotationMatrix();
45 Hep3Vector rotX( pRot[0], pRot[3], pRot[6] );
46 Hep3Vector rotY( pRot[1], pRot[4], pRot[7] );
47 Hep3Vector rotZ( pRot[2], pRot[5], pRot[8] );
48 HepRotation rotateCrystalToGlobal( rotX, rotY, rotZ );
49
50
51 Hep3Vector rotTX( pRot[0], pRot[1], pRot[2] );
52 Hep3Vector rotTY( pRot[3], pRot[4], pRot[5] );
53 Hep3Vector rotTZ( pRot[6], pRot[7], pRot[8] );
54 HepRotation rotateGlobalToCrystal( rotTX, rotTY, rotTZ );
55
56 double* pTrans;
57 pTrans = crystalPhysicalNode->GetMatrix()->GetTranslation();
58 Hep3Vector translateCrystalToGlobal( pTrans[0], pTrans[1], pTrans[2] );
59
60 Hep3Vector fPnt[10];
61 for ( int i = 0; i < 8; i++ )
62 {
63 if ( i < 4 )
64 {
65 fPnt[i] = Hep3Vector( arb->GetVertices()[i * 2], arb->GetVertices()[i * 2 + 1],
66 -arb->GetDz() );
67 }
68 else
69 {
70 fPnt[i] = Hep3Vector( arb->GetVertices()[i * 2], arb->GetVertices()[i * 2 + 1],
71 arb->GetDz() );
72 }
73
74 fPnt[i] *= rotateCrystalToGlobal;
75 fPnt[i] += translateCrystalToGlobal;
76 }
77
78 EmcRecCrystal aCrystal;
80
81 Hep3Vector tempVec;
82 if ( part == 1 )
83 {
84 tempVec = fPnt[3];
85 fPnt[3] = fPnt[0];
86 fPnt[0] = fPnt[1];
87 fPnt[1] = fPnt[2];
88 fPnt[2] = tempVec;
89 tempVec = fPnt[7];
90 fPnt[7] = fPnt[4];
91 fPnt[4] = fPnt[5];
92 fPnt[5] = fPnt[6];
93 fPnt[6] = tempVec;
94
95 for (
int i = 0; i < 8; i++ ) { aCrystal.
Set( i, fPnt[i] ); }
97 }
98 else
99 {
100 for ( int i = 0; i < 8; i++ )
101 {
102 if ( i % 2 == 0 )
103 {
104 tempVec = fPnt[i];
105 fPnt[i] = fPnt[i + 1];
106 fPnt[i + 1] = tempVec;
107 }
108 aCrystal.
Set( i, fPnt[i] );
109 }
110
111 int sector, nb;
112 if ( theta < 30 )
113 {
114 sector = phi;
115 nb = theta;
116 }
117 else
118 {
119 sector = phi;
121 if ( theta >= 30 && theta < 32 ) { nb = theta - 25; }
122 else { nb = theta - 18; }
123 int newTheta, newPhi;
126 EmcRecCrystal tempCrystal = m_crystalMap[id];
127
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 ) );
138 }
139
141 }
142 }
143 }
144 }
145
146 delete fEmcROOTGeo;
147}
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 Get(int index) const
void Set(int index, const HepPoint3D &aPoint)
void FillCrystalMap(EmcRecCrystal &, const int, const int, const int)