Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Bfield Class Reference

#include <Bfield.h>

List of all members.

Public Member Functions

float bx (const HepPoint3D &xyz) const
float bx (float x, float y, float z) const
 returns an element of B field
double bx (const HepPoint3D &xyz) const
double bx (double x, double y, double z) const
 returns an element of B field
float bx (const HepPoint3D &xyz) const
float bx (float x, float y, float z) const
 returns an element of B field
double bx (const HepPoint3D &xyz) const
double bx (double x, double y, double z) const
 returns an element of B field
float by (const HepPoint3D &xyz) const
float by (float x, float y, float z) const
double by (const HepPoint3D &xyz) const
double by (double x, double y, double z) const
float by (const HepPoint3D &xyz) const
float by (float x, float y, float z) const
double by (const HepPoint3D &xyz) const
double by (double x, double y, double z) const
float bz (const HepPoint3D &xyz) const
float bz (float x, float y, float z) const
double bz (const HepPoint3D &xyz) const
double bz (double x, double y, double z) const
float bz (const HepPoint3D &xyz) const
float bz (float x, float y, float z) const
double bz (const HepPoint3D &xyz) const
double bz (double x, double y, double z) const
int fieldID (void) const
 returns B field Map ID
int fieldID (void) const
 returns B field Map ID
int fieldID (void) const
 returns B field Map ID
int fieldID (void) const
 returns B field Map ID
void fieldMap (float *position, float *bfield)
const Hep3Vector & fieldMap (const HepPoint3D &xyz) const
const Hep3Vector & fieldMap (float x, float y, float z) const
 returns B field
void fieldMap (double *position, double *bfield)
const Hep3Vector & fieldMap (const HepPoint3D &xyz) const
const Hep3Vector & fieldMap (double x, double y, double z) const
 returns B field
void fieldMap (float *position, float *bfield)
const Hep3Vector & fieldMap (const HepPoint3D &xyz) const
const Hep3Vector & fieldMap (float x, float y, float z) const
 returns B field
void fieldMap (double *position, double *bfield)
const Hep3Vector & fieldMap (const HepPoint3D &xyz) const
const Hep3Vector & fieldMap (double x, double y, double z) const
 returns B field

Static Public Member Functions

BfieldgetBfield (int)
 returns Bfield object.
BfieldgetBfield (int)
 returns Bfield object.
BfieldgetBfield (int)
 returns Bfield object.
BfieldgetBfield (int)
 returns Bfield object.

Protected Member Functions

 Bfield (int)
 Constructor, Destructor.
 Bfield (int)
 Constructor, Destructor.
 Bfield (int)
 Constructor, Destructor.
 Bfield (int)
 Constructor, Destructor.
virtual ~Bfield (void)
virtual ~Bfield (void)

Private Member Functions

void updateCache (float, float, float) const
void updateCache (double, double, double) const
void updateCache (float, float, float) const
void updateCache (double, double, double) const

Private Attributes

float _Bphi [175][399]
double _Bphi [175][399]
float _BphiQL [17][51][52]
double _BphiQL [17][51][52]
float _BphiQR [101][163]
double _BphiQR [101][163]
float _Br [175][399]
double _Br [175][399]
float _BrQL [17][51][52]
double _BrQL [17][51][52]
float _BrQR [101][163]
double _BrQR [101][163]
float _Bz [175][399]
double _Bz [175][399]
float _BzQL [17][51][52]
double _BzQL [17][51][52]
float _BzQR [101][163]
double _BzQR [101][163]
int _fieldID
Hep3Vector m_Bfld
float m_Bx
double m_Bx
float m_By
double m_By
float m_Bz
double m_Bz
float m_x
double m_x
float m_y
double m_y
float m_z
double m_z

Static Private Attributes

Bfield_field [200]
Bfield_field [200]
Bfield_field [200]
Bfield_field [200] = {0}


Constructor & Destructor Documentation

Bfield::Bfield int   )  [protected]
 

Constructor, Destructor.

00058                        {
00059   std::cout << std::endl;
00060   std::cout << "***********************************************" << std::endl;
00061   std::cout << "           Bfield class  MAP ID = " << imap << std::endl;
00062   std::cout << "    #### R < 174 cm, -152 < Z < 246 cm ####    " << std::endl;
00063   std::cout << "                C++ version 1.00               " << std::endl;
00064   std::cout << "***********************************************" << std::endl;
00065 
00066   const double uniformBz[10] = {0, 15, 14.5, 14, 13, 12.5, 12, 11, 10, 15.5};
00067 
00068   //...initialization
00069   for(int i=0; i<175; i++)
00070     for(int j=0; j<399; j++) {
00071       _Bz[i][j] = 0;
00072       _Br[i][j] = 0;
00073       _Bz[i][j] = 0;
00074       if(i<101 && j<163) {
00075         _BzQR[i][j] = 0;
00076         _BrQR[i][j] = 0;
00077         _BphiQR[i][j] = 0;
00078       }
00079     }
00080   for(int i=0; i<17; i++)
00081     for(int j=0; j<51; j++)
00082       for(int k=0; k<52; k++) {
00083         _BzQL[i][j][k] = 0;
00084         _BrQL[i][j][k] = 0;
00085         _BphiQL[i][j][k] =0;
00086       }
00087   
00088   //...
00089   _fieldID  = imap;
00090 
00091   //...read B field map 
00092 
00093   if(imap<10){
00094     //
00095     // uniform B field map
00096     //
00097     m_Bx = 0.;
00098     m_By = 0.;
00099     m_Bz = uniformBz[imap];
00100     m_Bfld.setX((double) m_Bx);
00101     m_Bfld.setY((double) m_By);
00102     m_Bfld.setZ((double) m_Bz);
00103     std::cout << "Bfield class >> creating uniform B field with id = " << imap;
00104     std::cout << ", (Bx,By,Bz) = "<<m_Bfld<<std::endl;
00105   } else {
00106     //
00107     // non-uniform B field map
00108     //
00109     std::cout << "Bfield class >> loading non-uniform B field map" << std::endl;
00110 /*wangdy
00111      geo_coil_readmap_(&imap, _Bz, _Br, _Bphi);
00112     if( _fieldID == 21 ) {
00113       std::cout << "Bfield class >> loading QCS" << std::endl;
00114       geo_coil_readqcsrmap_(_BzQR,_BrQR, _BphiQR);
00115       geo_coil_readqcslmap_(_BzQL,_BrQL, _BphiQL);
00116     }
00117  */ 
00118     updateCache(0., 0., 0.);
00119   }
00120   std::cout << std::endl;
00121 
00122 }

virtual Bfield::~Bfield void   )  [inline, protected, virtual]
 

00052 {};

Bfield::Bfield int   )  [protected]
 

Constructor, Destructor.

Bfield::Bfield int   )  [protected]
 

Constructor, Destructor.

virtual Bfield::~Bfield void   )  [inline, protected, virtual]
 

00052 {};

Bfield::Bfield int   )  [protected]
 

Constructor, Destructor.


Member Function Documentation

float Bfield::bx const HepPoint3D xyz  )  const
 

float Bfield::bx float  x,
float  y,
float  z
const
 

returns an element of B field

double Bfield::bx const HepPoint3D xyz  )  const
 

double Bfield::bx double  x,
double  y,
double  z
const
 

returns an element of B field

float Bfield::bx const HepPoint3D xyz  )  const
 

float Bfield::bx float  x,
float  y,
float  z
const
 

returns an element of B field

00155                                           {
00156 
00157   if(_fieldID > 10){
00158     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00159   }
00160 
00161   return m_Bx;
00162 }

float Bfield::bx const HepPoint3D xyz  )  const
 

00194                                      {
00195 
00196   if(_fieldID > 10){
00197     double x = xyz.x();
00198     double y = xyz.y();
00199     double z = xyz.z();
00200     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00201   }
00202 
00203   return m_Bx;
00204 }

double Bfield::bx double  x,
double  y,
double  z
const
 

returns an element of B field

00164                                              {
00165 
00166   if(_fieldID > 10){
00167     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00168   }
00169 
00170   return m_Bx;
00171 }

float Bfield::by const HepPoint3D xyz  )  const
 

float Bfield::by float  x,
float  y,
float  z
const
 

double Bfield::by const HepPoint3D xyz  )  const
 

double Bfield::by double  x,
double  y,
double  z
const
 

float Bfield::by const HepPoint3D xyz  )  const
 

float Bfield::by float  x,
float  y,
float  z
const
 

