Newer
Older
Janik Zikovsky
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "MantidAPI/ISpectrum.h"
#include "MantidKernel/System.h"
namespace Mantid
{
namespace API
{
//----------------------------------------------------------------------------------------------
/** Constructor
*/
ISpectrum::ISpectrum()
: m_specNo(0),
detectorIDs(), refX(), refDx()
{
}
/** Constructor with spectrum number
* @param specNo :: spectrum # of the spectrum
*/
ISpectrum::ISpectrum(const specid_t specNo)
: m_specNo(specNo),
detectorIDs(), refX(), refDx()
{
}
//----------------------------------------------------------------------------------------------
/** Copy constructor
*/
ISpectrum::ISpectrum(const ISpectrum& other)
: m_specNo(other.m_specNo), detectorIDs(other.detectorIDs),
refX(other.refX), refDx(other.refDx)
{
}
//----------------------------------------------------------------------------------------------
/** Copy spectrum number and detector IDs, but not X vector, from another ISpectrum
*
* @param other :: take the values from other, put them in this
*/
void ISpectrum::copyInfoFrom(const ISpectrum& other)
{
m_specNo = other.m_specNo;
detectorIDs = other.detectorIDs;
}
//----------------------------------------------------------------------------------------------
/** Destructor
*/
ISpectrum::~ISpectrum()
{
}
// =============================================================================================
/// Sets the x data.
/// @param X :: vector of X data
void ISpectrum::setX(const MantidVec& X)
{ refX.access()=X; }
/// Sets the x error data.
/// @param Dx :: vector of X error data
void ISpectrum::setDx(const MantidVec& Dx)
{ refDx.access()=Dx; }
/// Sets the x data.
/// @param X :: vector of X data
void ISpectrum::setX(const MantidVecPtr& X)
{ refX=X; }
/// Sets the x error data.
/// @param Dx :: vector of X error data
void ISpectrum::setDx(const MantidVecPtr& Dx)
{ refDx=Dx; }
/// Sets the x data
Janik Zikovsky
committed
void ISpectrum::setX(const MantidVecPtr::ptr_type& X)
{ refX=X; }
/// Sets the x data error
/// @param Dx :: vector of X error data
void ISpectrum::setDx(const MantidVecPtr::ptr_type& Dx)
{refDx=Dx;}
// =============================================================================================
///Returns the x data
MantidVec& ISpectrum::dataX()
{ return refX.access(); }
///Returns the x error data
MantidVec& ISpectrum::dataDx()
{ return refDx.access(); }
/// Returns the x data const
const MantidVec& ISpectrum::dataX() const
{ return *refX; }
/// Returns the x error data const
const MantidVec& ISpectrum::dataDx() const
{ return *refDx; }
/// Returns the x data const
const MantidVec& ISpectrum::readX() const
{ return *refX; }
/// Returns the x error data const
const MantidVec& ISpectrum::readDx() const
{ return *refDx; }
/// Returns the y data const
const MantidVec& ISpectrum::readY() const
{ return this->dataY(); }
/// Returns the y error data const
const MantidVec& ISpectrum::readE() const
{ return this->dataE(); }
Janik Zikovsky
committed
/// Returns a pointer to the x data
MantidVecPtr ISpectrum::ptrX() const
{ return refX; }
// =============================================================================================
// --------------------------------------------------------------------------
/** Add a detector ID to the set of detector IDs
*
* @param detID :: detector ID to insert in set.
*/
void ISpectrum::addDetectorID(const detid_t detID)
{
this->detectorIDs.insert( detID );
}
/** Add a set of detector IDs to the set of detector IDs
*
* @param detIDs :: set of detector IDs to insert in set.
Janik Zikovsky
committed
*/
void ISpectrum::addDetectorIDs(const std::set<detid_t> detIDs)
{
if (detIDs.size() == 0) return;
this->detectorIDs.insert( detIDs.begin(), detIDs.end() );
}
/** Add a vector of detector IDs to the set of detector IDs
*
* @param detIDs :: vector of detector IDs to insert in set.
Janik Zikovsky
committed
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
*/
void ISpectrum::addDetectorIDs(const std::vector<detid_t> detIDs)
{
if (detIDs.size() == 0) return;
this->detectorIDs.insert( detIDs.begin(), detIDs.end() );
}
// --------------------------------------------------------------------------
/** Clear the list of detector IDs, then add one.
*
* @param detID :: detector ID to insert in set.
*/
void ISpectrum::setDetectorID(const detid_t detID)
{
this->detectorIDs.clear();
this->detectorIDs.insert( detID );
}
// --------------------------------------------------------------------------
/** Return true if the given detector ID is in the list for this ISpectrum */
bool ISpectrum::hasDetectorID(const detid_t detID) const
{
return ( detectorIDs.find(detID) != detectorIDs.end() );
}
// --------------------------------------------------------------------------
/** Get a const reference to the detector IDs set.
*/
const std::set<detid_t>& ISpectrum::getDetectorIDs() const
{
return this->detectorIDs;
}
// --------------------------------------------------------------------------
/** Clear the detector IDs set.
*/
void ISpectrum::clearDetectorIDs()
{
this->detectorIDs.clear();
return;
}
// --------------------------------------------------------------------------
/** Get a mutable reference to the detector IDs set.
*/
std::set<detid_t>& ISpectrum::getDetectorIDs()
{
return this->detectorIDs;
}
// ---------------------------------------------------------
/// @return the spectrum number of this spectrum
specid_t ISpectrum::getSpectrumNo() const
{
return m_specNo;
}
/** Sets the the spectrum number of this spectrum
* @param num :: the spectrum number of this spectrum */
void ISpectrum::setSpectrumNo(specid_t num)
{
m_specNo = num;
}
} // namespace Mantid
} // namespace API