Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Riccardo Longo
JZCaPA
Commits
71afb17a
Commit
71afb17a
authored
Nov 14, 2021
by
shengy3
Browse files
Optimize GetDifferential function using two sliding windows
parent
1e17fc77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Analysis/src/WFAnalysis.cpp
View file @
71afb17a
...
...
@@ -276,26 +276,41 @@ void WFAnalysis::MedianFilter( Channel* Ch ){
*/
void
WFAnalysis
::
GetDifferential
(
Channel
*
Ch
){
//Pad the front of the vector with 0s
for
(
int
bin
=
0
;
bin
<
Ch
->
diffSmoothing
;
bin
++
)
Ch
->
vDiff
.
push_back
(
0.0
);
// Loop over histogram
for
(
unsigned
int
bin
=
Ch
->
diffSmoothing
;
bin
<
Ch
->
WF_histo
->
GetNbinsX
()
-
Ch
->
diffSmoothing
;
bin
++
){
//decalare temp variable to store the sum before and after the i data point
double
sum_before
=
0
;
double
sum_after
=
0
;
//calculate the sum before and after the i data point
for
(
int
i
=
0
;
i
<
Ch
->
diffSmoothing
;
i
++
){
sum_before
+=
Ch
->
WF
.
at
(
bin
-
i
);
sum_after
+=
Ch
->
WF
.
at
(
bin
+
i
);
}
//decalare temp variable to store the sum before and after the i data point
double
sum_before
=
0
;
double
sum_after
=
0
;
// Generate 2 sliding window, sum_before and sum_after
// Calculate the sum before and after the start data point
for
(
int
i
=
1
;
i
<=
Ch
->
diffSmoothing
;
i
++
){
sum_before
+=
Ch
->
WF
.
at
(
Ch
->
diffSmoothing
-
i
);
sum_after
+=
Ch
->
WF
.
at
(
Ch
->
diffSmoothing
+
i
);
}
// Loop over histogram
for
(
unsigned
int
bin
=
Ch
->
diffSmoothing
;
bin
<
Ch
->
WF_histo
->
GetNbinsX
()
-
Ch
->
diffSmoothing
-
1
;
bin
++
){
//set the bin to the calculated derivative value
Ch
->
vDiff
.
push_back
(
sum_after
-
sum_before
);
Ch
->
FirstDerivative
->
SetBinContent
(
bin
,(
sum_after
-
sum_before
));
// Move the sum_before window forward
sum_before
+=
Ch
->
WF
.
at
(
bin
);
sum_before
-=
Ch
->
WF
.
at
(
bin
-
Ch
->
diffSmoothing
);
// Move the sum_after window forward
sum_after
-=
Ch
->
WF
.
at
(
bin
+
1
);
sum_after
+=
Ch
->
WF
.
at
(
bin
+
Ch
->
diffSmoothing
+
1
);
}
//end derivative loop
//Pad the back of the vector with 0s
for
(
int
bin
=
0
;
bin
<
Ch
->
diffSmoothing
;
bin
++
)
Ch
->
vDiff
.
push_back
(
0.0
);
for
(
int
bin
=
0
;
bin
<
=
Ch
->
diffSmoothing
;
bin
++
)
Ch
->
vDiff
.
push_back
(
0.0
);
}
/** @brief GetRMS method for WFAnalysis
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment