17 const Int_t nParts = 2;
18 const Int_t nComp = 3;
20 C =
new TH1F**[nParts];
21 M =
new TH1F**[nParts];
22 S =
new TH1F**[nParts];
24 f =
new TFile(
Form(
"fitParMonitor_%s.root", out.
Data()),
"recreate");
26 for (
Int_t iPart = 0; iPart < nParts; iPart++) {
27 C[iPart] =
new TH1F*[nComp];
28 M[iPart] =
new TH1F*[nComp];
29 S[iPart] =
new TH1F*[nComp];
30 for (
Int_t iComp = 0; iComp < nComp; iComp++) {
31 C[iPart][iComp] =
new TH1F(
Form(
"Constant_%d_%d", iPart, iComp),
"Constant", 100, 0., 0.);
32 M[iPart][iComp] =
new TH1F(
Form(
"Mean_%d_%d", iPart, iComp),
"Mean", 100, 0., 0.);
33 S[iPart][iComp] =
new TH1F(
Form(
"Sigma_%d_%d", iPart, iComp),
"Sigma", 100, 0., 0.);
40 for (
Int_t iPart = 0; iPart < 2; iPart++) {
41 for (
Int_t iComp = 0; iComp < 3; iComp++) {
42 C[iPart][iComp]->Write();
43 M[iPart][iComp]->Write();
44 S[iPart][iComp]->Write();
54 for (
Int_t iPart = 0; iPart < 2; iPart++) {
55 for (
Int_t iComponent = 0; iComponent < 3; iComponent++) {
57 delete mean[iPart][iComponent];
58 delete sigma[iPart][iComponent];
62 delete[]
sigma[iPart];
109 const Int_t nComponents = 3;
110 const Int_t nParts = 2;
115 for (
Int_t iPart = 0; iPart < nParts; iPart++) {
119 for (
Int_t iComponent = 0; iComponent < nComponents; iComponent++) {
134 fConditions->tailRangeLeft = make_pair(-100., -80.);
135 fConditions->tailRangeRight = make_pair(80., 100.);
138 fConditions->tailRangeRight = make_pair(340., 360.);
141 const Int_t nParts = 2;
142 const Int_t nComponents = 3;
145 for (
Int_t iPart = 0; iPart < nParts; iPart++)
146 for (
Int_t iComp = 0; iComp < nComponents; iComp++)
149 for (
Int_t iPart = 0; iPart < nParts; iPart++)
150 for (
Int_t iComp = 0; iComp < nComponents; iComp++)
153 cout <<
"Not supported direction!!! Exiting ..." << endl;
164 TString comp = (iComp == 0) ?
"x" : (iComp == 1) ?
"y" : (iComp == 2) ?
"z" :
"";
177 Double_t dz = (Zmax - Zmin) / nSlicesZ;
178 Double_t dy = (Ymax - Ymin) / nSlicesY;
185 cout <<
"Processing node " <<
i << endl;
190 Float_t zSlice = Zmin + j * dz;
193 for (
Int_t k = 0; k <
fMap->GetNx(); k++) {
196 (comp ==
"x") ?
fMap->GetBx(x, ySlice, zSlice)
197 : (comp ==
"y") ?
fMap->GetBy(x, ySlice, zSlice)
198 : (comp ==
"z") ?
fMap->GetBz(x, ySlice, zSlice)
202 vector<Double_t> fit_par;
207 f->SetParameter(2, 50.);
208 fit_par = bField[
i][j]->
Fit(f,
"SQ",
"", f->GetXmin(), f->GetXmax())->
Parameters();
211 f->SetParameter(2, 100.);
212 fit_par = bField[
i][j]->
Fit(f,
"SQ",
"", f->GetXmin(), f->GetXmax())->
Parameters();
215 fMonitor->C[iPart][iComp]->Fill(fit_par[0]);
216 fMonitor->M[iPart][iComp]->Fill(fit_par[1]);
217 fMonitor->S[iPart][iComp]->Fill(fit_par[2]);
219 constant[iPart][iComp]->SetPoint(counter, ySlice, zSlice, fit_par[0]);
220 mean[iPart][iComp]->SetPoint(counter, ySlice, zSlice, fit_par[1]);
221 sigma[iPart][iComp]->SetPoint(counter, ySlice, zSlice, fit_par[2]);
236 fit_func[
i][j] =
new TF1(
"func",
"[0]*exp(-0.5*((x-[1])/[2])**2)",
249 delete fit_func[
i][j];
250 delete[] fit_func[
i];
266 TString comp = (iComp == 0) ?
"x" : (iComp == 1) ?
"y" : (iComp == 2) ?
"z" :
"";
279 Double_t dx = (Xmax - Xmin) / nSlicesX;
280 Double_t dy = (Ymax - Ymin) / nSlicesY;
287 cout <<
"Processing node " <<
i << endl;
292 Float_t ySlice = Ymin + j * dy;
295 for (
Int_t k = 0; k <
fMap->GetNz(); k++) {
298 (comp ==
"x") ?
fMap->GetBx(xSlice, ySlice, z)
299 : (comp ==
"y") ?
fMap->GetBy(xSlice, ySlice, z)
300 : (comp ==
"z") ?
fMap->GetBz(xSlice, ySlice, z)
304 vector<Double_t> fit_par;
309 f->SetParameter(2, 100.);
310 fit_par = bField[
i][j]->
Fit(f,
"SQ",
"G", f->GetXmin(), f->GetXmax())->
Parameters();
313 f->SetParameter(2, 120.);
314 fit_par = bField[
i][j]->
Fit(f,
"SQ",
"G", f->GetXmin(), f->GetXmax())->
Parameters();
317 fMonitor->C[iPart][iComp]->Fill(fit_par[0]);
318 fMonitor->M[iPart][iComp]->Fill(fit_par[1]);
319 fMonitor->S[iPart][iComp]->Fill(fit_par[2]);
321 constant[iPart][iComp]->SetPoint(counter, xSlice, ySlice, fit_par[0]);
322 mean[iPart][iComp]->SetPoint(counter, xSlice, ySlice, fit_par[1]);
323 sigma[iPart][iComp]->SetPoint(counter, xSlice, ySlice, fit_par[2]);
338 fit_func[
i][j] =
new TF1(
"func",
"[0]*exp(-0.5*((x-[1])/[2])**2)",
351 delete fit_func[
i][j];
352 delete[] fit_func[
i];
386 gr[shiftI][shiftJ]->
Draw();
397 f[
i][j]->Draw(
"same");
414 gStyle->SetTitleFontSize(0.1);
427 gr[shiftI][shiftJ]->
Draw();
440 f[
i][j]->Draw(
"same");
441 f[
i][j]->SetLineWidth(2);
474 mapFile.precision(6);
475 mapFile << showpoint;
476 mapFile <<
"nosym" << endl;
484 Nx =
Int_t((Xmax - Xmin) / 2.) + 1;
485 mapFile << Xmin <<
" " << Xmax <<
" " << Nx << endl;
487 mapFile << Xmin <<
" " << Xmax <<
" " << Nx << endl;
489 mapFile << Ymin <<
" " << Ymax <<
" " << Ny << endl;
494 Nz =
Int_t((Zmax - Zmin) / 2.) + 1;
495 mapFile << Zmin <<
" " << Zmax <<
" " << Nz << endl;
497 mapFile << Zmin <<
" " << Zmax <<
" " << Nz << endl;
499 for (
Int_t ix = 0; ix < Nx; ix++) {
501 for (
Int_t iy = 0; iy < Ny; iy++) {
504 cout << x <<
" " << y << endl;
505 for (
Int_t iz = 0; iz < Nz; iz++) {
509 Double_t bx = -1., by = -1., bz = -1.;
514 if (x < fMap->GetXmin()) {
519 }
else if (x >
fMap->GetXmax() - 1.) {
526 if (z < fMap->GetZmin()) {
531 }
else if (z >
fMap->GetZmax() - 1.) {
540 bx =
fMap->GetBx(x, y, z);
541 by =
fMap->GetBy(x, y, z);
542 bz =
fMap->GetBz(x, y, z);
557 vector<TLorentzVector> vSmoo;
563 vSmoo.push_back(tmp);
586 mapFile.precision(6);
587 mapFile << showpoint;
588 mapFile <<
"nosym" << endl;
589 mapFile << Xmin <<
" " << -Xmin <<
" " << Nx << endl;
590 mapFile << Ymin <<
" " << -Ymin <<
" " << Ny << endl;
591 mapFile << Zmin <<
" " << Zmax <<
" " << Nz << endl;
593 for (
Int_t ix = 0; ix < Nx; ix++) {
596 for (
Int_t iy = 0; iy < Ny; iy++) {
599 for (
Int_t iz = 0; iz < Nz; iz++) {
600 index = ix * Ny * Nz + iy * Nz + iz;
604 for (
auto it = vSmoo.begin(); it != vSmoo.end(); it++) {
608 if (
v.X() != x ||
v.Y() != y ||
v.Z() != z)
620 mapFile << bx <<
" " << by <<
" " << bz << endl;
622 if (index % 1000 == 0)
623 cout <<
"nNodes processed# " << index << endl;
637 vector<Double_t> varToBePassed;
640 varToBePassed.push_back(y);
641 varToBePassed.push_back(z);
642 varToBePassed.push_back(x);
644 varToBePassed.push_back(x);
645 varToBePassed.push_back(y);
646 varToBePassed.push_back(z);
649 Double_t Mean =
m->Interpolate(varToBePassed[0], varToBePassed[1]);
652 return c->
Interpolate(varToBePassed[0], varToBePassed[1])
658 cout <<
"Nx = " << magField->
GetNx();
659 cout <<
"; Ny = " << magField->
GetNy();
660 cout <<
"; Nz = " << magField->
GetNz();
664 cout <<
"; Xmin = " << magField->
GetXmin() - shift;
665 cout <<
"; dx = " << magField->
GetXstep();
666 cout <<
"; Ymin = " << magField->
GetYmin() - shift;
667 cout <<
"; dy = " << magField->
GetYstep();
668 cout <<
"; Zmin = " << magField->
GetZmin() - shift;
669 cout <<
"; dz = " << magField->
GetZstep() << endl;
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
Double_t GetYstep() const
Double_t GetZstep() const
Double_t GetXstep() const
Double_t GetXmin() const
Accessors to field parameters in local coordinate system.
Field Map does not have any symmetries w.r.t coordinate axises.
void Print(BmnFieldMap *)
Double_t FieldExtrapolate(Double_t, Double_t, Double_t, TGraph2D *, TGraph2D *, TGraph2D *)
void DrawProfileExtrapZ(Int_t, TGraph ***, TF1 ***, TString, TString, Double_t, Double_t, Double_t, Double_t)
std::vector< Double_t > checkedFieldValue(Double_t bx, Double_t by, Double_t bz)
void DoExtrapolationAlongZ(Int_t, Int_t)
void DrawProfileExtrapX(Int_t, TGraph ***, TF1 ***, TString, TString, Double_t, Double_t, Double_t, Double_t)
void DoExtrapolationAlongX(Int_t, Int_t)
void SmoothMap(TClonesArray *)
virtual ~BmnSP41FieldMapCreator()
extrapolationConditions * fConditions
void CreateExtrapolatedMap()
const std::vector< double > & Parameters() const
virtual void SetLabelSize(Float_t size=0.04)
virtual void SetTitleSize(Float_t size=0.04)
virtual void SetNdivisions(Int_t n1, Int_t n2, Int_t n3, Bool_t optim=kTRUE)
virtual void SetLineWidth(Width_t lwidth)
virtual void SetLimits(Double_t xmin, Double_t xmax)
TVirtualPad * cd(Int_t subpadnumber=0) override
virtual void SetParameter(const TString &name, Double_t value)
Double_t Interpolate(Double_t x, Double_t y)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
void Draw(Option_t *chopt="") override
void SetTitle(const char *title="") override
virtual void SetTitle(const char *title="")
Int_t GetEntriesFast() const
TObject * UncheckedAt(Int_t i) const
friend friend class TClonesArray
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
void SaveAs(const char *filename="", Option_t *option="") const override
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
constexpr Double_t Sigma()
Double_t Mean(Iterator first, Iterator last)