#include <MagFieldReader.h>
Public Member Functions | |
MagFieldReader (const std::string &name, ISvcLocator *pSvcLocator) | |
Standard constructor. | |
virtual | ~MagFieldReader () |
virtual StatusCode | initialize () |
Destructor Algorithm initialization. | |
virtual StatusCode | execute () |
Algorithm execution. | |
virtual StatusCode | finalize () |
Algorithm finalization. | |
Private Member Functions | |
StatusCode | readField () |
Private Attributes | |
IMagneticFieldSvc * | m_pIMF |
double | m_zMin |
double | m_zMax |
double | m_step |
double | m_xMin |
double | m_xMax |
double | m_yMin |
double | m_yMax |
NTuple::Tuple * | m_ntuple |
NTuple::Tuple * | m_tuple1 |
NTuple::Tuple * | m_tuple2 |
NTuple::Tuple * | m_tuple3 |
NTuple::Tuple * | m_tuple4 |
NTuple::Item< float > | m_x |
NTuple::Item< float > | m_y |
NTuple::Item< float > | m_z |
NTuple::Item< float > | m_Bx |
NTuple::Item< float > | m_By |
NTuple::Item< float > | m_Bz |
NTuple::Item< float > | m_r |
NTuple::Item< float > | m_x2 |
NTuple::Item< float > | m_y2 |
NTuple::Item< float > | m_z2 |
NTuple::Item< float > | m_Bx2 |
NTuple::Item< float > | m_By2 |
NTuple::Item< float > | m_Bz2 |
NTuple::Item< float > | m_r2 |
NTuple::Item< float > | m_x3 |
NTuple::Item< float > | m_y3 |
NTuple::Item< float > | m_z3 |
NTuple::Item< float > | m_Bx3 |
NTuple::Item< float > | m_By3 |
NTuple::Item< float > | m_Bz3 |
NTuple::Item< float > | m_r3 |
NTuple::Item< float > | m_phi3 |
NTuple::Item< float > | m_sigma_bx |
NTuple::Item< float > | m_sigma_by |
NTuple::Item< float > | m_sigma_bz |
NTuple::Item< float > | m_time |
std::string | m_filename |
IBesTimerSvc * | m_timersvc |
BesTimer * | m_timer |
An | Algorithm to read and plot magnetic filed maps | |
for | x and y kept constant and varying z. The x, y | |
positions | and the z range can be set in job options. |
Definition at line 24 of file MagFieldReader.h.
MagFieldReader::MagFieldReader | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
Standard constructor.
Definition at line 47 of file MagFieldReader.cxx.
References m_filename, m_step, m_xMax, m_xMin, m_yMax, m_yMin, m_zMax, and m_zMin.
00049 : Algorithm ( name , pSvcLocator ) 00050 , m_pIMF(0) 00051 { 00052 declareProperty("Zmin", m_zMin = -1200.0*mm); 00053 declareProperty("Zmax", m_zMax = 1200.0*mm); 00054 declareProperty("Step", m_step = 50.0*mm); 00055 declareProperty("Xmin", m_xMin = -900.0*mm); 00056 declareProperty("Xmax", m_xMax = 900.0*mm); 00057 declareProperty("Ymin", m_yMin = -900.0*mm); 00058 declareProperty("Ymax", m_yMax = 900.0*mm); 00059 declareProperty("filename", m_filename ="rawmode3_out.dat"); 00060 }
virtual MagFieldReader::~MagFieldReader | ( | ) | [inline, virtual] |
StatusCode MagFieldReader::execute | ( | ) | [virtual] |
Algorithm execution.
Definition at line 167 of file MagFieldReader.cxx.
References Bes_Common::DEBUG, BesTimer::elapsed(), IMagneticFieldSvc::fieldVector(), genRecEmupikp::i, Bes_Common::INFO, m_pIMF, m_time, m_timer, m_tuple4, msgSvc(), BesTimer::start(), and BesTimer::stop().
00167 { 00168 00169 MsgStream msg( msgSvc(), name() ); 00170 00171 msg << MSG::DEBUG << "==> Execute MagFieldReader" << endreq; 00172 /* 00173 //calculate the error of Bfield 00174 std::ifstream infile( m_filename.c_str() ); 00175 if(!infile.good()) msg << MSG::FATAL << "Unable to read the file: " << m_filename << endreq; 00176 int nLine = 0; 00177 char line[ 255 ]; 00178 while( infile ) { 00179 // parse each line of the file, 00180 // comment lines begin with '#' in the cdf file 00181 infile.getline( line, 255 ); 00182 if ( line[0] == '#' ) continue; 00183 std::string gridx, gridy, gridz, sFx, sFy, sFz; 00184 char* token = strtok( line, " " ); 00185 if ( token ) { gridx = token; token = strtok( NULL, " " );} else continue; 00186 if ( token ) { gridy = token; token = strtok( NULL, " " );} else continue; 00187 if ( token ) { gridz = token; token = strtok( NULL, " " );} else continue; 00188 if ( token ) { sFx = token; token = strtok( NULL, " " );} else continue; 00189 if ( token ) { sFy = token; token = strtok( NULL, " " );} else continue; 00190 if ( token ) { sFz = token; token = strtok( NULL, " " );} else continue; 00191 if ( token != NULL ) continue; 00192 nLine++; 00193 double x,y,z,bx,by,bz; 00194 //Grid position 00195 x = atof( gridx.c_str() ); 00196 y = atof( gridy.c_str() ); 00197 z = atof( gridz.c_str() ); 00198 // Field values are given in tesla in CDF file. Convert to CLHEP units 00199 bx = atof( sFx.c_str() ); 00200 by = atof( sFy.c_str() ); 00201 bz = atof( sFz.c_str() ); 00202 //std::cout<<"x,y,z: "<<x<<" "<<y<<" "<<z<<" "<<"bx,by,bz: "<<bx<<" "<<by<<" "<<bz<<std::endl; 00203 x = -x*m; 00204 y = y*m; 00205 z = -z*m; 00206 00207 HepPoint3D r(x,y,z); 00208 HepVector3D b; 00209 m_pIMF->fieldVector(r,b); 00210 m_Bx = b.x()/tesla; 00211 m_By = b.y()/tesla; 00212 m_Bz = b.z()/tesla; 00213 m_sigma_bx = (b.x()/tesla + bx)*10000.; 00214 m_sigma_by = (b.y()/tesla - by)*10000.; 00215 m_sigma_bz = (b.z()/tesla + bz)*10000.; 00216 m_r = std::sqrt(x/m*x/m+y/m*y/m); 00217 m_x = x/m; 00218 m_y = y/m; 00219 m_z = z/m; 00220 m_tuple1->write(); 00221 } 00222 infile.close(); 00223 std::cout<<"Totally "<<nLine<<" in file "<<m_filename<<std::endl; 00224 00225 for(int k = 0; k < 5; k++) { 00226 double rr; 00227 if(k==0) rr = 0; 00228 if(k==1) rr = 200; 00229 if(k==2) rr = 400; 00230 if(k==3) rr = 600; 00231 if(k==4) rr = 800; 00232 for(int zz = -1195; zz <1200; zz+=50) { 00233 double bxt = 0.,byt= 0.,bzt = 0.; 00234 for(int i = 0; i < 100000; i++) { 00235 double phi = CLHEP::twopi*CLHEP::RandFlat::shoot(); 00236 double xx = rr*std::cos(phi); 00237 double yy = rr*std::sin(phi); 00238 HepPoint3D r(xx,yy,double(zz)); 00239 HepVector3D b; 00240 m_pIMF->fieldVector(r,b); 00241 bxt+=b.x()/tesla; 00242 byt+=b.y()/tesla; 00243 bzt+=b.z()/tesla; 00244 } 00245 m_z2 = zz; 00246 m_r2 = rr; 00247 m_Bx2 = bxt/100000; 00248 m_By2 = byt/100000; 00249 m_Bz2 = bzt/100000; 00250 m_tuple2->write(); 00251 } 00252 } 00253 00254 for(int k = 0; k < 3; k++) { 00255 double zz; 00256 if(k==0) zz = 0; 00257 if(k==1) zz = -800; 00258 if(k==2) zz = 800; 00259 for(int rr = 200; rr <=600; rr+=400) { 00260 for(double phi = 0; phi <= 2*3.14159; phi+=0.1745) { 00261 //double phi = CLHEP::twopi*CLHEP::RandFlat::shoot(); 00262 double xx = rr*std::cos(phi); 00263 double yy = rr*std::sin(phi); 00264 HepPoint3D r(xx,yy,double(zz)); 00265 HepVector3D b; 00266 m_pIMF->fieldVector(r,b); 00267 m_Bx3 = b.x()/tesla; 00268 m_By3 = b.y()/tesla; 00269 m_Bz3 = b.z()/tesla; 00270 m_phi3 = phi*180/CLHEP::pi; 00271 m_x3 = xx; 00272 m_y3 = yy; 00273 m_z3 = zz; 00274 m_r3 = rr; 00275 m_tuple3->write(); 00276 } 00277 } 00278 } 00279 */ 00280 m_timer->start(); 00281 for(int i = 0; i < 20000; i++) 00282 { 00283 double px,py,pz,bx,by,bz; 00284 double max_x = 1.8*m, min_x = -1.8*m, max_y = 1.8*m, min_y = -1.8*m, max_z = 2.1*m, min_z = -2.1*m; 00285 px = min_x + (max_x - min_x)*RandFlat::shoot(); 00286 py = min_y + (max_y - min_y)*RandFlat::shoot(); 00287 pz = min_z + (max_z - min_z)*RandFlat::shoot(); 00288 HepPoint3D r(px,py,pz); 00289 HepVector3D b; 00290 m_pIMF->fieldVector(r,b); 00291 bx = b.x()/tesla; 00292 by = b.y()/tesla; 00293 bz = b.z()/tesla; 00294 } 00295 m_timer->stop(); 00296 m_time = m_timer->elapsed(); 00297 m_tuple4->write(); 00298 /* 00299 StatusCode sc = this->readField(); 00300 if( sc.isFailure() ) { 00301 msg << MSG::FATAL << "Unable to execute MagFieldReader" 00302 << endreq; 00303 return sc; 00304 } 00305 */ 00306 msg << MSG::INFO << "MagFieldReader executed" << endreq; 00307 return StatusCode::SUCCESS; 00308 }
StatusCode MagFieldReader::finalize | ( | ) | [virtual] |
Algorithm finalization.
Definition at line 313 of file MagFieldReader.cxx.
References Bes_Common::DEBUG, and msgSvc().
00313 { 00314 00315 MsgStream msg(msgSvc(), name()); 00316 msg << MSG::DEBUG << "==> Finalize MagFieldReader" << endreq; 00317 00318 return StatusCode::SUCCESS; 00319 }
StatusCode MagFieldReader::initialize | ( | ) | [virtual] |
Destructor Algorithm initialization.
Definition at line 65 of file MagFieldReader.cxx.
References IBesTimerSvc::addItem(), Bes_Common::DEBUG, calibUtil::ERROR, Bes_Common::FATAL, Bes_Common::INFO, m_Bx, m_Bx2, m_Bx3, m_By, m_By2, m_By3, m_Bz, m_Bz2, m_Bz3, m_phi3, m_pIMF, m_r, m_r2, m_r3, m_sigma_bx, m_sigma_by, m_sigma_bz, m_time, m_timer, m_timersvc, m_tuple1, m_tuple2, m_tuple3, m_tuple4, m_x, m_x2, m_x3, m_y, m_y2, m_y3, m_z, m_z2, m_z3, msgSvc(), and ntupleSvc().
00065 { 00066 00067 MsgStream msg(msgSvc(), name()); 00068 00069 msg << MSG::INFO << "FieldReader intialize() has been called" << endreq; 00070 StatusCode status = service("MagneticFieldSvc", m_pIMF, true); 00071 if( !status.isSuccess() ) { 00072 msg << MSG::FATAL << "Unable to open Magnetic field service" 00073 << endreq; 00074 return StatusCode::FAILURE; 00075 } 00076 00077 msg << MSG::DEBUG << " Book ntuple" << endreq; 00078 00079 NTuplePtr nt1(ntupleSvc(), "FILE1/n1"); 00080 if(nt1) m_tuple1 = nt1; 00081 else { 00082 m_tuple1 = ntupleSvc()->book("FILE1/n1",CLID_ColumnWiseTuple,"Field"); 00083 if( m_tuple1 ) { 00084 status = m_tuple1->addItem("x", m_x ); 00085 status = m_tuple1->addItem("y", m_y ); 00086 status = m_tuple1->addItem("z", m_z ); 00087 status = m_tuple1->addItem("r", m_r ); 00088 status = m_tuple1->addItem("Bx", m_Bx ); 00089 status = m_tuple1->addItem("By", m_By ); 00090 status = m_tuple1->addItem("Bz", m_Bz ); 00091 status = m_tuple1->addItem("SigmaBx", m_sigma_bx ); 00092 status = m_tuple1->addItem("SigmaBy", m_sigma_by ); 00093 status = m_tuple1->addItem("SigmaBz", m_sigma_bz ); 00094 } 00095 else { 00096 msg << MSG::ERROR << " Cannot book N-tuple:" <<long(m_tuple1)<< endreq; 00097 return StatusCode::FAILURE; 00098 } 00099 } 00100 00101 NTuplePtr nt2(ntupleSvc(), "FILE1/n2"); 00102 if(nt2) m_tuple2 = nt2; 00103 else { 00104 m_tuple2 = ntupleSvc()->book("FILE1/n2",CLID_ColumnWiseTuple,"Field"); 00105 if( m_tuple2 ) { 00106 status = m_tuple2->addItem("x", m_x2 ); 00107 status = m_tuple2->addItem("y", m_y2 ); 00108 status = m_tuple2->addItem("z", m_z2 ); 00109 status = m_tuple2->addItem("r", m_r2 ); 00110 status = m_tuple2->addItem("Bx", m_Bx2 ); 00111 status = m_tuple2->addItem("By", m_By2 ); 00112 status = m_tuple2->addItem("Bz", m_Bz2 ); 00113 } 00114 else { 00115 msg << MSG::ERROR << " Cannot book N-tuple:" <<long(m_tuple2)<< endreq; 00116 return StatusCode::FAILURE; 00117 } 00118 } 00119 00120 NTuplePtr nt3(ntupleSvc(), "FILE1/n3"); 00121 if(nt3) m_tuple3 = nt3; 00122 else { 00123 m_tuple3 = ntupleSvc()->book("FILE1/n3",CLID_ColumnWiseTuple,"Field"); 00124 if( m_tuple3 ) { 00125 status = m_tuple3->addItem("x", m_x3 ); 00126 status = m_tuple3->addItem("y", m_y3 ); 00127 status = m_tuple3->addItem("z", m_z3 ); 00128 status = m_tuple3->addItem("r", m_r3 ); 00129 status = m_tuple3->addItem("phi", m_phi3 ); 00130 status = m_tuple3->addItem("Bx", m_Bx3 ); 00131 status = m_tuple3->addItem("By", m_By3 ); 00132 status = m_tuple3->addItem("Bz", m_Bz3 ); 00133 } 00134 else { 00135 msg << MSG::ERROR << " Cannot book N-tuple:" <<long(m_tuple3)<< endreq; 00136 return StatusCode::FAILURE; 00137 } 00138 } 00139 00140 NTuplePtr nt4(ntupleSvc(), "FILE1/n4"); 00141 if(nt4) m_tuple4 = nt4; 00142 else { 00143 m_tuple4 = ntupleSvc()->book("FILE1/n4",CLID_ColumnWiseTuple,"Field"); 00144 if( m_tuple4 ) { 00145 status = m_tuple4->addItem("time", m_time ); 00146 } 00147 else { 00148 msg << MSG::ERROR << " Cannot book N-tuple:" <<long(m_tuple4)<< endreq; 00149 return StatusCode::FAILURE; 00150 } 00151 } 00152 00153 status = service("BesTimerSvc", m_timersvc); 00154 if (status.isFailure()) { 00155 msg << MSG::ERROR << name() << ": Unable to locate BesTimer Service" << endreq; 00156 return StatusCode::FAILURE; 00157 } 00158 m_timer = m_timersvc->addItem("Read field Time"); 00159 00160 msg << MSG::INFO << "MagFieldReader initialized" << endreq; 00161 return StatusCode::SUCCESS; 00162 }
StatusCode MagFieldReader::readField | ( | ) | [private] |
Definition at line 326 of file MagFieldReader.cxx.
References EvtCyclic3::B, Bes_Common::DEBUG, dt, f1, IMagneticFieldSvc::fieldVector(), IMagneticFieldSvc::getReferField(), genRecEmupikp::i, IMagneticFieldSvc::ifRealField(), ganga-rec::j, m_pIMF, m_yMax, m_yMin, m_zMax, m_zMin, msgSvc(), n1, n2, boss::pos, and x.
00326 { 00327 00328 MsgStream msg( msgSvc(), name() ); 00329 msg << MSG::DEBUG << "m_pIMF = " << m_pIMF << endreq; 00330 00331 double referfield = m_pIMF->getReferField()/tesla; 00332 msg << MSG::DEBUG << "The reference field is " << referfield << " tesla" <<endreq; 00333 bool ifrealfield = m_pIMF->ifRealField(); 00334 if(ifrealfield) msg << MSG::DEBUG << "Use the real field"<<endreq; 00335 else msg << MSG::DEBUG << "Use the fake field"<<endreq; 00336 00337 HepVector3D B(0.0,0.0,0.0); 00338 /* for ( double z = m_zMin; z <= m_zMax; z += m_step ) { 00339 for( double y = m_yMin; y <= m_yMax; y += m_step ) { 00340 for( double x = m_xMin; x <= m_xMax; x += m_step ) { 00341 HepPoint3D P( x, y, z ); 00342 // get field at point P 00343 m_pIMF->fieldVector( P, B ); 00344 // fill ntuple 00345 m_x = P.x()/cm; 00346 m_y = P.y()/cm; 00347 m_z = P.z()/cm; 00348 m_Bx = B.x()/tesla; 00349 m_By = B.y()/tesla; 00350 m_Bz = B.z()/tesla; 00351 m_ntuple->write(); 00352 } 00353 } 00354 HepPoint3D P0( 0.0, 0.0, z ); 00355 m_pIMF->fieldVector( P0, B ); 00356 msg << MSG::DEBUG << "Magnetic Field at (" 00357 << P0.x() << ", " << P0.y() << ", " << P0.z() << " ) = " 00358 << (B.x())/tesla << ", " 00359 << (B.y())/tesla << ", " 00360 << (B.z())/tesla << " Tesla " 00361 << endreq; 00362 }*/ 00363 //magnetic field check bz vs z(m_zMin,m_zMax), x=0,200,400,600,800mm, y=0 00364 const int n1=241; 00365 double x[n1],y[n1],y1[n1],y2[n1],y3[n1],y4[n1]; 00366 //magnetic field check bz,br,bendp,bphi vs z(0,m_zMax), x=50,100,200,400,600,800mm, y=0 00367 const int n2=121; 00368 double x1[n2],bz1[n2],bz2[n2],bz3[n2],bz4[n2],bz5[n2],bz6[n2]; 00369 double br1[n2],br2[n2],br3[n2],br4[n2],br5[n2],br6[n2]; 00370 double bp1[n2],bp2[n2],bp3[n2],bp4[n2],bp5[n2],bp6[n2]; 00371 double bphi1[n2],bphi2[n2],bphi3[n2],bphi4[n2],bphi5[n2],bphi6[n2]; 00372 //magnetic field check bx,by vs y(m_yMin,m_yMax) 00373 const int n3=161; 00374 double x2[n3],bx1[n3],bx2[n3],bx3[n3],bx4[n3],bx5[n3],bx6[n3]; 00375 double by1[n3],by2[n3],by3[n3],by4[n3],by5[n3],by6[n3]; 00376 //check globle field value bz vs x (-2.6m,2.6m),y=0,z=0. 00377 const int n4=521; 00378 double globle_x[n4],globle_bz[n4]; 00379 int i=0; 00380 double px,py,pz; 00381 HepPoint3D pos(px,py,pz); 00382 for( px = -2600; px <= 2600; px += 10 ) { 00383 pos[0] = px; pos[1] = 0; pos[2] = 0; 00384 m_pIMF->fieldVector( pos, B ); 00385 globle_x[i]=px/m; 00386 globle_bz[i]=B.z()/tesla; 00387 i++; 00388 } 00389 i=0; 00390 for ( pz = m_zMin; pz <= m_zMax; pz += 10 ) { 00391 pos[0] = 0; pos[1] = 0; pos[2] = pz; 00392 m_pIMF->fieldVector( pos, B ); 00393 x[i]=pz/m; 00394 y[i]=B.z()/tesla; 00395 00396 pos[0] = 200; pos[1] = 0; pos[2] = pz; 00397 m_pIMF->fieldVector( pos, B ); 00398 y1[i]=B.z()/tesla; 00399 00400 pos[0] = 400; pos[1] = 0; pos[2] = pz; 00401 m_pIMF->fieldVector( pos, B ); 00402 y2[i]=B.z()/tesla; 00403 00404 pos[0] = 600; pos[1] = 0; pos[2] = pz; 00405 m_pIMF->fieldVector( pos, B ); 00406 y3[i]=B.z()/tesla; 00407 00408 pos[0] = 800; pos[1] = 0; pos[2] = pz; 00409 m_pIMF->fieldVector( pos, B ); 00410 y4[i]=B.z()/tesla; 00411 i++; 00412 } 00413 int j = 0; 00414 double tbx,tby,tbz,tbr,tbp,tbphi; 00415 for ( pz = 0; pz <= m_zMax; pz += 10 ) { 00416 pos[0] = 50; pos[1] = 0; pos[2] = pz; 00417 m_pIMF->fieldVector( pos, B ); 00418 x1[j]=pz/m; 00419 tbx=B.x()/tesla; 00420 tby=B.y()/tesla; 00421 tbz=B.z()/tesla; 00422 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00423 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00424 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00425 bz1[j] = tbz; 00426 br1[j] = tbr*10000; 00427 bp1[j] = tbp; 00428 bphi1[j] = tbphi*10000; 00429 00430 pos[0] = 100; pos[1] = 0; pos[2] = pz; 00431 m_pIMF->fieldVector( pos, B ); 00432 tbx=B.x()/tesla; 00433 tby=B.y()/tesla; 00434 tbz=B.z()/tesla; 00435 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00436 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00437 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00438 bz2[j] = tbz; 00439 br2[j] = tbr*10000; 00440 bp2[j] = tbp; 00441 bphi2[j] = tbphi*10000; 00442 00443 pos[0] = 200; pos[1] = 0; pos[2] = pz; 00444 m_pIMF->fieldVector( pos, B ); 00445 tbx=B.x()/tesla; 00446 tby=B.y()/tesla; 00447 tbz=B.z()/tesla; 00448 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00449 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00450 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00451 bz3[j] = tbz; 00452 br3[j] = tbr*10000; 00453 bp3[j] = tbp; 00454 bphi3[j] = tbphi*10000; 00455 00456 pos[0] = 400; pos[1] = 0; pos[2] = pz; 00457 m_pIMF->fieldVector( pos, B ); 00458 tbx=B.x()/tesla; 00459 tby=B.y()/tesla; 00460 tbz=B.z()/tesla; 00461 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00462 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00463 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00464 bz4[j] = tbz; 00465 br4[j] = tbr*10000; 00466 bp4[j] = tbp; 00467 bphi4[j] = tbphi*10000; 00468 00469 pos[0] = 600; pos[1] = 0; pos[2] = pz; 00470 m_pIMF->fieldVector( pos, B ); 00471 tbx=B.x()/tesla; 00472 tby=B.y()/tesla; 00473 tbz=B.z()/tesla; 00474 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00475 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00476 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00477 bz5[j] = tbz; 00478 br5[j] = tbr*10000; 00479 bp5[j] = tbp; 00480 bphi5[j] = tbphi*10000; 00481 00482 pos[0] = 800; pos[1] = 0; pos[2] = pz; 00483 m_pIMF->fieldVector( pos, B ); 00484 tbx=B.x()/tesla; 00485 tby=B.y()/tesla; 00486 tbz=B.z()/tesla; 00487 tbr=tbx*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00488 tbphi=tbx*pos[1]/sqrt(pos[0]*pos[0]+pos[1]*pos[1])+tby*pos[0]/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00489 tbp=tbz-tbr*pz/sqrt(pos[0]*pos[0]+pos[1]*pos[1]); 00490 bz6[j] = tbz; 00491 br6[j] = tbr*10000; 00492 bp6[j] = tbp; 00493 bphi6[j] = tbphi*10000; 00494 j++; 00495 } 00496 int l = 0; 00497 for(py = m_yMin; py<= m_yMax; py +=10){ 00498 pos[0] = 0; pos[1] = py; pos[2] = 0; 00499 m_pIMF->fieldVector( pos, B ); 00500 tbx=B.x()/tesla*10000; 00501 tby=B.y()/tesla*10000; 00502 tbz=B.z()/tesla*10000; 00503 x2[l] = py/m; 00504 bx1[l] = tbx; 00505 by1[l] = tby; 00506 00507 pos[0] = 100; pos[1] = py; pos[2] = 100; 00508 m_pIMF->fieldVector( pos, B ); 00509 tbx=B.x()/tesla*10000; 00510 tby=B.y()/tesla*10000; 00511 tbz=B.z()/tesla*10000; 00512 bx2[l] = tbx; 00513 by2[l] = tby; 00514 00515 pos[0] = 400; pos[1] = py; pos[2] = 400; 00516 m_pIMF->fieldVector( pos, B ); 00517 tbx=B.x()/tesla*10000; 00518 tby=B.y()/tesla*10000; 00519 tbz=B.z()/tesla*10000; 00520 bx3[l] = tbx; 00521 by3[l] = tby; 00522 l++; 00523 } 00524 00525 TGraph2D *dt = new TGraph2D(); 00526 int k = 0; 00527 for ( pz = -3000; pz <= 3000; pz += 50 ) { 00528 for( py = -2700; py <= 2700; py += 50){ 00529 pos[0] = 0; pos[1] = py; pos[2] = pz; 00530 m_pIMF->fieldVector( pos, B ); 00531 tbx=B.x()/tesla; 00532 tby=B.y()/tesla; 00533 tbz=B.z()/tesla; 00534 dt->SetPoint(k,pz/m,py/m,tbz); 00535 k++; 00536 } 00537 } 00538 TGraph2D *dt1 = new TGraph2D(); 00539 k = 0; 00540 for ( pz = -3000; pz <= 3000; pz += 50 ) { 00541 for( py = -3000; py <= 3000; py += 50){ 00542 pos[0] = 0; pos[1] = py; pos[2] = pz; 00543 m_pIMF->fieldVector( pos, B ); 00544 tbx=B.x()/tesla; 00545 tby=B.y()/tesla; 00546 tbz=B.z()/tesla; 00547 double btot = sqrt(tbx*tbx+tby*tby+tbz*tbz); 00548 dt1->SetPoint(k,pz/m,py/m,btot); 00549 k++; 00550 } 00551 } 00552 TGraph2D *dt2 = new TGraph2D(); 00553 k = 0; 00554 for ( pz = m_zMin; pz <= m_zMax; pz += 50 ) { 00555 for( py = m_yMin; py <= m_yMax; py += 50){ 00556 pos[0] = 0; pos[1] = py; pos[2] = pz; 00557 m_pIMF->fieldVector( pos, B ); 00558 tbx=B.x()/tesla; 00559 tby=B.y()/tesla; 00560 tbz=B.z()/tesla; 00561 //double btot = sqrt(tbx*tbx+tby*tby+tbz*tbz); 00562 dt2->SetPoint(k,pz/m,py/m,tbz); 00563 k++; 00564 } 00565 } 00566 gStyle->SetPalette(1); 00567 gStyle->SetOptTitle(1); 00568 gStyle->SetOptStat(0); 00569 00570 TFile* f1=new TFile("graph.root","RECREATE"); 00571 TGraph *gr1 = new TGraph(n1,x,y); 00572 TGraph *gr2 = new TGraph(n1,x,y1); 00573 TGraph *gr3 = new TGraph(n1,x,y2); 00574 TGraph *gr4 = new TGraph(n1,x,y3); 00575 TGraph *gr5 = new TGraph(n1,x,y4); 00576 00577 TGraph *g1 = new TGraph(n2,x1,bz1); 00578 TGraph *g2 = new TGraph(n2,x1,bz2); 00579 TGraph *g3 = new TGraph(n2,x1,bz3); 00580 TGraph *g4 = new TGraph(n2,x1,bz4); 00581 TGraph *g5 = new TGraph(n2,x1,bz5); 00582 TGraph *g6 = new TGraph(n2,x1,bz6); 00583 00584 TGraph *g7 = new TGraph(n2,x1,br1); 00585 TGraph *g8 = new TGraph(n2,x1,br2); 00586 TGraph *g9 = new TGraph(n2,x1,br3); 00587 TGraph *g10 = new TGraph(n2,x1,br4); 00588 TGraph *g11 = new TGraph(n2,x1,br5); 00589 TGraph *g12 = new TGraph(n2,x1,br6); 00590 00591 TGraph *g13 = new TGraph(n2,x1,bp1); 00592 TGraph *g14 = new TGraph(n2,x1,bp2); 00593 TGraph *g15 = new TGraph(n2,x1,bp3); 00594 TGraph *g16 = new TGraph(n2,x1,bp4); 00595 TGraph *g17 = new TGraph(n2,x1,bp5); 00596 TGraph *g18 = new TGraph(n2,x1,bp6); 00597 00598 TGraph *g19 = new TGraph(n2,x1,bphi1); 00599 TGraph *g20 = new TGraph(n2,x1,bphi2); 00600 TGraph *g21 = new TGraph(n2,x1,bphi3); 00601 TGraph *g22 = new TGraph(n2,x1,bphi4); 00602 TGraph *g23 = new TGraph(n2,x1,bphi5); 00603 TGraph *g24 = new TGraph(n2,x1,bphi6); 00604 00605 TGraph *g25 = new TGraph(n3,x2,bx1); 00606 TGraph *g26 = new TGraph(n3,x2,bx2); 00607 TGraph *g27 = new TGraph(n3,x2,bx3); 00608 00609 TGraph *g28 = new TGraph(n3,x2,by1); 00610 TGraph *g29 = new TGraph(n3,x2,by2); 00611 TGraph *g30 = new TGraph(n3,x2,by3); 00612 00613 TGraph *g31 = new TGraph(n4,globle_x,globle_bz); 00614 00615 TCanvas *c1 = new TCanvas("c1","Two Graphs",200,10,600,400); 00616 TCanvas *c2 = new TCanvas("c2","Two Graphs",200,10,600,400); 00617 c1->Divide(2,2); 00618 c2->Divide(2,2); 00619 c1->cd(1); 00620 gr1->SetLineColor(2); 00621 gr1->SetLineWidth(2); 00622 gr1->Draw("ALP"); 00623 gr1->SetTitle("bz vs z (y=0,x=0,200,400,600,800mm)"); 00624 gr1->GetXaxis()->SetTitle("m"); 00625 gr1->GetYaxis()->SetTitle("tesla"); 00626 gr2->SetLineWidth(2); 00627 gr2->SetLineColor(3); 00628 gr2->Draw("LP"); 00629 gr3->SetLineWidth(2); 00630 gr3->SetLineColor(4); 00631 gr3->Draw("LP"); 00632 gr4->SetLineWidth(2); 00633 gr4->SetLineColor(5); 00634 gr4->Draw("LP"); 00635 gr5->SetLineWidth(2); 00636 gr5->SetLineColor(6); 00637 gr5->Draw("LP"); 00638 00639 c1->cd(2); 00640 g1->SetLineColor(2); 00641 g1->SetLineWidth(2); 00642 g1->Draw("ALP"); 00643 g1->SetTitle("bz(red),bendp vs z (y=0,x=50,100,200,400,600,800mm)"); 00644 g1->GetXaxis()->SetTitle("m"); 00645 g1->GetYaxis()->SetTitle("tesla"); 00646 g1->GetYaxis()->SetRangeUser(0.2,2); 00647 g2->SetLineWidth(2); 00648 g2->SetLineColor(2); 00649 g2->Draw("LP"); 00650 g3->SetLineWidth(2); 00651 g3->SetLineColor(2); 00652 g3->Draw("LP"); 00653 g4->SetLineWidth(2); 00654 g4->SetLineColor(2); 00655 g4->Draw("LP"); 00656 g5->SetLineWidth(2); 00657 g5->SetLineColor(2); 00658 g5->Draw("LP"); 00659 g6->SetLineColor(2); 00660 g6->SetLineWidth(2); 00661 g6->Draw("LP"); 00662 00663 g13->SetLineWidth(2); 00664 g13->SetLineColor(4); 00665 g13->Draw("LP"); 00666 g14->SetLineWidth(2); 00667 g14->SetLineColor(4); 00668 g14->Draw("LP"); 00669 g15->SetLineWidth(2); 00670 g15->SetLineColor(4); 00671 g15->Draw("LP"); 00672 g16->SetLineWidth(2); 00673 g16->SetLineColor(4); 00674 g16->Draw("LP"); 00675 g17->SetLineWidth(2); 00676 g17->SetLineColor(4); 00677 g17->Draw("LP"); 00678 g18->SetLineWidth(2); 00679 g18->SetLineColor(4); 00680 g18->Draw("LP"); 00681 00682 c1->cd(3); 00683 g7->SetLineWidth(2); 00684 g7->SetLineColor(2); 00685 g7->Draw("ALP"); 00686 g7->SetTitle("br vs z (y=0,x=50,100,200,400,600,800mm)"); 00687 g7->GetXaxis()->SetTitle("m"); 00688 g7->GetYaxis()->SetTitle("gauss"); 00689 g7->GetYaxis()->SetRangeUser(-1100,1000); 00690 g8->SetLineWidth(2); 00691 g8->SetLineColor(3); 00692 g8->Draw("LP"); 00693 g9->SetLineWidth(2); 00694 g9->SetLineColor(4); 00695 g9->Draw("LP"); 00696 g10->SetLineWidth(2); 00697 g10->SetLineColor(5); 00698 g10->Draw("LP"); 00699 g11->SetLineWidth(2); 00700 g11->SetLineColor(6); 00701 g11->Draw("LP"); 00702 g12->SetLineWidth(2); 00703 g12->SetLineColor(7); 00704 g12->Draw("LP"); 00705 00706 c1->cd(4); 00707 g19->SetLineWidth(2); 00708 g19->SetLineColor(2); 00709 g19->Draw("ALP"); 00710 g19->SetTitle("bphi vs z (y=0,x=50,100,200,400,600,800mm)"); 00711 g19->GetXaxis()->SetTitle("m"); 00712 g19->GetYaxis()->SetTitle("gauss"); 00713 g19->GetYaxis()->SetRangeUser(-1000,200); 00714 g20->SetLineWidth(2); 00715 g20->SetLineColor(3); 00716 g20->Draw("LP"); 00717 g21->SetLineWidth(2); 00718 g21->SetLineColor(4); 00719 g21->Draw("LP"); 00720 g22->SetLineWidth(2); 00721 g22->SetLineColor(5); 00722 g22->Draw("LP"); 00723 g23->SetLineWidth(2); 00724 g23->SetLineColor(6); 00725 g23->Draw("LP"); 00726 g24->SetLineWidth(2); 00727 g24->SetLineColor(7); 00728 g24->Draw("LP"); 00729 00730 TCanvas *c3 = new TCanvas("c3","Two Graphs",200,10,600,400); 00731 c3->cd(1); 00732 //dt->Draw("surf2"); 00733 //dt->Draw("tril p3"); 00734 //dt->Draw("surf1z"); 00735 dt->Draw("z sinusoidal"); 00736 dt->SetTitle("bz vs y,z (x=0)"); 00737 00738 TCanvas *c4 = new TCanvas("c4","Two Graphs",200,10,600,400); 00739 c4->cd(1); 00740 dt1->Draw("z sinusoidal"); 00741 dt1->SetTitle("btot vs y,z (x=0)"); 00742 00743 TCanvas *c5 = new TCanvas("c5","Two Graphs",200,10,600,400); 00744 c5->cd(1); 00745 dt2->Draw("z sinusoidal"); 00746 dt2->SetTitle("bz vs y,z (x=0)"); 00747 00748 c2->cd(2); 00749 g25->SetLineWidth(2); 00750 g25->SetLineColor(2); 00751 g25->Draw("ALP"); 00752 g25->SetTitle("bx(red),by vs y (x,z=0,100,400mm)"); 00753 g25->GetXaxis()->SetTitle("m"); 00754 g25->GetYaxis()->SetTitle("gauss"); 00755 g25->GetYaxis()->SetRangeUser(-200,300); 00756 g26->SetLineWidth(2); 00757 g26->SetLineColor(2); 00758 g26->Draw("LP"); 00759 g27->SetLineWidth(2); 00760 g27->SetLineColor(2); 00761 g27->Draw("LP"); 00762 00763 g28->SetLineWidth(2); 00764 g28->SetLineColor(3); 00765 g28->Draw("LP"); 00766 g29->SetLineWidth(2); 00767 g29->SetLineColor(3); 00768 g29->Draw("LP"); 00769 g30->SetLineWidth(2); 00770 g30->SetLineColor(3); 00771 g30->Draw("LP"); 00772 00773 c2->cd(3); 00774 g31->SetLineWidth(2); 00775 g31->SetLineColor(2); 00776 g31->Draw("ALP"); 00777 g31->SetTitle("bz vs x (y,z=0)"); 00778 g31->GetXaxis()->SetTitle("m"); 00779 g31->GetYaxis()->SetTitle("tesla"); 00780 00781 c1->Write(); 00782 c2->Write(); 00783 c3->Write(); 00784 c4->Write(); 00785 c5->Write(); 00786 /* HepVector3D B1(0.0,0.0,0.0); 00787 int ii=0; 00788 double posx,posy,posz; 00789 ofstream outfile("tmp.txt",ios_base::app); 00790 for ( double posz = -2800;posz <= 2800; posz += 10 ) { 00791 for(double posy = -2650; posy <= 2650; posy += 10){ 00792 posx=1500; posy = 0; 00793 HepPoint3D p1(posx,posy,posz); 00794 m_pIMF->fieldVector( p1, B1 ); 00795 tbx=B1.x()/tesla; 00796 tby=B1.y()/tesla; 00797 tbz=B1.z()/tesla; 00798 tbr=tbx*posx/sqrt(posx*posx+posy*posy)+tby*posy/sqrt(posx*posx+posy*posy); 00799 tbp=tbz-tbr*posz/sqrt(posx*posx+posy*posy); 00800 outfile<<posz/m<<" "<<tby<<endl; 00801 ii++; 00802 } 00803 } 00804 outfile.close(); 00805 */ 00806 // Return status code. 00807 return StatusCode::SUCCESS; 00808 }
NTuple::Item<float> MagFieldReader::m_Bx [private] |
NTuple::Item<float> MagFieldReader::m_Bx2 [private] |
NTuple::Item<float> MagFieldReader::m_Bx3 [private] |
NTuple::Item<float> MagFieldReader::m_By [private] |
NTuple::Item<float> MagFieldReader::m_By2 [private] |
NTuple::Item<float> MagFieldReader::m_By3 [private] |
NTuple::Item<float> MagFieldReader::m_Bz [private] |
NTuple::Item<float> MagFieldReader::m_Bz2 [private] |
NTuple::Item<float> MagFieldReader::m_Bz3 [private] |
std::string MagFieldReader::m_filename [private] |
NTuple::Tuple* MagFieldReader::m_ntuple [private] |
Definition at line 50 of file MagFieldReader.h.
NTuple::Item<float> MagFieldReader::m_phi3 [private] |
IMagneticFieldSvc* MagFieldReader::m_pIMF [private] |
Definition at line 42 of file MagFieldReader.h.
Referenced by execute(), initialize(), and readField().
NTuple::Item<float> MagFieldReader::m_r [private] |
NTuple::Item<float> MagFieldReader::m_r2 [private] |
NTuple::Item<float> MagFieldReader::m_r3 [private] |
NTuple::Item<float> MagFieldReader::m_sigma_bx [private] |
NTuple::Item<float> MagFieldReader::m_sigma_by [private] |
NTuple::Item<float> MagFieldReader::m_sigma_bz [private] |
double MagFieldReader::m_step [private] |
NTuple::Item<float> MagFieldReader::m_time [private] |
BesTimer* MagFieldReader::m_timer [private] |
IBesTimerSvc* MagFieldReader::m_timersvc [private] |
NTuple::Tuple* MagFieldReader::m_tuple1 [private] |
NTuple::Tuple* MagFieldReader::m_tuple2 [private] |
NTuple::Tuple* MagFieldReader::m_tuple3 [private] |
NTuple::Tuple* MagFieldReader::m_tuple4 [private] |
NTuple::Item<float> MagFieldReader::m_x [private] |
NTuple::Item<float> MagFieldReader::m_x2 [private] |
NTuple::Item<float> MagFieldReader::m_x3 [private] |
double MagFieldReader::m_xMax [private] |
double MagFieldReader::m_xMin [private] |
NTuple::Item<float> MagFieldReader::m_y [private] |
NTuple::Item<float> MagFieldReader::m_y2 [private] |
NTuple::Item<float> MagFieldReader::m_y3 [private] |
double MagFieldReader::m_yMax [private] |
double MagFieldReader::m_yMin [private] |
NTuple::Item<float> MagFieldReader::m_z [private] |
NTuple::Item<float> MagFieldReader::m_z2 [private] |
NTuple::Item<float> MagFieldReader::m_z3 [private] |
double MagFieldReader::m_zMax [private] |
double MagFieldReader::m_zMin [private] |