00165                                           {
00166 
00167   if(_fieldID > 10){
00168     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00169   }
00170 
00171   return m_By;
00172 }

float Bfield::by const HepPoint3D xyz  )  const
 

00207                                      {
00208 
00209   if(_fieldID > 10){
00210     double x = xyz.x();
00211     double y = xyz.y();
00212     double z = xyz.z();
00213     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00214   }
00215 
00216   return m_By;
00217 }

double Bfield::by double  x,
double  y,
double  z
const
 

00174                                              {
00175 
00176   if(_fieldID > 10){
00177     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00178   }
00179 
00180   return m_By;
00181 }

float Bfield::bz const HepPoint3D xyz  )  const
 

float Bfield::bz float  x,
float  y,
float  z
const
 

double Bfield::bz const HepPoint3D xyz  )  const
 

double Bfield::bz double  x,
double  y,
double  z
const
 

float Bfield::bz const HepPoint3D xyz  )  const
 

float Bfield::bz float  x,
float  y,
float  z
const
 

00175                                           {
00176 
00177   if(_fieldID > 10){
00178     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00179   }
00180 
00181   return m_Bz;
00182 }

float Bfield::bz const HepPoint3D xyz  )  const
 

00220                                      {
00221 
00222   if(_fieldID > 10){
00223     double x = xyz.x();
00224     double y = xyz.y();
00225     double z = xyz.z();
00226     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00227   }
00228   return m_Bz;
00229 }

double Bfield::bz double  x,
double  y,
double  z
const
 

00184                                              {
00185 
00186   if(_fieldID > 10){
00187     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00188   }
00189 
00190   return m_Bz;
00191 }

int Bfield::fieldID void   )  const [inline]
 

returns B field Map ID

00049 {return _fieldID;}

int Bfield::fieldID void   )  const [inline]
 

returns B field Map ID

00057 {return _fieldID;}

int Bfield::fieldID void   )  const [inline]
 

returns B field Map ID

00049 {return _fieldID;}

int Bfield::fieldID void   )  const [inline]
 

returns B field Map ID

00057 {return _fieldID;}

void Bfield::fieldMap float *  position,
float *  bfield
 

const Hep3Vector& Bfield::fieldMap const HepPoint3D xyz  )  const
 

const Hep3Vector& Bfield::fieldMap float  x,
float  y,
float  z
const
 

returns B field

void Bfield::fieldMap double *  position,
double *  bfield
 

const Hep3Vector& Bfield::fieldMap const HepPoint3D xyz  )  const
 

const Hep3Vector& Bfield::fieldMap double  x,
double  y,
double  z
const
 

returns B field

void Bfield::fieldMap float *  position,
float *  bfield
 

00141                                               {
00142   if(_fieldID > 10){
00143     float x = position[0];
00144     float y = position[1];
00145     float z = position[2];
00146     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00147   }
00148   field[0] = m_Bx;
00149   field[1] = m_By;
00150   field[2] = m_Bz;
00151   return;
00152 }

const Hep3Vector& Bfield::fieldMap const HepPoint3D xyz  )  const
 

const Hep3Vector & Bfield::fieldMap float  x,
float  y,
float  z
const
 

returns B field

00118                                                 {
00119 
00120   if(_fieldID > 10){
00121     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00122   }
00123 
00124   return m_Bfld;
00125 }

void Bfield::fieldMap double *  position,
double *  bfield
 

00150                                                 {
00151   if(_fieldID > 10){
00152     double x = position[0];
00153     double y = position[1];
00154     double z = position[2];
00155     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00156   }
00157   field[0] = m_Bx;
00158   field[1] = m_By;
00159   field[2] = m_Bz;
00160   return;
00161 }

const Hep3Vector & Bfield::fieldMap const HepPoint3D xyz  )  const
 

00137                                            {
00138 
00139   if(_fieldID > 10){
00140     double x = xyz.x();
00141     double y = xyz.y();
00142     double z = xyz.z();
00143     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00144   }
00145 
00146   return m_Bfld;
00147 }

const Hep3Vector & Bfield::fieldMap double  x,
double  y,
double  z
const
 

returns B field

00127                                                    {
00128 
00129   if(_fieldID > 10){
00130     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00131   }
00132 
00133   return m_Bfld;
00134 }

Bfield* Bfield::getBfield int   )  [static]
 

returns Bfield object.

Bfield* Bfield::getBfield int   )  [static]
 

returns Bfield object.

Bfield* Bfield::getBfield int   )  [static]
 

returns Bfield object.

Bfield * Bfield::getBfield int   )  [static]
 

returns Bfield object.

00052                           {
00053   if (! _field[imap]) _field[imap] = new Bfield(imap);
00054   return _field[imap];
00055 }

void Bfield::updateCache float  ,
float  ,
float 
const [private]
 

void Bfield::updateCache double  ,
double  ,
double 
const [private]
 

void Bfield::updateCache float  ,
float  ,
float 
const [private]
 

00223                                                   {
00224 
00225   // this function is only for non-uniform B field
00226 
00227   if( _fieldID <= 10 ) return;
00228 
00229       float PI = 3.14159;
00230 
00231       //...
00232       float  r   = (float)sqrt((double)x*(double)x + (double)y*(double)y);
00233       float  phi = (float)atan2((double)y, (double)x);
00234 
00235       //... [cm] --> [mm]
00236       float zmm = z * 10.;
00237       float rmm = r * 10.;
00238       //... make index
00239       int tz = (int) (( zmm + 1520.)/10.);
00240       int tr = (int) (rmm/10.);
00241 
00242       //... 
00243       float bz = 0., br = 0., bphi = 0.;
00244 
00245       if(zmm >= -1520. && zmm < 2460. && rmm >= 0. && rmm < 1740.){
00246         if(_Bz[tr][tz] && _Bz[tr][tz+1]){
00247             float pz = (zmm + 1520.)/10.- (float)tz;
00248             float pr =  rmm/10.- (float)tr;
00249 
00250             //...
00251             bz = (_Bz[tr][tz]*(1.- pz)+_Bz[tr][tz+1]*pz)*(1.-pr)+
00252                  (_Bz[tr+1][tz]*(1.-pz)+_Bz[tr+1][tz+1]*pz)*pr;
00253             //...
00254             br = (_Br[tr][tz]*(1.-pz)+_Br[tr][tz+1]*pz)*(1.-pr)+
00255                  (_Br[tr+1][tz]*(1.-pz)+_Br[tr+1][tz+1]*pz)*pr;
00256             //...
00257             bphi = (_Bphi[tr][tz]*(1.-pz)+_Bphi[tr][tz+1]*pz)*(1.-pr)+
00258                    (_Bphi[tr+1][tz]*(1.-pz)+_Bphi[tr+1][tz+1]*pz)*pr;
00259 
00260             if(_fieldID == 21) {
00261               //
00262               // QCS Right
00263               //
00264               if( zmm>=800. && zmm < 2420. && rmm < 1000. ) {
00265                 int tqz = (int)( (zmm-800.)/10. );
00266                 bz += (((_BzQR[tr][tqz]*(1.-pz)+_BzQR[tr][tqz+1]*pz)*(1.-pr)
00267                       +(_BzQR[tr+1][tqz]*(1.-pz)+_BzQR[tr+1][tqz+1]*pz)*pr)
00268                       *(float)sin((double)(2.*phi+2./180.*(double)PI)));
00269                 br += (((_BrQR[tr][tqz]*(1.-pz)+_BrQR[tr][tqz+1]*pz)*(1.-pr)
00270                       +(_BrQR[tr+1][tqz]*(1.-pz)+_BrQR[tr+1][tqz+1]*pz)*pr)
00271                       *(float)sin((double)(2.*phi+2./180.*(double)PI)));
00272                 bphi += (((_BphiQR[tr][tqz]*(1.-pz)
00273                         +_BphiQR[tr][tqz+1]*pz)*(1.-pr)
00274                         +(_BphiQR[tr+1][tqz]*(1.-pz)
00275                         +_BphiQR[tr+1][tqz+1]*pz)*pr)
00276                         *(float)cos((double)(2.*phi+2./180.*(double)PI)));
00277               }
00278               //
00279               // QCS Left
00280               //
00281               if(zmm<=-500. && zmm>-1520. && rmm<1000.) {
00282                 int tqz = (int)((-zmm-500.)/20.);
00283                 int tqr = (int)(tr/2.);
00284                 pz = (pz+(float)( tz-(int)(tz/2.)*2. ))/2.;
00285                 pr = ( pr + (float)(tr-tqr*2) )/2.;
00286                 float f = 1.;
00287                 //              if( phi < (PI/2.) && phi >= (-PI/2.) ) {
00288                 //                phi = PI-phi;
00289                 //                f =-1.;
00290                 //              } else if( phi < -PI/2. ) {
00291                 //                phi = 2.*PI+phi;
00292                 //              }
00293                 //              float pphi = ( phi-PI/2. )/(11.25/180.*PI);
00294                 float phi_tmp = phi;
00295                 if( phi_tmp < (PI/2.) && phi_tmp >= (-PI/2.) ) {
00296                   phi_tmp = PI-phi_tmp;
00297                   f =-1.;
00298                 } else if( phi_tmp < -PI/2. ) {
00299                   phi_tmp = 2.*PI+phi_tmp;
00300                 }
00301                 float pphi = ( phi_tmp-PI/2. )/(11.25/180.*PI);
00302                 int tphi = (int)pphi;
00303                 pphi -= (float)tphi;
00304                 if (tphi >= 16) tphi -= 16;
00305                 
00306                 bz += f*
00307                   (((_BzQL[tphi][tqr][tqz]*(1.-pz)+_BzQL[tphi][tqr][tqz+1]*pz)
00308                   *(1-pr)+(_BzQL[tphi][tqr+1][tqz]*(1.-pz)
00309                   +_BzQL[tphi][tqr+1][tqz+1]*pz)*pr)*(1.-pphi)
00310                   +((_BzQL[tphi+1][tqr][tqz]*(1.-pz)
00311                   +_BzQL[tphi+1][tqr][tqz+1]*pz)*(1.-pr)
00312                   +(_BzQL[tphi+1][tqr+1][tqz]*(1.-pz)
00313                   +_BzQL[tphi+1][tqr+1][tqz+1]*pz)*pr)*pphi);
00314                 br += f*
00315                   (((_BrQL[tphi][tqr][tqz]*(1.- pz)
00316                   +_BrQL[tphi][tqr][tqz+1]*pz)*(1.-pr)
00317                   +(_BrQL[tphi][tqr+1][tqz]*(1.-pz)
00318                   +_BrQL[tphi][tqr+1][tqz+1]*pz)*pr)*(1-pphi)
00319                   +((_BrQL[tphi+1][tqr][tqz]*(1.- pz)
00320                   +_BrQL[tphi+1][tqr][tqz+1]*pz)*(1.-pr)
00321                   +(_BrQL[tphi+1][tqr+1][tqz]*(1.-pz)
00322                   +_BrQL[tphi+1][tqr+1][tqz+1]*pz)*pr)*pphi);
00323                 bphi += f*
00324                   (((_BphiQL[tphi][tqr][tqz]*(1.- pz)
00325                   +_BphiQL[tphi][tqr][tqz+1]*pz)*(1.-pr)
00326                   +(_BphiQL[tphi][tqr+1][tqz]*(1.-pz)
00327                   +_BphiQL[tphi][tqr+1][tqz+1]*pz)*pr)*(1.-pphi)
00328                   +((_BphiQL[tphi+1][tqr][tqz]*(1.- pz)
00329                   +_BphiQL[tphi+1][tqr][tqz+1]*pz)*(1.-pr)
00330                   +(_BphiQL[tphi+1][tqr+1][tqz]*(1.-pz)
00331                   +_BphiQL[tphi+1][tqr+1][tqz+1]*pz)*pr)*pphi);
00332               }
00333             }
00334          }  else {
00335            bz=0.;
00336            br=0.;
00337            bphi=0.;
00338          }
00339       } else if(zmm>=-1520. && zmm<=2460. && rmm<=0. && rmm<=1740.){
00340         if(tz == 246) tz=tz-1;
00341         if(tr == 174) tr=tr-1;
00342         float pz= (zmm + 1520.)/10.- (float)tz;
00343         float pr=  rmm/10.- (float)tr;
00344         bz   = (_Bz[tr][tz]*(1.- pz)+_Bz[tr][tz+1]*pz)*(1.-pr)+
00345                (_Bz[tr+1][tz]*(1.-pz)+_Bz[tr+1][tz+1]*pz)*pr;
00346 
00347         br   = (_Br[tr][tz]*(1.-pz)+_Br[tr][tz+1]*pz)*(1.-pr)+
00348                (_Br[tr+1][tz]*(1.-pz)+_Br[tr+1][tz+1]*pz)*pr;
00349 
00350         bphi = (_Bphi[tr][tz]*(1.-pz)+_Bphi[tr][tz+1]*pz)*(1.-pr)+
00351                (_Bphi[tr+1][tz]*(1.-pz)+_Bphi[tr+1][tz+1]*pz)*pr;
00352       } else {
00353         bz =0.;
00354         br =0.;
00355         bphi =0.;
00356       }
00357       
00358 
00359       //... Set B field
00360       float Bmag_xy = (float)sqrt(br*br + bphi*bphi);
00361       double Bphi_rp = (float)atan2( (double)bphi, (double)br );
00362       m_Bx = Bmag_xy * (float)cos((double)phi + Bphi_rp)/1000.;
00363       m_By = Bmag_xy * (float)sin((double)phi + Bphi_rp)/1000.;   
00364       //m_Bx = br * (float)cos((double)phi)/1000.;
00365       //m_By = br * (float)sin((double)phi)/1000.;   
00366       m_Bz = bz/1000.;
00367       m_x = x;
00368       m_y = y;
00369       m_z = z;
00370       m_Bfld.setX((double) m_Bx);
00371       m_Bfld.setY((double) m_By);
00372       m_Bfld.setZ((double) m_Bz);
00373 }

