Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BDScalar.cxx

Go to the documentation of this file.
00001 #include "BDScalar.h"
00002 #include <RawData/RawBeamMonBlock.h>
00003 #include <RawData/RawBeamData.h>
00004 
00005 #include "MessageService/MsgService.h"
00006 CVSID("$Id: BDScalar.cxx,v 1.3 2005/04/27 17:36:10 minoscvs Exp $");
00007 
00008 BDScalar::BDScalar(float max_dev, int nspills, const char* device_name)
00009     : fMaxDev(max_dev), fDeviceName(device_name)
00010 {
00011     this->SetSpillQueueSize(nspills);
00012 }
00013 BDScalar::~BDScalar()
00014 {
00015 }
00016 
00017 void BDScalar::SetDevice(const char* device_name)
00018 {
00019     fDeviceName = device_name;
00020 }
00021 
00022 void BDScalar::SetSpill(const RawBeamMonHeaderBlock& rbmhb,
00023                         const RawBeamMonBlock& rbmb)
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 }
00033 
00034 bool BDScalar::BeamChanged()
00035 {
00036     return fBeamChanged;
00037 }
00038 
00039 
00040 void BDScalar::SetSpillQueueSize(int nspills)
00041 {
00042     fPastSpills.SetSampleSize(nspills);
00043 }
00044 
00045 void BDScalar::SetAllowedSpillDeviation(float max_dev)
00046 {
00047     fMaxDev = max_dev;
00048 }
00049 
00050 double BDScalar::GetValue() const
00051 {
00052     return fPastSpills.LastSample();
00053 }
00054 
00055 double BDScalar::GetScalar(const RawBeamMonHeaderBlock& ,
00056                            const RawBeamMonBlock& rbmb)
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 }
00074 

Generated on Sat Nov 7 01:25:06 2009 for loon by  doxygen 1.3.9.1