/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Emc/EmcRecGeoSvc/EmcRecGeoSvc-01-01-07/src/EmcRecBarrelGeo.cxx

Go to the documentation of this file.
00001 //
00002 //   EmcRecBarrelGeo
00003 //
00004 //   Dec 18, 2003, Created by Wang.Zhe
00005 //
00006 //   unit: mm, radian
00007 //
00008 //#include "BesGeoEMC/DB2BesGeoEMC.h"
00009 #include "EmcRecGeoSvc/EmcRecBarrelGeo.h"
00010 
00011 EmcRecBarrelGeo::EmcRecBarrelGeo()
00012 {
00013    ParameterInitialize();
00014    CalculateStandardCrystal();
00015    Transform2Column1();
00016    FillCCenterVector();
00017 }
00018 
00019 EmcRecBarrelGeo::~EmcRecBarrelGeo()
00020 {
00021    fStandard.clear();
00022    fCCenter.clear();
00023    fCFrontCenter.clear();
00024 }
00025   
00026 void EmcRecBarrelGeo::ParameterInitialize()
00027 {
00028    /*
00029    DB2BesGeoEMC obj1;
00030    vector<BesGeoEMC> VecA;
00031    
00032    obj1.Get_BesGeoEMC(VecA);
00033    fBarrelR=VecA[0].Get_BarrelR();
00034    fBarrelOffset1=VecA[0].Get_BarrelOffset1();
00035    fBarrelOffset2=VecA[0].Get_BarrelOffset2();
00036    fBarrelh1=VecA[0].Get_Barrelh1();
00037    fBarrelh2=VecA[0].Get_Barrelh2();
00038    fBarrelh3=VecA[0].Get_Barrelh3();
00039    fBarrelL=VecA[0].Get_BarrelL();
00040    fBarrelL2=VecA[0].Get_BarrelL2();
00041    fBarrelNPhiMax=(int)VecA[0].Get_BarrelNPhiMax();
00042    fBarrelNThetaMax=(int)VecA[0].Get_BarrelNThetaMax();
00043    */
00044     
00045    fBarrelR=942;
00046    fBarrelOffset1=25;
00047    fBarrelOffset2=50;
00048    fBarrelh1=51;
00049    fBarrelh2=52;
00050    fBarrelh3=52.466;
00051    fBarrelL=280;
00052    fBarrelL2=240; 
00053    fBarrelNPhiMax=120;
00054    fBarrelNThetaMax=22;
00055    
00056    fBarrelAlpha=twopi/fBarrelNPhiMax;
00057 
00058    fStandard.clear();
00059    fCCenter.clear();
00060    fCFrontCenter.clear();
00061 }
00062 
00063 void EmcRecBarrelGeo::CalculateStandardCrystal()
00064 {
00065    double R1,R2,a;
00066    EmcRecCrystal pre,now;
00067    double dx,dy,dz;
00068    HepPoint3D t1,t2;
00069    double L,h;
00070    
00071    HepPoint3D O1(0,0,0);
00072    HepPoint3D O2(0,0,fBarrelOffset1);
00073    HepPoint3D O3(0,0,fBarrelOffset2);
00074 
00075    R1=2*fBarrelR*sin(fBarrelAlpha/2)/sin(fBarrelAlpha);
00076    R2=2*fBarrelR*sin(fBarrelAlpha/2)*(tan(fBarrelAlpha)+1/tan(fBarrelAlpha));
00077    a=2*fBarrelR*sin(fBarrelAlpha/2)/cos(fBarrelAlpha);
00078    
00079    HepPoint3D M4(0,R1,0);
00080    HepPoint3D A1(a,R1,0);
00081    
00082 //   cout<<O1<<", "<<O2<<", "<<O3<<endl;
00083 //   cout<<M4<<", "<<A1<<endl;
00084 //   cout<<R1<<", "<<R2<<endl;
00085    
00086    // No. 1  theta: 21; phi: 30
00087    EmcRecCrystal Crystal1;
00088 
00089    Crystal1.Set(0,M4);
00090    Crystal1.Set(1,A1);
00091    Crystal1.Set(2,A1);   Crystal1.SetZ(2,A1.z()+fBarrelh1);
00092    Crystal1.Set(3,M4);   Crystal1.SetZ(3,M4.z()+fBarrelh1);
00093    
00094    Crystal1.Set(4,M4);   Crystal1.SetY(4,M4.y()+fBarrelL);
00095    dx=a*(R1+fBarrelL)/R1;
00096    Crystal1.Set(5,Crystal1.Get(4));   Crystal1.SetX(5,dx);
00097    dz=fBarrelOffset1+(fBarrelh1-fBarrelOffset1)*(R1+fBarrelL)/R1;
00098    Crystal1.Set(6,Crystal1.Get(5));   Crystal1.SetZ(6,Crystal1.Get(5).z()+dz);
00099    Crystal1.Set(7,Crystal1.Get(4));   Crystal1.SetZ(7,Crystal1.Get(4).z()+dz);
00100    
00101    fStandard.push_back(Crystal1);
00102    pre=fStandard[0];
00103    
00104    // No. 2  theta: 20; phi: 30
00105    EmcRecCrystal Crystal2; 
00106    double sin_gamma,cos_gamma,tan_gamma;
00107    
00108    tan_gamma=R1/(fBarrelh1-fBarrelOffset1);
00109    sin_gamma=tan_gamma/(sqrt(1+tan_gamma*tan_gamma));
00110    cos_gamma=1/(sqrt(1+tan_gamma*tan_gamma));
00111    
00112    double aa,bb,Rp;
00113    aa=fBarrelh1/sin_gamma;
00114    bb=fBarrelh1/tan_gamma; 
00115    
00116    Crystal2.Set(0,pre.Get(3));   Crystal2.SetZ(0,pre.Get(3).z()+bb*cos_gamma);
00117                                  Crystal2.SetY(0,pre.Get(3).y()+bb*sin_gamma);
00118    Rp=R1/sin_gamma;
00119    dx=a*(Rp+bb)/Rp;
00120    Crystal2.Set(1,Crystal2.Get(0));   Crystal2.SetX(1,dx);   
00121    Crystal2.Set(3,pre.Get(3));        Crystal2.SetZ(3,pre.Get(3).z()+aa);
00122    Crystal2.Set(2,Crystal2.Get(3));   Crystal2.SetX(2,a);
00123    
00124    dz=(fBarrelL+bb)*cos_gamma;
00125    dy=(fBarrelL+bb)*sin_gamma;
00126    Crystal2.Set(4,pre.Get(3));   Crystal2.SetZ(4,pre.Get(3).z()+dz);
00127                                  Crystal2.SetY(4,pre.Get(3).y()+dy); 
00128    dx=a*(Rp+bb+fBarrelL)/Rp; 
00129    Crystal2.Set(5,Crystal2.Get(4));     Crystal2.SetX(5,dx);
00130    double gam2,gam3,Lp,Rpp;
00131    t1=pre.Get(3)-Crystal2.Get(3);
00132    t2=O3-Crystal2.Get(3);
00133    gam2=acos(t1*t2/(t1.mag()*t2.mag()));
00134    gam3=acos(cos_gamma)-gam2;
00135    Lp=fBarrelL/cos(gam3);
00136    dz=Lp*cos(gam2);
00137    dy=Lp*sin(gam2);
00138    Crystal2.Set(7,Crystal2.Get(3));     Crystal2.SetZ(7,Crystal2.Get(3).z()+dz);
00139                                         Crystal2.SetY(7,Crystal2.Get(3).y()+dy);
00140    Rpp=R1/sin(gam2);
00141    dx=a*(Rpp+Lp)/Rpp;
00142    Crystal2.Set(6,Crystal2.Get(7));     Crystal2.SetX(6,dx);
00143    
00144    fStandard.push_back(Crystal2);
00145 
00146    // No. 3 -- No. 22  theta: 19-0; phi: 30
00147    for(int i=3; i<=fBarrelNThetaMax; i++) {
00148       pre=fStandard[i-2];
00149       
00150       if(i<fBarrelNThetaMax) {
00151          L=fBarrelL;
00152          h=fBarrelh2;
00153       }
00154       else {
00155          L=fBarrelL2;
00156          h=fBarrelh3;
00157       }
00158       
00159       tan_gamma=R1/(pre.Get(3).z()-fBarrelOffset2);
00160       sin_gamma=tan_gamma/(sqrt(1+tan_gamma*tan_gamma));
00161       cos_gamma=1/(sqrt(1+tan_gamma*tan_gamma));
00162 
00163       aa=h/sin_gamma;
00164       bb=h/tan_gamma;
00165       
00166       now.Set(3,pre.Get(3));   now.SetZ(3,pre.Get(3).z()+aa);
00167       now.Set(0,pre.Get(3));   now.SetZ(0,pre.Get(3).z()+bb*cos_gamma);
00168                                now.SetY(0,pre.Get(3).y()+bb*sin_gamma);
00169       
00170       now.Set(4,pre.Get(3));   now.SetZ(4,pre.Get(3).z()+(L+bb)*cos_gamma);
00171                                now.SetY(4,pre.Get(3).y()+(L+bb)*sin_gamma);
00172       
00173       gam2=atan(R1/(now.Get(3).z()-fBarrelOffset2));
00174       gam3=acos(cos_gamma)-gam2;
00175       
00176       Lp=L/cos(gam3);
00177       dz=Lp*cos(gam2);
00178       dy=Lp*sin(gam2);
00179    
00180       now.Set(7,now.Get(3));   now.SetZ(7,now.Get(3).z()+dz);
00181                                now.SetY(7,now.Get(3).y()+dy);
00182 
00183       Rp=R1/sin_gamma;
00184       dx=a*(Rp+bb)/Rp;
00185       now.Set(1,now.Get(0));   now.SetX(1,dx);
00186       dx=a*(Rp+bb+L)/Rp;
00187       now.Set(5,now.Get(4));   now.SetX(5,dx);
00188       
00189       now.Set(2,now.Get(3));   now.SetX(2,a);
00190       
00191       Rpp=R1/sin(gam2);
00192       dx=a*(Rpp+Lp)/Rpp;
00193       now.Set(6,now.Get(7));   now.SetX(6,dx);
00194       
00195       fStandard.push_back(now);
00196    }
00197    
00198 //   for(int i=1; i<=fBarrelNThetaMax; i++) {
00199 //      cout<<endl;
00200 //      cout<<"No. "<<i<<endl;
00201 //      now=fStandard[i-1];
00202 //      now.BarrelCheckout();
00203 //      now.Dump();
00204 //   }  
00205 }
00206 
00207 void EmcRecBarrelGeo::Transform2Column1()  // to theta: 21-0; phi: 0
00208 {
00209    HepPoint3D O1(fBarrelR*sin(fBarrelAlpha/2),
00210                  fBarrelR*cos(fBarrelAlpha/2)-2*fBarrelR*sin(fBarrelAlpha/2)/tan(fBarrelAlpha),
00211                  0);
00212    
00213    HepPoint3D R=fStandard[0].Get(5);
00214    double phi=(R.rotateZ(fBarrelAlpha)+O1).phi();
00215 
00216    for(int i=1; i<=fBarrelNThetaMax; i++) {
00217       for(int m=0;m<8;m++)
00218         {
00219            fStandard[i-1].Type(EmcRecCrystal::SixPlane());
00220            fStandard[i-1].Set(m,fStandard[i-1].Get(m).rotateZ(fBarrelAlpha));
00221            fStandard[i-1].Set(m,fStandard[i-1].Get(m)+O1);
00222            fStandard[i-1].Set(m,fStandard[i-1].Get(m).rotateZ(-phi));
00223         }
00224 
00225 //      cout<<endl;
00226 //      cout<<"No. "<<i<<endl;
00227 //      fStandard[i-1].BarrelCheckout();
00228 //      fStandard[i-1].Dump();
00229    }
00230 }
00231 
00232 void EmcRecBarrelGeo::FillCCenterVector()
00233 {
00234    int phi,theta;
00235    EmcRecCrystal aCry;
00236    HepPoint3D aCenter;
00237    HepPoint3D aFrontCenter;
00238    
00239    for(theta=0;theta<2*fBarrelNThetaMax;++theta) {
00240       for(phi=0;phi<fBarrelNPhiMax;++phi) {
00241          aCry=GetCrystal(EmcID::crystal_id(EmcID::getBARREL(),theta,phi));
00242          aCenter=aCry.Center();
00243    aFrontCenter=aCry.FrontCenter();
00244          fCCenter.push_back(aCenter);
00245    fCFrontCenter.push_back(aFrontCenter);
00246 //       aCry.Dump();
00247 //       cout<<"("<<theta<<","<<phi<<")  ";
00248 //       cout<<aCenter<<endl;
00249       }
00250    }
00251 }
00252 
00253 
00254 // Access
00255 EmcRecCrystal EmcRecBarrelGeo::GetCrystal(const Identifier& id) const
00256 {
00257    EmcRecCrystal cry;
00258    unsigned int theta=EmcID::theta_module(id);
00259    unsigned int phi=EmcID::phi_module(id);
00260    
00261    double dphi=phi*fBarrelAlpha;
00262    
00263    if((int)theta>=fBarrelNThetaMax) {
00264       cry=fStandard[theta-fBarrelNThetaMax];
00265       for(int m=0;m<8;++m)
00266         {
00267            cry.SetZ(m,-cry.Get(m).z());
00268         }
00269    }
00270    else {
00271       cry=fStandard[fBarrelNThetaMax-theta-1];
00272    }
00273    
00274    for(int m=0;m<8;++m)
00275      {
00276         cry.Set(m,cry.Get(m).rotateZ(dphi));
00277      }
00278    
00279    return cry;
00280 }
00281 
00282 HepPoint3D EmcRecBarrelGeo::GetCCenter(const Identifier& id) const
00283 {
00284    unsigned int theta=EmcID::theta_module(id);
00285    unsigned int phi=EmcID::phi_module(id);
00286    
00287    return fCCenter[theta*fBarrelNPhiMax+phi];
00288 }
00289 
00290 HepPoint3D EmcRecBarrelGeo::GetCFrontCenter(const Identifier& id) const
00291 {
00292   unsigned int theta=EmcID::theta_module(id);
00293   unsigned int phi=EmcID::phi_module(id);
00294 
00295   return fCFrontCenter[theta*fBarrelNPhiMax+phi];
00296 }

Generated on Tue Nov 29 22:58:18 2016 for BOSS_7.0.2 by  doxygen 1.4.7