Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadSpecialModules
Commits
d932a482
Commit
d932a482
authored
Apr 20, 2020
by
yannick legoc
Browse files
Added controller VEXPDetectorSimulator
parent
b0bc80b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/controllers/vexp/Module.xml
View file @
d932a482
<module
name=
"vexp"
>
<controller
class=
"vexp::VEXPController"
/>
<controller
class=
"vexp::DetectorSimulator"
/>
<include
path=
"$(NOMAD_HOME)/../NomadModules/src"
/>
<link
path=
"/usr/local/lib"
lib=
"vexplib"
/>
</module>
src/controllers/vexp/VEXPDetectorSimulator.cpp
0 → 100644
View file @
d932a482
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "VEXPDetectorSimulator.h"
#include <fstream>
#include <boost/algorithm/string.hpp>
using
namespace
std
;
using
namespace
boost
;
namespace
vexp
{
const
string
DetectorSimulator
::
TYPE
=
"vexp_detector_simulator"
;
DetectorSimulator
::
DetectorSimulator
(
const
string
&
name
)
:
ExperimentController
(
name
),
m_dataHandle
(
0
),
m_coef
(
1.0
)
{
setFamily
(
family
::
HIDDEN
);
m_detector
.
init
(
this
,
"detector"
);
m_scattering
.
init
(
this
,
"scattering"
);
simulationFile
.
init
(
this
,
SAVE
,
"simulation_file"
);
intensity
.
init
(
this
,
NOSAVE
,
"intensity"
);
}
DetectorSimulator
::
DetectorSimulator
(
const
DetectorSimulator
&
controller
)
:
ExperimentController
(
controller
),
m_dataHandle
(
0
),
m_coef
(
1.0
)
{
}
DetectorSimulator
::~
DetectorSimulator
()
{
}
void
DetectorSimulator
::
postConfiguration
()
{
registerUpdater
(
m_detector
->
detSum
,
&
DetectorSimulator
::
updateData
,
this
);
loadSimulationFile
();
}
void
DetectorSimulator
::
loadSimulationFile
()
{
// Open the file.
ifstream
file
(
simulationFile
().
c_str
());
if
(
!
file
)
{
cerr
<<
"Cannot open simulation file "
<<
simulationFile
()
<<
endl
;
return
;
}
// Create a tree.
m_dataHandle
=
m_accessor
.
createSqwTree
();
// Calculate the max intensity.
float64
maxIntensity
=
0.0
;
float64
mh
,
mk
,
ml
,
me
;
typedef
tokenizer
<
char_separator
<
char
>
>
tokenizer
;
char_separator
<
char
>
sep
(
" "
);
// Read the file.
while
(
!
file
.
eof
())
{
string
line
;
getline
(
file
,
line
);
if
(
line
!=
""
)
{
try
{
tokenizer
tokens
(
line
,
sep
);
tokenizer
::
iterator
iter
=
tokens
.
begin
();
float64
qh
(
stod
(
*
iter
));
++
iter
;
float64
qk
(
stod
(
*
iter
));
++
iter
;
float64
ql
(
stod
(
*
iter
));
++
iter
;
float64
qe
(
stod
(
*
iter
));
++
iter
;
float64
qs
(
stod
(
*
iter
));
//cout << "found " << qh << " " << qk << " " << ql << " " << qe << " " << qs << endl;
// Add the point.
m_accessor
.
addSqwValue
(
m_dataHandle
,
qh
,
qk
,
ql
,
qe
,
qs
);
// Update the max intensity.
//maxIntensity = max(qs, maxIntensity);
if
(
qs
>
maxIntensity
)
{
maxIntensity
=
qs
;
mh
=
qh
;
mk
=
qk
;
ml
=
ql
;
me
=
qe
;
}
}
catch
(...)
{
// Line with bad characters are excluded.
}
}
}
m_coef
=
1000.0
/
maxIntensity
;
cout
<<
"Created the simulation data, max intensity is "
<<
maxIntensity
<<
" at "
<<
mh
<<
", "
<<
mk
<<
", "
<<
ml
<<
", "
<<
me
<<
endl
;
}
void
DetectorSimulator
::
updateData
()
{
// Query the s value from the data.
float64
h
,
k
,
l
,
e
,
s
;
h
=
m_scattering
->
qh
();
k
=
m_scattering
->
qk
();
l
=
m_scattering
->
ql
();
e
=
m_scattering
->
en
();
m_accessor
.
querySqwTree
(
m_dataHandle
,
h
,
k
,
l
,
e
,
s
);
//detector->detSum = (scattering->qh() + scattering->qk() + scattering->ql()) * 10.0;
//m_detector->detSum = 200.0 - ((m_scattering->qh() - 1.0) * 1000.0);
m_detector
->
detSum
=
s
*
m_coef
;
cout
<<
"updateData "
<<
m_detector
->
detSum
()
<<
", scattering "
<<
m_scattering
->
qh
()
<<
", "
<<
m_scattering
->
qk
()
<<
", "
<<
m_scattering
->
ql
()
<<
", "
<<
m_scattering
->
en
()
<<
endl
;
}
}
src/controllers/vexp/VEXPDetectorSimulator.h
0 → 100644
View file @
d932a482
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef VEXP_DETECTORSIMULATOR_H
#define VEXP_DETECTORSIMULATOR_H
#include "controllers/tas/common/Scattering.h"
#include "controllers/common/acquisition/detector/DetectorElement.h"
#include <vexplib.h>
namespace
vexp
{
class
DetectorSimulator
:
public
ExperimentController
{
public:
//! Type of controller
static
const
std
::
string
TYPE
;
DetectorSimulator
(
const
std
::
string
&
name
);
DetectorSimulator
(
const
DetectorSimulator
&
controller
);
virtual
~
DetectorSimulator
();
virtual
void
postConfiguration
();
Property
<
std
::
string
>
simulationFile
;
Property
<
float64
>
intensity
;
private:
void
loadSimulationFile
();
void
updateData
();
VEXPLib
m_accessor
;
int
m_dataHandle
;
float64
m_coef
;
// Controllers.
ControllerPtr
<
acquisition
::
DetectorElement
>
m_detector
;
ControllerPtr
<
tas
::
Scattering
>
m_scattering
;
};
}
#endif
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