Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Corryvreckan
Corryvreckan
Commits
92e5a006
Commit
92e5a006
authored
Oct 10, 2017
by
Simon Spannagel
Browse files
Move reading of detectors to TOML-like file and into Analysis.C
parent
f56b6513
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/core/Analysis.C
View file @
92e5a006
// ROOT include files
#include
<Math/DisplacementVector2D.h>
#include
<Math/Vector2D.h>
#include
<Math/Vector3D.h>
#include
<TFile.h>
#include
<TSystem.h>
#include
"TFile.h"
// Local include files
#include
"Analysis.h"
#include
"utils/ROOT.h"
#include
"utils/log.h"
#include
<dlfcn.h>
...
...
@@ -95,12 +99,6 @@ Analysis::Analysis(std::string config_file_name) : m_terminate(false) {
// Overwrite steering file values from command line
// parameters->readCommandLineOptions(argc,argv);
// Load alignment parameters
std
::
string
conditionsFile
=
global_config
.
get
<
std
::
string
>
(
"conditionsFile"
);
m_parameters
->
conditionsFile
=
conditionsFile
;
if
(
!
m_parameters
->
readConditions
())
throw
ConfigFileUnavailableError
(
conditionsFile
);
// Load mask file for the dut (if specified)
m_parameters
->
dutMaskFile
=
global_config
.
get
<
std
::
string
>
(
"dutMaskFile"
,
"defaultMask.dat"
);
m_parameters
->
readDutMask
();
...
...
@@ -122,7 +120,61 @@ void Analysis::add(Algorithm* algorithm) {
}
void
Analysis
::
load
()
{
load_detectors
();
load_algorithms
();
}
void
Analysis
::
load_detectors
()
{
std
::
string
detectors_file
=
global_config
.
getPath
(
"detectors_file"
);
// Load the detector configuration
det_mgr_
=
std
::
make_unique
<
corryvreckan
::
ConfigManager
>
(
detectors_file
);
for
(
auto
&
detector
:
det_mgr_
->
getConfigurations
())
{
LOG
(
INFO
)
<<
"Detector: "
<<
detector
.
getName
();
// Get information from the conditions file:
auto
position
=
detector
.
get
<
ROOT
::
Math
::
XYZPoint
>
(
"position"
,
ROOT
::
Math
::
XYZPoint
());
auto
orientation
=
detector
.
get
<
ROOT
::
Math
::
XYZVector
>
(
"orientation"
,
ROOT
::
Math
::
XYZVector
());
// Number of pixels
auto
npixels
=
detector
.
get
<
ROOT
::
Math
::
DisplacementVector2D
<
Cartesian2D
<
int
>>>
(
"number_of_pixels"
);
// Size of the pixels
auto
pitch
=
detector
.
get
<
ROOT
::
Math
::
XYVector
>
(
"pixel_pitch"
);
DetectorParameters
*
det_parm
=
new
DetectorParameters
(
detector
.
get
<
std
::
string
>
(
"type"
),
npixels
.
x
(),
npixels
.
y
(),
pitch
.
x
(),
pitch
.
y
(),
position
.
x
(),
position
.
y
(),
position
.
z
(),
orientation
.
x
(),
orientation
.
y
(),
orientation
.
z
(),
detector
.
get
<
double
>
(
"time_offset"
,
0
.
0
));
m_parameters
->
detector
[
detector
.
getName
()]
=
det_parm
;
m_parameters
->
registerDetector
(
detector
.
getName
());
}
// Now check that all devices which are registered have parameters as well
bool
unregisteredDetector
=
false
;
// Loop over all registered detectors
for
(
auto
&
det
:
m_parameters
->
detectors
)
{
if
(
m_parameters
->
detector
.
count
(
det
)
==
0
)
{
LOG
(
INFO
)
<<
"Detector "
<<
det
<<
" has no conditions loaded"
;
unregisteredDetector
=
true
;
}
}
if
(
unregisteredDetector
)
{
throw
RuntimeError
(
"Detector missing conditions."
);
}
// Finally, sort the list of detectors by z position (from lowest to highest)
// FIXME reimplement - std::sort(m_parameters->detectors.begin(), m_parameters->detectors.end(), sortByZ);
}
void
Analysis
::
load_algorithms
()
{
std
::
vector
<
Configuration
>
configs
=
conf_mgr_
->
getConfigurations
();
// Create histogram output file
...
...
src/core/Analysis.h
View file @
92e5a006
...
...
@@ -60,11 +60,15 @@ namespace corryvreckan {
int
m_events
;
private:
void
load_detectors
();
void
load_algorithms
();
// Log file if specified
std
::
ofstream
log_file_
;
std
::
atomic
<
bool
>
m_terminate
;
std
::
unique_ptr
<
corryvreckan
::
ConfigManager
>
conf_mgr_
;
std
::
unique_ptr
<
corryvreckan
::
ConfigManager
>
det_mgr_
;
Algorithm
*
create_algorithm
(
void
*
library
,
corryvreckan
::
Configuration
config
,
Clipboard
*
clipboard
);
std
::
tuple
<
LogLevel
,
LogFormat
>
set_algorithm_before
(
const
std
::
string
&
,
const
Configuration
&
config
);
...
...
src/core/DetectorParameters.h
View file @
92e5a006
...
...
@@ -9,6 +9,8 @@
#include
"Math/Translation3D.h"
#include
"Math/Vector3D.h"
#include
"utils/log.h"
using
namespace
ROOT
::
Math
;
namespace
corryvreckan
{
...
...
@@ -43,6 +45,14 @@ namespace corryvreckan {
m_timingOffset
=
timingOffset
;
this
->
initialise
();
LOG
(
TRACE
)
<<
"Initialized
\"
"
<<
m_detectorType
<<
"
\"
: "
<<
m_nPixelsX
<<
"x"
<<
m_nPixelsY
<<
" px, pitch of "
<<
m_pitchX
<<
"/"
<<
m_pitchY
<<
"mm"
;
LOG
(
TRACE
)
<<
"Position: "
<<
m_displacementX
<<
","
<<
m_displacementY
<<
","
<<
m_displacementZ
;
LOG
(
TRACE
)
<<
"Orientation: "
<<
m_rotationX
<<
","
<<
m_rotationY
<<
","
<<
m_rotationZ
;
if
(
m_timingOffset
>
0.
)
{
LOG
(
TRACE
)
<<
"Timing offset: "
<<
m_timingOffset
;
}
}
~
DetectorParameters
()
{}
...
...
src/core/Parameters.C
View file @
92e5a006
...
...
@@ -18,12 +18,6 @@ Parameters::Parameters() {
currentTime
=
0
.;
// seconds
}
// Sort function for detectors from low to high z
map
<
string
,
DetectorParameters
*>
globalDetector
;
bool
corryvreckan
::
sortByZ
(
string
detector1
,
string
detector2
)
{
return
(
globalDetector
[
detector1
]
->
displacementZ
()
<
globalDetector
[
detector2
]
->
displacementZ
());
}
bool
Parameters
::
writeConditions
()
{
// Open the conditions file to write detector information
...
...
@@ -111,9 +105,8 @@ bool Parameters::readConditions() {
return
false
;
// Finally, sort the list of detectors by z position (from lowest to highest)
globalDetector
=
detector
;
std
::
sort
(
detectors
.
begin
(),
detectors
.
end
(),
sortByZ
);
// FIXME reimplement
//
return
true
;
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment