Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nptool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
np
nptool
Commits
a66e530e
Commit
a66e530e
authored
4 years ago
by
Cyril Lenain
Browse files
Options
Downloads
Patches
Plain Diff
improving conv_fit in TMinosPhysics.cxx
parent
96b115b5
No related branches found
No related tags found
No related merge requests found
Pipeline
#88494
passed
4 years ago
Stage: build-NPLib
Stage: build-NPSimulation
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
NPLib/Detectors/Minos/TMinosPhysics.cxx
+296
-310
296 additions, 310 deletions
NPLib/Detectors/Minos/TMinosPhysics.cxx
NPLib/Detectors/Minos/TMinosPhysics.h
+1
-13
1 addition, 13 deletions
NPLib/Detectors/Minos/TMinosPhysics.h
with
297 additions
and
323 deletions
NPLib/Detectors/Minos/TMinosPhysics.cxx
+
296
−
310
View file @
a66e530e
...
@@ -101,11 +101,12 @@ void TMinosPhysics::BuildPhysicalEvent() {
...
@@ -101,11 +101,12 @@ void TMinosPhysics::BuildPhysicalEvent() {
// definition of the fit function for the signal Q(t)
// definition of the fit function for the signal Q(t)
double
TMinosPhysics
::
conv_fit
(
double
*
x
,
double
*
p
){
double
TMinosPhysics
::
conv_fit
(
double
*
x
,
double
*
p
){
double
val
;
static
double
p0
,
p1
,
p2
,
x0
;
if
(
!
(
x
[
0
]
<
p
[
1
]
||
x
[
0
]
>
512.
))
val
=
p
[
0
]
*
exp
(
-
3.
*
(
x
[
0
]
-
p
[
1
])
/
p
[
2
])
*
sin
((
x
[
0
]
-
p
[
1
])
/
p
[
2
])
*
pow
((
x
[
0
]
-
p
[
1
])
/
p
[
2
],
3
)
+
250
;
p0
=
p
[
0
];
p1
=
p
[
1
];
p2
=
p
[
2
];
//else val = p[3];
x0
=
x
[
0
];
else
val
=
250
;
if
(
x0
>
p1
&&
x0
<
512.
)
return
(
val
);
return
(
p0
*
exp
(
-
3.
*
(
x0
-
p1
)
/
p2
)
*
sin
((
x0
-
p1
)
/
p2
)
*
pow
((
x0
-
p1
)
/
p2
,
3
)
+
250
);
else
return
(
250
);
}
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
...
@@ -353,14 +354,16 @@ void TMinosPhysics::PreTreat() {
...
@@ -353,14 +354,16 @@ void TMinosPhysics::PreTreat() {
cluster_temp
=
0
;
cluster_temp
=
0
;
int
ringtouch
[
19
]
=
{
0
};
int
ringtouch
[
19
]
=
{
0
};
static
vector
<
double
>
xin
,
yin
,
zin
,
qin
;
static
vector
<
double
>
xout
,
yout
,
zout
,
qout
;
static
vector
<
double
>
xoutprime
,
youtprime
,
zoutprime
,
qoutprime
;
/* for(int ko=1; ko<19; ko++) ringtouch[ko] = 0; ///// Added by Cyril */
for
(
unsigned
int
i
=
0
;
i
<
(
XpadNew
.
size
());
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
(
XpadNew
.
size
());
i
++
){
if
(
xin
.
size
()
>
0
&&
((
cluster_temp
!=
int
(
clusternbr
[
i
])
&&
i
!=
0
)
||
i
==
(
XpadNew
.
size
()
-
1
))){
// We fill xin until the next cluster
if
(
xin
.
size
()
>
0
&&
((
cluster_temp
!=
int
(
clusternbr
[
i
])
&&
i
!=
0
)
||
i
==
(
XpadNew
.
size
()
-
1
))){
// We fill xin until the next cluster
Tracking_functions
->
Hough_3D
(
&
xin
,
&
yin
,
&
zin
,
&
qin
,
&
xout
,
&
yout
,
&
zout
,
&
qout
);
Tracking_functions
->
Hough_3D
(
&
xin
,
&
yin
,
&
zin
,
&
qin
,
&
xout
,
&
yout
,
&
zout
,
&
qout
);
for
(
unsigned
int
ij
=
0
;
ij
<
xout
.
size
();
ij
++
){
for
(
unsigned
int
ij
=
0
;
ij
<
xout
.
size
();
ij
++
){
if
(
zout
[
ij
]
>
zmax
)
{
zmax
=
zout
[
ij
];}
if
(
zout
[
ij
]
>
zmax
)
{
zmax
=
zout
[
ij
];}
ringtouch
[
int
(
round
((
sqrt
(
xout
[
ij
]
*
xout
[
ij
]
+
yout
[
ij
]
*
yout
[
ij
])
-
44.15
)
/
2.1
))]
++
;
// Corr by Cyril
ringtouch
[
int
(
round
((
sqrt
(
xout
[
ij
]
*
xout
[
ij
]
+
yout
[
ij
]
*
yout
[
ij
])
-
44.15
)
/
2.1
))]
++
;
// Corr by Cyril
}
}
for
(
int
ko
=
0
;
ko
<
19
;
ko
++
){
for
(
int
ko
=
0
;
ko
<
19
;
ko
++
){
if
(
ringtouch
[
ko
]
>
0
)
ringsum
++
;
if
(
ringtouch
[
ko
]
>
0
)
ringsum
++
;
...
@@ -411,28 +414,19 @@ void TMinosPhysics::PreTreat() {
...
@@ -411,28 +414,19 @@ void TMinosPhysics::PreTreat() {
chargeTot
.
push_back
(
charge_temp
);
chargeTot
.
push_back
(
charge_temp
);
lenght
.
push_back
(
lenght_temp
);
lenght
.
push_back
(
lenght_temp
);
}
// end of if(xout.size()>10 &&)
}
// end of if(xout.size()>10 &&)
//X_mm->Fill();
xin
.
clear
();
xin
.
clear
();
yin
.
clear
();
zin
.
clear
();
qin
.
clear
();
yin
.
clear
();
xout
.
clear
();
yout
.
clear
();
zout
.
clear
();
qout
.
clear
();
zin
.
clear
();
xoutprime
.
clear
();
youtprime
.
clear
();
zoutprime
.
clear
();
qin
.
clear
();
xout
.
clear
();
npoint_temp
=
0
;
ringsum
=
0
;
zmax
=
0.
;
yout
.
clear
();
for
(
int
ko
=
0
;
ko
<
18
;
ko
++
)
zout
.
clear
();
ringtouch
[
ko
]
=
0
;
xoutprime
.
clear
();
youtprime
.
clear
();
zoutprime
.
clear
();
qout
.
clear
();
npoint_temp
=
0
;
ringsum
=
0
;
// angle between 1st track and z axis in 3D in degrees
zmax
=
0.
;
for
(
int
ko
=
0
;
ko
<
18
;
ko
++
)
ringtouch
[
ko
]
=
0
;
}
// if(xin.size()>0 && (( cluster_temp .... )
}
// if(xin.size()>0 && (( cluster_temp .... )
cluster_temp
=
clusternbr
[
i
];
// Number of the track/cluster
cluster_temp
=
clusternbr
[
i
];
// Number of the track/cluster
/* if(!(clusterpads[i]>=10 && clusterringbool[i]==1 && ZpadNew[i]>-100 && ZpadNew[i]<=310)) continue; // Warning <=310 necessary ? (Cyril) */
if
(
!
(
clusterpads
[
i
]
>=
10
&&
clusterringbool
[
i
]
==
1
&&
ZpadNew
[
i
]
>-
100
&&
ZpadNew
[
i
]
<=
310
))
continue
;
if
(
!
(
clusterpads
[
i
]
>=
10
&&
clusterringbool
[
i
]
==
1
&&
ZpadNew
[
i
]
>-
100
&&
ZpadNew
[
i
]
<=
310
))
continue
;
// Warning <=310 necessary ? (Cyril)
else
else
{
{
xin
.
push_back
(
XpadNew
[
i
]);
xin
.
push_back
(
XpadNew
[
i
]);
...
@@ -442,7 +436,7 @@ void TMinosPhysics::PreTreat() {
...
@@ -442,7 +436,7 @@ void TMinosPhysics::PreTreat() {
npoint_temp
++
;
npoint_temp
++
;
}
}
}
//end of PadNews
}
//end of PadNews
/* //------------------------------------------------------- */
/* //------------------------------------------------------- */
/* // STEP 3.2: Fitting the filtered tracks in 3D */
/* // STEP 3.2: Fitting the filtered tracks in 3D */
...
@@ -450,339 +444,331 @@ void TMinosPhysics::PreTreat() {
...
@@ -450,339 +444,331 @@ void TMinosPhysics::PreTreat() {
/* //------------------------------------------------------- */
/* //------------------------------------------------------- */
if
(
trackNbr_FINAL
==
2
||
trackNbr_FINAL
==
1
){
if
(
trackNbr_FINAL
==
2
||
trackNbr_FINAL
==
1
){
//////////Minimization in 2D to reconstruct track lines
//////////Minimization in 2D to reconstruct track lines
allevt_2pfiltered
++
;
allevt_2pfiltered
++
;
for
(
int
itr
=
0
;
itr
<
trackNbr_FINAL
;
itr
++
)
{
for
(
int
itr
=
0
;
itr
<
trackNbr_FINAL
;
itr
++
)
{
pStart
[
0
]
=
0
;
pStart
[
2
]
=
0
;
pStart
[
1
]
=
1
;
pStart
[
3
]
=
3
;
pStart
[
0
]
=
0
;
pStart
[
2
]
=
0
;
pStart
[
1
]
=
1
;
pStart
[
3
]
=
3
;
min
=
new
TMinuit
(
4
);
min
=
new
TMinuit
(
4
);
min
->
SetPrintLevel
(
-
1
);
min
->
SetPrintLevel
(
-
1
);
arglist
[
0
]
=
3
;
arglist
[
0
]
=
3
;
Tracking_functions
->
FindStart
(
pStart
,
chi
,
fitStatus
,
&
grxz
.
at
(
itr
),
&
gryz
.
at
(
itr
));
Tracking_functions
->
FindStart
(
pStart
,
chi
,
fitStatus
,
&
grxz
.
at
(
itr
),
&
gryz
.
at
(
itr
));
NclusterFit
=
itr
+
1
;
NclusterFit
=
itr
+
1
;
current_phy
=
this
;
current_phy
=
this
;
min
->
SetFCN
(
SumDistance
);
min
->
SetFCN
(
SumDistance
);
// Set starting values and step sizes for parameters
// Set starting values and step sizes for parameters
min
->
mnparm
(
0
,
"x0"
,
pStart
[
0
],
0.1
,
-
500
,
500
,
iflag
);
min
->
mnparm
(
0
,
"x0"
,
pStart
[
0
],
0.1
,
-
500
,
500
,
iflag
);
min
->
mnparm
(
1
,
"Ax"
,
pStart
[
1
],
0.1
,
-
10
,
10
,
iflag
);
min
->
mnparm
(
1
,
"Ax"
,
pStart
[
1
],
0.1
,
-
10
,
10
,
iflag
);
min
->
mnparm
(
2
,
"y0"
,
pStart
[
2
],
0.1
,
-
500
,
500
,
iflag
);
min
->
mnparm
(
2
,
"y0"
,
pStart
[
2
],
0.1
,
-
500
,
500
,
iflag
);
min
->
mnparm
(
3
,
"Ay"
,
pStart
[
3
],
0.1
,
-
10
,
10
,
iflag
);
min
->
mnparm
(
3
,
"Ay"
,
pStart
[
3
],
0.1
,
-
10
,
10
,
iflag
);
arglist
[
0
]
=
200
;
// number of function calls
arglist
[
0
]
=
200
;
// number of function calls
arglist
[
1
]
=
0.000001
;
// tolerance
arglist
[
1
]
=
0.000001
;
// tolerance
min
->
mnexcm
(
"MIGRAD"
,
arglist
,
2
,
iflag
);
// minimization with MIGRAD
min
->
mnexcm
(
"MIGRAD"
,
arglist
,
2
,
iflag
);
// minimization with MIGRAD
min
->
mnstat
(
amin
,
edm
,
errdef
,
nvpar
,
nparx
,
iflag
);
//returns current status of the minimization
min
->
mnstat
(
amin
,
edm
,
errdef
,
nvpar
,
nparx
,
iflag
);
//returns current status of the minimization
// get fit parameters
// get fit parameters
for
(
int
i
=
0
;
i
<
4
;
i
++
)
min
->
GetParameter
(
i
,
parFit_temp
[
i
],
err_temp
[
i
]);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
min
->
GetParameter
(
i
,
parFit_temp
[
i
],
err_temp
[
i
]);
/* if( (parFit_temp[0] >-499 && parFit_temp[0]<499) && (parFit_temp[2] >-499 && parFit_temp[2]<499)) { */
/* if( (parFit_temp[0] >-499 && parFit_temp[0]<499) && (parFit_temp[2] >-499 && parFit_temp[2]<499)) { */
/* parFit1[itr] = push_back(parFit_temp[0]); */
/* parFit1[itr] = push_back(parFit_temp[0]); */
/* parFit2.push_back(parFit_temp[1]); */
/* parFit2.push_back(parFit_temp[1]); */
/* parFit3.push_back(parFit_temp[2]); */
/* parFit3.push_back(parFit_temp[2]); */
/* parFit4.push_back(parFit_temp[3]); */
/* parFit4.push_back(parFit_temp[3]); */
/* } */
/* } */
parFit1
[
itr
]
=
parFit_temp
[
0
];
parFit1
[
itr
]
=
parFit_temp
[
0
];
parFit2
[
itr
]
=
parFit_temp
[
1
];
parFit2
[
itr
]
=
parFit_temp
[
1
];
parFit3
[
itr
]
=
parFit_temp
[
2
];
parFit3
[
itr
]
=
parFit_temp
[
2
];
parFit4
[
itr
]
=
parFit_temp
[
3
];
parFit4
[
itr
]
=
parFit_temp
[
3
];
delete
min
;
delete
min
;
}
}
static
double
ParTrack1
[
4
],
ParTrack2
[
4
];
static
double
ParTrack1
[
4
],
ParTrack2
[
4
];
static
double
VectorTrack11
[
3
],
VectorTrack22
[
3
];
static
double
VectorTrack11
[
3
],
VectorTrack22
[
3
];
ParTrack1
[
0
]
=
parFit1
[
0
];
ParTrack1
[
0
]
=
parFit1
[
0
];
ParTrack1
[
1
]
=
parFit2
[
0
];
ParTrack1
[
1
]
=
parFit2
[
0
];
ParTrack1
[
2
]
=
parFit3
[
0
];
ParTrack1
[
2
]
=
parFit3
[
0
];
ParTrack1
[
3
]
=
parFit4
[
0
];
ParTrack1
[
3
]
=
parFit4
[
0
];
if
(
trackNbr_FINAL
==
2
){
if
(
trackNbr_FINAL
==
2
){
ParTrack2
[
0
]
=
parFit1
[
1
];
ParTrack2
[
0
]
=
parFit1
[
1
];
ParTrack2
[
1
]
=
parFit2
[
1
];
ParTrack2
[
1
]
=
parFit2
[
1
];
ParTrack2
[
2
]
=
parFit3
[
1
];
ParTrack2
[
2
]
=
parFit3
[
1
];
ParTrack2
[
3
]
=
parFit4
[
1
];
ParTrack2
[
3
]
=
parFit4
[
1
];
}
}
else
if
(
trackNbr_FINAL
==
1
){
// The vertex is still calculated with Zaxis
else
if
(
trackNbr_FINAL
==
1
){
// The vertex is still calculated with Zaxis
ParTrack2
[
0
]
=
0
;
ParTrack2
[
0
]
=
0
;
ParTrack2
[
1
]
=
0
;
ParTrack2
[
1
]
=
0
;
ParTrack2
[
2
]
=
0
;
ParTrack2
[
2
]
=
0
;
ParTrack2
[
3
]
=
0
;
ParTrack2
[
3
]
=
0
;
}
}
Dmin
=-
100
,
Theta_1
=
-
1
,
Theta_2
=
-
1
;
Dmin
=-
100
,
Theta_1
=
-
1
,
Theta_2
=
-
1
;
Tracking_functions
->
vertex
(
ParTrack1
,
ParTrack2
,
Xvertex
,
Yvertex
,
Zvertex
,
Dmin
,
Theta_1
,
Theta_2
,
Phi1
,
Phi2
,
VectorTrack11
,
VectorTrack22
);
Tracking_functions
->
vertex
(
ParTrack1
,
ParTrack2
,
Xvertex
,
Yvertex
,
Zvertex
,
Dmin
,
Theta_1
,
Theta_2
,
Phi1
,
Phi2
,
VectorTrack11
,
VectorTrack22
);
VectorTrack1
.
SetXYZ
(
VectorTrack11
[
0
],
VectorTrack11
[
1
],
VectorTrack11
[
2
]);
VectorTrack1
.
SetXYZ
(
VectorTrack11
[
0
],
VectorTrack11
[
1
],
VectorTrack11
[
2
]);
VectorTrack2
.
SetXYZ
(
VectorTrack22
[
0
],
VectorTrack22
[
1
],
VectorTrack22
[
2
]);
VectorTrack2
.
SetXYZ
(
VectorTrack22
[
0
],
VectorTrack22
[
1
],
VectorTrack22
[
2
]);
VectorTrack1
=
VectorTrack1
.
Unit
();
VectorTrack1
=
VectorTrack1
.
Unit
();
VectorTrack2
=
VectorTrack2
.
Unit
();
VectorTrack2
=
VectorTrack2
.
Unit
();
Theta_12
=
VectorTrack1
.
Angle
(
VectorTrack2
)
*
180
/
TMath
::
Pi
();
Theta_12
=
VectorTrack1
.
Angle
(
VectorTrack2
)
*
180
/
TMath
::
Pi
();
}
// end if trackNbr_FINAL>=1
}
// end if trackNbr_FINAL>=1
}
// end loop if 0<trackNbr < 5
}
// end loop if 0<trackNbr < 5
// instantiate CalibrationManager
// instantiate CalibrationManager
static
CalibrationManager
*
Cal
=
CalibrationManager
::
getInstance
();
static
CalibrationManager
*
Cal
=
CalibrationManager
::
getInstance
();
}
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void
TMinosPhysics
::
ReadAnalysisConfig
()
{
void
TMinosPhysics
::
ReadAnalysisConfig
()
{
bool
ReadingStatus
=
false
;
bool
ReadingStatus
=
false
;
// path to file
// path to file
string
FileName
=
"./configs/ConfigMinos.dat"
;
string
FileName
=
"./configs/ConfigMinos.dat"
;
// open analysis config file
// open analysis config file
ifstream
AnalysisConfigFile
;
ifstream
AnalysisConfigFile
;
AnalysisConfigFile
.
open
(
FileName
.
c_str
());
AnalysisConfigFile
.
open
(
FileName
.
c_str
());
if
(
!
AnalysisConfigFile
.
is_open
())
{
if
(
!
AnalysisConfigFile
.
is_open
())
{
cout
<<
" No ConfigMinos.dat found: Default parameter loaded for Analayis "
<<
FileName
<<
endl
;
cout
<<
" No ConfigMinos.dat found: Default parameter loaded for Analayis "
<<
FileName
<<
endl
;
return
;
return
;
}
}
cout
<<
" Loading user parameter for Analysis from ConfigMinos.dat "
<<
endl
;
cout
<<
" Loading user parameter for Analysis from ConfigMinos.dat "
<<
endl
;
// Save it in a TAsciiFile
// Save it in a TAsciiFile
TAsciiFile
*
asciiConfig
=
RootOutput
::
getInstance
()
->
GetAsciiFileAnalysisConfig
();
TAsciiFile
*
asciiConfig
=
RootOutput
::
getInstance
()
->
GetAsciiFileAnalysisConfig
();
asciiConfig
->
AppendLine
(
"%%% ConfigMinos.dat %%%"
);
asciiConfig
->
AppendLine
(
"%%% ConfigMinos.dat %%%"
);
asciiConfig
->
Append
(
FileName
.
c_str
());
asciiConfig
->
Append
(
FileName
.
c_str
());
asciiConfig
->
AppendLine
(
""
);
asciiConfig
->
AppendLine
(
""
);
// read analysis config file
// read analysis config file
string
LineBuffer
,
DataBuffer
,
whatToDo
;
string
LineBuffer
,
DataBuffer
,
whatToDo
;
while
(
!
AnalysisConfigFile
.
eof
())
{
while
(
!
AnalysisConfigFile
.
eof
())
{
// Pick-up next line
// Pick-up next line
getline
(
AnalysisConfigFile
,
LineBuffer
);
getline
(
AnalysisConfigFile
,
LineBuffer
);
// search for "header"
// search for "header"
string
name
=
"ConfigMinos"
;
string
name
=
"ConfigMinos"
;
if
(
LineBuffer
.
compare
(
0
,
name
.
length
(),
name
)
==
0
)
if
(
LineBuffer
.
compare
(
0
,
name
.
length
(),
name
)
==
0
)
ReadingStatus
=
true
;
ReadingStatus
=
true
;
// loop on tokens and data
// loop on tokens and data
while
(
ReadingStatus
)
{
while
(
ReadingStatus
)
{
whatToDo
=
""
;
whatToDo
=
""
;
AnalysisConfigFile
>>
whatToDo
;
AnalysisConfigFile
>>
whatToDo
;
// Search for comment symbol (%)
// Search for comment symbol (%)
if
(
whatToDo
.
compare
(
0
,
1
,
"%"
)
==
0
)
{
if
(
whatToDo
.
compare
(
0
,
1
,
"%"
)
==
0
)
{
AnalysisConfigFile
.
ignore
(
numeric_limits
<
streamsize
>::
max
(),
'\n'
);
AnalysisConfigFile
.
ignore
(
numeric_limits
<
streamsize
>::
max
(),
'\n'
);
}
}
else
if
(
whatToDo
==
"E_RAW_THRESHOLD"
)
{
else
if
(
whatToDo
==
"E_RAW_THRESHOLD"
)
{
AnalysisConfigFile
>>
DataBuffer
;
AnalysisConfigFile
>>
DataBuffer
;
m_E_RAW_Threshold
=
atof
(
DataBuffer
.
c_str
());
m_E_RAW_Threshold
=
atof
(
DataBuffer
.
c_str
());
cout
<<
whatToDo
<<
" "
<<
m_E_RAW_Threshold
<<
endl
;
cout
<<
whatToDo
<<
" "
<<
m_E_RAW_Threshold
<<
endl
;
}
}
else
if
(
whatToDo
==
"E_THRESHOLD"
)
{
else
if
(
whatToDo
==
"E_THRESHOLD"
)
{
AnalysisConfigFile
>>
DataBuffer
;
AnalysisConfigFile
>>
DataBuffer
;
m_E_Threshold
=
atof
(
DataBuffer
.
c_str
());
m_E_Threshold
=
atof
(
DataBuffer
.
c_str
());
cout
<<
whatToDo
<<
" "
<<
m_E_Threshold
<<
endl
;
cout
<<
whatToDo
<<
" "
<<
m_E_Threshold
<<
endl
;
}
}
else
{
else
{
ReadingStatus
=
false
;
ReadingStatus
=
false
;
}
}
}
}
}
}
}
double
TMinosPhysics
::
distance2
(
double
x
,
double
y
,
double
z
,
double
*
p
)
{
}
// distance line point is D= | (xp-x0) cross ux |
// where ux is direction of line and x0 is a point in the line (like t = 0)
ROOT
::
Math
::
XYZVector
xp
(
x
,
y
,
z
);
//point of the track
ROOT
::
Math
::
XYZVector
x0
(
p
[
0
],
p
[
2
],
0.
);
ROOT
::
Math
::
XYZVector
x1
(
p
[
0
]
+
p
[
1
],
p
[
2
]
+
p
[
3
],
1.
);
//line
ROOT
::
Math
::
XYZVector
u
=
(
x1
-
x0
).
Unit
();
double
d2
=
((
xp
-
x0
).
Cross
(
u
))
.
Mag2
();
return
d2
;
}
void
TMinosPhysics
::
SumDistance
(
int
&
,
double
*
,
double
&
sum
,
double
*
par
,
int
)
{
double
TMinosPhysics
::
distance2
(
double
x
,
double
y
,
double
z
,
double
*
p
)
{
TMinosPhysics
*
phy
=
current_phy
;
// distance line point is D= | (xp-x0) cross ux |
int
nused
=
0
;
// where ux is direction of line and x0 is a point in the line (like t = 0)
double
qtot
=
0
;
ROOT
::
Math
::
XYZVector
xp
(
x
,
y
,
z
);
//point of the track
sum
=
0
;
ROOT
::
Math
::
XYZVector
x0
(
p
[
0
],
p
[
2
],
0.
);
ROOT
::
Math
::
XYZVector
x1
(
p
[
0
]
+
p
[
1
],
p
[
2
]
+
p
[
3
],
1.
);
//line
ROOT
::
Math
::
XYZVector
u
=
(
x1
-
x0
).
Unit
();
double
d2
=
((
xp
-
x0
).
Cross
(
u
))
.
Mag2
();
return
d2
;
}
for
(
int
i
=
0
;
i
<
phy
->
data_result
.
GetEntriesFast
();
i
++
)
void
TMinosPhysics
::
SumDistance
(
int
&
,
double
*
,
double
&
sum
,
double
*
par
,
int
)
{
TMinosPhysics
*
phy
=
current_phy
;
int
nused
=
0
;
double
qtot
=
0
;
sum
=
0
;
for
(
int
i
=
0
;
i
<
phy
->
data_result
.
GetEntriesFast
();
i
++
)
{
phy
->
minosdata_result
=
(
TMinosResult
*
)
phy
->
data_result
.
At
(
i
);
if
(
phy
->
minosdata_result
->
n_Cluster
==
NclusterFit
)
{
{
phy
->
minosdata_result
=
(
TMinosResult
*
)
phy
->
data_result
.
At
(
i
);
float
x
=
phy
->
minosdata_result
->
x_mm
;
if
(
phy
->
minosdata_result
->
n_Cluster
==
NclusterFit
)
float
y
=
phy
->
minosdata_result
->
y_mm
;
{
float
z
=
phy
->
minosdata_result
->
z_mm
;
float
x
=
phy
->
minosdata_result
->
x_mm
;
float
q
=
phy
->
minosdata_result
->
Chargemax
;
float
y
=
phy
->
minosdata_result
->
y_mm
;
//if(nused<2)cout<<minosdata_result->n_Cluster<<" "<<x<<" "<<y<<" "<<z<<" "<<q<<endl;
float
z
=
phy
->
minosdata_result
->
z_mm
;
double
d
=
TMinosPhysics
::
distance2
(
x
,
y
,
z
,
par
);
float
q
=
phy
->
minosdata_result
->
Chargemax
;
sum
+=
d
*
q
;
//if(nused<2)cout<<minosdata_result->n_Cluster<<" "<<x<<" "<<y<<" "<<z<<" "<<q<<endl;
nused
++
;
double
d
=
TMinosPhysics
::
distance2
(
x
,
y
,
z
,
par
);
qtot
+=
q
;
sum
+=
d
*
q
;
nused
++
;
qtot
+=
q
;
}
}
}
//sum/=nused;
sum
/=
qtot
;
return
;
}
}
//sum/=nused;
sum
/=
qtot
;
return
;
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void
TMinosPhysics
::
Clear
()
{
void
TMinosPhysics
::
Clear
()
{
Xpad
.
clear
();
Xpad
.
clear
();
Ypad
.
clear
();
Ypad
.
clear
();
Qpad
.
clear
();
Qpad
.
clear
();
XpadNew
.
clear
();
XpadNew
.
clear
();
YpadNew
.
clear
();
YpadNew
.
clear
();
ZpadNew
.
clear
();
ZpadNew
.
clear
();
QpadNew
.
clear
();
QpadNew
.
clear
();
clusterringboolTemp
.
clear
();
clusterringboolTemp
.
clear
();
clusterringbool
.
clear
();
clusterringbool
.
clear
();
clusternbr
.
clear
();
clusternbr
.
clear
();
clusterpads
.
clear
();
clusterpads
.
clear
();
hfit
->
Reset
();
hfit
->
Reset
();
xin
.
clear
();
/* xoutprime.clear(); */
yin
.
clear
();
/* youtprime.clear(); */
zin
.
clear
();
/* zoutprime.clear(); */
qin
.
clear
();
xout
.
clear
();
trackclusternbr
.
clear
();
yout
.
clear
();
tracknbr
.
clear
();
zout
.
clear
();
TOTxoutprime
.
clear
();
xoutprime
.
clear
();
TOTyoutprime
.
clear
();
youtprime
.
clear
();
TOTzoutprime
.
clear
();
zoutprime
.
clear
();
TOTqout
.
clear
();
qout
.
clear
();
lenght
.
clear
();
trackclusternbr
.
clear
();
chargeTot
.
clear
();
tracknbr
.
clear
();
parFit1
.
clear
();
TOTxoutprime
.
clear
();
parFit2
.
clear
();
TOTyoutprime
.
clear
();
parFit3
.
clear
();
TOTzoutprime
.
clear
();
parFit4
.
clear
();
TOTqout
.
clear
();
grxz
.
clear
();
lenght
.
clear
();
gryz
.
clear
();
chargeTot
.
clear
();
parFit1
.
clear
();
hfit
->
Reset
();
parFit2
.
clear
();
parFit3
.
clear
();
filled
=
0
;
parFit4
.
clear
();
indexfill
=
0
;
ChargeBin
=
0.
;
grxz
.
clear
();
maxCharge
=
0.
;
gryz
.
clear
();
Iteration
=
0
;
filter_result
=
0
;
fit2DStatus
=
0
;
trackNbr
=
0
;
trackNbr_FINAL
=
0
;
x_mm
=
0.
;
y_mm
=
0.
;
z_mm
=
0.
;
q_pad
=
0.
;
t_pad
=
0.
;
array_final
=
0
;
ringsum
=
0
;
zmax
=
0.
;
hfit
->
Reset
();
}
filled
=
0
;
///////////////////////////////////////////////////////////////////////////
indexfill
=
0
;
void
TMinosPhysics
::
ReadConfiguration
(
NPL
::
InputParser
parser
)
{
ChargeBin
=
0.
;
}
maxCharge
=
0.
;
Iteration
=
0
;
filter_result
=
0
;
fit2DStatus
=
0
;
trackNbr
=
0
;
trackNbr_FINAL
=
0
;
x_mm
=
0.
;
y_mm
=
0.
;
z_mm
=
0.
;
q_pad
=
0.
;
t_pad
=
0.
;
array_final
=
0
;
ringsum
=
0
;
zmax
=
0.
;
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void
TMinosPhysics
::
ReadConfiguration
(
NPL
::
InputParser
parser
)
{
void
TMinosPhysics
::
AddParameterToCalibrationManager
()
{
CalibrationManager
*
Cal
=
CalibrationManager
::
getInstance
();
for
(
int
i
=
0
;
i
<
m_NumberOfDetectors
;
++
i
)
{
Cal
->
AddParameter
(
"Minos"
,
"D"
+
NPL
::
itoa
(
i
+
1
)
+
"_ENERGY"
,
"Minos_D"
+
NPL
::
itoa
(
i
+
1
)
+
"_ENERGY"
);
Cal
->
AddParameter
(
"Minos"
,
"D"
+
NPL
::
itoa
(
i
+
1
)
+
"_TIME"
,
"Minos_D"
+
NPL
::
itoa
(
i
+
1
)
+
"_TIME"
);
}
}
}
///////////////////////////////////////////////////////////////////////////
void
TMinosPhysics
::
InitializeRootInputRaw
()
{
///////////////////////////////////////////////////////////////////////////
TChain
*
inputChain
=
RootInput
::
getInstance
()
->
GetChain
();
void
TMinosPhysics
::
AddParameterToCalibrationManager
()
{
inputChain
->
SetBranchStatus
(
"Minos"
,
true
);
CalibrationManager
*
Cal
=
CalibrationManager
::
getInstance
();
inputChain
->
SetBranchAddress
(
"Minos"
,
&
m_EventData
);
for
(
int
i
=
0
;
i
<
m_NumberOfDetectors
;
++
i
)
{
Cal
->
AddParameter
(
"Minos"
,
"D"
+
NPL
::
itoa
(
i
+
1
)
+
"_ENERGY"
,
"Minos_D"
+
NPL
::
itoa
(
i
+
1
)
+
"_ENERGY"
);
Cal
->
AddParameter
(
"Minos"
,
"D"
+
NPL
::
itoa
(
i
+
1
)
+
"_TIME"
,
"Minos_D"
+
NPL
::
itoa
(
i
+
1
)
+
"_TIME"
);
}
}
///////////////////////////////////////////////////////////////////////////
fit_function
=
new
TF1
(
"fit_function"
,
conv_fit
,
0
,
511
,
3
);
void
TMinosPhysics
::
InitializeRootInputRaw
()
{
TChain
*
inputChain
=
RootInput
::
getInstance
()
->
GetChain
();
inputChain
->
SetBranchStatus
(
"Minos"
,
true
);
inputChain
->
SetBranchAddress
(
"Minos"
,
&
m_EventData
);
fit_function
=
new
TF1
(
"fit_function"
,
conv_fit
,
0
,
511
,
3
);
if
(
NPOptionManager
::
getInstance
()
->
HasDefinition
(
"simulation"
)){
cout
<<
"Considering input data as simulation"
<<
endl
;
if
(
NPOptionManager
::
getInstance
()
->
HasDefinition
(
"simulation"
)){
SimulationBool
=
true
;
cout
<<
"Considering input data as simulation"
<<
endl
;
SimulationBool
=
true
;
}
else
{
cout
<<
"Considering input data as real"
<<
endl
;
SimulationBool
=
false
;
ifstream
calibFile2
(
"Vdrift.txt"
);
string
buffer2
;
getline
(
calibFile2
,
buffer2
);
double
vdriftR
;
int
i
=
0
;
while
(
calibFile2
>>
vdriftR
){
VdriftperRing
[
i
]
=
vdriftR
;
// ns, s034 par.
i
++
;
}
}
else
{
cout
<<
"Considering input data as real"
<<
endl
;
SimulationBool
=
false
;
ifstream
calibFile2
(
"Vdrift.txt"
);
string
buffer2
;
getline
(
calibFile2
,
buffer2
);
double
vdriftR
;
int
i
=
0
;
while
(
calibFile2
>>
vdriftR
){
VdriftperRing
[
i
]
=
vdriftR
;
// ns, s034 par.
i
++
;
}
ifstream
calibFile
(
"Time_Offset.txt"
);
ifstream
calibFile
(
"Time_Offset.txt"
);
string
buffer
;
string
buffer
;
getline
(
calibFile
,
buffer
);
getline
(
calibFile
,
buffer
);
double
offset
;
double
offset
;
i
=
0
;
i
=
0
;
while
(
calibFile
>>
offset
){
while
(
calibFile
>>
offset
){
DelayTrig
[
i
]
=
offset
;
// ns, s034 par.
DelayTrig
[
i
]
=
offset
;
// ns, s034 par.
i
++
;
i
++
;
}
}
}
}
}
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void
TMinosPhysics
::
InitializeRootInputPhysics
()
{
void
TMinosPhysics
::
InitializeRootInputPhysics
()
{
TChain
*
inputChain
=
RootInput
::
getInstance
()
->
GetChain
();
TChain
*
inputChain
=
RootInput
::
getInstance
()
->
GetChain
();
inputChain
->
SetBranchAddress
(
"Minos"
,
&
m_EventPhysics
);
inputChain
->
SetBranchAddress
(
"Minos"
,
&
m_EventPhysics
);
}
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void
TMinosPhysics
::
InitializeRootOutput
()
{
void
TMinosPhysics
::
InitializeRootOutput
()
{
TTree
*
outputTree
=
RootOutput
::
getInstance
()
->
GetTree
();
TTree
*
outputTree
=
RootOutput
::
getInstance
()
->
GetTree
();
outputTree
->
Branch
(
"Minos"
,
"TMinosPhysics"
,
&
m_EventPhysics
);
outputTree
->
Branch
(
"Minos"
,
"TMinosPhysics"
,
&
m_EventPhysics
);
}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Construct Method to be pass to the DetectorFactory //
// Construct Method to be pass to the DetectorFactory //
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
NPL
::
VDetector
*
TMinosPhysics
::
Construct
()
{
NPL
::
VDetector
*
TMinosPhysics
::
Construct
()
{
return
(
NPL
::
VDetector
*
)
new
TMinosPhysics
();
return
(
NPL
::
VDetector
*
)
new
TMinosPhysics
();
}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Registering the construct method to the factory //
// Registering the construct method to the factory //
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
extern
"C"
{
extern
"C"
{
class
proxy_Minos
{
class
proxy_Minos
{
public:
public:
proxy_Minos
(){
proxy_Minos
(){
NPL
::
DetectorFactory
::
getInstance
()
->
AddToken
(
"Minos"
,
"Minos"
);
NPL
::
DetectorFactory
::
getInstance
()
->
AddToken
(
"Minos"
,
"Minos"
);
NPL
::
DetectorFactory
::
getInstance
()
->
AddDetector
(
"Minos"
,
TMinosPhysics
::
Construct
);
NPL
::
DetectorFactory
::
getInstance
()
->
AddDetector
(
"Minos"
,
TMinosPhysics
::
Construct
);
}
}
};
};
proxy_Minos
p_Minos
;
proxy_Minos
p_Minos
;
}
}
This diff is collapsed.
Click to expand it.
NPLib/Detectors/Minos/TMinosPhysics.h
+
1
−
13
View file @
a66e530e
...
@@ -243,19 +243,7 @@ TMinosResult *minosdata_result;//!
...
@@ -243,19 +243,7 @@ TMinosResult *minosdata_result;//!
TGraph
*
grxztmp
;
//!
TGraph
*
grxztmp
;
//!
double
zmax
;
//!
double
zmax
;
//!
vector
<
double
>
xin
;
//!
vector
<
double
>
yin
;
//!
vector
<
double
>
zin
;
//!
vector
<
double
>
qin
;
//!
vector
<
double
>
xout
;
//!
vector
<
double
>
yout
;
//!
vector
<
double
>
zout
;
//!
vector
<
double
>
qout
;
//!
vector
<
double
>
xoutprime
;
//!
vector
<
double
>
youtprime
;
//!
vector
<
double
>
zoutprime
;
//!
vector
<
double
>
qoutprime
;
//!
vector
<
double
>
TOTxoutprime
;
vector
<
double
>
TOTxoutprime
;
vector
<
double
>
TOTyoutprime
;
vector
<
double
>
TOTyoutprime
;
vector
<
double
>
TOTzoutprime
;
vector
<
double
>
TOTzoutprime
;
...
...
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