Peak.cpp 41.6 KB
Newer Older
1
#include "MantidDataObjects/Peak.h"
2
#include "MantidDataObjects/NoShape.h"
3
#include "MantidGeometry/Instrument/RectangularDetector.h"
4
#include "MantidGeometry/Instrument/ReferenceFrame.h"
5
#include "MantidGeometry/Objects/InstrumentRayTracer.h"
6
#include "MantidKernel/ConfigService.h"
7
#include "MantidKernel/Exception.h"
Janik Zikovsky's avatar
Janik Zikovsky committed
8
9
#include "MantidKernel/Strings.h"
#include "MantidKernel/System.h"
10

11
#include "boost/make_shared.hpp"
Lynch, Vickie's avatar
Lynch, Vickie committed
12
#include <boost/math/special_functions/round.hpp>
13

14
15
#include <algorithm>
#include <cctype>
Janik Zikovsky's avatar
Janik Zikovsky committed
16
#include <string>
17

18
19
20
21
using namespace Mantid;
using namespace Mantid::Kernel;
using namespace Mantid::Geometry;

22
23
24
25
26
27
namespace Mantid {
namespace DataObjects {

//----------------------------------------------------------------------------------------------
/** Default constructor */
Peak::Peak()
28
29
30
31
32
    : m_detectorID(-1), m_H(0), m_K(0), m_L(0), m_intensity(0),
      m_sigmaIntensity(0), m_binCount(0), m_initialEnergy(0.),
      m_finalEnergy(0.), m_GoniometerMatrix(3, 3, true),
      m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
      m_row(-1), m_col(-1), m_orig_H(0), m_orig_K(0), m_orig_L(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
33
      m_peakNumber(0), m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{ {0, 0, 0} },
Lynch, Vickie's avatar
Lynch, Vickie committed
34
      m_peakShape(boost::make_shared<NoShape>()) {
Lynch, Vickie's avatar
Lynch, Vickie committed
35
36
  convention = Kernel::ConfigService::Instance().getString("Q.convention");
}
37
38
39
40
41
42
43

//----------------------------------------------------------------------------------------------
/** Constructor that uses the Q position of the peak (in the lab frame).
 * No detector ID is set.
 *
 * @param m_inst :: Shared pointer to the instrument for this peak detection
 * @param QLabFrame :: Q of the center of the peak, in reciprocal space
44
45
 * @param detectorDistance :: Optional distance between the sample and the
 *detector. Calculated if not explicitly provided.
46
47
 *        Used to give a valid TOF. Default 1.0 meters.
 */
48
49
Peak::Peak(const Geometry::Instrument_const_sptr &m_inst,
           const Mantid::Kernel::V3D &QLabFrame,
Hahn, Steven's avatar
Hahn, Steven committed
50
           boost::optional<double> detectorDistance)
51
52
53
    : m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0),
      m_binCount(0), m_GoniometerMatrix(3, 3, true),
      m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
54
      m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
55
      m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{ {0, 0, 0} }, 
Lynch, Vickie's avatar
Lynch, Vickie committed
56
      m_peakShape(boost::make_shared<NoShape>()) {
Lynch, Vickie's avatar
Lynch, Vickie committed
57
  convention = Kernel::ConfigService::Instance().getString("Q.convention");
58
59
60
61
62
63
64
65
66
67
68
69
70
  this->setInstrument(m_inst);
  this->setQLabFrame(QLabFrame, detectorDistance);
}

//----------------------------------------------------------------------------------------------
/** Constructor that uses the Q position of the peak (in the sample frame)
 * and a goniometer rotation matrix.
 * No detector ID is set.
 *
 * @param m_inst :: Shared pointer to the instrument for this peak detection
 * @param QSampleFrame :: Q of the center of the peak, in reciprocal space, in
 *the sample frame (goniometer rotation accounted for).
 * @param goniometer :: a 3x3 rotation matrix
71
72
 * @param detectorDistance :: Optional distance between the sample and the
 *detector. Calculated if not explicitly provided.
73
74
 *        Used to give a valid TOF. Default 1.0 meters.
 */
75
76
77
Peak::Peak(const Geometry::Instrument_const_sptr &m_inst,
           const Mantid::Kernel::V3D &QSampleFrame,
           const Mantid::Kernel::Matrix<double> &goniometer,
Hahn, Steven's avatar
Hahn, Steven committed
78
           boost::optional<double> detectorDistance)
79
80
81
    : m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0),
      m_binCount(0), m_GoniometerMatrix(goniometer),
      m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
82
      m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
83
      m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{ {0, 0, 0} }, 
Lynch, Vickie's avatar
Lynch, Vickie committed
84
      m_peakShape(boost::make_shared<NoShape>()) {
Lynch, Vickie's avatar
Lynch, Vickie committed
85
  convention = Kernel::ConfigService::Instance().getString("Q.convention");
86
87
88
89
90
91
92
93
94
95
96
  if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8)
    throw std::invalid_argument(
        "Peak::ctor(): Goniometer matrix must non-singular.");
  this->setInstrument(m_inst);
  this->setQSampleFrame(QSampleFrame, detectorDistance);
}

//----------------------------------------------------------------------------------------------
/** Constructor
 *
 * @param m_inst :: Shared pointer to the instrument for this peak detection
97
 * @param m_detectorID :: ID to the detector of the center of the peak
98
99
100
 * @param m_Wavelength :: incident neutron wavelength, in Angstroms
 * @return
 */
101
Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
102
           double m_Wavelength)
103
104
105
    : m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0),
      m_binCount(0), m_GoniometerMatrix(3, 3, true),
      m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
106
      m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
107
      m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{ {0, 0, 0} }, 
Lynch, Vickie's avatar
Lynch, Vickie committed
108
      m_peakShape(boost::make_shared<NoShape>()) {
Lynch, Vickie's avatar
Lynch, Vickie committed
109
  convention = Kernel::ConfigService::Instance().getString("Q.convention");
110
  this->setInstrument(m_inst);
111
  this->setDetectorID(m_detectorID);
112
113
114
115
116
117
118
  this->setWavelength(m_Wavelength);
}

//----------------------------------------------------------------------------------------------
/** Constructor
 *
 * @param m_inst :: Shared pointer to the instrument for this peak detection
119
 * @param m_detectorID :: ID to the detector of the center of the peak
120
121
122
123
 * @param m_Wavelength :: incident neutron wavelength, in Angstroms
 * @param HKL :: vector with H,K,L position of the peak
 * @return
 */
124
125
Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
           double m_Wavelength, const Mantid::Kernel::V3D &HKL)
126
127
128
    : m_H(HKL[0]), m_K(HKL[1]), m_L(HKL[2]), m_intensity(0),
      m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(3, 3, true),
      m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
129
      m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
130
      m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{ {0, 0, 0} }, 
Lynch, Vickie's avatar
Lynch, Vickie committed
131
      m_peakShape(boost::make_shared<NoShape>()) {
Lynch, Vickie's avatar
Lynch, Vickie committed
132
  convention = Kernel::ConfigService::Instance().getString("Q.convention");
133
  this->setInstrument(m_inst);
134
  this->setDetectorID(m_detectorID);
135
136
137
138
139
140
141
  this->setWavelength(m_Wavelength);
}

//----------------------------------------------------------------------------------------------
/** Constructor
 *
 * @param m_inst :: Shared pointer to the instrument for this peak detection
142
 * @param m_detectorID :: ID to the detector of the center of the peak
143
144
145
146
147
 * @param m_Wavelength :: incident neutron wavelength, in Angstroms
 * @param HKL :: vector with H,K,L position of the peak
 * @param goniometer :: a 3x3 rotation matrix
 * @return
 */
148
149
150
Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
           double m_Wavelength, const Mantid::Kernel::V3D &HKL,
           const Mantid::Kernel::Matrix<double> &goniometer)
151
152
153
    : m_H(HKL[0]), m_K(HKL[1]), m_L(HKL[2]), m_intensity(0),
      m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(goniometer),
      m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
154
      m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
155
      m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{ {0, 0, 0} }, 
Lynch, Vickie's avatar
Lynch, Vickie committed
156
      m_peakShape(boost::make_shared<NoShape>()) {
Lynch, Vickie's avatar
Lynch, Vickie committed
157
  convention = Kernel::ConfigService::Instance().getString("Q.convention");
158
159
160
161
  if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8)
    throw std::invalid_argument(
        "Peak::ctor(): Goniometer matrix must non-singular.");
  this->setInstrument(m_inst);
162
  this->setDetectorID(m_detectorID);
163
164
165
166
167
168
169
170
171
172
  this->setWavelength(m_Wavelength);
}
//----------------------------------------------------------------------------------------------
/** Constructor
 *
 * @param m_inst :: Shared pointer to the instrument for this peak detection
 * @param scattering :: fake detector position using scattering angle
 * @param m_Wavelength :: incident neutron wavelength, in Angstroms
 * @return
 */
173
Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, double scattering,
174
           double m_Wavelength)
175
176
177
178
    : m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0),
      m_binCount(0), m_GoniometerMatrix(3, 3, true),
      m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
      m_row(-1), m_col(-1), m_orig_H(0), m_orig_K(0), m_orig_L(0),
Lynch, Vickie's avatar
Lynch, Vickie committed
179
      m_peakNumber(0), m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{ {0, 0, 0} }, 
Lynch, Vickie's avatar
Lynch, Vickie committed
180
      m_peakShape(boost::make_shared<NoShape>()) {
Lynch, Vickie's avatar
Lynch, Vickie committed
181
  convention = Kernel::ConfigService::Instance().getString("Q.convention");
182
183
  this->setInstrument(m_inst);
  this->setWavelength(m_Wavelength);
184
  m_detectorID = -1;
185
186
187
  // get the approximate location of the detector
  const auto detectorDir = V3D(sin(scattering), 0.0, cos(scattering));
  detPos = getVirtualDetectorPosition(detectorDir);
188
189
}

190
191
192
193
194
195
/**
 * @brief Copy constructor
 * @param other : Source
 * @return
 */
Peak::Peak(const Peak &other)
196
197
198
199
200
201
    : m_inst(other.m_inst), m_det(other.m_det), m_bankName(other.m_bankName),
      m_detectorID(other.m_detectorID), m_H(other.m_H), m_K(other.m_K),
      m_L(other.m_L), m_intensity(other.m_intensity),
      m_sigmaIntensity(other.m_sigmaIntensity), m_binCount(other.m_binCount),
      m_initialEnergy(other.m_initialEnergy),
      m_finalEnergy(other.m_finalEnergy),
202
203
      m_GoniometerMatrix(other.m_GoniometerMatrix),
      m_InverseGoniometerMatrix(other.m_InverseGoniometerMatrix),
204
205
206
207
      m_runNumber(other.m_runNumber), m_monitorCount(other.m_monitorCount),
      m_row(other.m_row), m_col(other.m_col), sourcePos(other.sourcePos),
      samplePos(other.samplePos), detPos(other.detPos),
      m_orig_H(other.m_orig_H), m_orig_K(other.m_orig_K),
208
      m_orig_L(other.m_orig_L), m_peakNumber(other.m_peakNumber),
Lynch, Vickie's avatar
Lynch, Vickie committed
209
      m_modulatedStructure(other.m_modulatedStructure), m_intHKL(other.m_intHKL), 
Lynch, Vickie's avatar
Lynch, Vickie committed
210
      m_detIDs(other.m_detIDs),
Lynch, Vickie's avatar
Lynch, Vickie committed
211
      m_peakShape(other.m_peakShape->clone()), convention(other.convention) {}