void Bfield::updateCache double  ,
double  ,
double 
const [private]
 

00232                                                      {
00233 
00234   // this function is only for non-uniform B field
00235 
00236   if( _fieldID <= 10 ) return;
00237 
00238       double PI = 3.14159;
00239 
00240       //...
00241       double  r   = (double)sqrt((double)x*(double)x + (double)y*(double)y);
00242       double  phi = (double)atan2((double)y, (double)x);
00243 
00244       //... [cm] --> [mm]
00245       double zmm = z * 10.;
00246       double rmm = r * 10.;
00247       //... make index
00248       int tz = (int) (( zmm + 1520.)/10.);
00249       int tr = (int) (rmm/10.);
00250 
00251       //... 
00252       double bz = 0., br = 0., bphi = 0.;
00253 
00254       if(zmm >= -1520. && zmm < 2460. && rmm >= 0. && rmm < 1740.){
00255         if(_Bz[tr][tz] && _Bz[tr][tz+1]){
00256             double pz = (zmm + 1520.)/10.- (double)tz;
00257             double pr =  rmm/10.- (double)tr;
00258 
00259             //...
00260             bz = (_Bz[tr][tz]*(1.- pz)+_Bz[tr][tz+1]*pz)*(1.-pr)+
00261                  (_Bz[tr+1][tz]*(1.-pz)+_Bz[tr+1][tz+1]*pz)*pr;
00262             //...
00263             br = (_Br[tr][tz]*(1.-pz)+_Br[tr][tz+1]*pz)*(1.-pr)+
00264                  (_Br[tr+1][tz]*(1.-pz)+_Br[tr+1][tz+1]*pz)*pr;
00265             //...
00266             bphi = (_Bphi[tr][tz]*(1.-pz)+_Bphi[tr][tz+1]*pz)*(1.-pr)+
00267                    (_Bphi[tr+1][tz]*(1.-pz)+_Bphi[tr+1][tz+1]*pz)*pr;
00268 
00269             if(_fieldID == 21) {
00270               //
00271               // QCS Right
00272               //
00273               if( zmm>=800. && zmm < 2420. && rmm < 1000. ) {
00274                 int tqz = (int)( (zmm-800.)/10. );
00275                 bz += (((_BzQR[tr][tqz]*(1.-pz)+_BzQR[tr][tqz+1]*pz)*(1.-pr)
00276                       +(_BzQR[tr+1][tqz]*(1.-pz)+_BzQR[tr+1][tqz+1]*pz)*pr)
00277                       *(double)sin((double)(2.*phi+2./180.*(double)PI)));
00278                 br += (((_BrQR[tr][tqz]*(1.-pz)+_BrQR[tr][tqz+1]*pz)*(1.-pr)
00279                       +(_BrQR[tr+1][tqz]*(1.-pz)+_BrQR[tr+1][tqz+1]*pz)*pr)
00280                       *(double)sin((double)(2.*phi+2./180.*(double)PI)));
00281                 bphi += (((_BphiQR[tr][tqz]*(1.-pz)
00282                         +_BphiQR[tr][tqz+1]*pz)*(1.-pr)
00283                         +(_BphiQR[tr+1][tqz]*(1.-pz)
00284                         +_BphiQR[tr+1][tqz+1]*pz)*pr)
00285                         *(double)cos((double)(2.*phi+2./180.*(double)PI)));
00286               }
00287               //
00288               // QCS Left
00289               //
00290               if(zmm<=-500. && zmm>-1520. && rmm<1000.) {
00291                 int tqz = (int)((-zmm-500.)/20.);
00292                 int tqr = (int)(tr/2.);
00293                 pz = (pz+(double)( tz-(int)(tz/2.)*2. ))/2.;
00294                 pr = ( pr + (double)(tr-tqr*2) )/2.;
00295                 double f = 1.;
00296                 //              if( phi < (PI/2.) && phi >= (-PI/2.) ) {
00297                 //                phi = PI-phi;
00298                 //                f =-1.;
00299                 //              } else if( phi < -PI/2. ) {
00300                 //                phi = 2.*PI+phi;
00301                 //              }
00302                 //              double pphi = ( phi-PI/2. )/(11.25/180.*PI);
00303                 double phi_tmp = phi;
00304                 if( phi_tmp < (PI/2.) && phi_tmp >= (-PI/2.) ) {
00305                   phi_tmp = PI-phi_tmp;
00306                   f =-1.;
00307                 } else if( phi_tmp < -PI/2. ) {
00308                   phi_tmp = 2.*PI+phi_tmp;
00309                 }
00310                 double pphi = ( phi_tmp-PI/2. )/(11.25/180.*PI);
00311                 int tphi = (int)pphi;
00312                 pphi -= (double)tphi;
00313                 if (tphi >= 16) tphi -= 16;
00314                 
00315                 bz += f*
00316                   (((_BzQL[tphi][tqr][tqz]*(1.-pz)+_BzQL[tphi][tqr][tqz+1]*pz)
00317                   *(1-pr)+(_BzQL[tphi][tqr+1][tqz]*(1.-pz)
00318                   +_BzQL[tphi][tqr+1][tqz+1]*pz)*pr)*(1.-pphi)
00319                   +((_BzQL[tphi+1][tqr][tqz]*(1.-pz)
00320                   +_BzQL[tphi+1][tqr][tqz+1]*pz)*(1.-pr)
00321                   +(_BzQL[tphi+1][tqr+1][tqz]*(1.-pz)
00322                   +_BzQL[tphi+1][tqr+1][tqz+1]*pz)*pr)*pphi);
00323                 br += f*
00324                   (((_BrQL[tphi][tqr][tqz]*(1.- pz)
00325                   +_BrQL[tphi][tqr][tqz+1]*pz)*(1.-pr)
00326                   +(_BrQL[tphi][tqr+1][tqz]*(1.-pz)
00327                   +_BrQL[tphi][tqr+1][tqz+1]*pz)*pr)*(1-pphi)
00328                   +((_BrQL[tphi+1][tqr][tqz]*(1.- pz)
00329                   +_BrQL[tphi+1][tqr][tqz+1]*pz)*(1.-pr)
00330                   +(_BrQL[tphi+1][tqr+1][tqz]*(1.-pz)
00331                   +_BrQL[tphi+1][tqr+1][tqz+1]*pz)*pr)*pphi);
00332                 bphi += f*
00333                   (((_BphiQL[tphi][tqr][tqz]*(1.- pz)
00334                   +_BphiQL[tphi][tqr][tqz+1]*pz)*(1.-pr)
00335                   +(_BphiQL[tphi][tqr+1][tqz]*(1.-pz)
00336                   +_BphiQL[tphi][tqr+1][tqz+1]*pz)*pr)*(1.-pphi)
00337                   +((_BphiQL[tphi+1][tqr][tqz]*(1.- pz)
00338                   +_BphiQL[tphi+1][tqr][tqz+1]*pz)*(1.-pr)
00339                   +(_BphiQL[tphi+1][tqr+1][tqz]*(1.-pz)
00340                   +_BphiQL[tphi+1][tqr+1][tqz+1]*pz)*pr)*pphi);
00341               }
00342             }
00343          }  else {
00344            bz=0.;
00345            br=0.;
00346            bphi=0.;
00347          }
00348       } else if(zmm>=-1520. && zmm<=2460. && rmm<=0. && rmm<=1740.){
00349         if(tz == 246) tz=tz-1;
00350         if(tr == 174) tr=tr-1;
00351         double pz= (zmm + 1520.)/10.- (double)tz;
00352         double pr=  rmm/10.- (double)tr;
00353         bz   = (_Bz[tr][tz]*(1.- pz)+_Bz[tr][tz+1]*pz)*(1.-pr)+
00354                (_Bz[tr+1][tz]*(1.-pz)+_Bz[tr+1][tz+1]*pz)*pr;
00355 
00356         br   = (_Br[tr][tz]*(1.-pz)+_Br[tr][tz+1]*pz)*(1.-pr)+
00357                (_Br[tr+1][tz]*(1.-pz)+_Br[tr+1][tz+1]*pz)*pr;
00358 
00359         bphi = (_Bphi[tr][tz]*(1.-pz)+_Bphi[tr][tz+1]*pz)*(1.-pr)+
00360                (_Bphi[tr+1][tz]*(1.-pz)+_Bphi[tr+1][tz+1]*pz)*pr;
00361       } else {
00362         bz =0.;
00363         br =0.;
00364         bphi =0.;
00365       }
00366       
00367 
00368       //... Set B field
00369       double Bmag_xy = (double)sqrt(br*br + bphi*bphi);
00370       double Bphi_rp = (double)atan2( (double)bphi, (double)br );
00371       m_Bx = Bmag_xy * (double)cos((double)phi + Bphi_rp)/1000.;
00372       m_By = Bmag_xy * (double)sin((double)phi + Bphi_rp)/1000.;   
00373       //m_Bx = br * (double)cos((double)phi)/1000.;
00374       //m_By = br * (double)sin((double)phi)/1000.;   
00375       m_Bz = bz/1000.;
00376       m_x = x;
00377       m_y = y;
00378       m_z = z;
00379       m_Bfld.setX((double) m_Bx);
00380       m_Bfld.setY((double) m_By);
00381       m_Bfld.setZ((double) m_Bz);
00382 }


