// // // This macro is used to generate ASCII files containing a parameterized // magnetic field map in a format suitable for use with the JANA // JCalibrationFile class. It takes as input the root files // BfieldParameters_Bz.root and BfieldParameters_Bx.root which themselves // are produced by the ParameterizeBField.C macro using bfield.root // file as input. (The bfield.root file is generated with the bfield2root // utility from a full map already in the calibDB). // //------------------------------ // ParameterizeBField_codegen //------------------------------ void ParameterizeBField_codegen(const char *based_on="_1500_poisson_20090814_01") { gROOT->Reset(); // Create master params file stringstream fname; fname<<"solenoid"<FindObject("z_bounds_hist"); UInt_t Nsec = z_bounds_hist->GetNbinsX()-1; for(UInt_t sec=1; sec<=Nsec; sec++){ zmin[sec-1] = z_bounds_hist->GetBinContent(z_bounds_hist->FindBin(sec)); zmax[sec-1] = z_bounds_hist->GetBinContent(z_bounds_hist->FindBin(sec+1)); stringstream hname; hname<<"sec"<<(sec)<<"_p0"; // sec1_p0, sec2_p0, ... TH1D *sec_p0 = (TH1D*)gROOT->FindObject(hname.str().c_str()); if(!sec_p0)break; rmin[sec-1] = sec_p0->GetXaxis()->GetXmin(); rmax[sec-1] = sec_p0->GetXaxis()->GetXmax(); } // Get order of Chebyshev polynomials used for 1st level of parameterization UInt_t order1; for(order1=0; order1<20; order1++){ stringstream hname; hname<<"sec1"<<"_p"<FindObject(hname.str().c_str()); if(!sec1_p){order1--; break;} } // Get order of Chebyshev polynomials used for 2nd level of parameterization TH1D *sec1_pp0 = (TH1D*)gROOT->FindObject("sec1_pp0"); UInt_t order2 = sec1_pp0->GetNbinsX()-1; cout<<"----------------------------------------------------------------------"<GetName()<FindObject(hname.str().c_str()); string line((order2+1)*chars_per_val, ' '); for(UInt_t j=0; j<=order2; j++){ stringstream val; val<GetBinContent(j); string &s = val.str(); if(s.length()>=chars_per_val){ cerr<<"ERROR: too many characters in val! ("<<__FILE__<<":"<<__LINE__<<")"<