212

213
214
215
216
217
218
//----------------------------------------------------------------------------------------------
/** Constructor making a Peak from IPeak interface
 *
 * @param ipeak :: const reference to an IPeak object
 * @return
 */
Owen Arnold's avatar
Owen Arnold committed
219
Peak::Peak(const Geometry::IPeak &ipeak)
220
221
    : IPeak(ipeak), m_detectorID(ipeak.getDetectorID()), m_H(ipeak.getH()),
      m_K(ipeak.getK()), m_L(ipeak.getL()), m_intensity(ipeak.getIntensity()),
222
223
224
225
      m_sigmaIntensity(ipeak.getSigmaIntensity()),
      m_binCount(ipeak.getBinCount()),
      m_initialEnergy(ipeak.getInitialEnergy()),
      m_finalEnergy(ipeak.getFinalEnergy()),
226
227
      m_GoniometerMatrix(ipeak.getGoniometerMatrix()),
      m_InverseGoniometerMatrix(ipeak.getGoniometerMatrix()),
228
      m_runNumber(ipeak.getRunNumber()),
229
230
      m_monitorCount(ipeak.getMonitorCount()), m_row(ipeak.getRow()),
      m_col(ipeak.getCol()), m_orig_H(0.), m_orig_K(0.), m_orig_L(0.),
Lynch, Vickie's avatar
Lynch, Vickie committed
231
      m_peakNumber(ipeak.getPeakNumber()), m_modulatedStructure(ipeak.getIntMNP()),
Lynch, Vickie's avatar
Lynch, Vickie committed
232
      m_intHKL{ {static_cast<int>(ipeak.getIntHKL()[0]), static_cast<int>(ipeak.getIntHKL()[1]), static_cast<int>(ipeak.getIntHKL()[2])} },
233
      m_peakShape(boost::make_shared<NoShape>()) {
Lynch, Vickie's avatar
Lynch, Vickie committed
234
  convention = Kernel::ConfigService::Instance().getString("Q.convention");
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
  if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8)
    throw std::invalid_argument(
        "Peak::ctor(): Goniometer matrix must non-singular.");
  setInstrument(ipeak.getInstrument());
  detid_t id = ipeak.getDetectorID();
  if (id >= 0) {
    setDetectorID(id);
  }
  if (const Peak *peak = dynamic_cast<const Peak *>(&ipeak)) {
    this->m_detIDs = peak->m_detIDs;
  }
}

//----------------------------------------------------------------------------------------------
/** Set the incident wavelength of the neutron. Calculates the energy from this.
 * Assumes elastic scattering.
 *
 * @param wavelength :: wavelength in Angstroms.
 */
void Peak::setWavelength(double wavelength) {
  // Velocity of the neutron (non-relativistic)
  double velocity = PhysicalConstants::h /
                    (wavelength * 1e-10 * PhysicalConstants::NeutronMass);
  // Energy in J of the neutron
  double energy = PhysicalConstants::NeutronMass * velocity * velocity / 2.0;
  // Convert to meV
261
262
  m_initialEnergy = energy / PhysicalConstants::meV;
  m_finalEnergy = m_initialEnergy;
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
}

//----------------------------------------------------------------------------------------------
/** Set the detector ID of the pixel at the centre of the peak and look up and
 * cache
 *  values related to it. It also adds it to the list of contributing detectors
 * for this peak but
 *  does NOT remove the old centre.
 * @param id :: ID of detector at the centre of the peak.
 */
void Peak::setDetectorID(int id) {
  if (!m_inst)
    throw std::runtime_error("Peak::setInstrument(): No instrument is set!");
  this->m_det = m_inst->getDetector(id);
  if (!m_det)
    throw std::runtime_error("Peak::setInstrument(): No detector was found!");

280
  this->m_detectorID = id;
281
282
283
284
285
  addContributingDetID(id);

  detPos = m_det->getPos();

  // We now look for the row/column. -1 if not found.
286
287
  m_row = -1;
  m_col = -1;
288
289
290
291
292
293

  // Go up 2 parents to find the bank/rectangular detector
  IComponent_const_sptr parent = m_det->getParent();

  // Find the ROW by looking at the string name of the pixel. E.g. "pixel12"
  // gives row 12.
294
  m_row = Strings::endsWithInt(m_det->getName());
295
296
297

  if (!parent)
    return;
298
  m_bankName = parent->getName();
299
300
301

  // Find the COLUMN by looking at the string name of the parent. E.g. "tube003"
  // gives column 3.
302
  m_col = Strings::endsWithInt(parent->getName());
303
304
305
306
307
308
309
310
311
312
313
314

  parent = parent->getParent();
  // Use the parent if there is no grandparent.
  if (!parent)
    return;

  // Use the parent if the grandparent is the instrument
  Instrument_const_sptr instrument =
      boost::dynamic_pointer_cast<const Instrument>(parent);
  if (instrument)
    return;
  // Use the grand-parent whenever possible
315
  m_bankName = parent->getName();
316
  // For CORELLI, one level above sixteenpack
317
  if (m_bankName == "sixteenpack") {
318
319
320
321
    parent = parent->getParent();
    m_bankName = parent->getName();
  }

322
323
324
325
326
  // Special for rectangular detectors: find the row and column.
  RectangularDetector_const_sptr retDet =
      boost::dynamic_pointer_cast<const RectangularDetector>(parent);
  if (!retDet)
    return;
327
328
329
  std::pair<int, int> xy = retDet->getXYForDetectorID(m_detectorID);
  m_row = xy.second;
  m_col = xy.first;
330
331
332
333
}

//----------------------------------------------------------------------------------------------
/** Get the ID of the detector at the center of the peak  */
334
int Peak::getDetectorID() const { return m_detectorID; }
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362

//----------------------------------------------------------------------------------------------
/**
 * Add a detector ID that contributed to this peak
 * @param id :: The ID of a detector that contributed to this peak
 */
void Peak::addContributingDetID(const int id) { m_detIDs.insert(id); }

//-------------------------------------------------------------------------------------
/**
 * Removes an ID from the list of contributing detectors
 * @param id :: This ID is removed from the list.
 */
void Peak::removeContributingDetector(const int id) { m_detIDs.erase(id); }

//----------------------------------------------------------------------------------------------
/**
 * Return the set of detector IDs that contribute to this peak
 * @returns A set of unique detector IDs that form this peak
 */
const std::set<int> &Peak::getContributingDetIDs() const { return m_detIDs; }

//----------------------------------------------------------------------------------------------
/** Set the instrument (and save the source/sample pos).
 * Call setDetectorID AFTER this call.
 *
 * @param inst :: Instrument sptr to use
 */
363
void Peak::setInstrument(const Geometry::Instrument_const_sptr &inst) {
364
365
366
367
368
369
  m_inst = inst;
  if (!inst)
    throw std::runtime_error("Peak::setInstrument(): No instrument is set!");

  // Cache some positions
  const Geometry::IComponent_const_sptr sourceObj = m_inst->getSource();
370
  if (sourceObj == nullptr)
371
372
373
374
    throw Exception::InstrumentDefinitionError("Peak::setInstrument(): Failed "
                                               "to get source component from "
                                               "instrument");
  const Geometry::IComponent_const_sptr sampleObj = m_inst->getSample();
375
  if (sampleObj == nullptr)
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
    throw Exception::InstrumentDefinitionError("Peak::setInstrument(): Failed "
                                               "to get sample component from "
                                               "instrument");

  sourcePos = sourceObj->getPos();
  samplePos = sampleObj->getPos();
}

//----------------------------------------------------------------------------------------------
/** Return a shared ptr to the detector at center of peak. */
Geometry::IDetector_const_sptr Peak::getDetector() const { return m_det; }

/** Return a shared ptr to the instrument for this peak. */
Geometry::Instrument_const_sptr Peak::getInstrument() const { return m_inst; }

// -------------------------------------------------------------------------------------
/** Calculate the neutron wavelength (in angstroms) at the peak
 * (Note for inelastic scattering - it is the wavelength corresponding to the
 * final energy)*/
double Peak::getWavelength() const {
  // Energy in J of the neutron
397
  double energy = PhysicalConstants::meV * m_finalEnergy;
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
  // v = sqrt(2.0 * E / m)
  double velocity = sqrt(2.0 * energy / PhysicalConstants::NeutronMass);
  // wavelength = h / mv
  double wavelength =
      PhysicalConstants::h / (PhysicalConstants::NeutronMass * velocity);
  // Return it in angstroms
  return wavelength * 1e10;
}

// -------------------------------------------------------------------------------------
/** Calculate the time of flight (in microseconds) of the neutrons for this
 * peak,
 * using the geometry of the detector  */
double Peak::getTOF() const {
  // First, get the neutron traveling distances
  double L1 = this->getL1();
  double L2 = this->getL2();
  // Energy in J of the neutron
416
417
  double Ei = PhysicalConstants::meV * m_initialEnergy;
  double Ef = PhysicalConstants::meV * m_finalEnergy;
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
  // v = sqrt(2 * E / m)
  double vi = sqrt(2.0 * Ei / PhysicalConstants::NeutronMass);
  double vf = sqrt(2.0 * Ef / PhysicalConstants::NeutronMass);
  // Time of flight in seconds = distance / speed
  double tof = L1 / vi + L2 / vf;
  // Return in microsecond units
  return tof * 1e6;
}

// -------------------------------------------------------------------------------------
/** Calculate the scattering angle of the peak  */
double Peak::getScattering() const {
  // The detector is at 2 theta scattering angle
  V3D beamDir = samplePos - sourcePos;
  V3D detDir = detPos - samplePos;

  return detDir.angle(beamDir);
}

437
438
439
440
441
442
443
444
445
// -------------------------------------------------------------------------------------
/** Calculate the azimuthal angle of the peak  */
double Peak::getAzimuthal() const {
  // The detector is at 2 theta scattering angle
  V3D detDir = detPos - samplePos;

  return atan2(detDir.Y(), detDir.X());
}

446
447
448
449
450
451
452
453
454
455
456
457
458
// -------------------------------------------------------------------------------------
/** Calculate the d-spacing of the peak, in 1/Angstroms  */
double Peak::getDSpacing() const {
  // The detector is at 2 theta scattering angle
  V3D beamDir = samplePos - sourcePos;
  V3D detDir = detPos - samplePos;

  double two_theta = detDir.angle(beamDir);

  // In general case (2*pi/d)^2=k_i^2+k_f^2-2*k_i*k_f*cos(two_theta)
  // E_i,f=k_i,f^2*hbar^2/(2 m)
  return 1e10 * PhysicalConstants::h /
         sqrt(2.0 * PhysicalConstants::NeutronMass * PhysicalConstants::meV) /
459
460
         sqrt(m_initialEnergy + m_finalEnergy -
              2.0 * sqrt(m_initialEnergy * m_finalEnergy) * cos(two_theta));
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
}

//----------------------------------------------------------------------------------------------
/** Return the Q change (of the lattice, k_i - k_f) for this peak.
 * The Q is in the Lab frame: the goniometer rotation was NOT taken out.
 *
 * Note: There is a 2*pi factor used, so |Q| = 2*pi/wavelength.
 * */
