EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
main.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file main.cc
1 
2 #include <stdio.h>
3 #include <stdlib.h>
4 
5 #include <BeastMagneticField.h>
6 
7 // --------------------------------------------------------------------------------------
8 
9 int main(int argc, char *argv[])
10 {
11  if (argc == 4) {
12  auto bmf = new BeastMagneticField(argv[1]);
13 
14  if (bmf->ValidMapImported()) {
15  // Turn linear interpolation on;
16  bmf->UseInterpolation();
17  double r = atof(argv[2]), z = atof(argv[3]), br, bz;
18  bool ret = bmf->GetFieldValue(r, z, br, bz);
19  if (!ret)
20  printf("{r,z} coordinates out of the map region!\n");
21  else
22  //printf("%8.4f %8.4f%s\n", br, bz, bmf->IsInsideTheBore(r, 0.0) ? "" : " # outside of the bore");
23  printf("%8.4f %8.4f [T]\n", br, bz);//, bmf->IsInsideTheBore(r, 0.0) ? "" : " # outside of the bore");
24  }
25  else
26  printf("File '%s' either does not exist or is not a valid field map!\n", argv[1]);
27  } else {
28  printf("\n usage (cylindrical coordinates {r,z} in [cm]): \n\n %s ASCII-field-map-file r z\n", argv[0]);
29  printf("\n output (radial and longitudinal field components in [T]): br bz\n\n");
30  } //if
31 } // main()
32 
33 // --------------------------------------------------------------------------------------