17 std::unique_ptr<TInverseMap> TInverseMap::fInverseMap =
nullptr;
21 ReadMapFile(filename);
31 return fInverseMap.get();
32 if (strlen(filename) == 0 || access(filename, F_OK) == -1) {
33 printf(
"no inverse map loaded and file \"%s\" not found.\n", filename);
36 fInverseMap = std::make_unique<TInverseMap>(filename);
37 return fInverseMap.get();
40 bool TInverseMap::ReadMapFile(
const char *filename)
42 std::string mapfile = filename;
45 if (mapfile.length() == 0 || access(mapfile.c_str(), F_OK) == -1) {
46 printf(
"no inverse map loaded and file \"%s\" not found.\n", mapfile.c_str());
52 infile.open(mapfile.c_str());
54 getline(infile, info);
55 sscanf(info.c_str(),
"S800 inverse map - Brho=%g - M=%d - Q=%d", &fBrho, &fMass, &fCharge);
59 while (getline(infile, line)) {
60 if (line.find(
"----------") != std::string::npos)
62 if (line.find(
"COEFFICIENT") != std::string::npos) {
68 std::stringstream ss(line);
76 invrow.coefficient = std::atof(temp.c_str());
88 fMap[par - 1].push_back(invrow);
98 std::cout <<
"mapfile size : " << mapfile_v.size() << std::endl;
100 for (
auto &i : mapfile_v) {
103 isRead = ReadMapFile(i.c_str());
104 fMap_v.push_back(fMap);
106 std::cout <<
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " << i << std::endl;
108 std::cout <<
"! Inv map file not read : " << i << std::endl;
111 std::vector<InvMapRow> invrow_v;
112 std::vector<std::vector<double>> coeff_v;
114 TSpline3 *spline[fsize];
117 if (fMap_v.size() > 0)
118 for (
int j = 0; j < fMap_v.at(0).size();
120 for (
int k = 0; k < fMap_v.at(0).at(j).size(); k++) {
121 std::vector<double> buff_v;
122 std::vector<InvMapRowS> blabla;
123 InvMapRowS invrow_s{};
124 for (
auto &i : fMap_v) {
126 buff_v.push_back((Double_t)i.at(j).at(k).coefficient);
129 coeff_v.push_back(buff_v);
131 sprintf(fname,
"f_%d", icoeff);
132 spline[icoeff] =
new TSpline3(fname, &fMapDist_v[0], &buff_v[0], fMap_v.size());
136 invrow_s.coefficient = spline[icoeff];
137 invrow_s.order = fMap_v.at(0).at(j).at(k).order;
138 invrow_s.exp[0] = fMap_v.at(0).at(j).at(k).exp[0];
139 invrow_s.exp[1] = fMap_v.at(0).at(j).at(k).exp[1];
140 invrow_s.exp[2] = fMap_v.at(0).at(j).at(k).exp[2];
141 invrow_s.exp[3] = fMap_v.at(0).at(j).at(k).exp[3];
142 invrow_s.exp[4] = fMap_v.at(0).at(j).at(k).exp[4];
143 invrow_s.exp[5] = fMap_v.at(0).at(j).at(k).exp[5];
144 fMap_s[j].push_back(invrow_s);
155 printf(
"%s\n", info.c_str());
156 printf(
"\tBrho = %.04f\t", fBrho);
157 printf(
"Mass = %i\t", fMass);
158 printf(
"Q = %i\n", fCharge);
159 for (
auto it1 : fMap) {
160 printf(
"----------- par: %i ---------------\n", it1.first);
162 for (
auto &i : it1.second) {
163 printf(
"\t%i\t%.04f\t\t%i\t%i %i %i %i %i %i\n", counter++, i.coefficient, i.order, i.exp[0], i.exp[1],
164 i.exp[2], i.exp[3], i.exp[4], i.exp[5]);
200 input[0] = -xfp / 1000.0;
202 input[2] = yfp / 1000.0;
206 return MapCalc(order, 0, input);
212 input[0] = -xfp / 1000.0;
214 input[2] = yfp / 1000.0;
218 return MapCalc(order, 2, input);
224 input[0] = -xfp / 1000.0;
226 input[2] = yfp / 1000.0;
230 return MapCalc(order, 1, input);
236 input[0] = -xfp / 1000.0;
238 input[2] = yfp / 1000.0;
242 return MapCalc(order, 3, input);
245 float TInverseMap::Ata(
int order,
double xfp,
double afp,
double yfp,
double bfp,
double z)
248 input[0] = -xfp / 1000.0;
250 input[2] = yfp / 1000.0;
257 float TInverseMap::Bta(
int order,
double xfp,
double afp,
double yfp,
double bfp,
double z)
260 input[0] = -xfp / 1000.0;
262 input[2] = yfp / 1000.0;
269 float TInverseMap::Yta(
int order,
double xfp,
double afp,
double yfp,
double bfp,
double z)
272 input[0] = -xfp / 1000.0;
274 input[2] = yfp / 1000.0;
281 float TInverseMap::Dta(
int order,
double xfp,
double afp,
double yfp,
double bfp,
double z)
284 input[0] = -xfp / 1000.0;
286 input[2] = yfp / 1000.0;
346 float multiplicator = 0.0;
347 std::vector<InvMapRow> vec = fMap.at(par);
348 for (
auto &x : vec) {
352 for (
int y = 0;
y < 6;
y++) {
354 multiplicator *= pow(input[
y], x.exp[
y]);
356 cumul += multiplicator * x.coefficient;
364 float multiplicator = 0.0;
365 std::vector<InvMapRowS> vec = fMap_s.at(par);
366 for (
auto &x : vec) {
370 for (
int y = 0;
y < 6;
y++) {
372 multiplicator *= pow(input[
y], x.exp[
y]);
374 cumul += multiplicator * x.coefficient->Eval(z);