BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Emc/EmcRecGeoSvc/include/EmcRecGeoSvc/EmcRecCrystal.h
Go to the documentation of this file.
1//
2// EmcRecCrystal
3//
4// Dec 18, 2003, Created by Zhe Wang
5//
6// unit: mm, radian
7//
8// Only six planes tower-like crystal in barrel EMC.
9// Two kinds of cryscal exist in endcap EMC:
10// six planes and some seven planes cystals
11// Be careful when using them.
12//
13#ifndef EMC_REC_CRYSTAL_H
14#define EMC_REC_CRYSTAL_H
15
16#include <iostream>
17
18#include "CLHEP/Geometry/Point3D.h"
19#include "CLHEP/Units/PhysicalConstants.h"
20#ifndef ENABLE_BACKWARDS_COMPATIBILITY
21typedef HepGeom::Point3D<double> HepPoint3D;
22#endif
23
24using namespace std;
25using namespace CLHEP;
26
28public:
29 // Constructors and destructors
31 fType = INVALID_CRYSTAL;
32 HepPoint3D O( 0, 0, 0 );
33 for ( int i = 0; i < 10; i++ ) { fV[i] = O; }
34 }
35
37
38 // Copy and Assignment
40 fType = aCry.Type();
41 for ( int i = 0; i < 10; i++ ) { fV[i] = aCry.Get( i ); }
42 }
43
45 if ( this != &aCry )
46 {
47 fType = aCry.Type();
48 for ( int i = 0; i < 10; i++ ) { fV[i] = aCry.Get( i ); }
49 }
50 return *this;
51 }
52
53 // Accessment
54 // Crystal type mask
55 static int InvalidCrystal() { return INVALID_CRYSTAL; }
56
57 static int SixPlane() { return SIX_PLANE; }
58
59 static int SevenPlane() { return SEVEN_PLANE; }
60
61 // Type read and write
62 int Type() const { return fType; }
63
64 int Type( int typ ) {
65 fType = typ;
66 if ( ( fType != SIX_PLANE ) && ( fType != SEVEN_PLANE ) ) { fType = INVALID_CRYSTAL; }
67 return fType;
68 }
69
70 // Read Vertex
71 HepPoint3D Get( int index ) const { return fV[index]; }
72
73 // Get Crystal center
75 if ( fType == SIX_PLANE )
76 { return ( fV[0] + fV[1] + fV[2] + fV[3] + fV[4] + fV[5] + fV[6] + fV[7] ) / 8; }
77 if ( fType == SEVEN_PLANE )
78 {
79 return ( fV[0] + fV[1] + fV[2] + fV[3] + fV[4] + fV[5] + fV[6] + fV[7] + fV[8] +
80 fV[9] ) /
81 10;
82 }
83 HepPoint3D O( 0, 0, 0 );
84 return O;
85 }
86
87 // Get Crystal front center
89 if ( fType == SIX_PLANE ) { return ( fV[0] + fV[1] + fV[2] + fV[3] ) / 4; }
90 if ( fType == SEVEN_PLANE ) { return ( fV[0] + fV[1] + fV[2] + fV[3] + fV[4] ) / 5; }
91 HepPoint3D O( 0, 0, 0 );
92 return O;
93 }
94
95 // Write Vertex
96 void Set( int index, const HepPoint3D& aPoint ) { fV[index] = aPoint; }
97
98 void SetX( int index, double value ) { fV[index].setX( value ); }
99
100 void SetY( int index, double value ) { fV[index].setY( value ); }
101
102 void SetZ( int index, double value ) { fV[index].setZ( value ); }
103
104 void BarrelCheckout() const {
105 HepPoint3D t1, t2;
106 cout << "H=" << fV[4].distance( fV[7] ) << endl;
107 cout << "h=" << fV[0].distance( fV[3] ) << endl;
108 t1 = fV[3] - fV[7];
109 t2 = fV[4] - fV[7];
110 cout << "t=" << acos( t1 * t2 / ( t1.mag() * t2.mag() ) ) * 180 / pi << endl;
111 cout << "B=" << fV[4].distance( fV[5] ) << endl;
112 cout << "b=" << fV[0].distance( fV[1] ) << endl;
113 cout << "A=" << fV[7].distance( fV[6] ) << endl;
114 cout << "a=" << fV[3].distance( fV[2] ) << endl;
115 cout << "L=" << fV[4].distance( fV[0] ) << endl;
116 }
117
118 void EndCapCheckout() const {
119 if ( fType == SIX_PLANE )
120 {
121 cout << "A=" << fV[5].distance( fV[6] ) << endl;
122 cout << "a=" << fV[1].distance( fV[2] ) << endl;
123 cout << "B=" << fV[7].distance( fV[4] ) << endl;
124 cout << "b=" << fV[0].distance( fV[3] ) << endl;
125 cout << "C=" << fV[7].distance( fV[6] ) << endl;
126 cout << "c=" << fV[3].distance( fV[2] ) << endl;
127 cout << "D=" << fV[4].distance( fV[5] ) << endl;
128 cout << "d=" << fV[1].distance( fV[0] ) << endl;
129 HepPoint3D t1, t2;
130 double t;
131 t1 = fV[0] - fV[3];
132 t2 = fV[2] - fV[3];
133 cout << "alpha1=" << acos( t1 * t2 / ( t1.mag() * t2.mag() ) ) * 180 / pi << endl;
134 t1 = fV[3] - fV[2];
135 t2 = fV[1] - fV[2];
136 cout << "alpha2=" << acos( t1 * t2 / ( t1.mag() * t2.mag() ) ) * 180 / pi << endl;
137 t1 = fV[2] - fV[1];
138 t2 = fV[0] - fV[1];
139 cout << "alpha3=" << acos( t1 * t2 / ( t1.mag() * t2.mag() ) ) * 180 / pi << endl;
140 t1 = fV[3] - fV[0];
141 t2 = fV[1] - fV[0];
142 cout << "alpha4=" << acos( t1 * t2 / ( t1.mag() * t2.mag() ) ) * 180 / pi << endl;
143 t1 = fV[3] - fV[7];
144 t2 = fV[4] - fV[7];
145 t = t1 * t2 / ( t1.mag() * t2.mag() );
146 t = sqrt( 1 - t * t );
147 cout << "L=" << t1.mag() * t << endl;
148 }
149 else
150 {
151 cout << "A=" << fV[5].distance( fV[9] ) << endl;
152 cout << "a=" << fV[0].distance( fV[4] ) << endl;
153 cout << "B=" << fV[9].distance( fV[8] ) << endl;
154 cout << "b=" << fV[4].distance( fV[3] ) << endl;
155 cout << "C=" << fV[8].distance( fV[7] ) << endl;
156 cout << "c=" << fV[3].distance( fV[2] ) << endl;
157 cout << "D=" << fV[7].distance( fV[6] ) << endl;
158 cout << "d=" << fV[2].distance( fV[1] ) << endl;
159 cout << "E=" << fV[6].distance( fV[5] ) << endl;
160 cout << "e=" << fV[1].distance( fV[0] ) << endl;
161 HepPoint3D t1, t2;
162 double t;
163 t1 = fV[1] - fV[0];
164 t2 = fV[4] - fV[0];
165 cout << "alpha1=" << acos( t1 * t2 / ( t1.mag() * t2.mag() ) ) * 180 / pi << endl;
166 t1 = fV[3] - fV[4];
167 t2 = fV[0] - fV[4];
168 cout << "alpha2=" << acos( t1 * t2 / ( t1.mag() * t2.mag() ) ) * 180 / pi << endl;
169 t1 = fV[2] - fV[3];
170 t2 = fV[4] - fV[3];
171 cout << "alpha3=" << acos( t1 * t2 / ( t1.mag() * t2.mag() ) ) * 180 / pi << endl;
172 t1 = fV[3] - fV[2];
173 t2 = fV[1] - fV[2];
174 cout << "alpha4=" << acos( t1 * t2 / ( t1.mag() * t2.mag() ) ) * 180 / pi << endl;
175 t1 = fV[0] - fV[1];
176 t2 = fV[2] - fV[1];
177 cout << "alpha5=" << acos( t1 * t2 / ( t1.mag() * t2.mag() ) ) * 180 / pi << endl;
178 t1 = fV[0] - fV[6];
179 t2 = fV[5] - fV[6];
180 t = t1 * t2 / ( t1.mag() * t2.mag() );
181 t = sqrt( 1 - t * t );
182 cout << "L=" << t1.mag() * t << endl;
183 }
184 }
185
186 // data members
187private:
188 // Different type will gives different result.
189 int fType;
190 // Ten vertexes
191 // For six planes crystal, only eight ones are in use
192 HepPoint3D fV[10];
193
194 // Type definition
195 static const int INVALID_CRYSTAL = -1;
196 static const int SIX_PLANE = 0;
197 static const int SEVEN_PLANE = 1;
198};
199
200ostream& operator<<( ostream& os, const EmcRecCrystal& aCrystal );
201#endif /* EMC_REC_CRYSTAL_H */
HepGeom::Point3D< double > HepPoint3D
ostream & operator<<(ostream &os, const EmcRecCrystal &aCrystal)
double pi
EmcRecCrystal & operator=(const EmcRecCrystal &aCry)
void Set(int index, const HepPoint3D &aPoint)
int t()
Definition t.c:1