Skip to content

Commit

Permalink
Refs #8550. Removed unused functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Dec 9, 2013
1 parent d55eb1e commit 432974f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 251 deletions.
Expand Up @@ -247,9 +247,6 @@ private slots:
void createPlotWS(const std::string& groupName,
const std::string& inputWS, const std::string& outWS);

/// Apply whatever grouping is specified in GUI tables to workspace
bool applyGroupingToWS( const std::string& inputWS, const std::string& outputWS);

/// Update front
void updateFront();

Expand Down Expand Up @@ -399,10 +396,6 @@ private slots:
/// Get the new plot name
QString getNewPlotName(const QString & cropWSfirstPart);

/// set grouping in table from information from nexus raw file
void setGroupingFromNexus(const QString& nexusFile);


/// title of run
std::string m_title;

Expand Down
244 changes: 0 additions & 244 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp
Expand Up @@ -2475,89 +2475,6 @@ bool MuonAnalysis::isGroupingSet()
return true;
}

/**
* Apply whatever grouping is specified in GUI tables to workspace.
*/
bool MuonAnalysis::applyGroupingToWS( const std::string& inputWsName, const std::string& outputWsName)
{
if (!isGroupingSet() || !AnalysisDataService::Instance().doesExist(inputWsName))
return false;

std::string complaint = isGroupingAndDataConsistent();
if (!( complaint.empty() ) )
{
if (m_uiForm.frontPlotButton->isEnabled() )
QMessageBox::warning(this, "MantidPlot - MuonAnalysis", complaint.c_str());
m_optionTab->noDataAvailable();
return false;
}
else
{
if (!m_uiForm.frontPlotButton->isEnabled() )
m_optionTab->nowDataAvailable();
}

// If output workspace exists, remove explicitly, so even if something goes wrong - old data
// is not used
if(AnalysisDataService::Instance().doesExist(outputWsName))
{
// Using DeleteWorkspace algorithm so if outputWs is a group - it is fully removed
Mantid::API::IAlgorithm_sptr rmWs = AlgorithmManager::Instance().create("DeleteWorkspace");
rmWs->initialize();
rmWs->setPropertyValue("Workspace", outputWsName);
rmWs->execute();
}

Grouping tableGrouping;
parseGroupingTable(m_uiForm, tableGrouping);

// Retrieve input workspace
Workspace_sptr inputWs = AnalysisDataService::Instance().retrieve(inputWsName);

Workspace_sptr outputWs;

try // ... to group
{
// Single workspace
if(MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>(inputWs))
{
outputWs = groupWorkspace(ws, tableGrouping);
}
// Workspace group
else if(WorkspaceGroup_sptr group = boost::dynamic_pointer_cast<WorkspaceGroup>(inputWs))
{
// Create output group
WorkspaceGroup_sptr outputGroup = boost::make_shared<WorkspaceGroup>();

for(size_t i = 0; i < group->size(); i++)
{
if(MatrixWorkspace_sptr member = boost::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(i)))
{
MatrixWorkspace_sptr groupedMember = groupWorkspace(member, tableGrouping);

outputGroup->addWorkspace(groupedMember);
}
else
throw std::invalid_argument("Group contains unsupported workspace type");
}

outputWs = outputGroup;
}
else
throw std::invalid_argument("Unsupported workspace type");
}
catch(std::exception& e)
{
m_optionTab->noDataAvailable();
g_log.error(e.what());
return false;
}

AnalysisDataService::Instance().add(outputWsName, outputWs);

return true;
}

/**
* Calculate number of detectors from string of type 1-3, 5, 10-15
*
Expand Down Expand Up @@ -2767,167 +2684,6 @@ void MuonAnalysis::startUpLook()
}
}

/**
* set grouping in table from information from nexus raw file
*/
void MuonAnalysis::setGroupingFromNexus(const QString& nexusFile)
{
if ( isGroupingSet() )
return;

std::string groupedWS = m_workspace_name+"Grouped";

// Setup Load Nexus Algorithm
Mantid::API::IAlgorithm_sptr loadMuonAlg = Mantid::API::AlgorithmManager::Instance().create("LoadMuonNexus");
loadMuonAlg->setPropertyValue("Filename", nexusFile.toStdString());
loadMuonAlg->setPropertyValue("OutputWorkspace", groupedWS);
loadMuonAlg->setProperty("AutoGroup", true);
if (! (loadMuonAlg->execute() ) )
{
QMessageBox::warning(this,"Mantid - MuonAnalysis", "Problem when executing LoadMuonNexus algorithm.");
}

// get hold of a matrix-workspace. If period data assume each period has
// the same grouping
Workspace_sptr ws_ptr = AnalysisDataService::Instance().retrieve(groupedWS);
WorkspaceGroup_sptr wsPeriods = boost::dynamic_pointer_cast<WorkspaceGroup>(ws_ptr);
MatrixWorkspace_sptr matrix_workspace;
if (wsPeriods)
{
Workspace_sptr ws_ptr1 = AnalysisDataService::Instance().retrieve(groupedWS + "_1");
matrix_workspace = boost::dynamic_pointer_cast<MatrixWorkspace>(ws_ptr1);
}
else
{
matrix_workspace = boost::dynamic_pointer_cast<MatrixWorkspace>(ws_ptr);
}

// check if there is any grouping in file
bool thereIsGrouping = false;
int numOfHist = static_cast<int>(matrix_workspace->getNumberHistograms()); //Qt has no size_t understanding
for (int wsIndex = 0; wsIndex < numOfHist; wsIndex++)
{
IDetector_const_sptr det;
try // for some bizarry reason when reading EMUautorun_A.tmp this
// underlying nexus file think there are more histogram than there is
// hence the reason for this try/catch here
{
det = matrix_workspace->getDetector(wsIndex);
}
catch (...)
{
break;
}

if( boost::dynamic_pointer_cast<const DetectorGroup>(det) )
{
// prepare IDs string

boost::shared_ptr<const DetectorGroup> detG = boost::dynamic_pointer_cast<const DetectorGroup>(det);
std::vector<Mantid::detid_t> detIDs = detG->getDetectorIDs();
if (detIDs.size() > 1)
{
thereIsGrouping = true;
break;
}
}
}

// if no grouping in nexus then return
if ( thereIsGrouping == false )
{
return;
}

// Add info about grouping from Nexus file to group table
for (int wsIndex = 0; wsIndex < numOfHist; wsIndex++)
{
IDetector_const_sptr det = matrix_workspace->getDetector(wsIndex);

if( boost::dynamic_pointer_cast<const DetectorGroup>(det) )
{
// prepare IDs string

boost::shared_ptr<const DetectorGroup> detG = boost::dynamic_pointer_cast<const DetectorGroup>(det);
std::vector<Mantid::detid_t> detIDs = detG->getDetectorIDs();
std::stringstream idstr;
int leftInt = detIDs[0]; // meaning left as in the left number of the range 8-18 for instance
int numIDs = static_cast<int>(detIDs.size());
idstr << detIDs[0];
for (int i = 1; i < numIDs; i++)
{
if (detIDs[i] != detIDs[i-1]+1 )
{
if (detIDs[i-1] == leftInt)
{
idstr << ", " << detIDs[i];
leftInt = detIDs[i];
}
else
{
idstr << "-" << detIDs[i-1] << ", " << detIDs[i];
leftInt = detIDs[i];
}
}
else if ( i == numIDs-1 )
{
idstr << "-" << detIDs[i];
}
}

// prepare group name string

std::stringstream gName;
gName << wsIndex;

// create table row
QTableWidgetItem* it = m_uiForm.groupTable->item(wsIndex, 0);
if (it)
it->setText(gName.str().c_str());
else
{
m_uiForm.groupTable->setItem(wsIndex, 0, new QTableWidgetItem(gName.str().c_str()));
}

it = m_uiForm.groupTable->item(wsIndex, 1);
if (it)
it->setText(idstr.str().c_str());
else
m_uiForm.groupTable->setItem(wsIndex, 1, new QTableWidgetItem(idstr.str().c_str()));
}
} // end loop over wsIndex

// check if exactly two groups added in which case assume these are forward/backward groups
// and automatically then create a pair from which, where the first group is assumed to be
// the forward group

updatePairTable();
if ( numGroups() == 2 && numPairs() <= 0 )
{
QTableWidgetItem* it = m_uiForm.pairTable->item(0, 0);
if (it)
it->setText("pair");
else
{
m_uiForm.pairTable->setItem(0, 0, new QTableWidgetItem("long"));
}
it = m_uiForm.pairTable->item(0, 3);
if (it)
it->setText("1.0");
else
{
m_uiForm.pairTable->setItem(0, 3, new QTableWidgetItem("1.0"));
}
updatePairTable();
updateFrontAndCombo();
m_uiForm.frontGroupGroupPairComboBox->setCurrentIndex(2);
runFrontGroupGroupPairComboBox(2);
}
updatePairTable();
updateFrontAndCombo();
}


/**
* If nothing else work set dummy grouping and display comment to user
*/
Expand Down

0 comments on commit 432974f

Please sign in to comment.