Skip to content
Snippets Groups Projects
Commit b986869f authored by Gagik Vardanyan's avatar Gagik Vardanyan
Browse files

Re #22212 D22 move, rotate, full logs

parent a675d4eb
No related merge requests found
......@@ -97,17 +97,18 @@ private:
Kernel::V3D getComponentPosition(const std::string &componentName);
void loadMetaData(const NeXus::NXEntry &, const std::string &);
std::string getInstrumentFilePath(const std::string &) const;
void rotateD22(double, const std::string &);
LoadHelper m_loader;
std::string m_instrumentName; ///< Name of the instrument
std::vector<std::string> m_supportedInstruments;
API::MatrixWorkspace_sptr m_localWorkspace;
std::vector<double> m_defaultBinning;
std::string m_resMode; ///< Resolution mode for D11
std::string m_resMode; ///< Resolution mode for D11 and D22
double calculateQ(const double lambda, const double twoTheta) const;
std::pair<double, double> calculateQMaxQMin();
void setFinalProperties();
void setFinalProperties(const std::string& filename);
};
} // namespace DataHandling
......
......@@ -101,9 +101,17 @@ void LoadILLSANS::exec() {
double distance = m_loader.getDoubleFromNexusPath(
firstEntry, instrumentPath + "/detector/det_calc");
moveDetectorDistance(distance, "detector");
if (m_instrumentName == "D22") {
double offset = m_loader.getDoubleFromNexusPath(
firstEntry, instrumentPath + "/detector/dtr_actual");
moveDetectorHorizontal(offset / 1000, "detector"); // mm to meter
double angle = m_loader.getDoubleFromNexusPath(
firstEntry, instrumentPath + "/detector/dan_actual");
rotateD22(angle, "detector");
}
}
setFinalProperties();
setFinalProperties(filename);
// Set the output workspace property
setProperty("OutputWorkspace", m_localWorkspace);
}
......@@ -184,7 +192,7 @@ void LoadILLSANS::initWorkSpace(NeXus::NXEntry &firstEntry,
size_t nextIndex =
loadDataIntoWorkspaceFromVerticalTubes(data, m_defaultBinning, 0);
nextIndex = loadDataIntoWorkspaceFromMonitors(firstEntry, nextIndex);
if (data.dim0() == 128 && m_instrumentName == "D11") {
if (data.dim1() == 128) {
m_resMode = "low";
}
}
......@@ -441,7 +449,7 @@ void LoadILLSANS::runLoadInstrument() {
IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument");
if (m_resMode == "nominal") {
loadInst->setPropertyValue("InstrumentName", m_instrumentName);
} else if (m_resMode == "low" && m_instrumentName == "D11") {
} else if (m_resMode == "low") {
loadInst->setPropertyValue("Filename",
getInstrumentFilePath(m_instrumentName + "lr"));
}
......@@ -492,6 +500,21 @@ void LoadILLSANS::moveDetectorDistance(double distance,
}
}
void LoadILLSANS::rotateD22(double angle, const ::std::string &componentName) {
API::IAlgorithm_sptr rotater =
createChildAlgorithm("RotateInstrumentComponent");
rotater->setProperty<MatrixWorkspace_sptr>("Workspace", m_localWorkspace);
rotater->setProperty("ComponentName", componentName);
rotater->setProperty("X", 0.);
rotater->setProperty("Y", 1.);
rotater->setProperty("Z", 0.);
rotater->setProperty("Angle", angle);
rotater->setProperty("RelativeRotation", false);
rotater->executeAsChildAlg();
g_log.debug() << "Rotating component '" << componentName
<< "' to angle = " << angle << " degrees.\n";
}
/**
* Move detectors in X
*/
......@@ -560,31 +583,12 @@ void LoadILLSANS::loadMetaData(const NeXus::NXEntry &entry,
API::Run &runDetails = m_localWorkspace->mutableRun();
int runNum = entry.getInt("run_number");
std::string run_num = std::to_string(runNum);
runDetails.addProperty("run_number", run_num);
if (entry.getFloat("mode") == 0.0) { // Not TOF
runDetails.addProperty<std::string>("tof_mode", "Non TOF");
} else {
runDetails.addProperty<std::string>("tof_mode", "TOF");
}
std::string desc =
m_loader.getStringFromNexusPath(entry, "sample_description");
runDetails.addProperty("sample_description", desc);
std::string start_time = entry.getString("start_time");
start_time = m_loader.dateTimeInIsoFormat(start_time);
runDetails.addProperty("run_start", start_time);
std::string end_time = entry.getString("end_time");
end_time = m_loader.dateTimeInIsoFormat(end_time);
runDetails.addProperty("run_end", end_time);
double duration = entry.getFloat("duration");
runDetails.addProperty("timer", duration);
double wavelength =
entry.getFloat(instrumentNamePath + "/selector/wavelength");
g_log.debug() << "Wavelength found in the nexus file: " << wavelength << '\n';
......@@ -660,13 +664,18 @@ std::pair<double, double> LoadILLSANS::calculateQMaxQMin() {
return std::pair<double, double>(min, max);
}
void LoadILLSANS::setFinalProperties() {
void LoadILLSANS::setFinalProperties(const std::string &filename) {
API::Run &runDetails = m_localWorkspace->mutableRun();
runDetails.addProperty("is_frame_skipping", 0);
std::pair<double, double> minmax = LoadILLSANS::calculateQMaxQMin();
runDetails.addProperty("qmin", minmax.first);
runDetails.addProperty("qmax", minmax.second);
NXhandle nxHandle;
NXstatus nxStat = NXopen(filename.c_str(), NXACC_READ, &nxHandle);
if (nxStat != NX_ERROR) {
m_loader.addNexusFieldsToWsRun(nxHandle, runDetails);
nxStat = NXclose(&nxHandle);
}
}
} // namespace DataHandling
......
<?xml version='1.0' encoding='ASCII'?>
<instrument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mantidproject.org/IDF/1.0" last-modified="2018-04-06 09:44:22.868716" name="D11" valid-from="2017-10-01 23:59:59" valid-to="2100-01-31 23:59:59" xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd">
<instrument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mantidproject.org/IDF/1.0" last-modified="2018-04-26 11:25:14.536260" name="D11" valid-from="2017-10-01 23:59:59" valid-to="2100-01-31 23:59:59" xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd">
<!-- This is the instrument definition file of the D11 Lowest momentum transfer & lowest background
small-angle neutron scattering instrument at the ILL.
Generated file, PLEASE DO NOT EDIT THIS FILE!
......@@ -101,3 +101,4 @@
<algebra val="pixel-shape"/>
</type>
</instrument>
<?xml version='1.0' encoding='ASCII'?>
<instrument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mantidproject.org/IDF/1.0" last-modified="2018-04-06 09:47:30.244021" name="D11" valid-from="2017-10-01 23:59:59" valid-to="2100-01-31 23:59:59" xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd">
<instrument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mantidproject.org/IDF/1.0" last-modified="2018-04-26 11:25:32.985566" name="D11lr" valid-from="2017-10-01 23:59:59" valid-to="2100-01-31 23:59:59" xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd">
<!-- This is the instrument definition file of the D11 Lowest momentum transfer & lowest background
small-angle neutron scattering instrument at the ILL.
Generated file, PLEASE DO NOT EDIT THIS FILE!
This file was automatically generated by mantidgeometry/ILL/IDF/d11_generateIDF.py choosing factor = 1!
This file was automatically generated by mantidgeometry/ILL/IDF/d11_generateIDF.py
z axis defines the direction of the beam
y axis will be the axis used for rotation
......@@ -101,3 +101,4 @@
<algebra val="pixel-shape"/>
</type>
</instrument>
<?xml version='1.0' encoding='ASCII'?>
<instrument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mantidproject.org/IDF/1.0" last-modified="2018-04-06 09:43:30.732495" name="D22" valid-from="2017-10-01 23:59:59" valid-to="2100-01-31 23:59:59" xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd">
<instrument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mantidproject.org/IDF/1.0" last-modified="2018-04-26 11:23:20.975212" name="D22" valid-from="2017-10-01 23:59:59" valid-to="2100-01-31 23:59:59" xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd">
<!-- This is the instrument definition file of the D22 Large dynamic range small-angle diffractometer
at the ILL.
Generated file, PLEASE DO NOT EDIT THIS FILE!
......@@ -24,8 +24,13 @@
Default sample dimension is 10 mm x 300 mm
Multi-detector:
Size 1024 mm x 980 mm
Pixel size 8 x 8 mm^2 ( 128 x 122 pixels )
Size 1024 mm x 1024 mm
Nominal resolution:
128 x 256
Pixel size 8 x 4 mm2
Low resolution:
128 x 128
Pixel size 8 x 8 mm2
For more information, please visit
https://www.ill.eu/instruments-support/instruments-groups/instruments/d22/characteristics/
......@@ -76,18 +81,19 @@
<id val="100001"/>
</idlist>
<!--DETECTOR-->
<component idfillbyfirst="y" idstart="0" idstepbyrow="122" type="detector">
<component idfillbyfirst="y" idstart="0" idstepbyrow="256" type="detector">
<location x="0.0" y="0.0" z="12.8"/>
</component>
<type is="rectangular_detector" name="detector" type="pixel" xpixels="128" xstart="-0.508" xstep="0.008" ypixels="122" ystart="-0.484" ystep="0.008"/>
<type is="rectangular_detector" name="detector" type="pixel" xpixels="128" xstart="-0.508" xstep="0.008" ypixels="256" ystart="-0.51" ystep="0.004"/>
<!--PIXEL, EACH PIXEL IS A DETECTOR-->
<type is="detector" name="pixel">
<cuboid id="pixel-shape">
<left-front-bottom-point x="-0.004" y="-0.004" z="0.0"/>
<left-front-top-point x="0.004" y="0.004" z="0.0"/>
<left-back-bottom-point x="-0.004" y="-0.004" z="-0.0001"/>
<right-front-bottom-point x="0.004" y="-0.004" z="0.0"/>
<left-front-bottom-point x="-0.004" y="-0.002" z="0.0"/>
<left-front-top-point x="0.004" y="0.002" z="0.0"/>
<left-back-bottom-point x="-0.004" y="-0.002" z="-0.0001"/>
<right-front-bottom-point x="0.004" y="-0.002" z="0.0"/>
</cuboid>
<algebra val="pixel-shape"/>
</type>
</instrument>
<?xml version='1.0' encoding='ASCII'?>
<instrument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mantidproject.org/IDF/1.0" last-modified="2018-04-26 11:23:43.832671" name="D22lr" valid-from="2017-10-01 23:59:59" valid-to="2100-01-31 23:59:59" xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd">
<!-- This is the instrument definition file of the D22 Large dynamic range small-angle diffractometer
at the ILL.
Generated file, PLEASE DO NOT EDIT THIS FILE!
This file was automatically generated by mantidgeometry/ILL/IDF/d22_generateIDF.py
z axis defines the direction of the beam
y axis will be the axis used for rotation
coordinate system is right-handed
y axis rotation defined by theta
x axis rotation defined by phi
z axis rotation defined by chi
width x direction, height y direction
Collimation
8 guide sections of 55 mm x 40 mm
Source-to-sample distances are 1.4 m; 2.0 m; 2.8 m; 4.0 m; 5.6 m; 8.0 m; 11.2 m; 14.4 m; 17.6 m
Variable apertures at 19.1 m
Sample
Default sample dimension is 10 mm x 300 mm
Multi-detector:
Size 1024 mm x 1024 mm
Nominal resolution:
128 x 256
Pixel size 8 x 4 mm2
Low resolution:
128 x 128
Pixel size 8 x 8 mm2
For more information, please visit
https://www.ill.eu/instruments-support/instruments-groups/instruments/d22/characteristics/
-->
<defaults>
<length unit="metre"/>
<angle unit="degree"/>
<reference-frame>
<along-beam axis="z"/>
<pointing-up axis="y"/>
<handedness val="right"/>
</reference-frame>
</defaults>
<!--SOURCE-->
<component type="moderator">
<location x="0.0" y="0.0" z="-2.0"/>
</component>
<type is="Source" name="moderator"/>
<!--Sample position-->
<component type="sample_position">
<location x="0.0" y="0.0" z="0.0"/>
</component>
<type is="SamplePos" name="sample_position"/>
<!--MONITORS-->
<component idlist="monitors" type="monitors">
<location/>
</component>
<type name="monitors">
<component type="monitor">
<location name="monitor1" z="-16.7"/>
<location name="monitor2" z="-1.2"/>
</component>
</type>
<!--MONITOR SHAPE-->
<!--FIXME: Do something real here.-->
<type is="monitor" name="monitor">
<cylinder id="cyl-approx">
<centre-of-bottom-base p="0.0" r="0.0" t="0.0"/>
<axis x="0.0" y="0.0" z="1.0"/>
<radius val="0.01"/>
<height val="0.03"/>
</cylinder>
<algebra val="cyl-approx"/>
</type>
<!--MONITOR IDs-->
<idlist idname="monitors">
<id val="100000"/>
<id val="100001"/>
</idlist>
<!--DETECTOR-->
<component idfillbyfirst="y" idstart="0" idstepbyrow="128" type="detector">
<location x="0.0" y="0.0" z="12.8"/>
</component>
<type is="rectangular_detector" name="detector" type="pixel" xpixels="128" xstart="-0.508" xstep="0.008" ypixels="128" ystart="-0.508" ystep="0.008"/>
<!--PIXEL, EACH PIXEL IS A DETECTOR-->
<type is="detector" name="pixel">
<cuboid id="pixel-shape">
<left-front-bottom-point x="-0.004" y="-0.004" z="0.0"/>
<left-front-top-point x="0.004" y="0.004" z="0.0"/>
<left-back-bottom-point x="-0.004" y="-0.004" z="-0.0001"/>
<right-front-bottom-point x="0.004" y="-0.004" z="0.0"/>
</cuboid>
<algebra val="pixel-shape"/>
</type>
</instrument>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment