From f30c5a46aa33b670ab9f71249daa2ae343584fce Mon Sep 17 00:00:00 2001
From: Dennis Mikkelson <mikkelsond@uwstout.edu>
Date: Wed, 11 Jul 2012 12:24:59 -0400
Subject: [PATCH] RE 5602 Added monitor count to Peaks object

Added monitor count to IPeak.h, IPeak.cpp, Peak.h, Peak.cpp.
LoadIsawPeaks and SaveIsawPeaks also now handle the monitor count.
refs #5602
---
 .../Framework/API/inc/MantidAPI/IPeak.h       |  3 ++
 .../Framework/Crystal/src/LoadIsawPeaks.cpp   |  1 +
 .../Framework/Crystal/src/SaveIsawPeaks.cpp   |  7 ++++-
 .../DataObjects/inc/MantidDataObjects/Peak.h  |  6 ++++
 .../Mantid/Framework/DataObjects/src/Peak.cpp | 28 +++++++++++++------
 .../mantid/api/src/Exports/IPeak.cpp          |  2 ++
 6 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IPeak.h b/Code/Mantid/Framework/API/inc/MantidAPI/IPeak.h
index 4168f93c742..b783f3be255 100644
--- a/Code/Mantid/Framework/API/inc/MantidAPI/IPeak.h
+++ b/Code/Mantid/Framework/API/inc/MantidAPI/IPeak.h
@@ -33,6 +33,9 @@ namespace API
     virtual int getRunNumber() const = 0;
     virtual void setRunNumber(int m_RunNumber) = 0;
 
+    virtual double getMonitorCount() const = 0;
+    virtual void setMonitorCount(double m_MonitorCount) = 0;
+
     virtual double getH() const = 0;
     virtual double getK() const = 0;
     virtual double getL() const = 0;
diff --git a/Code/Mantid/Framework/Crystal/src/LoadIsawPeaks.cpp b/Code/Mantid/Framework/Crystal/src/LoadIsawPeaks.cpp
index f755a296423..10ecae8f373 100644
--- a/Code/Mantid/Framework/Crystal/src/LoadIsawPeaks.cpp
+++ b/Code/Mantid/Framework/Crystal/src/LoadIsawPeaks.cpp
@@ -499,6 +499,7 @@ namespace Crystal
 
         peak.setGoniometerMatrix(gonMat);
         peak.setRunNumber(run);
+        peak.setMonitorCount( monCount );
 
         double tof = peak.getTOF()+T0;
         Kernel::Units::Wavelength wl;
diff --git a/Code/Mantid/Framework/Crystal/src/SaveIsawPeaks.cpp b/Code/Mantid/Framework/Crystal/src/SaveIsawPeaks.cpp
index 16cbb78e223..4f196acac20 100644
--- a/Code/Mantid/Framework/Crystal/src/SaveIsawPeaks.cpp
+++ b/Code/Mantid/Framework/Crystal/src/SaveIsawPeaks.cpp
@@ -256,7 +256,12 @@ namespace Crystal
           out  <<  std::setw( 7 ) <<  std::fixed <<  std::setprecision( 2 )  <<  chi << " ";
           out  <<  std::setw( 7 ) <<  std::fixed <<  std::setprecision( 2 )  <<  phi << " ";
           out  <<  std::setw( 7 ) <<  std::fixed <<  std::setprecision( 2 )  <<  omega << " ";
-          out  <<  std::setw( 7 ) <<  (int)( 1 ) <<  std::endl;
+
+          // Get the monitor count from the first peak (should all be the same for one run)
+          size_t first_peak_index = ids[0];
+          Peak & first_peak = peaks[ first_peak_index ];
+          double monct = first_peak.getMonitorCount();
+          out  <<  std::setw( 7 ) <<  (int)( monct ) <<  std::endl;
 
           out << header << std::endl;
 
diff --git a/Code/Mantid/Framework/DataObjects/inc/MantidDataObjects/Peak.h b/Code/Mantid/Framework/DataObjects/inc/MantidDataObjects/Peak.h
index fc7808506de..924b90be463 100644
--- a/Code/Mantid/Framework/DataObjects/inc/MantidDataObjects/Peak.h
+++ b/Code/Mantid/Framework/DataObjects/inc/MantidDataObjects/Peak.h
@@ -50,6 +50,9 @@ namespace DataObjects
     int getRunNumber() const;
     void setRunNumber(int m_RunNumber);
 
+    double getMonitorCount() const;
+    void setMonitorCount( double m_MonitorCount );
+
     double getH() const;
     double getK() const;
     double getL() const;
@@ -147,6 +150,9 @@ namespace DataObjects
     /// Originating run number for this peak
     int m_RunNumber;
 
+    /// Integrated monitor count over TOF range for this run
+    double m_MonitorCount;
+
     /// Cached row in the detector
     int m_Row;
 
diff --git a/Code/Mantid/Framework/DataObjects/src/Peak.cpp b/Code/Mantid/Framework/DataObjects/src/Peak.cpp
index 6de74ba854a..cd235035bac 100644
--- a/Code/Mantid/Framework/DataObjects/src/Peak.cpp
+++ b/Code/Mantid/Framework/DataObjects/src/Peak.cpp
@@ -23,7 +23,7 @@ namespace DataObjects
     m_Intensity(0), m_SigmaIntensity(0), m_BinCount(0),
     m_GoniometerMatrix(3,3,true),
     m_InverseGoniometerMatrix(3,3,true),
-    m_RunNumber(0),orig_H(0),orig_K(0),orig_L(0)
+    m_RunNumber(0),m_MonitorCount(0),orig_H(0),orig_K(0),orig_L(0)
   {
   }
 
@@ -41,7 +41,7 @@ namespace DataObjects
     m_Intensity(0), m_SigmaIntensity(0), m_BinCount(0),
     m_GoniometerMatrix(3,3,true),
     m_InverseGoniometerMatrix(3,3,true),
