BDScalar Class Reference

Working base class for BDProcessors that watch a single value. More...

#include <BDScalar.h>

Inheritance diagram for BDScalar:
BDProcessor BDHornCurrent

List of all members.

Public Member Functions

 BDScalar (float max_dev=5.0, int nspills=10, const char *device_name=0)
 ~BDScalar ()
void SetDevice (const char *device_name)
void SetSpill (const RawBeamMonHeaderBlock &rbmhb, const RawBeamMonBlock &rbmb)
 Set the current spill blocks.
bool BeamChanged ()
void SetSpillQueueSize (int nspills)
void SetAllowedSpillDeviation (float sigmas)
double GetValue () const
 Return the last scalar added.

Protected Member Functions

virtual double GetScalar (const RawBeamMonHeaderBlock &rbmhb, const RawBeamMonBlock &rbmb)

Private Attributes

UtilRunningAverage fPastSpills
float fMaxDev
bool fBeamChanged
const char * fDeviceName

Detailed Description

Working base class for BDProcessors that watch a single value.

This maintains a running average of the scalar value. It can be used in two ways:

1) Simply give the constructor a device name and it will use that devices data for the scalar value

2) Subclass and override GetScalar() to handle unpacking/caculating more complex values.

(last to touch it)
2005/04/27 17:36:10


Created on: Fri Apr 15 09:59:46 2005

BDScalar.h,v 1.3 2005/04/27 17:36:10 minoscvs Exp

Definition at line 37 of file BDScalar.h.

Constructor & Destructor Documentation

BDScalar::BDScalar ( float  max_dev = 5.0,
int  nspills = 10,
const char *  device_name = 0 

Construct a BDScalar.

max_dev maximum number of standard deviations before a change is considered significant.
nspills number of spills to average over
device_name optionally set a device to watch. See also SetDevice().

Definition at line 8 of file BDScalar.cxx.

References SetSpillQueueSize().

00009     : fMaxDev(max_dev), fDeviceName(device_name)
00010 {
00011     this->SetSpillQueueSize(nspills);
00012 }

BDScalar::~BDScalar (  ) 

Definition at line 13 of file BDScalar.cxx.

00014 {
00015 }

Member Function Documentation

bool BDScalar::BeamChanged (  ) 

Return true if the latest spill is a "significant change" from previous as determined by the maximum deviation allowed.

Definition at line 34 of file BDScalar.cxx.

References fBeamChanged.

00035 {
00036     return fBeamChanged;
00037 }

double BDScalar::GetScalar ( const RawBeamMonHeaderBlock rbmhb,
const RawBeamMonBlock rbmb 
) [protected, virtual]

Reimplemented in BDHornCurrent.

Definition at line 55 of file BDScalar.cxx.

References fDeviceName, RawBeamData::GetData(), RawBeamData::GetDataLength(), Msg::kWarning, and MSG.

Referenced by SetSpill().

00057 {
00058     if (!fDeviceName) return 0.0;
00060     const RawBeamData* dev = rbmb[fDeviceName];
00061     double value = 0;
00062     if (!dev) {
00063         MSG("BD",Msg::kWarning)
00064         << "No "<<fDeviceName<<" in the data\n";
00065     }
00066     else if (! dev->GetDataLength()) {
00067         MSG("BD",Msg::kWarning)
00068             << fDeviceName<<" exists but w/out data\n";
00069     }
00070     else value = dev->GetData()[0];
00072     return value;
00073 }

double BDScalar::GetValue (  )  const

Return the last scalar added.

Definition at line 50 of file BDScalar.cxx.

References fPastSpills, and UtilRunningAverage::LastSample().

Referenced by NtpBDFullModule::FillToroids(), BMSpillFiller::Spill(), and BMFileSummaryFiller::Timestamp().

00051 {
00052     return fPastSpills.LastSample();
00053 }

void BDScalar::SetAllowedSpillDeviation ( float  sigmas  ) 

Set the number of standard deviations a toroid measurement is allowed to deviate from the average before it is considered a significant deviation. Deviation is not checked until the configured number of spills have been collected.

Definition at line 45 of file BDScalar.cxx.

References fMaxDev.

00046 {
00047     fMaxDev = max_dev;
00048 }

void BDScalar::SetDevice ( const char *  device_name  ) 

Set device name.

If GetScalar() hasn't been overridden, this device name will be used to pull out data to be used as the watched scalar.

Definition at line 17 of file BDScalar.cxx.

References fDeviceName.

Referenced by BeamMonDbuModule::FillPipeline().

00018 {
00019     fDeviceName = device_name;
00020 }

void BDScalar::SetSpill ( const RawBeamMonHeaderBlock rbmhb,
const RawBeamMonBlock rbmb 
) [virtual]

Set the current spill blocks.

Implements BDProcessor.

Definition at line 22 of file BDScalar.cxx.

References UtilRunningAverage::Add(), fBeamChanged, fMaxDev, fPastSpills, GetScalar(), and UtilRunningAverage::SampleDeviation().

Referenced by NtpBDFullModule::FillToroids().

00024 {
00025     double value = this->GetScalar(rbmhb,rbmb);
00026     fBeamChanged = false;
00027     if (fPastSpills.SampleDeviation(value) > fMaxDev)
00028         fBeamChanged = true;
00030     fPastSpills.Add(value);
00032 }

void BDScalar::SetSpillQueueSize ( int  nspills  ) 

Set the number of spills overwhich to maintain the running average

Definition at line 40 of file BDScalar.cxx.

References fPastSpills, and UtilRunningAverage::SetSampleSize().

Referenced by BDScalar().

00041 {
00042     fPastSpills.SetSampleSize(nspills);
00043 }

Member Data Documentation

bool BDScalar::fBeamChanged [private]

Definition at line 95 of file BDScalar.h.

Referenced by BeamChanged(), and SetSpill().

const char* BDScalar::fDeviceName [private]

Definition at line 96 of file BDScalar.h.

Referenced by GetScalar(), and SetDevice().

float BDScalar::fMaxDev [private]

Definition at line 94 of file BDScalar.h.

Referenced by SetAllowedSpillDeviation(), and SetSpill().

Definition at line 93 of file BDScalar.h.

Referenced by GetValue(), SetSpill(), and SetSpillQueueSize().

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

Generated on 24 Apr 2017 for loon by  doxygen 1.6.1