15 #include <evioFileChannel.hxx>
16 #include <evioUtil.hxx>
24 int main(
int narg,
char *argv[])
37 for(
int i=1; i<narg; i++){
39 string next(i<narg-1 ? argv[i+1]:
"");
40 float argf = atof(next.c_str());
41 bool used_next =
false;
42 if(arg==
"-zmin"){used_next=
true; zmin = argf;}
43 if(arg==
"-zmax"){used_next=
true; zmax = argf;}
44 if(arg==
"-rmin"){used_next=
true; rmin = argf;}
45 if(arg==
"-rmax"){used_next=
true; rmax = argf;}
46 if(arg==
"-dr"){used_next=
true;dr=argf;}
47 if(arg==
"-dz"){used_next=
true;dz=argf;}
48 if(arg==
"-file"){evioFileName=next;};
55 _DBG_<<
"No argument given for \""<<arg<<
"\" argument!"<<endl;
61 cout <<
"Generation fine-mesh B-field map with the following parameters:"
63 cout <<
" rmin = " << rmin <<endl;
64 cout <<
" rmax = " << rmax << endl;
65 cout <<
" dr = " << dr <<endl;
66 cout <<
" zmin = " << zmin << endl;
67 cout <<
" zmax = " << zmax << endl;
68 cout <<
" dz = " << dz <<endl;
80 unsigned int Nr=(
unsigned int)floor((rmax-rmin)/dr+0.5);
81 unsigned int Nz=(
unsigned int)floor((zmax-zmin)/dz+0.5);
90 for (
unsigned int i=0;i<
Nr;i++){
91 double r=rmin+dr*double(i);
92 for (
unsigned int j=0;j<
Nz;j++){
93 double z=zmin+dz*double(j);
95 double dBxdx,dBxdy,dBxdz,dBydx,dBydy,dBydz,dBzdx,dBzdy,dBzdz;
98 dBydx,dBydy,dBydz,dBzdx,dBzdy,dBzdz);
102 dBrdr_.push_back(dBxdx);
103 dBrdz_.push_back(dBxdz);
104 dBzdr_.push_back(dBzdx);
105 dBzdz_.push_back(dBzdz);
110 unsigned long bufsize=Nr*Nz*6*
sizeof(float)+6;
111 evioFileChannel
chan(evioFileName,
"w",bufsize);
115 evioDOMTree tree(1,0);
118 tree.addBank(2,0,minmaxdelta,6);
121 tree.addBank(3,0,Br_);
122 tree.addBank(3,1,Bz_);
123 tree.addBank(3,2,dBrdr_);
124 tree.addBank(3,3,dBrdz_);
125 tree.addBank(3,4,dBzdr_);
126 tree.addBank(3,5,dBzdz_);
140 cout<<
"Usage:"<<endl;
141 cout<<
" bfield_finemesh -rmin [rmin] -rmax [rmax] -dr [dr] -zmin [zmin] -zmax [zmax] -dz [dz] [-file filename]"<<endl;
virtual void GetFieldAndGradient(double x, double y, double z, double &Bx, double &By, double &Bz, double &dBxdx, double &dBxdy, double &dBxdz, double &dBydx, double &dBydy, double &dBydz, double &dBzdx, double &dBzdy, double &dBzdz) const =0
DMagneticFieldMap * GetBfield(unsigned int run_number=1)
static string evioFileName
static evioFileChannel * chan
void Usage(JApplication &app)
int main(int argc, char *argv[])