Skip to content

Commit

Permalink
Solved a namespace issue. Refs #9326.
Browse files Browse the repository at this point in the history
  • Loading branch information
wdzhou committed Apr 21, 2014
1 parent d936208 commit 021fb0c
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 71 deletions.
6 changes: 3 additions & 3 deletions Code/Mantid/Framework/Algorithms/CMakeLists.txt
Expand Up @@ -30,6 +30,7 @@ set ( SRC_FILES
src/ChangePulsetime.cpp
src/CheckWorkspacesMatch.cpp
src/ChopData.cpp
src/ChopEventFilters.cpp
src/ClearMaskFlag.cpp
src/CloneWorkspace.cpp
src/CommutativeBinaryOperation.cpp
Expand Down Expand Up @@ -224,14 +225,12 @@ set ( SRC_FILES
src/WeightingStrategy.cpp
src/WorkspaceJoiners.cpp
src/XDataConverter.cpp
src/ChopEventFilters.cpp
)

set ( INC_FILES
# inc/MantidAlgorithms/Q1DTOF.h
# inc/MantidAlgorithms/CountEventsInPulses.h
# inc/MantidAlgorithms/UpdatePeakParameterTable.h
inc/MantidAlgorithms/ChopEventFilters.h
inc/MantidAlgorithms/AbsorptionCorrection.h
inc/MantidAlgorithms/AddLogDerivative.h
inc/MantidAlgorithms/AddPeak.h
Expand Down Expand Up @@ -260,6 +259,7 @@ set ( INC_FILES
inc/MantidAlgorithms/ChangePulsetime.h
inc/MantidAlgorithms/CheckWorkspacesMatch.h
inc/MantidAlgorithms/ChopData.h
inc/MantidAlgorithms/ChopEventFilters.h
inc/MantidAlgorithms/ClearMaskFlag.h
inc/MantidAlgorithms/CloneWorkspace.h
inc/MantidAlgorithms/CommutativeBinaryOperation.h
Expand Down Expand Up @@ -500,6 +500,7 @@ set ( TEST_FILES
ChangePulsetimeTest.h
CheckWorkspacesMatchTest.h
ChopDataTest.h
ChopEventFiltersTest.h
ClearMaskFlagTest.h
CloneWorkspaceTest.h
CommutativeBinaryOperationTest.h
Expand Down Expand Up @@ -672,7 +673,6 @@ set ( TEST_FILES
WeightingStrategyTest.h
WorkspaceCreationHelperTest.h
WorkspaceGroupTest.h
ChopEventFiltersTest.h
)

set ( TEST_PY_FILES NormaliseToUnityTest.py )
Expand Down
Expand Up @@ -2,44 +2,41 @@
#define MANTID_ALGORITHMS_CHOPEVENTFILTERS_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/Algorithm.h"


namespace Mantid
{
namespace Algorithms
{

/**
* Add a peak to a PeaksWorkspace.
@date 2012-10-16
Copyright © 2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport ChopEventFilters : public API::Algorithm
/** ChopEventFilters : TODO: DESCRIPTION
Copyright &copy; 2014 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport ChopEventFilters : public API::Algorithm
{
public:
ChopEventFilters();
~ChopEventFilters();
virtual ~ChopEventFilters();

/// Algorithm's name for identification
virtual const std::string name() const { return "ChopEventFilters";};
Expand Down Expand Up @@ -80,8 +77,8 @@ namespace Algorithms

};

} // namespace Mantid
} // namespace Algorithms

} // namespace Algorithms
} // namespace Mantid

#endif /* MANTID_ALGORITHMS_CHOPEVENTFILTERS_H_ */
64 changes: 36 additions & 28 deletions Code/Mantid/Framework/Algorithms/src/ChopEventFilters.cpp
@@ -1,26 +1,25 @@
/* WIKI
Develop time: P0 (45min) +
/*WIKI*
Develop time: P0 (45min) +
== Divide splitter by time ==
* Required:
1. WorkspaceGroup (wg)
2. Number of time slots (N)
3. Index of time slot (i)
* Algorithm:
For each splitter (t_i^(s), t_i^(e)) corresponding to workspace group, wg,
a new splitter will be generated as
For each splitter (t_i^(s), t_i^(e)) corresponding to workspace group, wg,
a new splitter will be generated as
T_i^(s) = t_i^(s) + deltaT \cdot i
T_i^(e) = t_i^(s) + deltaT \cdot (i+1)
where
deltaT = (t_i^(e) - t_i^(s))/N
WIKI*/
*WIKI*/

#include "MantidAlgorithms/ChopEventFilters.h"
#include "MantidKernel/System.h"
#include "MantidAPI/WorkspaceProperty.h"
#include "MantidAPI/WorkspaceValidators.h"
#include "MantidAPI/WorkspaceFactory.h"
Expand All @@ -29,7 +28,6 @@ namespace Mantid
{
namespace Algorithms
{

using namespace Mantid::API;
using namespace Mantid::Kernel;

Expand All @@ -39,10 +37,17 @@ namespace Algorithms

DECLARE_ALGORITHM(ChopEventFilters)


//----------------------------------------------------------------------------------------------
/** Constructor
*/
ChopEventFilters::ChopEventFilters()
{
}


//----------------------------------------------------------------------------------------------
/** Destructor
*/
ChopEventFilters::~ChopEventFilters()
{
}
Expand All @@ -61,15 +66,15 @@ namespace Algorithms
{
declareProperty(new WorkspaceProperty<MatrixWorkspace>("InputWorkspace", "", Direction::Input),
"Name of input event filter workspace to be processed.");

declareProperty(new WorkspaceProperty<MatrixWorkspace>("OutputWorkspace", "", Direction::Output),
"Name of the output event filter workspace as a result of processing.");

declareProperty("WorkspaceGroup", EMPTY_INT(), "Workspace group of the evnet filers to be processed.");

// FIXME - Need a validator for integer range
declareProperty("NumberOfSlots", 2, "Number of time slots for an individual filter to split to. ");

// FIXME - Need a validator for slot index
declareProperty("IndexOfSlot", EMPTY_INT(), "Index of the time slot to be kept.");

Expand All @@ -81,10 +86,10 @@ namespace Algorithms
{
// Process inputs
processAlgProperties();

// Calculating splitted
chopEventFilterByTime();

// Finale
if (m_outputWS) setProperty("OutputWorkspace", m_outputWS);
else throw std::runtime_error("Output workspace is a null pointer.");
Expand All @@ -97,13 +102,13 @@ namespace Algorithms
void ChopEventFilters::processAlgProperties()
{
m_inputWS = getProperty("InputWorkspace");

m_wsGroup = getProperty("WorkspaceGroup");
if (isEmpty(m_wsGroup))
throw std::runtime_error("Workspace must be given.");

m_numSlots = getProperty("NumberOfSlots");

m_slotIndex = getProperty("IndexOfSlot");
if (m_slotIndex >= m_numSlots)
throw std::runtime_error("Slot index is out of boundary as number of slots.");
Expand All @@ -123,7 +128,7 @@ namespace Algorithms
{
throw runtime_error("Input workspace is wrong at x and y's sizes.");
}

// Find out splitters with matched workspace group
double invertN = 1./static_cast<double> (m_numSlots);
double slotindex_d = static_cast<double> (m_slotIndex);
Expand Down Expand Up @@ -172,7 +177,7 @@ namespace Algorithms
}

} /// END(for i)

// Check
if (m_outX.size() == 0)
{
Expand All @@ -181,7 +186,7 @@ namespace Algorithms
<< m_wsGroup << ", as user specified. ";
throw runtime_error(errss.str());
}

// Build output workspace group
size_t nspec = 1;
size_t sizey = m_outY.size();
Expand All @@ -194,9 +199,12 @@ namespace Algorithms
dataY[i] = m_outY[i];
}
dataX[sizey] = m_outX[sizey];

return;
}

}
}



} // namespace Algorithms
} // namespace Mantid
22 changes: 13 additions & 9 deletions Code/Mantid/Framework/Algorithms/test/ChopEventFiltersTest.h
@@ -1,5 +1,5 @@
#ifndef MANTID_ALGORITHMS_CHOPEVENTFILTERS_H_
#define MANTID_ALGORITHMS_CHOPEVENTFILTERS_H_
#ifndef MANTID_ALGORITHMS_CHOPEVENTFILTERSTEST_H_
#define MANTID_ALGORITHMS_CHOPEVENTFILTERSTEST_H_

#include <cxxtest/TestSuite.h>

Expand All @@ -12,11 +12,9 @@
using Mantid::Algorithms::ChopEventFilters;

using namespace Mantid;
using namespace Mantid::Algorithms;
using namespace Mantid::API;
using namespace Mantid::Kernel;
using namespace Mantid::DataObjects;

using namespace std;

class ChopEventFiltersTest : public CxxTest::TestSuite
{
Expand All @@ -30,6 +28,12 @@ class ChopEventFiltersTest : public CxxTest::TestSuite
}
static void destroySuite( ChopEventFiltersTest *suite ) { delete suite; }


void test_Something()
{
TSM_ASSERT( "You forgot to write a test!", 0);
}

//----------------------------------------------------------------------------------------------
/** Test on init and setup
*/
Expand Down Expand Up @@ -57,8 +61,8 @@ class ChopEventFiltersTest : public CxxTest::TestSuite

return;
}


//----------------------------------------------------------------------------------------------
/** Test on init and setup
*/
Expand Down Expand Up @@ -112,7 +116,7 @@ class ChopEventFiltersTest : public CxxTest::TestSuite
*/
MatrixWorkspace_sptr gen_Splitters()
{
vector<double> vecx, vecy, vece;
std::vector<double> vecx, vecy, vece;

vecx.push_back(10000); vecy.push_back(1.000000 ); vece.push_back(1.00000E+00);
vecx.push_back(20000); vecy.push_back(0.000000 ); vece.push_back(1.00000E+00);
Expand Down Expand Up @@ -151,4 +155,4 @@ class ChopEventFiltersTest : public CxxTest::TestSuite
};


#endif /* MANTID_ALGORITHMS_CHOPEVENTFILTERS_H_ */
#endif /* MANTID_ALGORITHMS_CHOPEVENTFILTERSTEST_H_ */

0 comments on commit 021fb0c

Please sign in to comment.