-    m_RunNumber(0),orig_H(0),orig_K(0),orig_L(0)
+    m_RunNumber(0),m_MonitorCount(0),orig_H(0),orig_K(0),orig_L(0)
   {
     this->setInstrument(m_inst);
     this->setQLabFrame(QLabFrame, detectorDistance);
@@ -65,7 +65,7 @@ namespace DataObjects
     m_Intensity(0), m_SigmaIntensity(0), m_BinCount(0),
     m_GoniometerMatrix(goniometer),
     m_InverseGoniometerMatrix(goniometer),
-    m_RunNumber(0),orig_H(0),orig_K(0),orig_L(0)
+    m_RunNumber(0),m_MonitorCount(0),orig_H(0),orig_K(0),orig_L(0)
   {
     if(fabs(m_InverseGoniometerMatrix.Invert())<1e-8) throw std::invalid_argument("Peak::ctor(): Goniometer matrix must non-singular.");
     this->setInstrument(m_inst);
@@ -87,7 +87,7 @@ namespace DataObjects
     m_Intensity(0), m_SigmaIntensity(0), m_BinCount(0),
     m_GoniometerMatrix(3,3,true),
     m_InverseGoniometerMatrix(3,3,true),
-    m_RunNumber(0),orig_H(0),orig_K(0),orig_L(0)
+    m_RunNumber(0),m_MonitorCount(0),orig_H(0),orig_K(0),orig_L(0)
   {
     this->setInstrument(m_inst);
     this->setDetectorID(m_DetectorID);
@@ -109,7 +109,7 @@ namespace DataObjects
     m_Intensity(0), m_SigmaIntensity(0), m_BinCount(0),
     m_GoniometerMatrix(3,3,true),
     m_InverseGoniometerMatrix(3,3,true),
-    m_RunNumber(0),orig_H(0),orig_K(0),orig_L(0)
+    m_RunNumber(0),m_MonitorCount(0),orig_H(0),orig_K(0),orig_L(0)
   {
     this->setInstrument(m_inst);
     this->setDetectorID(m_DetectorID);
@@ -131,7 +131,7 @@ namespace DataObjects
     m_Intensity(0), m_SigmaIntensity(0), m_BinCount(0),
     m_GoniometerMatrix(goniometer),
     m_InverseGoniometerMatrix(goniometer),
-    m_RunNumber(0),orig_H(0),orig_K(0),orig_L(0)
+    m_RunNumber(0),m_MonitorCount(0),orig_H(0),orig_K(0),orig_L(0)
   {
     if(fabs(m_InverseGoniometerMatrix.Invert())<1e-8) throw std::invalid_argument("Peak::ctor(): Goniometer matrix must non-singular.");
     this->setInstrument(m_inst);
@@ -151,7 +151,7 @@ namespace DataObjects
     m_Intensity(0), m_SigmaIntensity(0), m_BinCount(0),
     m_GoniometerMatrix(3,3,true),
     m_InverseGoniometerMatrix(3,3,true),
-    m_RunNumber(0),orig_H(0),orig_K(0),orig_L(0)
+    m_RunNumber(0),m_MonitorCount(0),orig_H(0),orig_K(0),orig_L(0)
   {
     this->setInstrument(m_inst);
     this->setWavelength(m_Wavelength);
@@ -182,6 +182,7 @@ namespace DataObjects
     m_GoniometerMatrix(peak.m_GoniometerMatrix),
     m_InverseGoniometerMatrix(peak.m_InverseGoniometerMatrix),
     m_RunNumber(peak.m_RunNumber),
+    m_MonitorCount(peak.m_MonitorCount),
     m_Row(peak.m_Row),
     m_Col(peak.m_Col),
     sourcePos(peak.sourcePos),
@@ -210,7 +211,8 @@ namespace DataObjects
   m_FinalEnergy(ipeak.getFinalEnergy()),
   m_GoniometerMatrix(ipeak.getGoniometerMatrix()),
   m_InverseGoniometerMatrix(ipeak.getGoniometerMatrix()),
-  m_RunNumber(ipeak.getRunNumber())
+  m_RunNumber(ipeak.getRunNumber()),
+  m_MonitorCount(ipeak.getMonitorCount())
   {
     if(fabs(m_InverseGoniometerMatrix.Invert())<1e-8) throw std::invalid_argument("Peak::ctor(): Goniometer matrix must non-singular.");
     setInstrument(ipeak.getInstrument());
@@ -549,6 +551,16 @@ namespace DataObjects
   void Peak::setRunNumber(int m_RunNumber)
   {    this->m_RunNumber = m_RunNumber;  }
 
+  //----------------------------------------------------------------------------------------------
+  /** Return the monitor count stored in this peak. */
+  double Peak::getMonitorCount() const
+  {    return m_MonitorCount;  }
+
+  /** Set the monitor count for this peak 
+   * @param m_MonitorCount :: the monitor count */
+  void Peak::setMonitorCount(double m_MonitorCount)
+  {    this->m_MonitorCount = m_MonitorCount;  }
+
   //----------------------------------------------------------------------------------------------
   /** Get the ID of the detector at the center of the peak  */
   int Peak::getDetectorID() const
diff --git a/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp b/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp
index f601fafc32a..c6075247fd8 100644
--- a/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp
+++ b/Code/Mantid/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp
@@ -14,6 +14,8 @@ void export_IPeak()
     .def("setDetectorID", &IPeak::setDetectorID, "Set the detector ID and look up and cache values related to it.")
     .def("getRunNumber", &IPeak::getRunNumber, "Return the run number this peak was measured at")
     .def("setRunNumber", &IPeak::setRunNumber, "Set the run number that measured this peak")
+    .def("getMonitorCount", &IPeak::getMonitorCount, "Get the monitor count set for this peak")
+    .def("setMonitorCount", &IPeak::setMonitorCount, "Set the monitor count for this peak")
     .def("getH", &IPeak::getH, "Get the H index of the peak")
     .def("getK", &IPeak::getK, "Get the K index of the peak")
     .def("getL", &IPeak::getL, "Get the L index of the peak")
-- 
GitLab