Bfield Class Reference

#include <Bfield.h>

List of all members.

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

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

Private Member Functions

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

Private Attributes

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

Static Private Attributes

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


Detailed Description

Definition at line 43 of file Bfield.h.


Constructor & Destructor Documentation

Bfield::Bfield ( int   )  [protected]

Constructor, Destructor.

Definition at line 58 of file Bfield.cxx.

References _BphiQL, _BphiQR, _Br, _BrQL, _BrQR, _Bz, _BzQL, _BzQR, _fieldID, genRecEmupikp::i, ganga-rec::j, m_Bfld, m_Bx, m_By, m_Bz, and updateCache().

Referenced by getBfield().

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]

Definition at line 52 of file Bfield.h.

00052 {};

Bfield::Bfield ( int   )  [protected]

Constructor, Destructor.

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

float Bfield::bx ( const HepPoint3D xyz  )  const

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

returns an element of B field

Definition at line 132 of file Bfield.cxx.

References _fieldID, m_x, m_y, m_z, and updateCache().

00132                                           {
00133 
00134   if(_fieldID > 10){
00135     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00136   }
00137 
00138   return m_Bx;
00139 }

float Bfield::bx ( const HepPoint3D xyz  )  const

Definition at line 194 of file Bfield.cxx.

References _fieldID, m_Bx, m_x, m_y, m_z, updateCache(), and x.

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

Definition at line 164 of file Bfield.cxx.

References _fieldID, m_Bx, m_x, m_y, m_z, and updateCache().

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

float Bfield::by ( const HepPoint3D xyz  )  const

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

Definition at line 142 of file Bfield.cxx.

References _fieldID, m_x, m_y, m_z, and updateCache().

00142                                           {
00143 
00144   if(_fieldID > 10){
00145     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00146   }
00147 
00148   return m_By;
00149 }

float Bfield::by ( const HepPoint3D xyz  )  const

Definition at line 207 of file Bfield.cxx.

References _fieldID, m_By, m_x, m_y, m_z, updateCache(), and x.

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

Definition at line 174 of file Bfield.cxx.

References _fieldID, m_By, m_x, m_y, m_z, and updateCache().

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

float Bfield::bz ( const HepPoint3D xyz  )  const

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

Definition at line 152 of file Bfield.cxx.

References _fieldID, m_Bz, m_x, m_y, m_z, and updateCache().

00152                                           {
00153 
00154   if(_fieldID > 10){
00155     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00156   }
00157 
00158   return m_Bz;
00159 }

float Bfield::bz ( const HepPoint3D xyz  )  const

Definition at line 220 of file Bfield.cxx.

References _fieldID, m_Bz, m_x, m_y, m_z, updateCache(), and x.

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

Definition at line 184 of file Bfield.cxx.

References _fieldID, m_Bz, m_x, m_y, m_z, and updateCache().

Referenced by updateCache().

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

Definition at line 49 of file Bfield.h.

References _fieldID.

00049 {return _fieldID;}

int Bfield::fieldID ( void   )  const [inline]

returns B field Map ID

Definition at line 49 of file Bfield.h.

References _fieldID.

00049 {return _fieldID;}

int Bfield::fieldID ( void   )  const [inline]

returns B field Map ID

Definition at line 57 of file Bfield.h.

References _fieldID.

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 ( float *  position,
float *  bfield 
)

Definition at line 118 of file Bfield.cxx.

References _fieldID, m_Bz, m_x, m_y, m_z, and updateCache().

00118                                               {
00119   if(_fieldID > 10){
00120     float x = position[0];
00121     float y = position[1];
00122     float z = position[2];
00123     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00124   }
00125   field[0] = m_Bx;
00126   field[1] = m_By;
00127   field[2] = m_Bz;
00128   return;
00129 }

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

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

returns B field

Definition at line 95 of file Bfield.cxx.

References _fieldID, m_Bfld, m_x, m_y, m_z, and updateCache().

00095                                                 {
00096 
00097   if(_fieldID > 10){
00098     if(x != m_x || y != m_y || z != m_z)  updateCache(x, y, z);
00099   }
00100 
00101   return m_Bfld;
00102 }

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

Definition at line 150 of file Bfield.cxx.

References _fieldID, m_Bx, m_By, m_Bz, m_x, m_y, m_z, updateCache(), and x.

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

Definition at line 137 of file Bfield.cxx.

References _fieldID, m_Bfld, m_x, m_y, m_z, updateCache(), and x.

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

Definition at line 127 of file Bfield.cxx.

References _fieldID, m_Bfld, m_x, m_y, m_z, and updateCache().

Referenced by get_bfield_().

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 }

static Bfield* Bfield::getBfield ( int   )  [static]

returns Bfield object.

static Bfield* Bfield::getBfield ( int   )  [static]

returns Bfield object.

