Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
np
nptool
Commits
9dbc8211
Commit
9dbc8211
authored
Jun 04, 2021
by
Charlie Paxman
Browse files
* minor correction
* Thickness wasn't being properly varied
parent
92a68c66
Pipeline
#122807
passed with stages
in 9 minutes and 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
26 deletions
+21
-26
Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.cxx
Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.cxx
+20
-25
Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.h
Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.h
+1
-1
No files found.
Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.cxx
View file @
9dbc8211
...
...
@@ -58,7 +58,6 @@ double devE(const double* parameter){
double
ThetaMugast
=
dir
.
Angle
(
MugastNormal
);
double
Energy
=
energy
[
i
];
//NOTE!!! Not calucualting energy loss in Al???
//Energy loss in Al
Energy
=
Al
.
EvaluateInitialEnergy
(
Energy
,
//energy after Al
...
...
@@ -67,16 +66,14 @@ double devE(const double* parameter){
//Energy loss in target
Energy
=
CD2
.
EvaluateInitialEnergy
(
Energy
,
//energy after leaving target
0.5
*
parameter
[
4
]
*
micrometer
,
//pass through half target
0.5
*
parameter
[
3
]
*
micrometer
,
//pass through half target
ThetaTarget
);
//angle leaving target
//Final value of Ex
double
Ex
=
reaction
.
ReconstructRelativistic
(
Energy
,
ThetaTarget
);
//Fill histogram with ERROR in Ex!
//h->Fill(Ex-refE);
h
->
Fill
(
Ex
);
//Fill histograms with Ex
h
->
Fill
(
Ex
);
switch
(
detnum
[
i
]){
case
1
:
h1
->
Fill
(
Ex
);
...
...
@@ -97,30 +94,28 @@ double devE(const double* parameter){
h7
->
Fill
(
Ex
);
break
;
default:
cout
<<
"ERRO:: Invalid DetNum "
<<
detnum
[
i
]
<<
" at event "
<<
i
<<
endl
;
cout
<<
"ERRO
R
:: Invalid DetNum "
<<
detnum
[
i
]
<<
" at event "
<<
i
<<
endl
;
return
1
;
// Exit code
}
}
//End loop over events
//Write vals to screen
cout
<<
"Mean: "
<<
h
->
GetMean
()
<<
"
\t
StdDev: "
<<
h
->
GetStdDev
()
<<
"
\t
Thickness
??
: "
<<
parameter
[
4
]
<<
"
\t
Thickness: "
<<
parameter
[
3
]
<<
" um"
<<
endl
;
//Draw histogram(s)
h
->
Draw
();
if
(
flagDraw
){
InitiliseCanvas
();
}
/*
cout << pow(h->GetMean()-refE,2) << " + "
<< pow(0.1*h->GetStdDev(),2) << " = "
<< pow(h->GetMean()-refE,2) + pow(0.1*h->GetStdDev(),2)
<< endl;
*/
//Adapt the metric as needed
return
sqrt
(
pow
(
h
->
GetMean
()
-
refE
,
2
)
+
pow
(
0.1
*
h
->
GetStdDev
(),
2
)
);
...
...
@@ -128,47 +123,47 @@ double devE(const double* parameter){
////////////////////////////////////////////////////////////////////////////////
void
MinimizeBeamSpot
(){
//
Read data in
//Read data in
LoadFile
();
//
Start with beam (0,0,0) and 4.7um 0.5mg/c2 target
double
parameter
[
4
]
=
{
0.0
,
0.0
,
0.0
,
4.7
};
//Start with beam (0,0,0) and 4.7
6
um 0.5mg/c2 target
double
parameter
[
4
]
=
{
0.0
,
0.0
,
0.0
,
4.7
6
};
devE
(
parameter
);
//
Function with 4 parameter XYZ and Target thickness
//Function with 4 parameter XYZ and Target thickness
auto
func
=
ROOT
::
Math
::
Functor
(
&
devE
,
4
);
//
Minimizer
//Minimizer
auto
minim
=
ROOT
::
Math
::
Factory
::
CreateMinimizer
(
"Minuit2"
,
"Migrad"
);
minim
->
SetPrintLevel
(
0
);
minim
->
SetPrecision
(
1e-10
);
//
Set minimizer function
//Set minimizer function
minim
->
SetFunction
(
func
);
//
Assign variable limits
//Assign variable limits
minim
->
SetLimitedVariable
(
0
,
"X"
,
parameter
[
0
],
0.01
,
-
10
,
10
);
minim
->
SetLimitedVariable
(
1
,
"Y"
,
parameter
[
1
],
0.01
,
-
10
,
10
);
minim
->
SetLimitedVariable
(
2
,
"Z"
,
parameter
[
2
],
0.01
,
-
5
,
5
);
minim
->
SetLimitedVariable
(
3
,
"T"
,
parameter
[
3
],
0.01
,
4.7
-
3.0
,
4.7
+
3.0
);
minim
->
SetLimitedVariable
(
3
,
"T"
,
parameter
[
3
],
0.01
,
4.7
6
*
0.5
,
4.76
*
1.5
);
//
Don't draw iterations of minimizer
//Don't draw iterations of minimizer
flagDraw
=
0
;
//
Shrink it, babeyyy
//Shrink it, babeyyy
minim
->
Minimize
();
//
Draw minimal value
//Draw minimal value
flagDraw
=
1
;
//
Pull values from minimizer
//Pull values from minimizer
const
double
*
x
=
minim
->
X
();
cout
<<
"========================================"
<<
endl
;
cout
<<
"
\t\t
X ="
<<
x
[
0
]
<<
endl
;
cout
<<
"
\t\t
Y ="
<<
x
[
1
]
<<
endl
;
cout
<<
"
\t\t
Z ="
<<
x
[
2
]
<<
endl
;
cout
<<
"
\t\t
T ="
<<
x
[
3
]
<<
endl
;
cout
<<
"Minimum: "
<<
devE
(
x
)
<<
endl
;
devE
(
x
)
;
cout
<<
"========================================"
<<
endl
;
}
Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.h
View file @
9dbc8211
...
...
@@ -14,7 +14,7 @@ NPL::EnergyLoss Al("proton_Al.G4table","G4Table",100);
using
namespace
std
;
bool
flagDraw
=
0
;
static
auto
h
=
new
TH1D
(
"h"
,
"All MG#'s"
,
8
0
,
-
1.
,
1.
);
static
auto
h
=
new
TH1D
(
"h"
,
"All MG#'s"
,
6
0
,
-
1.
,
1.
);
static
auto
h1
=
new
TH1D
(
"h1"
,
"Individual MG#'s"
,
40
,
-
1.
,
1.
);
static
auto
h2
=
new
TH1D
(
"h2"
,
"h2"
,
40
,
-
1.
,
1.
);
static
auto
h3
=
new
TH1D
(
"h3"
,
"h3"
,
40
,
-
1.
,
1.
);
...
...
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