Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
centrality
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
Oleksii Lubynets
centrality
Commits
29f58cc6
Commit
29f58cc6
authored
6 years ago
by
Viktor Klochkov
Browse files
Options
Downloads
Patches
Plain Diff
bug fix(thanks, Oleksii), add some comments
parent
2e7ac031
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/BordersFinder2D.cpp
+20
-10
20 additions, 10 deletions
src/BordersFinder2D.cpp
src/BordersFinder2D.h
+0
-3
0 additions, 3 deletions
src/BordersFinder2D.h
with
20 additions
and
13 deletions
src/BordersFinder2D.cpp
+
20
−
10
View file @
29f58cc6
...
...
@@ -27,7 +27,7 @@ void BordersFinder2D::Init()
}
for
(
int
iBin
=
histo2d_
.
GetNbinsY
();
iBin
>=
1
;
--
iBin
)
{
if
(
histo2d_
.
Integral
(
0
,
histo2d_
.
GetNbins
Y
(),
iBin
,
iBin
)
>=
1.
)
if
(
histo2d_
.
Integral
(
0
,
histo2d_
.
GetNbins
X
(),
iBin
,
iBin
)
>=
1.
)
{
ymax_
=
histo2d_
.
GetYaxis
()
->
GetBinCenter
(
iBin
);
break
;
...
...
@@ -37,7 +37,11 @@ void BordersFinder2D::Init()
histo2d_
.
GetYaxis
()
->
SetLimits
(
0
,
histo2d_
.
GetYaxis
()
->
GetXmax
()
/
ymax_
);
}
/**
* Converts 2D histo to 1D. Transformation is done moving along
* fit to 2D distribution and counting number of entries perpendicular to it.
* @return pointer to 1D histo
*/
std
::
unique_ptr
<
TH1F
>
BordersFinder2D
::
Convert
()
{
Init
();
...
...
@@ -56,10 +60,10 @@ std::unique_ptr<TH1F> BordersFinder2D::Convert()
const
float
x1
=
iBin
==
1
?
-
0.2
:
histo2d_
.
GetXaxis
()
->
GetBinCenter
(
iBin
-
1
);
const
float
x2
=
iBin
==
histo2d_
.
GetNbinsX
()
?
1.2
:
histo2d_
.
GetXaxis
()
->
GetBinCenter
(
iBin
);
const
auto
kb
1
=
FindNorm
(
par
,
x1
);
const
auto
kb
2
=
FindNorm
(
par
,
x2
);
const
auto
norm
1
=
FindNorm
(
par
,
x1
);
const
auto
norm
2
=
FindNorm
(
par
,
x2
);
const
float
integral
=
FindIntegral
(
kb1
,
kb
2
);
const
float
integral
=
FindIntegral
(
norm1
,
norm
2
);
// std::cout << integral << std::endl;
histo1d
->
SetBinContent
(
iBin
,
integral
);
...
...
@@ -67,6 +71,12 @@ std::unique_ptr<TH1F> BordersFinder2D::Convert()
return
std
::
move
(
histo1d
);
}
/**
* Find number of entries between lines norm1 and norm2
* @param norm1 first line parametrization y=a+bx
* @param norm2 seconsd line parametrization
* @return number of entries (integral)
*/
float
BordersFinder2D
::
FindIntegral
(
const
std
::
array
<
float
,
2
>
&
norm1
,
const
std
::
array
<
float
,
2
>
&
norm2
)
{
float
sum
{
0.
};
...
...
@@ -144,7 +154,7 @@ void BordersFinder2D::Fit2D(const TString func)
*/
std
::
array
<
float
,
2
>
BordersFinder2D
::
FindNorm
(
const
std
::
vector
<
double
>
par
,
float
x
)
{
std
::
array
<
float
,
2
>
kb
;
std
::
array
<
float
,
2
>
ret
;
const
float
dx
=
(
histo2d_
.
GetXaxis
()
->
GetXmax
()
-
histo2d_
.
GetXaxis
()
->
GetXmin
())
/
10000.
;
/* left */
...
...
@@ -161,10 +171,10 @@ std::array <float,2> BordersFinder2D::FindNorm (const std::vector <double> par,
const
float
c
=
-
cx
*
x
-
cy
*
polN
(
par
,
x
);
kb
[
1
]
=
-
c
x
/
cy
;
kb
[
0
]
=
-
c
/
cy
;
return
kb
;
}
ret
[
0
]
=
-
c
/
cy
;
ret
[
1
]
=
-
c
x
/
cy
;
return
ret
;
}
}
This diff is collapsed.
Click to expand it.
src/BordersFinder2D.h
+
0
−
3
View file @
29f58cc6
...
...
@@ -25,17 +25,14 @@ public:
BordersFinder2D
(){}
void
SetHisto2D
(
TH2F
&&
histo2d
)
{
histo2d_
=
histo2d
;
}
TH2F
&&
GetHisto2D
()
{
return
std
::
move
(
histo2d_
);
}
void
Init
();
std
::
unique_ptr
<
TH1F
>
Convert
();
void
Fit2D
(
const
TString
func
);
std
::
array
<
float
,
2
>
FindNorm
(
const
std
::
vector
<
double
>
par
,
float
x
);
float
FindIntegral
(
const
std
::
array
<
float
,
2
>
&
norm1
,
const
std
::
array
<
float
,
2
>
&
norm2
);
void
SaveBorders2D
(
const
std
::
string
&
filename
,
const
std
::
string
&
getter_name
);
/**
...
...
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