Commit ac9292b1 authored by Steve Williams's avatar Steve Williams
Browse files

ShapeFactory now ensures that the centre of cylinders is midway between the...

ShapeFactory now ensures that the centre of cylinders is midway between the end caps. MERLIN detectors are more accurately modelled, being cylinders and not cuboids. LoadDetectorInfo deals with missing detectors and getEi uses spectra numbers which seem better known by the Exciations Group. refs #841
parent aea935b1
......@@ -79,8 +79,8 @@ private:
void init();
void exec();
void getGeometry(IInstrument_const_sptr geometry, int det0ID, int det1ID, double &monitor0Dist, double &monitor1Dist) const;
std::vector<int> getMonitorSpecIndexs(Workspace2D_const_sptr WS, const std::vector<int> &detIDs) const;
void getGeometry(Workspace2D_const_sptr WS, int mon0Spec, int mon1Spec, double &monitor0Dist, double &monitor1Dist) const;
std::vector<int> getMonitorSpecIndexs(Workspace2D_const_sptr WS, int specNum1, int specNum2) const;
double timeToFly(double s, double E_KE) const;
double getPeakCentre(Workspace2D_const_sptr WS, const int monitIn, const double peakTime);
void extractSpec(int specInd, double start, double end);
......
......@@ -48,10 +48,10 @@ void GetEi::init()
"micro-seconds");
BoundedValidator<int> *mustBePositive = new BoundedValidator<int>();
mustBePositive->setLower(0);
declareProperty("Monitor1ID", -1, mustBePositive,
"The detector ID of the first monitor");
declareProperty("Monitor2ID", -1, mustBePositive->clone(),
"The detector ID of the second monitor");
declareProperty("Monitor1Spec", -1, mustBePositive,
"The spectrum number of the output of the first monitor");
declareProperty("Monitor2Spec", -1, mustBePositive->clone(),
"The spectrum number of the output of the second monitor");
BoundedValidator<double> *positiveDouble = new BoundedValidator<double>();
positiveDouble->setLower(0);
declareProperty("EnergyEstimate", -1.0, positiveDouble,
......@@ -64,19 +64,18 @@ void GetEi::init()
/** Executes the algorithm
* @throw out_of_range if the peak runs off the edge of the histogram
* @throw NotFoundError if no detector is found for the detector ID given
* @throw NotFoundError if one of the requested spectrum numbers was not found in the workspace
* @throw IndexError if there is a problem converting spectra indexes to spectra numbers, which would imply there is a problem with the workspace
* @throw invalid_argument if a good peak fit wasn't made or the input workspace does not have common binning
* @throw runtime_error a sub-algorithm falls over
* @throw runtime_error if there is a problem with the SpectraDetectorMap or a sub-algorithm falls over
*/
void GetEi::exec()
{
Workspace2D_const_sptr WS = getProperty("InputWorkspace");
std::vector<int> monIDs;
monIDs.push_back(getProperty("Monitor1ID"));
monIDs.push_back(getProperty("Monitor2ID"));
Workspace2D_const_sptr inWS = getProperty("InputWorkspace");
const int mon1Spec = getProperty("Monitor1Spec");
const int mon2Spec = getProperty("Monitor2Spec");
double dist2moni0 = -1, dist2moni1 = -1;
getGeometry(WS->getInstrument(), monIDs[0], monIDs[1],dist2moni0,dist2moni1);
getGeometry(inWS, mon1Spec, mon2Spec, dist2moni0, dist2moni1);
// the E_i estimate is used to find (identify) the monitor peaks, checking prior to fitting will throw an exception if this estimate is too big or small
const double E_est = getProperty("EnergyEstimate");
......@@ -87,13 +86,14 @@ void GetEi::exec()
const double peakLoc1 = 1e6*timeToFly(dist2moni1, E_est);
g_log.information() << "Based on the user selected energy the second peak will be searched for at TOF " << peakLoc1 << " micro seconds +/-" << boost::lexical_cast<std::string>(100.0*HALF_WINDOW) << "%" << std::endl;
// get the histograms created by the monitors
std::vector<int> indexes = getMonitorSpecIndexs(WS, monIDs);
// get the histograms created by the monitors
std::vector<int> indexes = getMonitorSpecIndexs(inWS, mon1Spec, mon2Spec);
g_log.information() << "Looking for a peak in the first monitor spectrum, spectra index " << indexes[0] << std::endl;
double t_monitor0 = getPeakCentre(WS, indexes[0], peakLoc0);
double t_monitor0 = getPeakCentre(inWS, indexes[0], peakLoc0);
g_log.information() << "The first peak has been found at TOF = " << t_monitor0 << std::endl;
g_log.information() << "Looking for a peak in the second monitor spectrum, spectra index " << indexes[1] << std::endl;
double t_monitor1 = getPeakCentre(WS, indexes[1], peakLoc1);
double t_monitor1 = getPeakCentre(inWS, indexes[1], peakLoc1);
g_log.information() << "The second peak has been found at TOF = " << t_monitor1 << std::endl;
// assumes that the source and the both mintors lie on one straight line, the 1e-6 converts microseconds to seconds as the mean speed needs to be in m/s
......@@ -101,45 +101,62 @@ void GetEi::exec()
// uses 0.5mv^2 to get the kinetic energy in joules which we then convert to meV
double E_i = neutron_E_At(meanSpeed)/PhysicalConstants::meV;
g_log.notice() << "The incident energy is estimated to be " << E_i << " meV" << " (your estimated value was " << E_est << " meV)" << std::endl;
g_log.notice() << "The incident energy has been calculated to be " << E_i << " meV" << " (your estimate was " << E_est << " meV)" << std::endl;
setProperty("IncidentEnergy", E_i);
}
/** Gets the distances between the source and detectors whose IDs you pass to it
* @param geometry the instrument from a workspace
* @param det0ID ID number of a detector
* @param det1ID ID number of a detector
* @param WS the input workspace
* @param mon0Spec Spectrum number of the output from the first monitor
* @param mon1Spec Spectrum number of the output from the second monitor
* @param monitor0Dist the calculated distance to the detector whose ID was passed to this function first
* @param monitor1Dist calculated distance to the detector whose ID was passed to this function second
* @throw NotFoundError if no detector is found for the detector ID given
* @throw runtime_error if there is a problem with the SpectraDetectorMap
*/
void GetEi::getGeometry(IInstrument_const_sptr geometry, int det0ID, int det1ID, double &monitor0Dist, double &monitor1Dist) const
void GetEi::getGeometry(Workspace2D_const_sptr WS, int mon0Spec, int mon1Spec, double &monitor0Dist, double &monitor1Dist) const
{
const IObjComponent_sptr source = geometry->getSource();
const IObjComponent_sptr source = WS->getInstrument()->getSource();
// retrieve a pointer to the first detector and get its distance
Geometry::IDetector_sptr det = geometry->getDetector(det0ID);
const IComponent * const first = det->getComponent();
monitor0Dist = source->getDistance(*first);
IDetector_sptr dets = WS->getDetector(mon0Spec);
monitor0Dist = dets->getDistance(*(source.get()));
// repeat above for the second detector
det = geometry->getDetector(det1ID);
const IComponent * const second = det->getComponent();
monitor1Dist = source->getDistance(*second);
}
// repeat for the second detector
dets = WS->getDetector(mon1Spec);
monitor1Dist = dets->getDistance(*(source.get()));
}
/** Converts detector IDs to spectra indexes
* @param WS the workspace on which the calculations are being performed
* @param detIDs the detector IDs to search for
* @param specNum1 spectrum number of the output of the first monitor
* @param specNum2 spectrum number of the output of the second monitor
* @return the indexes of the histograms created by the detector whose ID were passed
* @throw IndexError if there is a problem converting spectra indexes to spectra numbers, which would imply there is a problem with the workspace
* @throw NotFoundError if one of the requested spectrum numbers was not found in the workspace
*/
std::vector<int> GetEi::getMonitorSpecIndexs(Workspace2D_const_sptr WS, const std::vector<int> &detIDs) const
std::vector<int> GetEi::getMonitorSpecIndexs(Workspace2D_const_sptr WS, int specNum1, int specNum2) const
{// getting spectra numbers from detector IDs is hard because the map works the other way, getting index numbers from spectra numbers has the same problem and we are about to do both
std::vector<int> specInds;
// this function creates a new multimap for detectorIDs to index numbers
std::vector<int> spectraList = WS->spectraMap().getSpectra(detIDs);
// this creates a new map from spectra numbers to indices
WorkspaceHelpers::getIndicesFromSpectra(WS, spectraList, specInds);
// get the index number of the histogram for the first monitor
std::vector<int> specNumTemp(&specNum1, &specNum1+1);
WorkspaceHelpers::getIndicesFromSpectra(WS, specNumTemp, specInds);
if ( specInds.size() != 1 )
{// the monitor spectrum isn't present in the workspace, we can't continue from here
g_log.error() << "Couldn't find the first monitor spectrum, number " << specNum1 << std::endl;
throw Exception::NotFoundError("GetEi::getMonitorSpecIndexs()", specNum1);
}
// nowe the second monitor
std::vector<int> specIndexTemp;
specNumTemp[0] = specNum2;
WorkspaceHelpers::getIndicesFromSpectra(WS, specNumTemp, specIndexTemp);
if ( specIndexTemp.size() != 1 )
{// the monitor spectrum isn't present in the workspace, we can't continue from here
g_log.error() << "Couldn't find the second monitor spectrum, number " << specNum2 << std::endl;
throw Exception::NotFoundError("GetEi::getMonitorSpecIndexs()", specNum2);
}
specInds.push_back(specIndexTemp[0]);
return specInds;
}
/** Uses E_KE = mv^2/2 and s = vt to calculate the time required for a neutron
......@@ -189,7 +206,7 @@ double GetEi::getPeakCentre(Workspace2D_const_sptr WS, const int monitIn, const
// find the index of the centre point. The centre can't be at index zero as this is at the edge of the spectrum, so centreIndex = 0 is the error value
MantidVec::size_type cenGausIn = 0;
for ( MantidVec::size_type i = 0; i < m_tempWS->readX(0).size(); ++i )
for ( MantidVec::size_type i = 0; i < m_tempWS->readY(0).size(); ++i )
{// assumes that the bin boundaries are all in order of increasing time
if ( m_tempWS->readX(0)[i] > centreGaussian )
{
......@@ -197,6 +214,7 @@ double GetEi::getPeakCentre(Workspace2D_const_sptr WS, const int monitIn, const
break;
}
}
// the peak centre is defined as the centre of the two half maximum points as this is better for asymmetric peaks
// first loop backwards along the histogram to get the first half height point
MantidVec::size_type lHalf = findHalfLoc(cenGausIn, height, GO_LEFT);
......@@ -222,7 +240,7 @@ double GetEi::getPeakCentre(Workspace2D_const_sptr WS, const int monitIn, const
void GetEi::extractSpec(int specInd, double start, double end)
{
IAlgorithm_sptr childAlg =
createSubAlgorithm("CropWorkspace", 100*m_fracCompl, 100*m_fracCompl+CROP );
createSubAlgorithm("CropWorkspace", 100*m_fracCompl, 100*(m_fracCompl+CROP) );
m_fracCompl += CROP;
childAlg->setPropertyValue( "InputWorkspace",
......
......@@ -35,7 +35,7 @@ public:
grouper.setPropertyValue("InputWorkspace", m_WS);
grouper.setPropertyValue("Monitor1ID", "2");
grouper.setPropertyValue("Monitor2ID", "3");
grouper.setPropertyValue("EnergyEstimate", "12");
grouper.setPropertyValue("EnergyEstimate", "14");
//MAPS one off test, takes to long to do it every time. To activate uncomment the code below and two sections below that
// when the MAP workspace that is load in the constructor
......@@ -43,13 +43,19 @@ public:
grouper.setPropertyValue("Monitor1ID", "1000002");
grouper.setPropertyValue("Monitor2ID", "1000003");
grouper.setPropertyValue("EnergyEstimate", "400");*/
//MERLIN one off test, takes 30 or more seconds. To activate uncomment the code below and two sections below that
/* grouper.setPropertyValue("InputWorkspace", m_WS);
grouper.setPropertyValue("Monitor1Spec", "69634");
grouper.setPropertyValue("Monitor2Spec", "69638");
grouper.setPropertyValue("EnergyEstimate", "15");
TS_ASSERT_THROWS_NOTHING( grouper.execute());
TS_ASSERT( grouper.isExecuted() );
TS_ASSERT( grouper.isExecuted() );*/
double finalAnswer = grouper.getProperty("IncidentEnergy");
TS_ASSERT_DELTA( finalAnswer, 12.9462875, 1e-6 )
/*MAPS one off test, takes to long to do it every time. */ //TS_ASSERT_DELTA( finalAnswer, 398.7392468, 1e-6 )
/*MERLIN one off test, takes to long to do it every time. */ // TS_ASSERT_DELTA( finalAnswer, 15.07969180873369, 1e-6 )
}
void loadRawFile()
......@@ -57,16 +63,17 @@ public:
LoadRaw3 loader;
loader.initialize();
loader.setPropertyValue("Filename", MAR11001);
loader.setPropertyValue("Filename", MARI);
loader.setPropertyValue("OutputWorkspace", m_WS);
TS_ASSERT_THROWS_NOTHING(loader.execute());
}
GetEiTest() : m_WS("GetEi_input_workspace"), MAR11001()
GetEiTest() : m_WS("GetEi_input_workspace"), MARI()
{
MAR11001 = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/MAR11001.RAW").toString();
/*MAPS one off test, takes to long to do it every time. */ // MAR11001 = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/MAP10266.RAW").toString();
MARI = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/MAR11001.RAW").toString();
/*MAPS one off test, takes to long to do it every time. */ // MARI = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/MAP10266.RAW").toString();
/*MERLIN one off test, takes to long to do it every time. */ // MARI = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/MER02257.RAW").toString();
loadRawFile();
}
......@@ -77,7 +84,7 @@ public:
private:
const std::string m_WS;
std::string MAR11001;
std::string MARI;
};
#endif /*GETE_ITEST_H_*/
......@@ -82,6 +82,8 @@ private:
bool m_commonXs;
/// the delay time for monitors, this algorithm requires all monitors have the same delay. Normally the delay is zero
float m_monitOffset;
/// notes if an error was found and the workspace was possibly only partially corrected
bool m_error;
/// An estimate of the percentage of the algorithm runtimes that has been completed
double m_FracCompl;
......@@ -92,10 +94,16 @@ private:
void readDAT(const std::string& fName);
void readRAW(const std::string& fName);
void setDetectorParams(int detID, double pressure, double wallThick);
void adjDelayTOFs(double lastOffset, bool &differentDelays, const std::vector<int> &detectIDs=std::vector<int>(), const std::vector<float> &delays=std::vector<float>());
void adjDelayTOFs(double lastOffset, bool &differentDelays, const int * const detectIDs, const float * const delays, int numDetectors);
void adjustXs(const std::vector<int> &detIDs, const std::vector<float> &offsets);
void adjustXs(const float detectorOffset);
void adjustXs(const double detectorOffset);
void adjustXsCommon(const std::vector<float> &offsets, const std::vector<int> &spectraList, std::map<int,int> &specs2index, std::vector<int> missingDetectors);
void adjustXsUnCommon(const std::vector<float> &offsets, const std::vector<int> &spectraList, std::map<int,int> &specs2index, std::vector<int> missingDetectors);
void noteMonitorOffset(const float offSet, const int detID);
void setUpXArray(Histogram1D::RCtype &theXValuesArray, int specInd, float offset);
void setUpXArray(Histogram1D::RCtype &theXValuesArray, int specInd, double offset);
void logErrorsFromRead(const std::vector<int> &missingDetectors);
/// used to check that all the monitors have the same offset time
static const float UNSETOFFSET;
......@@ -123,7 +131,7 @@ private:
WALL_THICK_TAB_NUM = 8,
};
static const int INTERVAL = 256; ///< update this many detectors before checking for user cancel messages and updating the progress bar
static const int INTERVAL = 512; ///< update this many detectors before checking for user cancel messages and updating the progress bar
};
......
......@@ -144,7 +144,7 @@ void GroupDetectors2::getGroups(Workspace2D_const_sptr workspace,
}
catch ( std::exception )
{
g_log.error() << name() << "Error reading input file " << filename << std::endl;
g_log.error() << name() << ": Error reading input file " << filename << std::endl;
throw;
}
return;
......@@ -221,7 +221,6 @@ void GroupDetectors2::processFile( std::string fname,
// allow spectra number to spectra index look ups
std::map<int,int> specs2index;
// if we could use a version of boost with bimap and converted to using it for index-spectra number lookups we wouldn't have to do this
workspace->getAxis(1)->getSpectraIndexMap(specs2index);
try
......
......@@ -166,7 +166,7 @@ public:
grouper.setPropertyValue("Workspace", m_MariWS);
grouper.setPropertyValue("DataFilename", m_RawFile);
// grouper.setPropertyValue("DataFilename", "C:/mantid/Test/Data/merlin_detector.sca");
TS_ASSERT_THROWS_NOTHING( grouper.execute());
TS_ASSERT( grouper.isExecuted() );
......@@ -176,6 +176,8 @@ public:
const int numRandom = 7;
// this arbitary list contains the first listed dectetor, last lowerest detID, largest, and a repeated value
const int randDetects[] = { 4101, 4804, 1323, 1101, 3805, 1323, 3832 };
// /*random detectors in MAP*/ {22608069, 22608073, 22608077, 22608081, 22608085, 22608089, 22608093};
// /*random detectors in MERLIN*/ {6470765, 6470769, 6470773, 6470777, 6470781, 6470785, 6470789};
for ( int i = 0; i < numRandom; ++i)
{
int detID = randDetects[i];
......@@ -194,10 +196,10 @@ public:
// compare the arrays that store the X-values for detectors but not the monitors
int firstNonMontor = 5;
// all non-monitors should shared the same array
const double& first = WS->readX(firstNonMontor)[0];
const double *first = &WS->readX(firstNonMontor)[0];
for (int i = firstNonMontor; i < WS->getNumberHistograms(); ++i)
{
TS_ASSERT_EQUALS( &first, &(WS->readX(i)[0]) )
TS_ASSERT_EQUALS( first, &(WS->readX(i)[0]) )
}/**//*
// to test Different Bins Same Offsets comment out the code above and uncomment the code below
for (int j = 0; j < WS->readX(1).size(); j++ )
......@@ -210,10 +212,12 @@ public:
// the code above proves that the X-values for each histogram are the same so just check one histogram
TS_ASSERT( WS->readX(1).size() > 0 )
double timeOff = 3.9; //MARI
// double timeOff = 5.3; //MERLIN
// the time of flight values that matter are the differences between the detector values and the monitors
for (int j = 0; j < WS->readX(1).size(); j++ )
{// we're assuming here that the second spectrum (index 1) is a monitor
TS_ASSERT_DELTA( WS->readX(1)[j] - WS->readX(firstNonMontor)[j] , 3.9, 1e-6 )
TS_ASSERT_DELTA( WS->readX(1)[j] - WS->readX(firstNonMontor)[j], timeOff, 1e-6 )
}
AnalysisDataService::Instance().remove(m_MariWS);
......@@ -236,8 +240,9 @@ public:
m_MariWS("MARfromRaw")
{
// a smallish raw file that contains the detailed detector information stored by the excitations group
m_RawFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/MAR11015.RAW").toString();
m_RawFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/MAR11015.RAW").toString();
// m_RawFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/MAP10241.RAW").toString();
// m_RawFile = Poco::Path(Poco::Path::current()).resolve("../../../../Test/Data/MER02257.RAW").toString();
// create a .dat file in the current directory that we'll load later
writeDatFile();
}
......
......@@ -401,7 +401,7 @@ std::string ShapeFactory::parseInfiniteCylinder(Poco::XML::Element* pElem, std::
*/
std::string ShapeFactory::parseCylinder(Poco::XML::Element* pElem, std::map<int, Surface*>& prim, int& l_id)
{
Element* pElemCentre = getShapeElement(pElem, "centre-of-bottom-base");
Element* pElemBase = getShapeElement(pElem, "centre-of-bottom-base");
Element* pElemAxis = getShapeElement(pElem, "axis");
Element* pElemRadius = getShapeElement(pElem, "radius");
Element* pElemHeight = getShapeElement(pElem, "height");
......@@ -415,7 +415,8 @@ std::string ShapeFactory::parseCylinder(Poco::XML::Element* pElem, std::map<int,
// add infinite cylinder
Cylinder* pCylinder = new Cylinder();
pCylinder->setCentre(parsePosition(pElemCentre));
V3D centreOfBottomBase = parsePosition(pElemBase);
pCylinder->setCentre(centreOfBottomBase+normVec*(0.5*height));
pCylinder->setNorm(normVec);
pCylinder->setRadius(radius);
prim[l_id] = pCylinder;
......@@ -426,8 +427,8 @@ std::string ShapeFactory::parseCylinder(Poco::XML::Element* pElem, std::map<int,
// add top plane
Plane* pPlaneTop = new Plane();
V3D pointInPlane = parsePosition(pElemCentre);
pointInPlane += (normVec * height); // to get point in top plane
// to get point in top plane
V3D pointInPlane = centreOfBottomBase + (normVec * height);
pPlaneTop->setPlane(pointInPlane, normVec);
prim[l_id] = pPlaneTop;
retAlgebraMatch << "-" << l_id << " ";
......@@ -435,7 +436,7 @@ std::string ShapeFactory::parseCylinder(Poco::XML::Element* pElem, std::map<int,
// add bottom plane
Plane* pPlaneBottom = new Plane();
pPlaneBottom->setPlane(parsePosition(pElemCentre), normVec);
pPlaneBottom->setPlane(centreOfBottomBase, normVec);
prim[l_id] = pPlaneBottom;
retAlgebraMatch << "" << l_id << ")";
l_id++;
......
inOutWS = "Will be deleted when DetectorEfficiencyCorrection ends"
def ApplyDetectorMask( workspace, filename ):
maskFile = open(filename, 'r')
for maskFile in f:
print maskFile
maskFile.close()
#----Start here------------------
#--Get user input
InSettings = EfficiencyScriptInputDialog(\
RawFile = "C:/mantid/Test/Data/MAP10266.RAW",\
# RawFile = "C:/mantid/Test/Data/MAP10241.RAW",\
BinBoundaries = "-50.0, 4.0, 380",\
# BinBoundaries = "-5.0, 4.0, 28",\
MapFile = "C:/Users/wht13119/Desktop/docs/Excitations/4to1.map",\
OutFile = "C:/Users/wht13119?Desktop/docs/maps.spe")
InputFN = InSettings.getPropertyValue("RawFile")
RebinBoundaries = InSettings.getPropertyValue("BinBoundaries")
DataFN = InSettings.getPropertyValue("OutFile")
try:
LoadRaw(InputFN, inOutWS)
GetEiData = GetEiDialog(inOutWS, 1000002, 1000003, 400)
#GetEiData = GetEiDialog(inOutWS, 1000002, 1000003, 30.1)
IncidentE = GetEiData.getPropertyValue("IncidentEnergy")
try:
LoadDetectorInfo(inOutWS, InputFN)
except:
print "Skipping the corrections in LoadDetectorInfo"
ConvertUnits(inOutWS, inOutWS, "DeltaE", "Direct", IncidentE, 0)
Rebin(inOutWS, "efficiencies", RebinBoundaries)
DetectorEfficiencyCor("efficiencies", inOutWS, IncidentE)
# Divide("efficiencies", inOutWS, "efficiencies")
# ApplyDetectorMask( inOutWS, InSettings.getPropertyValue("MaskFile") )
GroupDetectors( "efficiencies", "grouped", InSettings.getPropertyValue("MapFile") )
#does solid angle work OK with the masked?
SA = SolidAngle(inOutWS, "Angles")
Divide(inOutWS, SA.getPropertyValue("OutputWorkspace"), inOutWS)
# do we do a normalisation agains the monitors?
# -output to a file in ASCII
SaveSPEDialog(inOutWS, DataFN)
finally:
i = 0
# mantid.delete(inOutWS)
inOutWS = "Will be deleted when DetectorEfficiencyCorrection ends"
def ApplyDetectorMask( workspace, filename ):
maskFile = open(filename, 'r')
for maskFile in f:
print maskFile
maskFile.close()
#----Start here------------------
#--Get user input
InSettings = EfficiencyScriptInputDialog(RawFile = "C:\mantid\Test\Data\MAP10266.RAW",\
BinBoundaries = "-11.0, 0.05, 11.0",\
MapFile = "C:\Users\wht13119\Desktop\docs\Excitations\mari_res.map",\
OutFile = "C:\Users\wht13119\Desktop\docs\mari.spe")
InputFN = InSettings.getPropertyValue("RawFile")
RebinBoundaries = InSettings.getPropertyValue("BinBoundaries")
DataFN = InSettings.getPropertyValue("OutFile")
try:
LoadRaw(InputFN, inOutWS)
GetEiData = GetEiDialog(inOutWS, 2, 3, 12.98)
IncidentE = GetEiData.getPropertyValue("IncidentEnergy")
try:
LoadDetectorInfo(inOutWS, InputFN)
except:
print "Skipping the corrections in LoadDetectorInfo"
ConvertUnits(inOutWS, inOutWS, "DeltaE", "Direct", IncidentE, 0)
Rebin(inOutWS, "efficiencies", RebinBoundaries)
DetectorEfficiencyCor("efficiencies", inOutWS, IncidentE)
# Divide("efficiencies", inOutWS, "efficiencies")
# ApplyDetectorMask( inOutWS, InSettings.getPropertyValue("MaskFile") )
GroupDetectors( "efficiencies", "grouped", InSettings.getPropertyValue("MapFile") )
#does solid angle work OK with the masked?
SA = SolidAngle(inOutWS, "Angles")
Divide(inOutWS, SA.getPropertyValue("OutputWorkspace"), inOutWS)
# do we do a normalisation agains the monitors?
# -output to a file in ASCII
SaveSPEDialog(inOutWS, DataFN)
finally:
i = 0
# mantid.delete(inOutWS)
inOutWS = "Will be deleted when DetectorEfficiencyCorrection ends"
def ApplyDetectorMask( workspace, filename ):
maskFile = open(filename, 'r')
for maskFile in f:
print maskFile
maskFile.close()
#----Start here------------------
#--Get user input
InSettings = EfficiencyScriptInputDialog( \
RawFile = "C:/mantid/Test/Data/MER02257.RAW",\
BinBoundaries = "-10,0.1,35",\
MapFile="C:/Users/wht13119/Desktop/docs/Excitations/merlin.map",\
OutFile = "C:/Users/wht13119/Desktop/docs/mer.spe")
try:
LoadRaw(InSettings.getPropertyValue("RawFile"), inOutWS\
#, SpectrumMin = 69600
)
GetEiData = GetEiDialog(inOutWS, 69634, 69638, 14)
IncidentE = GetEiData.getPropertyValue("IncidentEnergy")
#LoadDetectorInfo(inOutWS, InputFN)
LoadDetectorInfo(inOutWS, "C:/mantid/Test/Data/merlin_detector.sca")
ConvertUnits(inOutWS, inOutWS, "DeltaE", "Direct", IncidentE, 0)
Rebin(inOutWS, inOutWS, InSettings.getPropertyValue("BinBoundaries"))
DetectorEfficiencyCor(inOutWS, "efficiencies", IncidentE)
# Divide("efficiencies", inOutWS, "efficiencies")
# ApplyDetectorMask( inOutWS, InSettings.getPropertyValue("MaskFile") )
GroupDetectors( inOutWS, inOutWS, InSettings.getPropertyValue("MapFile") )
#does solid angle work OK with the masked?
SA = SolidAngle(inOutWS, "Angles")
####################
Divide(inOutWS, SA.getPropertyValue("OutputWorkspace"), inOutWS)
####################
# do we do a normalisation agains the monitors?
# -output to a file in ASCII
SaveSPE(inOutWS, InSettings.getPropertyValue("OutFile"))
finally:
i = 0
# mantid.delete(inOutWS)
inOutWS = "Will be deleted when FindBadDetects ends"
def ApplyDetectorMask( workspace, filename )
maskFile = open(filename, 'r')
for maskFile in f:
print maskFile
maskFile.close()
#----Start here------------------
#--Get user input
InSettings = EfficiencyScriptInputDialog()
InputFN = InSettings.getPropertyValue("RawFile")
IncidentE = InSettings.getPropertyValue("IncidentEnergy")
RebinBoundaries = InSettings.getPropertyValue("BinBoundaries")
DataFN = InSettings.getPropertyValue("RawFile")
try:
LoadRaw(InputFN, inOutWS)
LoadDetectorInfo(inOutWS, InputFN)
IncidentE = getEiDialog(InputWorkspace = inOutWS)
ConvertUnits(inOutWS, inOutWS, "DeltaE", "Direct", IncidentE, false)
rebin(inOutWS, inOutWS, RebinBoundaries)
DetectorEfficiencyCor(inOutWS, inputWS, IncidentE, pressure of He)#default is 10 atm partial pressure of He