24 if (suggested_index < array_size)
25 return suggested_index;
27 return (suggested_index - 5);
53 this->SetName(pBsName);
54 this->SetTitle(pBsName);
115 delete (FairField*)
this;
119 TString tmp_FileName;
120 TString dir = gSystem->Getenv(
"VMCWORKDIR");
121 tmp_FileName = dir +
"/input/" +
fBsName +
".root";
127 Double_t po[3], B[3], sm = 100;
128 fNx = (pNx <= 0) ?
fX->GetSize() - 3 : pNx;
129 fNy = (pNy <= 0) ?
fY->GetSize() - 3 : pNy;
130 fNz = (pNz <= 0) ?
fZ->GetSize() - 3 : pNz;
131 if ((
fNx < 2) || (
fNy < 2) || (
fNz < 2)) {
132 cout <<
"CalculateMapFromBs ERROR [Ns]: " <<
fNx <<
" " <<
fNy <<
" " <<
fNz
136 fXmin = (
fX->GetArray())[3] * sm;
137 fYmin = (
fY->GetArray())[3] * sm;
138 fZmin = (
fZ->GetArray())[3] * sm;
139 fXmax = (
fX->GetArray())[
fX->GetSize() - 1] * sm;
140 fYmax = (
fY->GetArray())[
fY->GetSize() - 1] * sm;
141 fZmax = (
fZ->GetArray())[
fZ->GetSize() - 1] * sm;
153 cout <<
"CalculateMapFromBs [Ns]: " <<
fNx <<
" " <<
fNy <<
" " <<
fNz
155 cout <<
"CalculateMapFromBs [MINs]: " <<
fXmin <<
" " <<
fYmin <<
" " <<
fZmin
157 cout <<
"CalculateMapFromBs [MAXs]: " <<
fXmax <<
" " <<
fYmax <<
" " <<
fZmax
159 cout <<
"CalculateMapFromBs [STEPs]: " <<
fXstep <<
" " <<
fYstep <<
" "
161 cout <<
"CalculateMapFromBs [POSs]: " <<
fPosX <<
" " <<
fPosY <<
" " <<
fPosZ
166 for (Int_t ix = 0; ix <
fNx; ix++) {
168 for (Int_t iy = 0; iy <
fNy; iy++) {
170 for (Int_t iz = 0; iz <
fNz; iz++) {
174 if (
fBx) (*fBx)[index] = B[0];
175 if (
fBy) (*fBy)[index] = B[1];
176 if (
fBz) (*fBz)[index] = B[2];
185 TFile* oldfile = gFile;
186 TFile*
f =
new TFile(name,
"RECREATE");
189 if (oldfile) oldfile->cd();
194 TFile* oldfile = gFile;
195 TFile*
f =
new TFile(name,
"READ");
197 cout <<
"-E- CbmBsField::readBsRootfile: can not read from file: " << endl;
198 Fatal(
"CbmBsField::readBsRootfile:",
"Can not read from input file");
200 const char* bsname =
fBsName.Data();
203 cout <<
"-I- CbmBsField Reading splined field : " << bsname
204 <<
" from root file : " << name << endl;
205 f->GetObject(bsname, fnew);
217 fX =
new TArrayF(*fnew->
GetX());
218 fY =
new TArrayF(*fnew->
GetY());
219 fZ =
new TArrayF(*fnew->
GetZ());
222 if (oldfile) oldfile->cd();
224 UX1 =
fX->GetArray();
225 UX2 =
fY->GetArray();
226 UX3 =
fZ->GetArray();
241 Double_t XX, YY, ZZ, X, Y, Z, FX, FY, FZ, pfScale;
242 Float_t fHemiX = 1., fHemiY = 1., fHemiZ = 1;
268 if (X < 0.) fHemiX = -1.;
269 if (Y < 0.) fHemiY = -1.;
271 FX = FX * fHemiX * fHemiY;
273 if ((fType == 3) && (Z < 0.))
276 FZ = FZ * fHemiY * fHemiZ;
317 const char* BsFortranAsciiFileName2,
318 const char* BsFortranAsciiFileName3) {
322 TString fileNam1 = BsFortranAsciiFileName1;
323 ifstream fBsFortranAscii1(fileNam1);
324 if (!fBsFortranAscii1.is_open()) {
325 cerr <<
"ERROR: File " << BsFortranAsciiFileName1 <<
" not opened!" << endl;
329 fX =
new TArrayF(
LL1);
330 UX1 =
fX->GetArray();
331 for (
i = 0;
i <
LL1;
i++) {
332 fBsFortranAscii1 >> val;
339 fBsFortranAscii1 >> val;
343 fBsFortranAscii1.close();
346 TString fileNam2 = BsFortranAsciiFileName2;
347 ifstream fBsFortranAscii2(fileNam2);
348 if (!fBsFortranAscii2.is_open()) {
349 cerr <<
"ERROR: File " << BsFortranAsciiFileName2 <<
" not opened!" << endl;
352 fY =
new TArrayF(
LL2);
353 UX2 =
fY->GetArray();
354 for (
i = 0;
i <
LL2;
i++) {
355 fBsFortranAscii2 >> val;
361 fBsFortranAscii2 >> val;
364 fBsFortranAscii2.close();
367 TString fileNam3 = BsFortranAsciiFileName3;
368 ifstream fBsFortranAscii3(fileNam3);
369 if (!fBsFortranAscii3.is_open()) {
370 cerr <<
"ERROR: File " << BsFortranAsciiFileName3 <<
" not opened!" << endl;
373 fZ =
new TArrayF(
LL3);
374 UX3 =
fZ->GetArray();
375 for (
i = 0;
i <
LL3;
i++) {
376 fBsFortranAscii3 >> val;
382 fBsFortranAscii3 >> val;
385 fBsFortranAscii3.close();
395 Double_t UX[4], UY[4], UZ[4], X0, X1, X2, X3, X4, X5, X6, X7, Y0, Y1, Y2, Y3,
396 Y4, Y5, Y6, Y7, VX0, VX1, VX2, VX3, VX4, VX5, VX6, VX7;
397 Long64_t INT1[4], INT2[4], INT3[4], KK, K1, K2, K3, KK1, KK2, KK3, NN0, I1,
398 JJ0, I2, JJ1, I3, JJ2;
399 Double_t EPS = 1.0e-7, XRZYX, YRZYX, ZRZYX, XRZY, YRZY, ZRZY, XRZ, YRZ, ZRZ,
401 Int_t izero4 = 3, izero5 = 4;
402 if (X < (
UX1[izero4] - EPS))
goto m100;
403 for (KK = izero5; KK <
LL1; KK++) {
404 if (X <=
UX1[KK])
goto m52;
409 if (Y < (
UX2[izero4] - EPS))
goto m100;
410 for (KK = izero5; KK <
LL2; KK++) {
411 if (Y <=
UX2[KK])
goto m54;
416 if (Z < (
UX3[izero4] - EPS))
goto m100;
418 for (KK = izero5; KK <
LL3; KK++) {
419 if (Z <=
UX3[KK])
goto m56;
432 UX[1 - 1] =
SPL0(X, X0, X1, X2, X3, X4);
433 UX[2 - 1] =
SPL0(X, X1, X2, X3, X4, X5);
434 UX[3 - 1] =
SPL0(X, X2, X3, X4, X5, X6);
435 UX[4 - 1] =
SPL0(X, X3, X4, X5, X6, X7);
445 UY[1 - 1] =
SPL0(Y, Y0, Y1, Y2, Y3, Y4);
446 UY[2 - 1] =
SPL0(Y, Y1, Y2, Y3, Y4, Y5);
447 UY[3 - 1] =
SPL0(Y, Y2, Y3, Y4, Y5, Y6);
448 UY[4 - 1] =
SPL0(Y, Y3, Y4, Y5, Y6, Y7);
458 UZ[1 - 1] =
SPL0(Z, VX0, VX1, VX2, VX3, VX4);
459 UZ[2 - 1] =
SPL0(Z, VX1, VX2, VX3, VX4, VX5);
460 UZ[3 - 1] =
SPL0(Z, VX2, VX3, VX4, VX5, VX6);
461 UZ[4 - 1] =
SPL0(Z, VX3, VX4, VX5, VX6, VX7);
464 if (KK2 < 0) KK2 = 0;
466 if (KK3 < 0) KK3 = 0;
467 NN0 = KK1 +
II1 * (KK2 +
II2 * (KK3));
469 INT1[2 - 1] = NN0 + 1;
470 INT1[3 - 1] = NN0 + 2;
471 INT1[4 - 1] = NN0 + 3;
474 INT2[2 - 1] = (1) *
II1;
475 INT2[3 - 1] = (2) *
II1;
476 INT2[4 - 1] = (3) *
II1;
480 INT3[2 - 1] = (1) *
II1 *
II2;
481 INT3[3 - 1] = (2) *
II1 *
II2;
482 INT3[4 - 1] = (3) *
II1 *
II2;
488 for (I1 = 1; I1 <= 4; I1++) {
494 for (I2 = 1; I2 <= 4; I2++) {
495 JJ1 = JJ0 + INT2[I2 - 1];
499 for (I3 = 1; I3 <= 4; I3++) {
500 JJ2 = JJ1 + INT3[I3 - 1];
502 XRZ = XRZ +
F0[JJ2] * SS3;
503 YRZ = YRZ +
G0[JJ2] * SS3;
504 ZRZ = ZRZ +
U0[JJ2] * SS3;
507 XRZY = XRZY + XRZ * SS2;
508 YRZY = YRZY + YRZ * SS2;
509 ZRZY = ZRZY + ZRZ * SS2;
512 XRZYX = XRZYX + XRZY * SS1;
513 YRZYX = YRZYX + YRZY * SS1;
514 ZRZYX = ZRZYX + ZRZY * SS1;
536 Double_t W0, C0, TT, RR, TPL, W1, W2, W3, value_SPL0;
537 if (T < X0)
goto n100;
538 if (T < X1)
goto n200;
539 if (T < X2)
goto n300;
540 if (T < X3)
goto n400;
541 if (T > X4)
goto n100;
543 W0 = (X1 - X0) * (X2 - X0) * (X3 - X0) * (X4 - X0);
546 TPL = RR * (TT * TT * TT);
547 W1 = (X0 - X1) * (X2 - X1) * (X3 - X1) * (X4 - X1);
550 TPL = RR * (TT * TT * TT) + TPL;
551 W2 = (X0 - X2) * (X1 - X2) * (X3 - X2) * (X4 - X2);
554 TPL = RR * (TT * TT * TT) + TPL;
555 W3 = (X0 - X3) * (X1 - X3) * (X2 - X3) * (X4 - X3);
558 value_SPL0 = RR * (TT * TT * TT) + TPL;
559 return ((Float_t) value_SPL0);
562 W0 = (X1 - X0) * (X2 - X0) * (X3 - X0) * (X4 - X0);
565 value_SPL0 = RR * (TT * TT * TT);
566 return ((Float_t) value_SPL0);
569 W0 = (X1 - X0) * (X2 - X0) * (X3 - X0) * (X4 - X0);
572 TPL = RR * (TT * TT * TT);
573 W1 = (X0 - X1) * (X2 - X1) * (X3 - X1) * (X4 - X1);
576 value_SPL0 = RR * (TT * TT * TT) + TPL;
577 return ((Float_t) value_SPL0);
580 W0 = (X1 - X0) * (X2 - X0) * (X3 - X0) * (X4 - X0);
583 TPL = RR * (TT * TT * TT);
584 W1 = (X0 - X1) * (X2 - X1) * (X3 - X1) * (X4 - X1);
587 TPL = RR * (TT * TT * TT) + TPL;
588 W2 = (X0 - X2) * (X1 - X2) * (X3 - X2) * (X4 - X2);
591 value_SPL0 = RR * (TT * TT * TT) + TPL;
592 return ((Float_t) value_SPL0);
595 return ((Float_t) value_SPL0);