00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef EMC_REC_CRYSTAL_H
00014 #define EMC_REC_CRYSTAL_H
00015
00016 #include <iostream>
00017
00018 #include "CLHEP/Units/PhysicalConstants.h"
00019 #include "CLHEP/Geometry/Point3D.h"
00020 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00021 typedef HepGeom::Point3D<double> HepPoint3D;
00022 #endif
00023
00024 using namespace std;
00025 using namespace CLHEP;
00026
00027 class EmcRecCrystal
00028 {
00029 public:
00030
00031 EmcRecCrystal() {
00032 fType=INVALID_CRYSTAL;
00033 HepPoint3D O(0,0,0);
00034 for(int i=0;i<10;i++){
00035 fV[i]=O;
00036 }
00037 }
00038
00039 ~EmcRecCrystal() {}
00040
00041
00042 EmcRecCrystal(const EmcRecCrystal& aCry) {
00043 fType=aCry.Type();
00044 for(int i=0;i<10;i++){
00045 fV[i]=aCry.Get(i);
00046 }
00047 }
00048
00049 EmcRecCrystal& operator=(const EmcRecCrystal& aCry) {
00050 if(this!=&aCry)
00051 {
00052 fType=aCry.Type();
00053 for(int i=0;i<10;i++){
00054 fV[i]=aCry.Get(i);
00055 }
00056 }
00057 return *this;
00058 }
00059
00060
00061
00062 static int InvalidCrystal()
00063 { return INVALID_CRYSTAL; }
00064
00065 static int SixPlane()
00066 { return SIX_PLANE; }
00067
00068 static int SevenPlane()
00069 { return SEVEN_PLANE; }
00070
00071
00072 int Type() const
00073 { return fType; }
00074
00075 int Type(int typ)
00076 { fType=typ;
00077 if( (fType!=SIX_PLANE) && (fType!=SEVEN_PLANE) )
00078 { fType=INVALID_CRYSTAL; }
00079 return fType;
00080 }
00081
00082
00083 HepPoint3D Get(int index) const {
00084 return fV[index];
00085 }
00086
00087
00088 HepPoint3D Center() const {
00089 if(fType==SIX_PLANE) {
00090 return (fV[0]+fV[1]+fV[2]+fV[3]+fV[4]+fV[5]+fV[6]+fV[7])/8;
00091 }
00092 if(fType==SEVEN_PLANE) {
00093 return (fV[0]+fV[1]+fV[2]+fV[3]+fV[4]+fV[5]+fV[6]+fV[7]+fV[8]+fV[9])/10;
00094 }
00095 HepPoint3D O(0,0,0);
00096 return O;
00097 }
00098
00099
00100 HepPoint3D FrontCenter() const {
00101 if(fType==SIX_PLANE) {
00102 return (fV[0]+fV[1]+fV[2]+fV[3])/4;
00103 }
00104 if(fType==SEVEN_PLANE) {
00105 return (fV[0]+fV[1]+fV[2]+fV[3]+fV[4])/5;
00106 }
00107 HepPoint3D O(0,0,0);
00108 return O;
00109 }
00110
00111
00112 void Set(int index, const HepPoint3D& aPoint) {
00113 fV[index]=aPoint;
00114 }
00115
00116 void SetX(int index, double value) {
00117 fV[index].setX(value);
00118 }
00119
00120 void SetY(int index, double value) {
00121 fV[index].setY(value);
00122 }
00123
00124 void SetZ(int index, double value) {
00125 fV[index].setZ(value);
00126 }
00127
00128
00129 void BarrelCheckout() const {
00130 HepPoint3D t1,t2;
00131 cout<<"H="<<fV[4].distance(fV[7])<<endl;
00132 cout<<"h="<<fV[0].distance(fV[3])<<endl;
00133 t1=fV[3]-fV[7];
00134 t2=fV[4]-fV[7];
00135 cout<<"t="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
00136 cout<<"B="<<fV[4].distance(fV[5])<<endl;
00137 cout<<"b="<<fV[0].distance(fV[1])<<endl;
00138 cout<<"A="<<fV[7].distance(fV[6])<<endl;
00139 cout<<"a="<<fV[3].distance(fV[2])<<endl;
00140 cout<<"L="<<fV[4].distance(fV[0])<<endl;
00141 }
00142
00143 void EndCapCheckout() const {
00144 if(fType==SIX_PLANE) {
00145 cout<<"A="<<fV[5].distance(fV[6])<<endl;
00146 cout<<"a="<<fV[1].distance(fV[2])<<endl;
00147 cout<<"B="<<fV[7].distance(fV[4])<<endl;
00148 cout<<"b="<<fV[0].distance(fV[3])<<endl;
00149 cout<<"C="<<fV[7].distance(fV[6])<<endl;
00150 cout<<"c="<<fV[3].distance(fV[2])<<endl;
00151 cout<<"D="<<fV[4].distance(fV[5])<<endl;
00152 cout<<"d="<<fV[1].distance(fV[0])<<endl;
00153 HepPoint3D t1,t2;
00154 double t;
00155 t1=fV[0]-fV[3];
00156 t2=fV[2]-fV[3];
00157 cout<<"alpha1="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
00158 t1=fV[3]-fV[2];
00159 t2=fV[1]-fV[2];
00160 cout<<"alpha2="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
00161 t1=fV[2]-fV[1];
00162 t2=fV[0]-fV[1];
00163 cout<<"alpha3="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
00164 t1=fV[3]-fV[0];
00165 t2=fV[1]-fV[0];
00166 cout<<"alpha4="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
00167 t1=fV[3]-fV[7];
00168 t2=fV[4]-fV[7];
00169 t=t1*t2/(t1.mag()*t2.mag());
00170 t=sqrt(1-t*t);
00171 cout<<"L="<<t1.mag()*t<<endl;
00172 } else {
00173 cout<<"A="<<fV[5].distance(fV[9])<<endl;
00174 cout<<"a="<<fV[0].distance(fV[4])<<endl;
00175 cout<<"B="<<fV[9].distance(fV[8])<<endl;
00176 cout<<"b="<<fV[4].distance(fV[3])<<endl;
00177 cout<<"C="<<fV[8].distance(fV[7])<<endl;
00178 cout<<"c="<<fV[3].distance(fV[2])<<endl;
00179 cout<<"D="<<fV[7].distance(fV[6])<<endl;
00180 cout<<"d="<<fV[2].distance(fV[1])<<endl;
00181 cout<<"E="<<fV[6].distance(fV[5])<<endl;
00182 cout<<"e="<<fV[1].distance(fV[0])<<endl;
00183 HepPoint3D t1,t2;
00184 double t;
00185 t1=fV[1]-fV[0];
00186 t2=fV[4]-fV[0];
00187 cout<<"alpha1="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
00188 t1=fV[3]-fV[4];
00189 t2=fV[0]-fV[4];
00190 cout<<"alpha2="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
00191 t1=fV[2]-fV[3];
00192 t2=fV[4]-fV[3];
00193 cout<<"alpha3="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
00194 t1=fV[3]-fV[2];
00195 t2=fV[1]-fV[2];
00196 cout<<"alpha4="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
00197 t1=fV[0]-fV[1];
00198 t2=fV[2]-fV[1];
00199 cout<<"alpha5="<<acos(t1*t2/(t1.mag()*t2.mag()))*180/pi<<endl;
00200 t1=fV[0]-fV[6];
00201 t2=fV[5]-fV[6];
00202 t=t1*t2/(t1.mag()*t2.mag());
00203 t=sqrt(1-t*t);
00204 cout<<"L="<<t1.mag()*t<<endl;
00205 }
00206 }
00207
00208
00209 private:
00210
00211 int fType;
00212
00213
00214 HepPoint3D fV[10];
00215
00216
00217 static const int INVALID_CRYSTAL = -1;
00218 static const int SIX_PLANE = 0;
00219 static const int SEVEN_PLANE = 1;
00220 };
00221
00222 ostream& operator<<(ostream & os, const EmcRecCrystal& aCrystal);
00223 #endif