#include <BDScalar.h>
Inheritance diagram for BDScalar:

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 |
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.
Created on: Fri Apr 15 09:59:46 2005
Definition at line 37 of file BDScalar.h.
| 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 | ( | ) |
| 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; 00059 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]; 00071 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; 00029 00030 fPastSpills.Add(value); 00031 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 }
bool BDScalar::fBeamChanged [private] |
const char* BDScalar::fDeviceName [private] |
float BDScalar::fMaxDev [private] |
UtilRunningAverage BDScalar::fPastSpills [private] |
Definition at line 93 of file BDScalar.h.
Referenced by GetValue(), SetSpill(), and SetSpillQueueSize().
1.4.7