Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CEPCSW
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Li Zhihao
CEPCSW
Commits
7f8efc35
Commit
7f8efc35
authored
3 years ago
by
lintao@ihep.ac.cn
Browse files
Options
Downloads
Patches
Plain Diff
WIP: calculate the index.
parent
50ce326d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Detector/MagneticFieldMap/src/FieldMapFileProvider.cpp
+48
-5
48 additions, 5 deletions
Detector/MagneticFieldMap/src/FieldMapFileProvider.cpp
Detector/MagneticFieldMap/src/FieldMapFileProvider.h
+3
-0
3 additions, 0 deletions
Detector/MagneticFieldMap/src/FieldMapFileProvider.h
with
51 additions
and
5 deletions
Detector/MagneticFieldMap/src/FieldMapFileProvider.cpp
+
48
−
5
View file @
7f8efc35
...
...
@@ -9,24 +9,62 @@
#include
<sstream>
FieldMapFileProvider
::
FieldMapFileProvider
(
const
std
::
string
&
url_
)
:
m_url
(
url_
),
rBinMax
(
-
1
),
zBinMax
(
-
1
),
drBin
(
-
1
),
dzBin
(
-
1
)
{
:
m_url
(
url_
),
nr
(
-
1
),
nz
(
-
1
),
rBinMin
(
-
1
),
zBinMin
(
-
1
),
rBinMax
(
-
1
),
zBinMax
(
-
1
),
drBin
(
-
1
),
dzBin
(
-
1
)
{
init
();
}
int
FieldMapFileProvider
::
rBinIdx
(
double
r
)
{
//
// | --- | --- | --- |
// ^ ^ ^
// rmin | rmax
// r
// |
// return
double
absr
=
std
::
fabs
(
r
);
int
idx
=
-
1
;
if
(
rBinMin
<=
absr
&&
absr
<
rBinMax
)
{
idx
=
(
absr
-
rBinMin
)
/
drBin
;
}
return
-
1
;
return
idx
;
}
int
FieldMapFileProvider
::
zBinIdx
(
double
z
)
{
double
absz
=
std
::
fabs
(
z
);
int
idx
=
-
1
;
if
(
zBinMin
<=
absz
&&
absz
<
zBinMax
)
{
idx
=
(
absz
-
zBinMin
)
/
drBin
;
}
return
-
1
;
return
idx
;
}
void
FieldMapFileProvider
::
access
(
int
rbin
,
int
zbin
,
double
&
Br
,
double
&
Bz
)
{
// the valid bin should between [0, n)
// if the point is not in the valid region, return 0
if
((
rbin
<
0
||
rbin
>=
nr
)
||
(
zbin
<
0
||
zbin
>=
nr
))
{
Br
=
0
;
Bz
=
0
;
}
// convert to the internal table (with left col and top row)
int
ridx
=
rbin
+
1
;
int
zidx
=
zbin
+
1
;
int
globalidx
=
ridx
+
zidx
*
(
nr
+
1
);
Br
=
Brdata
[
globalidx
];
Bz
=
Bzdata
[
globalidx
];
}
// ======================
...
...
@@ -120,14 +158,19 @@ bool FieldMapFileProvider::loadBr(const std::string& fn) {
nr
=
ncol
-
1
;
// skip the top row and left col
nz
=
nrow
-
1
;
rBinMin
=
Brdata
[
1
];
zBinMin
=
Brdata
[
ncol
];
rBinMax
=
Brdata
[
ncol
-
1
];
zBinMax
=
Brdata
[
ncol
*
(
nrow
-
1
)];
drBin
=
rBinMax
/
(
nr
-
1
);
dzBin
=
zBinMax
/
(
nz
-
1
);
drBin
=
(
rBinMax
-
rBinMin
)
/
(
nr
-
1
);
dzBin
=
(
zBinMax
-
zBinMin
)
/
(
nz
-
1
);
std
::
cout
<<
"nr: "
<<
nr
<<
std
::
endl
;
std
::
cout
<<
"nz: "
<<
nz
<<
std
::
endl
;
std
::
cout
<<
"rBinMin: "
<<
rBinMin
<<
std
::
endl
;
std
::
cout
<<
"zBinMin: "
<<
zBinMin
<<
std
::
endl
;
std
::
cout
<<
"rBinMax: "
<<
rBinMax
<<
std
::
endl
;
std
::
cout
<<
"zBinMax: "
<<
zBinMax
<<
std
::
endl
;
std
::
cout
<<
"drBin: "
<<
drBin
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
Detector/MagneticFieldMap/src/FieldMapFileProvider.h
+
3
−
0
View file @
7f8efc35
...
...
@@ -39,6 +39,9 @@ private:
int
nr
;
// include the two endpoints, so nr = nrBin + 1
int
nz
;
double
rBinMin
;
double
zBinMin
;
double
rBinMax
;
double
zBinMax
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment