// $Id$ // // File: DMagneticFieldMapParameterized.cc // Created: Tue Oct 20 14:06:19 EDT 2009 // Creator: davidl (on Darwin harriet.jlab.org 9.8.0 i386) // #include using namespace std; #include using namespace jana; #include "DMagneticFieldMapParameterized.h" // Chebyshev polynomial functions #define T0() (1) #define T1(x_1) (x_1) #define T2(x_2) (2*x_2-1) #define T3(x_1,x_3) (4*x_3-3*x_1) #define T4(x_2,x_4) (8*x_4-8*x_2+1) #define T5(x_5,x_3,x_1) (16*x_5-20*x_3+5*x_1) #define T6(x_6,x_4,x_2) (32*x_6-48*x_4+18*x_2-1) #define T7(x_7,x_5,x_3,x_1) (64*x_7-112*x_5+56*x_3-7*x_1) #define T8(x_8,x_6,x_4,x_2) (128*x_8-256*x_6+160*x_4-32*x_2+1) #define T9(x_9,x_7,x_5,x_3,x_1) (256*x_9-576*x_7+432*x_5-120*x_3+9*x_1) // First derivative of Chebyshev polynomial functions #define dT0dx(x) (0) #define dT1dx(x) (1) #define dT2dx(x) (2*2*pow(x,2-1)) #define dT3dx(x) (3*4*pow(x,3-1)-3) #define dT4dx(x) (4*8*pow(x,4-1)-2*8*pow(x,2-1)) #define dT5dx(x) (5*16*pow(x,5-1)-3*20*pow(x,3-1)+5) #define dT6dx(x) (6*32*pow(x,6-1)-4*48*pow(x,4-1)+2*18*pow(x,2-1)) #define dT7dx(x) (7*64*pow(x,7-1)-5*112*pow(x,5-1)+3*56*pow(x,3-1)-7) #define dT8dx(x) (8*128*pow(x,8-1)-6*256*pow(x,6-1)+4*160*pow(x,4-1)-2*32*pow(x,2-1)) #define dT9dx(x) (9*256*pow(x,9-1)-7*576*pow(x,7-1)+5*432*pow(x,5-1)-3*120*pow(x,3-1)+9) //--------------------------------- // DMagneticFieldMapParameterized (Constructor) //--------------------------------- DMagneticFieldMapParameterized::DMagneticFieldMapParameterized(jana::JApplication *japp, string namepath) { int runnumber = 1; jcalib = japp->GetJCalibration(runnumber); JParameterManager *jparms = japp->GetJParameterManager(); jparms->SetDefaultParameter("BFIELD_MAP", namepath); Init(jcalib, namepath); } //--------------------------------- // DMagneticFieldMapParameterized (Constructor) //--------------------------------- DMagneticFieldMapParameterized::DMagneticFieldMapParameterized(jana::JCalibration *jcalib, string namepath) { Init(jcalib, namepath); } //--------------------------------- // ~DMagneticFieldMapParameterized (Destructor) //--------------------------------- DMagneticFieldMapParameterized::~DMagneticFieldMapParameterized() { } //--------------------------------- // Init //--------------------------------- void DMagneticFieldMapParameterized::Init(jana::JCalibration *jcalib, string namepath) { this->jcalib = jcalib; // First, get the parameters specifying the number of sections and their ranges in z, r vector > sections_map; jcalib->Get(namepath, sections_map); // Loop over entries in the master list and read in those tables for(unsigned int k=0; k &vals = sections_map[k]; Dsection section; section.namepath = vals["namepath"]; section.Bi = vals["Bi"]; section.section = atoi(vals["sec"].c_str()); section.zmin = atof(vals["zmin"].c_str()); section.zmax = atof(vals["zmax"].c_str()); section.zmid = atof(vals["zmid"].c_str()); section.znorm = atof(vals["znorm"].c_str()); section.rmid = atof(vals["rmid"].c_str()); section.rnorm = atof(vals["rnorm"].c_str()); // Get parameters for this section jcalib->Get(section.namepath, section.pp); section.order1 = section.pp.size() - 1; section.order2 = section.pp[0].size() - 1; cout<<"---- parameterized B-field section ---------------"<