Bfield * Bfield::getBfield ( int   )  [static]

returns Bfield object.

Definition at line 52 of file Bfield.cxx.

References _field, and Bfield().

Referenced by TRunge::BfieldID(), get_bfield_(), init_bfield_(), main(), and TRunge::TRunge().

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 ( float  ,
float  ,
float   
) const [private]

Definition at line 200 of file Bfield.cxx.

References _Bphi, _BphiQL, _BphiQR, _Br, _BrQL, _BrQR, _Bz, _BzQL, _BzQR, _fieldID, bz(), cos(), m_Bfld, m_Bz, m_x, m_y, m_z, PI, pr, sin(), and tr.

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

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

Definition at line 232 of file Bfield.cxx.

References _Bphi, _BphiQL, _BphiQR, _Br, _BrQL, _BrQR, _Bz, _BzQL, _BzQR, _fieldID, bz(), cos(), m_Bfld, m_Bx, m_By, m_Bz, m_x, m_y, m_z, PI, pr, sin(), and tr.

Referenced by Bfield(), bx(), by(), bz(), and fieldMap().

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]

Definition at line 68 of file Bfield.h.

float Bfield::_Bphi [private]

Definition at line 76 of file Bfield.h.

Referenced by updateCache().

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

Definition at line 74 of file Bfield.h.

float Bfield::_BphiQL [private]

Definition at line 82 of file Bfield.h.

Referenced by Bfield(), and updateCache().

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

Definition at line 71 of file Bfield.h.

float Bfield::_BphiQR [private]

Definition at line 79 of file Bfield.h.

Referenced by Bfield(), and updateCache().

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

Definition at line 67 of file Bfield.h.

float Bfield::_Br [private]

Definition at line 75 of file Bfield.h.

Referenced by Bfield(), and updateCache().

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

Definition at line 73 of file Bfield.h.

float Bfield::_BrQL [private]

Definition at line 81 of file Bfield.h.

Referenced by Bfield(), and updateCache().

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

Definition at line 70 of file Bfield.h.

float Bfield::_BrQR [private]

Definition at line 78 of file Bfield.h.

Referenced by Bfield(), and updateCache().

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

Definition at line 66 of file Bfield.h.

float Bfield::_Bz [private]

Definition at line 74 of file Bfield.h.

Referenced by Bfield(), and updateCache().

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

Definition at line 72 of file Bfield.h.

float Bfield::_BzQL [private]

Definition at line 80 of file Bfield.h.

Referenced by Bfield(), and updateCache().

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

Definition at line 69 of file Bfield.h.

float Bfield::_BzQR [private]

Definition at line 77 of file Bfield.h.

Referenced by Bfield(), and updateCache().

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

Definition at line 65 of file Bfield.h.

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

Definition at line 65 of file Bfield.h.

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

Definition at line 73 of file Bfield.h.

Referenced by getBfield().

int Bfield::_fieldID [private]

Definition at line 83 of file Bfield.h.

Referenced by Bfield(), bx(), by(), bz(), fieldID(), fieldMap(), and updateCache().

Hep3Vector Bfield::m_Bfld [mutable, private]

Definition at line 90 of file Bfield.h.

Referenced by Bfield(), fieldMap(), and updateCache().

float Bfield::m_Bx [mutable, private]

Definition at line 76 of file Bfield.h.

float Bfield::m_Bx [mutable, private]

Definition at line 84 of file Bfield.h.

Referenced by Bfield(), bx(), fieldMap(), and updateCache().

float Bfield::m_By [mutable, private]

Definition at line 77 of file Bfield.h.

float Bfield::m_By [mutable, private]

Definition at line 85 of file Bfield.h.

Referenced by Bfield(), by(), fieldMap(), and updateCache().

float Bfield::m_Bz [mutable, private]

Definition at line 78 of file Bfield.h.

float Bfield::m_Bz [mutable, private]

Definition at line 86 of file Bfield.h.

Referenced by Bfield(), bz(), fieldMap(), and updateCache().

float Bfield::m_x [mutable, private]

Definition at line 79 of file Bfield.h.

float Bfield::m_x [mutable, private]

Definition at line 87 of file Bfield.h.

Referenced by bx(), by(), bz(), fieldMap(), and updateCache().

float Bfield::m_y [mutable, private]

Definition at line 80 of file Bfield.h.

float Bfield::m_y [mutable, private]

Definition at line 88 of file Bfield.h.

Referenced by bx(), by(), bz(), fieldMap(), and updateCache().

float Bfield::m_z [mutable, private]

Definition at line 81 of file Bfield.h.

float Bfield::m_z [mutable, private]

Definition at line 89 of file Bfield.h.

Referenced by bx(), by(), bz(), fieldMap(), and updateCache().


Generated on Tue Nov 29 23:17:54 2016 for BOSS_7.0.2 by  doxygen 1.4.7