Mantid::Kernel::V3D Peak::getQLabFrame() const {
  // Normalized beam direction
  V3D beamDir = samplePos - sourcePos;
  beamDir /= beamDir.norm();
  // Normalized detector direction
  V3D detDir = (detPos - samplePos);
  detDir /= detDir.norm();

  // Energy in J of the neutron
478
  double ei = PhysicalConstants::meV * m_initialEnergy;
479
480
481
482
483
484
485
486
487
488
489
  // v = sqrt(2.0 * E / m)
  double vi = sqrt(2.0 * ei / PhysicalConstants::NeutronMass);
  // wavenumber = h_bar / mv
  double wi = PhysicalConstants::h_bar / (PhysicalConstants::NeutronMass * vi);
  // in angstroms
  wi *= 1e10;
  // wavevector=1/wavenumber = 2pi/wavelength
  double wvi = 1.0 / wi;
  // Now calculate the wavevector of the scattered neutron
  double wvf = (2.0 * M_PI) / this->getWavelength();
  // And Q in the lab frame
490
491
492
493
494
  // Default for ki-kf is positive
  double qSign = 1.0;
  if (convention == "Crystallography")
    qSign = -1.0;
  return (beamDir * wvi - detDir * wvf) * qSign;
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
}

//----------------------------------------------------------------------------------------------
/** Return the Q change (of the lattice, k_i - k_f) for this peak.
 * The Q is in the Sample frame: the goniometer rotation WAS taken out. */
Mantid::Kernel::V3D Peak::getQSampleFrame() const {
  V3D Qlab = this->getQLabFrame();
  // Multiply by the inverse of the goniometer matrix to get the sample frame
  V3D Qsample = m_InverseGoniometerMatrix * Qlab;
  return Qsample;
}

//----------------------------------------------------------------------------------------------
/** Set the peak using the peak's position in reciprocal space, in the sample
 *frame.
 * The GoniometerMatrix will be used to find the Q in the lab frame, so it
 *should
 * be set beforehand.
 *
 * @param QSampleFrame :: Q of the center of the peak, in reciprocal space
 *        This is in inelastic convention: momentum transfer of the LATTICE!
 *        Also, q does NOT have a 2pi factor = it is equal to 1/wavelength.
 * @param detectorDistance :: distance between the sample and the detector.
518
 *        Used to give a valid TOF. You do NOT need to explicitly set this.
519
 */
520
void Peak::setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
Hahn, Steven's avatar
Hahn, Steven committed
521
                           boost::optional<double> detectorDistance) {
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
  V3D Qlab = m_GoniometerMatrix * QSampleFrame;
  this->setQLabFrame(Qlab, detectorDistance);
}

//----------------------------------------------------------------------------------------------
/** Set the peak using the peak's position in reciprocal space, in the lab
 *frame.
 * The detector position will be determined.
 * DetectorID, row and column will be set to -1 since they are not (necessarily)
 *found.
 * You can call findDetector to look for the detector ID
 *
 * @param QLabFrame :: Q of the center of the peak, in reciprocal space.
 *        This is in inelastic convention: momentum transfer of the LATTICE!
 *        Also, q does have a 2pi factor = it is equal to 2pi/wavelength (in
 *Angstroms).
538
539
 * @param detectorDistance :: distance between the sample and the detector. If
 *this is provided. Then we do not
540
 * ray trace to find the intersecing detector.
541
 */
542
void Peak::setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
Hahn, Steven's avatar
Hahn, Steven committed
543
                        boost::optional<double> detectorDistance) {
544
  // Clear out the detector = we can't know them
545
  m_detectorID = -1;
Samuel Jackson's avatar
Samuel Jackson committed
546
  detPos = V3D();
547
  m_det = IDetector_sptr();
548
549
550
  m_row = -1;
  m_col = -1;
  m_bankName = "None";
551

552
553
554
  // The q-vector direction of the peak is = goniometer * ub * hkl_vector
  V3D q = QLabFrame;

555
556
  /* The incident neutron wavevector is along the beam direction, ki = 1/wl
   * (usually z, but referenceframe is definitive).
557
   * In the inelastic convention, q = ki - kf.
558
559
   * The final neutron wavector kf = -qx in x; -qy in y; and (-q.beam_dir+1/wl)
   * in beam direction.
560
   * AND: norm(kf) = norm(ki) = 2*pi/wavelength
561
   * THEREFORE: 1/wl = norm(q)^2 / (2*q.beam_dir)
562
   */
563
  double norm_q = q.norm();
564
565
566
  if (!this->m_inst) {
    throw std::invalid_argument("Setting QLab without an instrument would lead "
                                "to an inconsistent state for the Peak");
567
  }
568
569
  boost::shared_ptr<const ReferenceFrame> refFrame =
      this->m_inst->getReferenceFrame();
570
  const V3D refBeamDir = refFrame->vecPointingAlongBeam();
571
572
573
574
575
  // Default for ki-kf has -q
  double qSign = 1.0;
  if (convention == "Crystallography")
    qSign = -1.0;
  const double qBeam = q.scalar_prod(refBeamDir) * qSign;
576
577
578

  if (norm_q == 0.0)
    throw std::invalid_argument("Peak::setQLabFrame(): Q cannot be 0,0,0.");
579
  if (qBeam == 0.0)
580
    throw std::invalid_argument(
581
        "Peak::setQLabFrame(): Q cannot be 0 in the beam direction.");
582

583
  double one_over_wl = (norm_q * norm_q) / (2.0 * qBeam);
584
585
586
587
588
589
590
591
592
593
594
  double wl = (2.0 * M_PI) / one_over_wl;
  if (wl < 0.0) {
    std::ostringstream mess;
    mess << "Peak::setQLabFrame(): Wavelength found was negative (" << wl
         << " Ang)! This Q is not physical.";
    throw std::invalid_argument(mess.str());
  }

  // Save the wavelength
  this->setWavelength(wl);

595
596
597
598
599
600
  // Default for ki-kf has -q
  qSign = -1.0;
  if (convention == "Crystallography")
    qSign = 1.0;

  V3D detectorDir = q * qSign;
601
  detectorDir[refFrame->pointingAlongBeam()] = one_over_wl - qBeam;
602
603
  detectorDir.normalize();

604
  // Use the given detector distance to find the detector position.
605
606
607
608
609
610
  if (detectorDistance.is_initialized()) {
    detPos = samplePos + detectorDir * detectorDistance.get();
    // We do not-update the detector as by manually setting the distance the
    // client seems to know better.
  } else {
    // Find the detector
611
612
    InstrumentRayTracer tracer(m_inst);
    const bool found = findDetector(detectorDir, tracer);
613
614
615
616
617
    if (!found) {
      // This is important, so we ought to log when this fails to happen.
      g_log.debug("Could not find detector after setting qLab via setQLab with "
                  "QLab : " +
                  q.toString());
618
619

      detPos = getVirtualDetectorPosition(detectorDir);
620
    }
621
  }
622
623
}

624
625
626
V3D Peak::getVirtualDetectorPosition(const V3D &detectorDir) const {
  const auto component =
      getInstrument()->getComponentByName("extended-detector-space");
627
  if (!component) {
628
    return detectorDir; // the best idea we have is just the direction
629
630
  }

631
632
  const auto object =
      boost::dynamic_pointer_cast<const ObjComponent>(component);
633
  Geometry::Track track(samplePos, detectorDir);
634
  object->shape()->interceptSurface(track);
635
636
637
  return track.back().exitPoint;
}

638
639
640
641
642
643
644
645
646
647
/** After creating a peak using the Q in the lab frame,
 * the detPos is set to the direction of the detector (but the detector is
 *unknown)
 *
 * Using the instrument set in the peak, perform ray tracing
 * to find the exact detector.
 *
 * @return true if the detector ID was found.
 */
bool Peak::findDetector() {
648
649
650
  InstrumentRayTracer tracer(m_inst);
  return findDetector(tracer);
}
651

652
653
654
655
656
657
658
659
/**
 * Performs the same algorithm as findDetector() but uses a pre-existing
 * InstrumentRayTracer object to be able to take adavtange of its caches.
 * This method should be preferred if findDetector is to be called many times
 * over the same instrument.
 * @param tracer A reference to an existing InstrumentRayTracer object.
 * @return true if the detector ID was found.
 */
660
bool Peak::findDetector(const InstrumentRayTracer &tracer) {
661
662
663
664
  // Scattered beam direction
  V3D beam = detPos - samplePos;
  beam.normalize();

665
  return findDetector(beam, tracer);
666
667
668
}

/**
669
670
 * @brief Peak::findDetector : Find the detector along the beam location. sets
 * the detector, and detector position if found
Owen Arnold's avatar
Owen Arnold committed
671
672
 * @param beam : Detector direction from the sample as V3D
 * @param tracer : Ray tracer to use for detector finding
673
674
 * @return True if a detector has been found
 */
675
676
bool Peak::findDetector(const Mantid::Kernel::V3D &beam,
                        const InstrumentRayTracer &tracer) {
677
  bool found = false;
678
  // Create a ray tracer
679
680
  tracer.traceFromSample(beam);
  IDetector_const_sptr det = tracer.getDetectorResult();
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
  if (det) {
    // Set the detector ID, the row, col, etc.
    this->setDetectorID(det->getID());
    // The old detector position is not more precise if it comes from
    // FindPeaksMD
    detPos = det->getPos();
    found = true;
  }
  // Use tube-gap parameter in instrument parameter file  to find peaks with
  // center in gaps between tubes
  else if (m_inst->hasParameter("tube-gap")) {
    std::vector<double> gaps = m_inst->getNumberParameter("tube-gap", true);
    if (!gaps.empty()) {
      const double gap = static_cast<double>(gaps.front());
      // try adding and subtracting tube-gap in 3 q dimensions to see if you can
      // find detectors on each side of tube gap
      for (int i = 0; i < 3; i++) {
        V3D gapDir = V3D(0., 0., 0.);
        gapDir[i] = gap;
        V3D beam1 = beam + gapDir;
701
702
        tracer.traceFromSample(beam1);
        IDetector_const_sptr det1 = tracer.getDetectorResult();
703
        V3D beam2 = beam - gapDir;
704
705
        tracer.traceFromSample(beam2);
        IDetector_const_sptr det2 = tracer.getDetectorResult();
706
707
708
709
710
711
712
        if (det1 && det2) {
          // Set the detector ID to one of the neighboring pixels
          this->setDetectorID(static_cast<int>(det1->getID()));
          ;
          detPos = det1->getPos();
          found = true;
          break;
Lynch, Vickie's avatar
Lynch, Vickie committed
713
        }
714
      }
Lynch, Vickie's avatar
Lynch, Vickie committed
715
    }
716
  }
717
718
719
720
721
  return found;
}

//----------------------------------------------------------------------------------------------
/** Return the run number this peak was measured at. */
722
int Peak::getRunNumber() const { return m_runNumber; }
723
724

/** Set the run number that measured this peak
725
726
 * @param m_runNumber :: the run number   */
void Peak::setRunNumber(int m_runNumber) { this->m_runNumber = m_runNumber; }
727
728
729

//----------------------------------------------------------------------------------------------
/** Return the monitor count stored in this peak. */
730
double Peak::getMonitorCount() const { return m_monitorCount; }
731
732

/** Set the monitor count for this peak
733
734
735
 * @param m_monitorCount :: the monitor count */
void Peak::setMonitorCount(double m_monitorCount) {
  this->m_monitorCount = m_monitorCount;
736
737
738
}

//----------------------------------------------------------------------------------------------
Samuel Jackson's avatar
Samuel Jackson committed
739
/** Get the final neutron energy in meV */
740
double Peak::getFinalEnergy() const { return m_finalEnergy; }
741

Samuel Jackson's avatar
Samuel Jackson committed
742
/** Get the initial (incident) neutron energy in meV */
743
double Peak::getInitialEnergy() const { return m_initialEnergy; }
744

Samuel Jackson's avatar
Samuel Jackson committed
745
/** Get the difference between the initial and final neutron energy in meV */
Samuel Jackson's avatar
Samuel Jackson committed
746
747
748
double Peak::getEnergyTransfer() const {
  return getInitialEnergy() - getFinalEnergy();
}
749

750
751
752
753
754
755
756
757
758
759
760
761
762
//----------------------------------------------------------------------------------------------
/** Get the H index of the peak */
double Peak::getH() const { return m_H; }

/** Get the K index of the peak */
double Peak::getK() const { return m_K; }

/** Get the L index of the peak */
double Peak::getL() const { return m_L; }

/** Return the HKL vector */
Mantid::Kernel::V3D Peak::getHKL() const { return V3D(m_H, m_K, m_L); }

Lynch, Vickie's avatar
Lynch, Vickie committed
763
/** Return the int HKL vector */
Lynch, Vickie's avatar
Lynch, Vickie committed
764
Mantid::Kernel::V3D Peak::getIntHKL() const {
Lynch, Vickie's avatar
Lynch, Vickie committed
765
  return V3D(m_intHKL[0], m_intHKL[1], m_intHKL[2]);
Lynch, Vickie's avatar
Lynch, Vickie committed
766
}
Lynch, Vickie's avatar
Lynch, Vickie committed
767

768
769
770
771
772
773
774
775
776
777
778
779
780
781
//----------------------------------------------------------------------------------------------
/** Set the H index of this peak
 * @param m_H :: index to set   */
void Peak::setH(double m_H) { this->m_H = m_H; }

/** Set the K index of this peak
 * @param m_K :: index to set   */
void Peak::setK(double m_K) { this->m_K = m_K; }

/** Set the L index of this peak
 * @param m_L :: index to set   */
void Peak::setL(double m_L) { this->m_L = m_L; }

/** Set the BankName of this peak
782
783
784
 * @param m_bankName :: index to set   */
void Peak::setBankName(std::string m_bankName) {
  this->m_bankName = m_bankName;
785
786
787
788
}

/** Set all three H,K,L indices of the peak */
void Peak::setHKL(double H, double K, double L) {
789
790
791
792
  if (m_orig_H == 0 && m_orig_K == 0 && m_orig_L == 0) {
    m_orig_H = m_H;
    m_orig_K = m_K;
    m_orig_L = m_L;
793
794
795
796
  }
  m_H = H;
  m_K = K;
  m_L = L;
Lynch, Vickie's avatar
Lynch, Vickie committed
797
  setIntHKL(V3D(m_H, m_K, m_L));
798
799
800
801
}

/** Reset all three H,K,L indices of the peak to values before setHKL */
void Peak::resetHKL() {
802
  if (m_orig_H == 0 && m_orig_K == 0 && m_orig_L == 0)
803
    return;
804
805
806
  m_H = m_orig_H;
  m_K = m_orig_K;
  m_L = m_orig_L;
Lynch, Vickie's avatar
Lynch, Vickie committed
807
  setIntHKL(V3D(m_H, m_K, m_L));
808
809
810
811
812
813
}

/** Set all HKL
 *
 * @param HKL :: vector with x,y,z -> h,k,l
 */
814
void Peak::setHKL(const Mantid::Kernel::V3D &HKL) {
815
816
817
818
  if (m_orig_H == 0 && m_orig_K == 0 && m_orig_L == 0) {
    m_orig_H = m_H;
    m_orig_K = m_K;
    m_orig_L = m_L;
819
820
821
822
  }
  m_H = HKL.X();
  m_K = HKL.Y();
  m_L = HKL.Z();
Lynch, Vickie's avatar
Lynch, Vickie committed
823
  setIntHKL(HKL);
824
825
}

Lynch, Vickie's avatar
Lynch, Vickie committed
826
827
828
829
830
/** Set int HKL
 *
 * @param HKL :: vector with integer x,y,z -> h,k,l
 */
void Peak::setIntHKL(const Mantid::Kernel::V3D &HKL) {
Lynch, Vickie's avatar
Lynch, Vickie committed
831
  m_intHKL = {boost::math::iround(HKL.X()), boost::math::iround(HKL.Y()), boost::math::iround(HKL.Z())};
Lynch, Vickie's avatar
Lynch, Vickie committed
832
833
}

834
835
//----------------------------------------------------------------------------------------------
/** Return the # of counts in the bin at its peak*/
836
double Peak::getBinCount() const { return m_binCount; }
837
838

/** Return the integrated peak intensity */
839
double Peak::getIntensity() const { return m_intensity; }
840
841

/** Return the error on the integrated peak intensity */
842
double Peak::getSigmaIntensity() const { return m_sigmaIntensity; }
843

844
/** Return the peak intensity divided by the error in the intensity */
845
double Peak::getIntensityOverSigma() const {
846
847
  const auto result = m_intensity / m_sigmaIntensity;
  return (std::isinf(result)) ? 0.0 : result;
848
849
}

850
/** Set the integrated peak intensity
851
852
 * @param m_intensity :: intensity value   */
void Peak::setIntensity(double m_intensity) { this->m_intensity = m_intensity; }
853
854

/** Set the # of counts in the bin at its peak
855
856
 * @param m_binCount :: counts  */
void Peak::setBinCount(double m_binCount) { this->m_binCount = m_binCount; }
857
858

/** Set the error on the integrated peak intensity
859
860
861
 * @param m_sigmaIntensity :: intensity error value   */
void Peak::setSigmaIntensity(double m_sigmaIntensity) {
  this->m_sigmaIntensity = m_sigmaIntensity;
862
863
864
}

/** Set the final energy
865
866
867
 * @param m_finalEnergy :: final energy in meV   */