Member Data Documentation

float Bfield::_Bphi[175][399] [private]
 

float Bfield::_Bphi [private]
 

float Bfield::_BphiQL[17][51][52] [private]
 

float Bfield::_BphiQL [private]
 

float Bfield::_BphiQR[101][163] [private]
 

float Bfield::_BphiQR [private]
 

float Bfield::_Br[175][399] [private]
 

float Bfield::_Br [private]
 

float Bfield::_BrQL[17][51][52] [private]
 

float Bfield::_BrQL [private]
 

float Bfield::_BrQR[101][163] [private]
 

float Bfield::_BrQR [private]
 

float Bfield::_Bz[175][399] [private]
 

float Bfield::_Bz [private]
 

float Bfield::_BzQL[17][51][52] [private]
 

float Bfield::_BzQL [private]
 

float Bfield::_BzQR[101][163] [private]
 

float Bfield::_BzQR [private]
 

Bfield* Bfield::_field[200] [static, private]
 

Bfield* Bfield::_field[200] [static, private]
 

Bfield* Bfield::_field[200] [static, private]
 

Bfield * Bfield::_field = {0} [static, private]
 

int Bfield::_fieldID [private]
 

Hep3Vector Bfield::m_Bfld [mutable, private]
 

float Bfield::m_Bx [mutable, private]
 

float Bfield::m_Bx [mutable, private]
 

float Bfield::m_By [mutable, private]
 

float Bfield::m_By [mutable, private]
 

float Bfield::m_Bz [mutable, private]
 

float Bfield::m_Bz [mutable, private]
 

float Bfield::m_x [mutable, private]
 

float Bfield::m_x [mutable, private]
 

float Bfield::m_y [mutable, private]
 

float Bfield::m_y [mutable, private]
 

float Bfield::m_z [mutable, private]
 

float Bfield::m_z [mutable, private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 15:55:27 2011 for BOSS6.5.5 by  doxygen 1.3.9.1