CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
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/Units/PhysicalConstants.h"
19#include "CLHEP/Geometry/Point3D.h"
20#ifndef ENABLE_BACKWARDS_COMPATIBILITY
22#endif
23
24using namespace std;
25using namespace CLHEP;
26
28{
29 public:
30 // Constructors and destructors
32 fType=INVALID_CRYSTAL;
33 HepPoint3D O(0,0,0);
34 for(int i=0;i<10;i++){
35 fV[i]=O;
36 }
37 }
38
40
41 // Copy and Assignment
43 fType=aCry.Type();
44 for(int i=0;i<10;i++){
45 fV[i]=aCry.Get(i);
46 }
47 }
48
50 if(this!=&aCry)
51 {
52 fType=aCry.Type();
53 for(int i=0;i<10;i++){
54 fV[i]=aCry.Get(i);
55 }
56 }
57 return *this;
58 }
59
60 // Accessment
61 // Crystal type mask
62 static int InvalidCrystal()
63 { return INVALID_CRYSTAL; }
64
65 static int SixPlane()
66 { return SIX_PLANE; }
67
68 static int SevenPlane()
69 { return SEVEN_PLANE; }
70
71 // Type read and write
72 int Type() const
73 { return fType; }
74
75 int Type(int typ)
76 { fType=typ;
77 if( (fType!=SIX_PLANE) && (fType!=SEVEN_PLANE) )
78 { fType=INVALID_CRYSTAL; }
79 return fType;
80 }
81
82 // Read Vertex
83 HepPoint3D Get(int index) const {
84 return fV[index];
85 }
86
87 // Get Crystal center
89 if(fType==SIX_PLANE) {
90 return (fV[0]+fV[1]+fV[2]+fV[3]+fV[4]+fV[5]+fV[6]+fV[7])/8;
91 }
92 if(fType==SEVEN_PLANE) {
93 return (fV[0]+fV[1]+fV[2]+fV[3]+fV[4]+fV[5]+fV[6]+fV[7]+fV[8]+fV[9])/10;
94 }
95 HepPoint3D O(0,0,0);
96 return O;
97 }
98
99 // Get Crystal front center
101 if(fType==SIX_PLANE) {
102 return (fV[0]+fV[1]+fV[2]+fV[3])/4;
103 }
104 if(fType==SEVEN_PLANE) {
105 return (fV[0]+fV[1]+fV[2]+fV[3]+fV[4])/5;
106 }
107 HepPoint3D O(0,0,0);
108 return O;
109 }
110
111 // Write Vertex
112 void Set(int index, const HepPoint3D& aPoint) {
113 fV[index]=aPoint;
114 }
115
116 void SetX(int index, double value) {
117 fV[index].setX(value);
118 }
119
120 void SetY(int index, double value) {
121 fV[index].setY(value);
122 }
123
124 void SetZ(int index, double value) {
125 fV[index].setZ(value);
126 }
127
128
129 void BarrelCheckout() const {
130 HepPoint3D t1,t2;
131 cout<<"H="<<fV[4].distance(fV[7])<<endl;
132 cout<<"h="<<fV[0].distance(fV[3])<<endl;
133 t1=fV[3]-fV[7];
134 t2=fV[4]-fV[7];
135 cout<<"t="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
136 cout<<"B="<<fV[4].distance(fV[5])<<endl;
137 cout<<"b="<<fV[0].distance(fV[1])<<endl;
138 cout<<"A="<<fV[7].distance(fV[6])<<endl;
139 cout<<"a="<<fV[3].distance(fV[2])<<endl;
140 cout<<"L="<<fV[4].distance(fV[0])<<endl;
141 }
142
143 void EndCapCheckout() const {
144 if(fType==SIX_PLANE) {
145 cout<<"A="<<fV[5].distance(fV[6])<<endl;
146 cout<<"a="<<fV[1].distance(fV[2])<<endl;
147 cout<<"B="<<fV[7].distance(fV[4])<<endl;
148 cout<<"b="<<fV[0].distance(fV[3])<<endl;
149 cout<<"C="<<fV[7].distance(fV[6])<<endl;
150 cout<<"c="<<fV[3].distance(fV[2])<<endl;
151 cout<<"D="<<fV[4].distance(fV[5])<<endl;
152 cout<<"d="<<fV[1].distance(fV[0])<<endl;
153 HepPoint3D t1,t2;
154 double t;
155 t1=fV[0]-fV[3];
156 t2=fV[2]-fV[3];
157 cout<<"alpha1="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
158 t1=fV[3]-fV[2];
159 t2=fV[1]-fV[2];
160 cout<<"alpha2="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
161 t1=fV[2]-fV[1];
162 t2=fV[0]-fV[1];
163 cout<<"alpha3="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
164 t1=fV[3]-fV[0];
165 t2=fV[1]-fV[0];
166 cout<<"alpha4="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
167 t1=fV[3]-fV[7];
168 t2=fV[4]-fV[7];
169 t=t1*t2/(t1.mag()*t2.mag());
170 t=sqrt(1-t*t);
171 cout<<"L="<<t1.mag()*t<<endl;
172 } else {
173 cout<<"A="<<fV[5].distance(fV[9])<<endl;
174 cout<<"a="<<fV[0].distance(fV[4])<<endl;
175 cout<<"B="<<fV[9].distance(fV[8])<<endl;
176 cout<<"b="<<fV[4].distance(fV[3])<<endl;
177 cout<<"C="<<fV[8].distance(fV[7])<<endl;
178 cout<<"c="<<fV[3].distance(fV[2])<<endl;
179 cout<<"D="<<fV[7].distance(fV[6])<<endl;
180 cout<<"d="<<fV[2].distance(fV[1])<<endl;
181 cout<<"E="<<fV[6].distance(fV[5])<<endl;
182 cout<<"e="<<fV[1].distance(fV[0])<<endl;
183 HepPoint3D t1,t2;
184 double t;
185 t1=fV[1]-fV[0];
186 t2=fV[4]-fV[0];
187 cout<<"alpha1="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
188 t1=fV[3]-fV[4];
189 t2=fV[0]-fV[4];
190 cout<<"alpha2="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
191 t1=fV[2]-fV[3];
192 t2=fV[4]-fV[3];
193 cout<<"alpha3="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
194 t1=fV[3]-fV[2];
195 t2=fV[1]-fV[2];
196 cout<<"alpha4="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
197 t1=fV[0]-fV[1];
198 t2=fV[2]-fV[1];
199 cout<<"alpha5="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
200 t1=fV[0]-fV[6];
201 t2=fV[5]-fV[6];
202 t=t1*t2/(t1.mag()*t2.mag());
203 t=sqrt(1-t*t);
204 cout<<"L="<<t1.mag()*t<<endl;
205 }
206 }
207
208 // data members
209 private:
210 // Different type will gives different result.
211 int fType;
212 // Ten vertexes
213 // For six planes crystal, only eight ones are in use
214 HepPoint3D fV[10];
215
216 // Type definition
217 static const int INVALID_CRYSTAL = -1;
218 static const int SIX_PLANE = 0;
219 static const int SEVEN_PLANE = 1;
220};
221
222ostream& operator<<(ostream & os, const EmcRecCrystal& aCrystal);
223#endif /* EMC_REC_CRYSTAL_H */
HepGeom::Point3D< double > HepPoint3D
ostream & operator<<(ostream &os, const EmcRecCrystal &aCrystal)
void EndCapCheckout() const
HepPoint3D Center() const
void SetY(int index, double value)
HepPoint3D Get(int index) const
void BarrelCheckout() const
static int SixPlane()
void SetX(int index, double value)
static int InvalidCrystal()
HepPoint3D FrontCenter() const
int Type() const
void SetZ(int index, double value)
EmcRecCrystal(const EmcRecCrystal &aCry)
static int SevenPlane()
EmcRecCrystal & operator=(const EmcRecCrystal &aCry)
void Set(int index, const HepPoint3D &aPoint)
int Type(int typ)
int t()
Definition t.c:1
const float pi
Definition vector3.h:133