/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Muc/MucGeoCreateAlg/MucGeoCreateAlg-00-01-00/src/MucBox.cxx

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------|
00002 //      [File  ]:                       MucBox.cxx                              |
00003 //      [Brief ]:       MUC geometry box creating class                         |
00004 //      [Author]:       Xie Yuguang, <ygxie@mail.ihep.ac.cn>                    |
00005 //      [Date  ]:       May 22, 2005                                            |
00006 //------------------------------------------------------------------------------|
00007 
00008 #include <iostream>
00009 #include <cmath>
00010 
00011 #include "MucGeoCreateAlg/MucGeoConst.h"
00012 #include "MucGeoCreateAlg/MucBox.h"
00013 
00014 using namespace std;
00015 
00016 // Constructor
00017 MucBox::MucBox( int part, int segment, int layer, int id ) : MucEntity( part, segment, layer, id )
00018 {
00019         MucBox::Init();
00020         
00021         m_MucStripPlane = NULL;
00022         m_MucRpc        = NULL;
00023         m_MucBoxCover   = NULL;
00024 }
00025 
00026 // Copy constructor             
00027 MucBox::MucBox( const MucBox &other ) : MucEntity( other )
00028 {
00029         m_MucStripPlane = other.m_MucStripPlane;
00030         m_MucRpc        = other.m_MucRpc;
00031         m_MucBoxCover   = other.m_MucBoxCover;
00032 }
00033 
00034 // Operator =
00035 MucBox& MucBox::operator =( const MucBox &other )
00036 {
00037         if( this == &other)
00038                 return *this;
00039 
00040         MucEntity::operator =(other);
00041 
00042         m_MucRpc        = other.m_MucRpc;
00043         m_MucBoxCover   = other.m_MucBoxCover;
00044         m_MucStripPlane = other.m_MucStripPlane;
00045 
00046         return *this;   
00047 }
00048 
00049 // Destructor
00050 MucBox::~MucBox()
00051 {       
00052         delete m_MucStripPlane;
00053         delete m_MucRpc;
00054         delete m_MucBoxCover;   
00055 }
00056 
00057 // Initialize
00058 void MucBox::Init()
00059 {
00060         SetTheta();
00061         SetRin();
00062         SetRout();
00063         SetRc();
00064 
00065         SetThin();
00066         SetW();
00067         SetWu();
00068         SetWd();
00069         SetH();
00070         SetL();
00071         SetArea();
00072 
00073         SetLocOrgInBes();
00074         SetObjRotToMot();
00075         SetObjOrgInBes();
00076         SetObjOrgInLoc();
00077 }
00078                 
00079 //----------------------------- Get methods --------------------------
00080 
00081 MucStripPlane* MucBox::GetStripPlane( )
00082 {
00083         if( m_MucStripPlane != NULL )
00084                 return m_MucStripPlane;
00085         else
00086                 return ( m_MucStripPlane = new MucStripPlane( m_Part, m_Segment, m_Layer, ((m_Part==BRID)?0:-1) ) );
00087 }
00088 
00089 MucRpc* MucBox::GetRpc( int upDown, int id )
00090 {
00091         if( m_MucRpc != NULL )
00092                 delete m_MucRpc;
00093         
00094         return ( m_MucRpc = new MucRpc( m_Part, m_Segment, m_Layer, upDown, id ) );
00095 }
00096 
00097 MucBoxCover* MucBox::GetBoxCover( int upDown, int id )
00098 {
00099         if( m_MucBoxCover != NULL )
00100                 delete m_MucBoxCover;
00101 
00102         return ( m_MucBoxCover = new MucBoxCover( m_Part, m_Segment, m_Layer, upDown, id ) );
00103 }
00104 
00105 
00106 //------------------------------- Set motheds -------------------------
00107 void MucBox::SetTheta()
00108 {
00109         if( m_Part == BRID )
00110                 m_Theta = m_Segment * ( MUC_PI/4.0 );
00111         else
00112         {
00113                 if( m_ID == -1 )
00114                         m_Theta = ( 2*m_Segment + 1 ) * ( MUC_PI/4.0 );
00115                 else
00116                         m_Theta = ( MUC_PI/4.0 ) + ( m_ID - 1) * MUC_PI / 8.0 ;
00117         }
00118 }
00119 
00120 void MucBox::SetRin()
00121 {
00122         if( m_Part == BRID )
00123                 m_Rin = B_AS_RMIN[m_Layer] - ( AS_GAP + BOX_TH ) / 2.0;
00124         else
00125         {
00126                 if( m_ID == -1 )
00127                         m_Rin = 0.;
00128                 else
00129                         m_Rin = E_GP_RMIN[m_Layer];
00130         }
00131 }
00132 
00133 void MucBox::SetRout()
00134 {
00135         if( m_Part == BRID )
00136                 m_Rout = B_AS_RMIN[m_Layer] -( AS_GAP - BOX_TH ) / 2.0;
00137         else
00138                 m_Rout = E_AS_RMAX - E_BOX_DR;
00139 }
00140 
00141 void MucBox::SetRc()
00142 {
00143         if( m_Part == BRID )
00144                 m_Rc = B_AS_RMIN[m_Layer] - AS_GAP/2.0;
00145         else
00146         {
00147                 if( m_ID == -1 )
00148                         m_Rc = sqrt(2.0) * ( E_AS_RMAX - E_BOX_DR ) / 2.0;
00149                 else
00150                         m_Rc = (m_Rin + m_Rout)/2.0;
00151         }
00152 }
00153 
00154 void MucBox::SetThin()
00155 {
00156         m_Thin = BOX_TH;
00157 }
00158 
00159 void MucBox::SetW()
00160 {
00161         if( m_Part == BRID)
00162         {
00163                 if( m_Segment != B_TOP )
00164                          m_W = B_BOX_WT[m_Layer];
00165                 else    // top segment
00166                 {
00167                         if( m_ID == -1 || m_ID == 2 )
00168                                 m_W = B_BOX_WT[m_Layer];
00169                         else
00170                                 m_W = ( B_BOX_WT[m_Layer] - B_BOX_SLOT_WT )/2.0;
00171                 }
00172         }
00173         else
00174         {
00175                 if( m_ID == -1 ) // virtual encap gap 
00176                         m_W = E_AS_RMAX - E_BOX_DR - E_GP_DX;
00177                 else
00178                         m_W = 0.;
00179         }
00180 }
00181 
00182 void MucBox::SetH()
00183 {
00184         if( m_Part == BRID )
00185                 m_H = BOX_TH;
00186         else
00187         {
00188                 if( m_ID == -1 ) // virtual encap gap
00189                         m_H = E_AS_RMAX - E_BOX_DR - E_GP_DY;
00190                 else if( m_ID == 1 )
00191                 {       // for panel logical operation "AND" valid;
00192                         m_H = E_AS_RMAX - E_BOX_DR - E_GP_RMIN[m_Layer] + OVERLAP_WIDTH;
00193                 }
00194                 else    
00195                         m_H = E_AS_RMAX - E_BOX_DR - E_GP_RMIN[m_Layer];
00196         }
00197 }
00198 
00199 void MucBox::SetL()
00200 {
00201         if( m_Part == BRID )
00202         {
00203                 if( m_Segment != B_TOP || m_ID == -1 )
00204                         m_L = B_BOX_LT;
00205                 else // top segment
00206                 {
00207                         if( m_ID == 2 )
00208                                 m_L = B_BOX_LT - B_TOPRPC_LTS[(m_Layer==0)?1:(m_Layer%2)];
00209                         else
00210                                 m_L = B_TOPRPC_LTS[(m_Layer==0)?1:(m_Layer%2)];
00211                 }
00212         }
00213         else
00214                 m_L = BOX_TH;
00215 }
00216 
00217 void MucBox::SetWu()
00218 {
00219         if( m_Part == BRID )
00220                 m_Wu = m_W;
00221         else
00222         {       
00223                 if( m_ID == -1 )     // virtual box 
00224                         m_Wu = m_W;
00225                 else if( m_ID == 1 ) // center fraction
00226                 {       
00227                         m_Wu = 2 * VALUE * m_Rin ;
00228                         m_Wu -= 2*VALUE*(2.0/2); // for panel operation "AND" valid
00229                         m_Wu += OVERLAP_WIDTH;
00230                 }       
00231                 else if( m_ID == 0 )
00232                         m_Wu = VALUE * m_Rin - E_GP_DY;
00233                 else
00234                         m_Wu = VALUE * m_Rin - E_GP_DX;
00235 
00236                 if( m_ID != -1 ) m_Wu+=OVERLAP_WIDTH; // avoid panels overlap
00237         }
00238 }
00239 
00240 void MucBox::SetWd()
00241 {
00242          if( m_Part == BRID )
00243                 m_Wd = m_W;
00244         else
00245         {       
00246                 if( m_ID == -1 )     // virtual box
00247                         m_Wd = m_W;
00248                 else if( m_ID == 1 ) // center fraction
00249                 {       
00250                         m_Wd = 2 * VALUE * m_Rout;
00251                         m_Wd += 2*VALUE*(2.0/2); // for panel operation "AND" valid
00252                         m_Wd += OVERLAP_WIDTH;
00253                 }       
00254                 else if( m_ID == 0 )
00255                         m_Wd = VALUE * m_Rout - E_GP_DY;
00256                 else
00257                         m_Wd = VALUE * m_Rout - E_GP_DX;
00258 
00259                 if( m_ID != -1 ) m_Wd+=OVERLAP_WIDTH; // avoid panels overlap
00260 
00261         }
00262 }
00263 
00264 void MucBox::SetArea()
00265 {
00266         if( m_Part == BRID )
00267                 m_Area = m_W * m_L;
00268         else
00269                 m_Area = m_W * m_L; 
00270 }
00271 
00272 
00273 // local is gap
00274 void MucBox::SetLocOrgInBes()
00275 {
00276         double x, y, z;
00277         x = y = z = 0.;
00278 
00279         if( m_Part == BRID )
00280         {
00281                 x = m_Rc*cos( m_Theta );
00282                 y = m_Rc*sin( m_Theta );
00283                 z = 0.;
00284 
00285         } // barrel
00286         else
00287         {
00288                 //------------ set x and y ---------------
00289                 // segment 0 as reference
00290                 if( m_ID == -1 ) // for box, local is gap
00291                 {
00292                         x = (E_AS_RMAX + E_GP_DX) / 2.0;
00293                         y = (E_AS_RMAX + E_GP_DY) / 2.0;
00294                 }
00295                 else // for box panel, local is box
00296                 {
00297                         x = (E_AS_RMAX - E_BOX_DR + E_GP_DX) / 2.0;
00298                         y = (E_AS_RMAX - E_BOX_DR + E_GP_DY) / 2.0;
00299                 }
00300 
00301                 // x, y signs of coordinate different by segment 
00302                 if      ( m_Segment == 0 ) {    ;               }
00303                 else if ( m_Segment == 1 ) {    x = -x;         }
00304                 else if ( m_Segment == 2 ) {    x = -x; y = -y; }
00305                 else                       {    y = -y;         }
00306 
00307                 //------------- set z --------------------
00308                 for( int i=0; i<m_Layer+1; i++ ) z += E_AS_TH[i];
00309                 
00310                 z += m_Layer * AS_GAP;
00311                 z += (E_AS_ZMAX - E_AS_TOTAL_TH) + AS_GAP/2.0;  
00312                 z *= cos( m_Part*MUC_PI/2.0 );
00313 
00314         }// endcap
00315 
00316         m_LocOrgInBes[0] = x;
00317         m_LocOrgInBes[1] = y;
00318         m_LocOrgInBes[2] = z;
00319 
00320         // limit cut
00321         for(int i=0;i<3;i++) {
00322                 if( fabs(m_LocOrgInBes[i]) < ERR_LIMIT ) m_LocOrgInBes[i] = 0;
00323         }
00324 }
00325 
00326 void MucBox::SetObjRotToMot()
00327 {
00328         m_ObjRotToMot[0] = 0.;
00329         m_ObjRotToMot[1] = 0.;
00330 
00331         if( m_Part == BRID )
00332         {
00333                 // for barrel segment 5, 6 and 7, the box is uppended in the gap
00334                 if( m_Segment == 5 || m_Segment == 6 || m_Segment == 7 )
00335                         m_ObjRotToMot[2] = MUC_PI;
00336                 else
00337                         m_ObjRotToMot[2] = 0.;
00338         }
00339         else
00340         {
00341                 m_ObjRotToMot[2] = 0.;
00342         }
00343 }
00344 
00345 void MucBox::SetObjOrgInBes()
00346 {
00347         double x, y, z;
00348         x = y = z = 0.;
00349 
00350         if( m_Part == BRID )
00351         {
00352                 if( m_Segment != B_TOP  || m_ID == -1 )
00353                         for( int i=0; i<3; i++ ) m_ObjOrgInBes[i] = m_LocOrgInBes[i];
00354                 else // top segment
00355                 {
00356                         // set x
00357                         if( m_ID == 2 ) x = 0.;
00358                         else            x = (1-2*m_ID) * ( B_BOX_WT[m_Layer] + B_BOX_SLOT_WT )/4.0; 
00359                         
00360 
00361                         // set z
00362                         if( m_ID == 2 ) z = -B_TOPRPC_LTS[(m_Layer==0)?1:(m_Layer%2)] / 2.0;
00363                         else            z = ( B_BOX_LT - B_TOPRPC_LTS[(m_Layer==0)?1:(m_Layer%2)] )/2.0;
00364                         
00365                         m_ObjOrgInBes[0] = x;
00366                         m_ObjOrgInBes[2] = z;
00367                         
00368                         // set y
00369                         m_ObjOrgInBes[1] = m_LocOrgInBes[1];
00370 
00371                         // limit cut
00372                         for( int i=0; i<3; i++ ) {
00373                                 if( fabs(m_ObjOrgInBes[i]) < ERR_LIMIT ) m_ObjOrgInBes[i] = 0;
00374 
00375                         }
00376                 }
00377         }
00378         else // endcap 
00379         {
00380                 //------------- set x, y --------------------------
00381                 // segment 0 as reference 
00382                 if( m_ID == -1 )
00383                 {
00384                         x = (E_AS_RMAX - E_BOX_DR + E_GP_DX) / 2.0; 
00385                         y = (E_AS_RMAX - E_BOX_DR + E_GP_DY) / 2.0;     
00386                 }
00387                 else if( m_ID == 0 )
00388                 {
00389                         x = m_Rc;
00390                         y = ( m_Rc * tan( m_Theta ) + E_GP_DY ) / 2.0;
00391                 }
00392                 else if ( m_ID ==1 )
00393                 {
00394                         x = m_Rc * cos( m_Theta );
00395                         y = m_Rc * sin( m_Theta );
00396                 }
00397                 else // m_ID == 2
00398                 {
00399                         x = ( m_Rc / tan( m_Theta ) + E_GP_DX ) / 2.0;
00400                         y = m_Rc;
00401                 }
00402 
00403                 // x, y signs of coordinate different by segment 
00404                 if      ( m_Segment == 0 ) {    ;               }
00405                 else if ( m_Segment == 1 ) {    x = -x;         }
00406                 else if ( m_Segment == 2 ) {    x = -x; y = -y; }
00407                 else                       {    y = -y;         }
00408                 
00409                 m_ObjOrgInBes[0] = x;
00410                 m_ObjOrgInBes[1] = y;   
00411 
00412                 // limit cut
00413                 for( int i=0; i<2; i++ ) {
00414                         if( fabs(m_ObjOrgInBes[i]) < ERR_LIMIT ) m_ObjOrgInBes[i] = 0;
00415                 }
00416                 
00417                 //---------- set z ---------------------
00418                 m_ObjOrgInBes[2] = m_LocOrgInBes[2];
00419 
00420         } // else, panels
00421 }
00422 
00423 void MucBox::SetObjOrgInLoc()
00424 {
00425         if( m_Part == BRID )
00426         {
00427                 if( m_Segment != B_TOP )
00428                         for(int i=0; i<3; i++) m_ObjOrgInLoc[i] = 0.;
00429                 else
00430                         for(int i=0; i<3; i++) m_ObjOrgInLoc[i] = m_ObjOrgInBes[i] - m_LocOrgInBes[i];
00431         }
00432         else
00433                 for(int i=0; i<3; i++) m_ObjOrgInLoc[i] = m_ObjOrgInBes[i] - m_LocOrgInBes[i];
00434 }
00435 
00436 void MucBox::SetAlignment( double dx, double dy, double dz )
00437 {
00438         
00439         if( m_Part == BRID || m_ID == -1 )
00440         {
00441                 m_ObjOrgInLoc[0] += dx;
00442                 m_ObjOrgInLoc[1] += dy;
00443                 m_ObjOrgInLoc[2] += dz;
00444         }
00445 }
00446 
00447 // END

Generated on Tue Nov 29 23:12:56 2016 for BOSS_7.0.2 by  doxygen 1.4.7