Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NeuRad_tests
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vratislav Chudoba
NeuRad_tests
Commits
3fb4f668
Commit
3fb4f668
authored
Jan 09, 2017
by
Muzalevsky I.A
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
script for CFD method added
parent
90bdde37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
142 additions
and
0 deletions
+142
-0
IntegralCFD.c
convertTektronix/IntegralCFD.c
+142
-0
No files found.
convertTektronix/IntegralCFD.c
0 → 100644
View file @
3fb4f668
void
IntegralCFD
(){
const
Int_t
Tdelta
=
12
;
const
Double_t
coeff
=
0
.
5
;
Int_t
j
,
i
,
nentry
,
NumM
,
imax
,
imin
;
Double_t
A
[
1000
];
/// амплитуды с сырых данных (отрицательные)
Double_t
T
[
1000
];
Double_t
Am
[
1000
];
// амплитуды с перевёрнутых пиков
Double_t
Tim
[
1000
];
Double_t
Acfd
[
1000
];
Double_t
sum
,
zeroLEVEL1
,
zeroLEVEL2
,
tm
,
t1_15
,
m
,
m1_15
,
t2_15
,
m2_15
,
tL_15
,
mL_15
,
Integrall
,
LinPar
,
ChiSquare
,
t1_90
,
t2_90
,
minCFD
,
maxCFD
,
zCFD
,
Tcfd
,
deltaZero
;
TString
var
;
//TF1 *func = new TF1("fit",p,0,20e-09,1); // функция фитирования
TF1
*
fit1
=
new
TF1
(
"fit1"
,
"[0]"
);
fit1
->
SetParName
(
0
,
"Rlevel"
);
fit1
->
SetRange
(
0
,
2e-08
);
TF1
*
fit2
=
new
TF1
(
"fit2"
,
"[0]"
);
////////// создание функций фитирования
fit2
->
SetRange
(
8e-08
,
1e-07
);
fit2
->
SetParName
(
0
,
"Llevel"
);
TF1
*
fit3
=
new
TF1
(
"fit3"
,
"[0]*x+[1]"
);
fit3
->
SetParName
(
0
,
"LinPar"
);
TFile
*
f
=
new
TFile
(
"exp2.root"
,
"READ"
);
TTree
*
tree1
=
(
TTree
*
)
f
->
Get
(
"tree"
);
//////
TBranch
*
branch1
=
tree1
->
GetBranch
(
"A"
);
branch1
->
SetAddress
(
A
);
TBranch
*
branch2
=
tree1
->
GetBranch
(
"T"
);
branch2
->
SetAddress
(
T
);
//////
TFile
*
f1
=
new
TFile
(
"exp2Integral.root"
,
"RECREATE"
);
// файл для записи
TTree
*
theTree
=
new
TTree
(
"theTree"
,
"peak"
);
theTree
->
Branch
(
"Am"
,
Am
,
"Am[1000]/D"
);
theTree
->
Branch
(
"Tim"
,
Tim
,
"Tim[1000]/D"
);
theTree
->
Branch
(
"sum"
,
&
sum
,
"sum/D"
);
theTree
->
Branch
(
"zeroLEVEL1"
,
&
zeroLEVEL1
,
"zeroLEVEL1/D"
);
theTree
->
Branch
(
"zCFD"
,
&
zCFD
,
"zCFD/D"
);
theTree
->
Branch
(
"tm"
,
&
tm
,
"tm/D"
);
//// tm - положение пика(максимума амплитуды) записывается время(T[i]) при котором этот максимум был
theTree
->
Branch
(
"t1_15"
,
&
t1_15
,
"t1 _15/D"
);
/// время когда амплитуда достигла 20 процентов от максимума( смотрим слева направо)
theTree
->
Branch
(
"t2_15"
,
&
t2_15
,
"t2_15/D"
);
theTree
->
Branch
(
"m"
,
&
m
,
"m/D"
);
// максимальная амплитуда
theTree
->
Branch
(
"m1_15"
,
&
m1_15
,
"m1_15/D"
);
// амплитуда в первой точке превышения 20%
theTree
->
Branch
(
"m2_15"
,
&
m2_15
,
"m2_15/D"
);
// амплитуда во второй точке превышения 20%
theTree
->
Branch
(
"tL_15"
,
&
tL_15
,
"tL_15/D"
);
// время последнего превышения 20%
theTree
->
Branch
(
"mL_15"
,
&
mL_15
,
"mL_15/D"
);
//амплитуда в последнем превышении 20%
theTree
->
Branch
(
"Integrall"
,
&
Integrall
,
"Integrall/D"
);
//интеграл в диапозоне 20 нс
theTree
->
Branch
(
"LinPar"
,
&
LinPar
,
"LinPar/D"
);
//параметр фита прямой границы сигнала
theTree
->
Branch
(
"ChiSquare"
,
&
ChiSquare
,
"ChiSquare/D"
);
//хи квадрат
theTree
->
Branch
(
"t2_90"
,
&
t2_90
,
"t2_90/D"
);
// 90% от максимума после максимума
theTree
->
Branch
(
"Acfd"
,
Acfd
,
"Acfd[1000]/D"
);
// am cdf
theTree
->
Branch
(
"Tcfd"
,
&
Tcfd
,
"Tcfd/D"
);
// момент пересечения нуля в CFD
///////// заполнение дерева
TCanvas
*
c1
=
new
TCanvas
(
"c"
,
"zero line"
);
j
=
0
;
for
(
j
=
0
;
j
<
tree1
->
GetEntries
();
j
++
)
// j - номер события , i - внутри!
{
tree1
->
GetEntry
(
j
);
sum
=
0
;
// обнуление интеграла
m
=
0
;
// и максимума
for
(
i
=
0
;
i
<
1000
;
i
++
)
{
Acfd
[
i
]
=
0
;}
for
(
i
=
0
;
i
<
1000
;
i
++
)
// нахожу интеграл, полный, точку максимума для фрейма номер j
{
Am
[
i
]
=
-
A
[
i
];
Tim
[
i
]
=
T
[
i
];
if
(
i
>
Tdelta
){
Acfd
[
i
]
=
A
[
i
]
*
coeff
;
Acfd
[
i
]
=
Acfd
[
i
]
+
Am
[
i
-
Tdelta
];
}
if
((
Am
[
i
]
>
m
)
||
(
Am
[
i
]
==
m
)){
m
=
Am
[
i
];
tm
=
T
[
i
];}
sum
=
sum
+
Am
[
i
];
}
maxCFD
=
0
;
minCFD
=
0
;
for
(
i
=
0
;
i
<
1000
;
i
++
){
// поиск максимума и минимума у преобразованного сигнала, для поиска пересечения с нулём
if
(
Acfd
[
i
]
>
maxCFD
)
{
maxCFD
=
Acfd
[
i
];
imax
=
i
;
t1
=
Tim
[
i
];}
if
(
Acfd
[
i
]
<
minCFD
)
{
minCFD
=
Acfd
[
i
];
imin
=
i
;
t2
=
Tim
[
i
];}
}
/*TGraph *gr3 = new TGraph(1000,Tim,Acfd);
gr3->Draw("Al*");
c1->Update();
cout<<endl<<imin<<" "<<imax<<endl; */
NumM
=
(
tm
-
5e-013
)
*
(
1e+10
);
// номер точки (0,1000) с максимальной амплитудой сигнала
Integrall
=
0
;
for
(
i
=
0
;
i
<
1000
;
i
++
)
// нахожу интеграл, c границами
{
if
(
(
Tim
[
i
]
>
(
tm
-
3e-9
))
&&
(
Tim
[
i
]
<
(
tm
+
17e-9
))
)
{
Integrall
=
Integrall
+
Am
[
i
];}
}
//cout<<endl<<"integral= "<<Integrall<<endl;
//////////////////
TGraph
*
gr1
=
new
TGraph
(
1000
,
Tim
,
Am
);
// поиск нуля
gr1
->
Draw
(
"Al*"
);
gr1
->
Fit
(
"fit1"
,
"R"
,
"goff"
);
zeroLEVEL1
=
fit1
->
GetParameter
(
0
);
c1
->
Update
();
m1_15
=
0
;
t1_15
=
0
;
//поиск начальной границы поднятия на 10%
t2_15
=
0
;
m2_15
=
0
;
mL_15
=
0
;
for
(
i
=
NumM
;
i
>
0
;
i
--
)
{
if
((
Am
[
i
]
-
zeroLEVEL1
)
<
0
.
1
*
(
m
-
zeroLEVEL1
))
{
t1_15
=
Tim
[
i
+
1
];
m1_15
=
A
[
i
+
1
];
break
;}
}
for
(
i
=
NumM
;
i
>
0
;
i
--
)
{
if
((
Am
[
i
]
-
zeroLEVEL1
)
<
0
.
9
*
(
m
-
zeroLEVEL1
))
{
t1_90
=
Tim
[
i
+
1
];
break
;}
}
for
(
i
=
NumM
;
i
<
1000
;
i
++
)
{
if
((
Am
[
i
]
-
zeroLEVEL1
)
<
0
.
9
*
(
m
-
zeroLEVEL1
))
{
t2_90
=
Tim
[
i
-
1
];
break
;}
}
for
(
i
=
NumM
;
i
<
1000
;
i
++
)
{
if
((
Am
[
i
]
-
zeroLEVEL1
)
<
0
.
15
*
(
m
-
zeroLEVEL1
))
{
t2_15
=
Tim
[
i
-
1
];
m2_15
=
A
[
i
-
1
];
break
;}
}
for
(
i
=
NumM
;
i
<
1000
;
i
++
)
{
if
((
Am
[
i
]
-
zeroLEVEL1
)
>
0
.
15
*
(
m
-
zeroLEVEL1
))
{
tL_15
=
Tim
[
i
-
1
];
mL_15
=
A
[
i
-
1
];}
}
deltaZero
=
100
;
for
(
i
=
imin
;
i
<
imax
;
i
++
){
// поиск нуля в сигнале CFD
if
(
abs
(
A
[
i
])
<
deltaZero
)
{
deltaZero
=
abs
(
A
[
i
]);
Tcfd
=
T
[
i
];}
}
fit3
->
SetRange
(
t1_15
,
t1_90
);
gr1
->
Fit
(
"fit3"
,
"R"
,
"goff"
);
c1
->
Update
();
ChiSquare
=
fit3
->
GetChisquare
();
LinPar
=
fit3
->
GetParameter
(
0
);
theTree
->
Fill
();
}
//////////
theTree
->
Write
();
f1
->
Close
();
f
->
Close
();
}
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