qse  0.5.0
Public Member Functions | Private Attributes | Friends
QseScanAverager Class Reference

#include <qsescanaverager.h>

Inheritance diagram for QseScanAverager:
Inheritance graph

List of all members.

Public Member Functions

 QseScanAverager (QseDataSet *inData, QseDataSet *outData, const QString &name, QObject *parent=0)
void exec ()
void startAveraging ()
void addScanToAverage (int i)
void finishAveraging ()
- Public Member Functions inherited from QseEXAFSOperator
 QseEXAFSOperator (QseDataSet *inData, QseDataSet *outData, const QString &name, QObject *parent=0)
QseDataSetinputData ()
QseDataSetoutputData ()
bool matchesEnergyPattern (const QseColumn *col, int colnum)
bool matchesEnergyColumn (const QseColumn *col, int colnum)
bool matchesDetectorPattern (const QseColumn *col, int colnum)
bool matchesDetectorColumn (const QseColumn *col, int colnum)
bool matchesNormalizationPattern (const QseColumn *col, int colnum)
bool matchesNormalizationColumn (const QseColumn *col, int colnum)
bool matchesSecondsPattern (const QseColumn *col, int colnum)
bool matchesSecondsColumn (const QseColumn *col, int colnum)
bool matchesCopyPattern (const QseColumn *col, int colnum)
bool matchesCopyColumn (const QseColumn *col, int colnum)
bool matchesCopyNormalizedPattern (const QseColumn *col, int colnum)
bool matchesCopyNormalizedColumn (const QseColumn *col, int colnum)
bool matchesCopyRatePattern (const QseColumn *col, int colnum)
bool matchesCopyRateColumn (const QseColumn *col, int colnum)
bool matchesCopyTotalCountsPattern (const QseColumn *col, int colnum)
bool matchesCopyTotalCountsColumn (const QseColumn *col, int colnum)
- Public Member Functions inherited from QseOperator
 QseOperator (const QString &name, QObject *parent=0)
QString name () const
void setName (const QString &name)
void addParameter (QseParameter *parameter)

Private Attributes

QseScanm_Result
QseScanm_Totals
int m_NScans
int m_LookupIndex

Friends

class QseScanAveragerUI

Additional Inherited Members

- Public Types inherited from QseEXAFSOperator
enum  QseScanRole { UnspecifiedScanRole = -1, ScanNotUsedRole, ScanUsedRole }
enum  QseColumnRole {
  UnspecifiedRole = -1, NotUsedRole, DetectorRole, NormalizationRole,
  EnergyRole, SecondsRole, CopyRole, CopyNormalizedRole,
  CopyRateRole, CopyTotalCountsRole
}
- Static Public Member Functions inherited from QseEXAFSOperator
static QColor colorForRole (QseColumnRole r)
static QColor backgroundColorForRole (QseColumnRole r)
- Protected Attributes inherited from QseEXAFSOperator
QseDataSetm_InputData
QseDataSetm_OutputData
QseRegExpParameter m_EnergyPattern
QseRegExpParameter m_DetectorPattern
QseRegExpParameter m_NormalizationPattern
QseRegExpParameter m_SecondsPattern
QseRegExpParameter m_CopyPattern
QseRegExpParameter m_CopyNormalizedPattern
QseRegExpParameter m_CopyRatePattern
QseRegExpParameter m_CopyTotalCountsPattern
QHash< const QseScan
*, QseScanRole
m_ScanExceptions
QHash< const QseColumn
*, QseColumnRole
m_Exceptions

Detailed Description

Definition at line 10 of file qsescanaverager.h.


Constructor & Destructor Documentation

QseScanAverager::QseScanAverager ( QseDataSet inData,
QseDataSet outData,
const QString &  name,
QObject *  parent = 0 
)

Definition at line 8 of file qsescanaverager.cpp.

: QseEXAFSOperator(inData, outData, name, parent),
m_Result(NULL),
m_Totals(NULL),
{
}

Member Function Documentation

void QseScanAverager::addScanToAverage ( int  i)

Definition at line 32 of file qsescanaverager.cpp.

References QseColumn::data(), QseScan::header(), QseEXAFSOperator::m_InputData, m_LookupIndex, m_NScans, m_Result, m_Totals, QseColumn::name(), QseScan::name(), QseScan::scanCommand(), QseColumn::setData(), and QseOperator::setName().

{
QseScan *scan = m_InputData -> scan(i);
if (scan) {
if (m_NScans == 0) {
m_Result -> setName(scan->name()+"_avg");
m_Result -> setScanCommand(scan->scanCommand()+"_avg");
m_Result -> setScanDateTime(QDateTime::currentDateTime());
m_Result -> mergeHeaders(scan->header());
m_Totals -> setName(scan->name()+"_totals");
m_Totals -> setScanCommand(scan->scanCommand()+"_totals");
m_Totals -> setScanDateTime(QDateTime::currentDateTime());
m_Totals -> mergeHeaders(scan->header());
int ncols = scan -> columnCount();
for (int i=0; i<ncols; i++) {
QseColumn *col = scan -> column(i);
QString nam = col->name();
QseColumn *res = m_Result -> appendColumn(nam, col);
QseColumn *sum = m_Totals -> appendColumn(nam, col);
sum -> assignment(1.0);
}
} else {
m_Result -> appendHeader("#C Averaged : "+scan->scanCommand());
m_Result -> mergeHeaders(scan->header());
int ncols = scan -> columnCount();
for (int i=0; i<ncols; i++) {
QseColumn *col = scan -> column(i);
QString nam = col->name();
QseColumn *res = NULL;
QseColumn *sum = NULL;
res = m_Result -> column(i);
sum = m_Totals -> column(i);
} else {
res = m_Result -> column(nam);
sum = m_Totals -> column(nam);
}
if (res == NULL) {
res = m_Result -> appendColumn(nam, col);
if (sum != NULL) {
printf("Problem: sum != NULL when res == NULL\n");
}
sum = m_Totals -> appendColumn(nam, col);
sum -> assignment(1.0);
} else {
if (sum == NULL) {
printf("Problem: sum == NULL when res != NULL\n");
sum = m_Totals -> appendColumn(nam, col);
sum -> assignment(1.0);
}
int nRowsIn = col -> rowCount();
int nRowsOut = res -> rowCount();
if (nRowsOut < nRowsIn) {
res -> setRowCount(nRowsIn);
sum -> setRowCount(nRowsIn);
}
for (int r=0; r<nRowsIn; r++) {
double vres = res->data(r);
double vsum = sum->data(r);
res->setData(r, vres+col->data(r));
sum->setData(r, vsum+1.0);
}
}
}
}
m_NScans += 1;
}
}
void QseScanAverager::exec ( )
virtual

Implements QseOperator.

Definition at line 17 of file qsescanaverager.cpp.

{
}
void QseScanAverager::finishAveraging ( )

Definition at line 117 of file qsescanaverager.cpp.

References QseScan::column(), QseColumn::division(), QseEXAFSOperator::m_OutputData, m_Result, and m_Totals.

{
int ncols = m_Result -> columnCount();
for (int i = 0; i<ncols; i++) {
res->division(tot);
}
delete m_Totals;
m_Result = NULL;
m_Totals = NULL;
m_OutputData -> emitOperationCompleted();
}
void QseScanAverager::startAveraging ( )

Definition at line 21 of file qsescanaverager.cpp.

References QseEXAFSOperator::m_InputData, m_NScans, QseEXAFSOperator::m_OutputData, m_Result, and m_Totals.

{
m_OutputData -> setHeader(m_InputData -> header());
m_OutputData -> setFileName(m_InputData -> fileName()+"_avg");
m_Result = m_OutputData -> appendScan();
m_Totals = new QseScan("totals");
// m_Totals = m_OutputData -> appendScan();
m_NScans = 0;
}

Friends And Related Function Documentation

friend class QseScanAveragerUI
friend

Definition at line 20 of file qsescanaverager.h.


Member Data Documentation

int QseScanAverager::m_LookupIndex
private

Definition at line 32 of file qsescanaverager.h.

Referenced by addScanToAverage().

int QseScanAverager::m_NScans
private

Definition at line 31 of file qsescanaverager.h.

Referenced by addScanToAverage(), and startAveraging().

QseScan* QseScanAverager::m_Result
private

Definition at line 29 of file qsescanaverager.h.

Referenced by addScanToAverage(), finishAveraging(), and startAveraging().

QseScan* QseScanAverager::m_Totals
private

Definition at line 30 of file qsescanaverager.h.

Referenced by addScanToAverage(), finishAveraging(), and startAveraging().


The documentation for this class was generated from the following files: