Skip to content

Commit

Permalink
Fix cppcheck warnings in LoadMuonNexus HDF4 algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
robertapplin committed Dec 4, 2024
1 parent ebdc3cb commit e3a0c97
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 45 deletions.
23 changes: 5 additions & 18 deletions Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,7 @@ together based on the groupings in the NeXus file. </LI>
*/
class MANTID_DATAHANDLING_DLL LoadMuonNexus1 : public LoadMuonNexus {
public:
/// Default constructor
LoadMuonNexus1();
/// Algorithm's name for identification overriding a virtual method
const std::string name() const override { return "LoadMuonNexus"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "The LoadMuonNexus algorithm will read the given NeXus Muon data "
"file Version 1 and use the results to populate the named "
"workspace. LoadMuonNexus may be invoked by LoadNexus if it is "
"given a NeXus file of this type.";
}

/// Algorithm's version for identification overriding a virtual method
int version() const override { return 1; }
/// Algorithm's category for identification overriding a virtual method
const std::string category() const override { return "DataHandling\\Nexus;Muon\\DataHandling"; }

/// Returns a confidence value that this algorithm can load a file
int confidence(Kernel::NexusDescriptor &descriptor) const override;
Expand All @@ -79,7 +64,7 @@ class MANTID_DATAHANDLING_DLL LoadMuonNexus1 : public LoadMuonNexus {
void exec() override;

private:
void loadData(size_t hist, specnum_t &i, specnum_t specNo, MuonNexusReader &nxload, const int64_t lengthIn,
void loadData(size_t hist, specnum_t const &i, specnum_t specNo, MuonNexusReader &nxload, const int64_t lengthIn,
const DataObjects::Workspace2D_sptr &localWorkspace);
void runLoadMappingTable(DataObjects::Workspace2D_sptr);
void runLoadLog(const DataObjects::Workspace2D_sptr &);
Expand All @@ -91,14 +76,16 @@ class MANTID_DATAHANDLING_DLL LoadMuonNexus1 : public LoadMuonNexus {
void loadDeadTimes(Mantid::NeXus::NXRoot &root);

/// Creates Dead Time Table using all the data between begin and end
DataObjects::TableWorkspace_sptr createDeadTimeTable(std::vector<int> specToLoad, std::vector<double> deadTimes);
DataObjects::TableWorkspace_sptr createDeadTimeTable(std::vector<int> const &specToLoad,
std::vector<double> const &deadTimes);

/// Loads detector grouping information
API::Workspace_sptr loadDetectorGrouping(Mantid::NeXus::NXRoot &root,
const Mantid::Geometry::Instrument_const_sptr &inst);

/// Creates Detector Grouping Table using all the data from the range
DataObjects::TableWorkspace_sptr createDetectorGroupingTable(std::vector<int> specToLoad, std::vector<int> grouping);
DataObjects::TableWorkspace_sptr createDetectorGroupingTable(std::vector<int> const &specToLoad,
std::vector<int> const &grouping);
};

} // namespace DataHandling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,22 @@ together based on the groupings in the NeXus file. </LI>
*/
class MANTID_DATAHANDLING_DLL LoadMuonNexus2 : public LoadMuonNexus {
public:
/// Default constructor
LoadMuonNexus2();
/// Algorithm's name for identification overriding a virtual method
const std::string name() const override { return "LoadMuonNexus"; }
/// Summary of algorithms purpose

const std::string summary() const override {
return "The LoadMuonNexus algorithm will read the given NeXus Muon data "
"file Version 2 and use the results to populate the named "
"workspace. LoadMuonNexus may be invoked by LoadNexus if it is "
"given a NeXus file of this type.";
}

/// Algorithm's version for identification overriding a virtual method
int version() const override { return 2; }
const std::vector<std::string> seeAlso() const override { return {"LoadNexus"}; }
/// Algorithm's category for identification overriding a virtual method
const std::string category() const override { return "DataHandling\\Nexus;Muon\\DataHandling"; }

/// Returns a confidence value that this algorithm can load a file
int confidence(Kernel::NexusDescriptor &descriptor) const override;

private:
/// Overwrites Algorithm method
void exec() override;

HistogramData::Histogram loadData(const Mantid::HistogramData::BinEdges &edges, const Mantid::NeXus::NXInt &counts,
Expand Down
15 changes: 8 additions & 7 deletions Framework/DataHandling/src/LoadMuonNexus1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ Workspace_sptr LoadMuonNexus1::loadDetectorGrouping(NXRoot &root, const Geometry
[&groupingData](const auto spec) { return groupingData[spec - 1]; });
} else {
// User selected an entry number
for (auto &spec : specToLoad) {
for (auto const &spec : specToLoad) {
int index = spec - 1 + static_cast<int>((m_entrynumber - 1) * m_numberOfSpectra);
grouping.emplace_back(groupingData[index]);
}
Expand Down Expand Up @@ -548,7 +548,7 @@ Workspace_sptr LoadMuonNexus1::loadDetectorGrouping(NXRoot &root, const Geometry

// Get the grouping
grouping.clear();
for (auto &spec : specToLoad) {
for (auto const &spec : specToLoad) {
int index = spec - 1 + i * static_cast<int>(m_numberOfSpectra);
grouping.emplace_back(groupingData[index]);
}
Expand Down Expand Up @@ -601,7 +601,8 @@ Workspace_sptr LoadMuonNexus1::loadDetectorGrouping(NXRoot &root, const Geometry
* @param deadTimes :: vector containing the corresponding dead times
* @return Dead Time Table create using the data
*/
TableWorkspace_sptr LoadMuonNexus1::createDeadTimeTable(std::vector<int> specToLoad, std::vector<double> deadTimes) {
TableWorkspace_sptr LoadMuonNexus1::createDeadTimeTable(std::vector<int> const &specToLoad,
std::vector<double> const &deadTimes) {
TableWorkspace_sptr deadTimeTable =
std::dynamic_pointer_cast<TableWorkspace>(WorkspaceFactory::Instance().createTable("TableWorkspace"));

Expand All @@ -623,8 +624,8 @@ TableWorkspace_sptr LoadMuonNexus1::createDeadTimeTable(std::vector<int> specToL
* @param grouping :: Vector containing corresponding grouping
* @return Detector Grouping Table create using the data
*/
TableWorkspace_sptr LoadMuonNexus1::createDetectorGroupingTable(std::vector<int> specToLoad,
std::vector<int> grouping) {
TableWorkspace_sptr LoadMuonNexus1::createDetectorGroupingTable(std::vector<int> const &specToLoad,
std::vector<int> const &grouping) {
auto detectorGroupingTable =
std::dynamic_pointer_cast<TableWorkspace>(WorkspaceFactory::Instance().createTable("TableWorkspace"));

Expand All @@ -638,7 +639,7 @@ TableWorkspace_sptr LoadMuonNexus1::createDetectorGroupingTable(std::vector<int>
groupingMap[grouping[i]].emplace_back(specToLoad[i]);
}

for (auto &group : groupingMap) {
for (auto const &group : groupingMap) {
if (group.first != 0) // Skip 0 group
{
TableRow newRow = detectorGroupingTable->appendRow();
Expand All @@ -658,7 +659,7 @@ TableWorkspace_sptr LoadMuonNexus1::createDetectorGroupingTable(std::vector<int>
* @param localWorkspace :: A pointer to the workspace in which the data will
* be stored
*/
void LoadMuonNexus1::loadData(size_t hist, specnum_t &i, specnum_t specNo, MuonNexusReader &nxload,
void LoadMuonNexus1::loadData(size_t hist, specnum_t const &i, specnum_t specNo, MuonNexusReader &nxload,
const int64_t lengthIn, const DataObjects::Workspace2D_sptr &localWorkspace) {
// Read in a spectrum
// Put it into a vector, discarding the 1st entry, which is rubbish
Expand Down
12 changes: 0 additions & 12 deletions buildconfig/CMake/CppCheck_Suppressions.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -635,18 +635,6 @@ constVariableReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadMuonSt
stlIfStrFind:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRKH.cpp:521
knownConditionTrueFalse:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadNexusMonitors2.cpp:452
uselessOverride:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed2.h:38
uselessOverride:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h:60
uselessOverride:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h:62
uselessOverride:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h:70
uselessOverride:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus1.h:72
uselessOverride:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h:52
uselessOverride:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h:65
passedByValue:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadMuonNexus1.cpp:604
passedByValue:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadMuonNexus1.cpp:627
constVariableReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadMuonNexus1.cpp:519
constVariableReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadMuonNexus1.cpp:551
constVariableReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadMuonNexus1.cpp:641
constParameterReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadMuonNexus1.cpp:661
constParameterReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadTBL.cpp:133
constVariableReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadPreNexus.cpp:244
returnByReference:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h:30
Expand Down

0 comments on commit e3a0c97

Please sign in to comment.