void Peak::setFinalEnergy(double m_finalEnergy) {
  this->m_finalEnergy = m_finalEnergy;
868
869
870
}

/** Set the initial energy
871
872
873
 * @param m_initialEnergy :: initial energy in meV   */
void Peak::setInitialEnergy(double m_initialEnergy) {
  this->m_initialEnergy = m_initialEnergy;
874
875
876
877
878
879
880
881
882
883
884
885
}

// -------------------------------------------------------------------------------------
/** Get the goniometer rotation matrix at which this peak was measured. */
Mantid::Kernel::Matrix<double> Peak::getGoniometerMatrix() const {
  return this->m_GoniometerMatrix;
}

/** Set the goniometer rotation matrix at which this peak was measured.
 * @param goniometerMatrix :: 3x3 matrix that represents the rotation matrix of
 * the goniometer
 * @throw std::invalid_argument if matrix is not 3x3*/
886
void Peak::setGoniometerMatrix(
887
    const Mantid::Kernel::Matrix<double> &goniometerMatrix) {
888
889
890
891
892
893
894
895
  if ((goniometerMatrix.numCols() != 3) || (goniometerMatrix.numRows() != 3))
    throw std::invalid_argument(
        "Peak::setGoniometerMatrix(): Goniometer matrix must be 3x3.");
  this->m_GoniometerMatrix = goniometerMatrix;
  // Calc the inverse rotation matrix
  m_InverseGoniometerMatrix = m_GoniometerMatrix;
  if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8)
    throw std::invalid_argument(
Samuel Jackson's avatar
Samuel Jackson committed
896
        "Peak::setGoniometerMatrix(): Goniometer matrix must be non-singular.");
897
898
899
900
901
902
903
}

// -------------------------------------------------------------------------------------
/** Find the name of the bank that is the parent of the detector. This works
 * best for RectangularDetector instruments (goes up two levels)
 * @return name of the bank.
 */
904
std::string Peak::getBankName() const { return m_bankName; }
905
906
907

// -------------------------------------------------------------------------------------
/** For RectangularDetectors only, returns the row (y) of the pixel of the
908
909
 * detector.
 * Returns -1 if it could not find it. */
910
int Peak::getRow() const { return m_row; }
911
912
913
914
915

// -------------------------------------------------------------------------------------
/** For RectangularDetectors only, returns the column (x) of the pixel of the
 * detector.
 * Returns -1 if it could not find it. */
916
int Peak::getCol() const { return m_col; }
917

918
919
920
// -------------------------------------------------------------------------------------
/**Returns the unique peak number
 * Returns -1 if it could not find it. */
921
int Peak::getPeakNumber() const { return m_peakNumber; }
922

923
924
925
// -------------------------------------------------------------------------------------
/**Returns the unique peak number
 * Returns -1 if it could not find it. */
Lynch, Vickie's avatar
Lynch, Vickie committed
926
V3D Peak::getIntMNP() const { return m_modulatedStructure; }
927

928
929
930
931
932
933
934
935
936
937
938
939
// -------------------------------------------------------------------------------------
/** For RectangularDetectors only, sets the row (y) of the pixel of the
 * detector.
 * @param m_row :: row value   */
void Peak::setRow(int m_row) { this->m_row = m_row; }

// -------------------------------------------------------------------------------------
/** For RectangularDetectors only, sets the column (x) of the pixel of the
 * detector.
 * @param m_col :: col value   */
void Peak::setCol(int m_col) { this->m_col = m_col; }

940
941
// -------------------------------------------------------------------------------------
/** Sets the unique peak number
942
 * @param m_peakNumber :: unique peak number value   */
943
void Peak::setPeakNumber(int m_peakNumber) {
944
945
946
  this->m_peakNumber = m_peakNumber;
}

947
948
// -------------------------------------------------------------------------------------
/** Sets the modulated peak structure number
Lynch, Vickie's avatar
Lynch, Vickie committed
949
950
 * @param m_modulatedStructure :: modulated peak structure value   */
void Peak::setIntMNP(V3D modulatedStructure) { this->m_modulatedStructure = modulatedStructure; }
951

952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// -------------------------------------------------------------------------------------
/** Return the detector position vector */
Mantid::Kernel::V3D Peak::getDetPos() const { return detPos; }

// -------------------------------------------------------------------------------------
/** Return the L1 flight path length (source to sample), in meters. */
double Peak::getL1() const { return (samplePos - sourcePos).norm(); }

// -------------------------------------------------------------------------------------
/** Return the L2 flight path length (sample to detector), in meters. */
double Peak::getL2() const { return (detPos - samplePos).norm(); }

// -------------------------------------------------------------------------------------
/** Helper function for displaying/sorting peaks in MantidPlot
 *
 * @param name_in :: name of the column in the table workspace
 * @return a double representing that value (if that's possible)
 * @throw std::runtime_error if you asked for a column that can't convert to
 *double.
 */
double Peak::getValueByColName(const std::string &name_in) const {
  std::string name = name_in;
  std::transform(name.begin(), name.end(), name.begin(), ::tolower);
  if (name == "runnumber")
    return double(this->getRunNumber());
  else if (name == "detid")
    return double(this->getDetectorID());
  else if (name == "h")
    return this->getH();
  else if (name == "k")
    return this->getK();
  else if (name == "l")
    return this->getL();
  else if (name == "wavelength")
    return this->getWavelength();
  else if (name == "energy")
    return this->getInitialEnergy();
  else if (name == "tof")
    return this->getTOF();
  else if (name == "dspacing")
    return this->getDSpacing();
  else if (name == "intens")
    return this->getIntensity();
  else if (name == "sigint")
    return this->getSigmaIntensity();
  else if (name == "bincount")
    return this->getBinCount();
  else if (name == "row")
    return this->getRow();
For faster browsing, not all history is shown. View entire blame