00001 #include "BDHornCurrent.h"
00002
00003 #include <RawData/RawBeamData.h>
00004 #include <RawData/RawBeamMonBlock.h>
00005
00006 #include "MessageService/MsgService.h"
00007 CVSID("$Id: BDHornCurrent.cxx,v 1.3 2005/07/11 18:33:33 bv Exp $");
00008
00009
00010 BDHornCurrent::BDHornCurrent(float max_dev, int nspills)
00011 : BDScalar(max_dev,nspills)
00012 {
00013 }
00014
00015 double BDHornCurrent::GetScalar(const RawBeamMonHeaderBlock& ,
00016 const RawBeamMonBlock& rbmb)
00017 {
00018 const char* dev[] = {
00019 "E:NSLINA",
00020 "E:NSLINB",
00021 "E:NSLINC",
00022 "E:NSLIND",
00023 0
00024 };
00025
00026 double value = 0;
00027 for (int ind=0; dev[ind]; ++ind) {
00028 const RawBeamData* hc = rbmb[dev[ind]];
00029 double val = 0;
00030 if (!hc) {
00031 MSG("BD",Msg::kDebug) << "No "<<dev[ind]<<" in the data\n";
00032 }
00033 else if (! hc->GetDataLength()) {
00034 MSG("BD",Msg::kWarning)
00035 << dev[ind]<<" exists but w/out data\n";
00036 }
00037 else if (hc->GetDataLength() != 1) {
00038 MSG("BD",Msg::kWarning)
00039 << dev[ind]<<" exists but is wrong size\n";
00040 }
00041 else val = hc->GetData()[0];
00042 value += val;
00043 }
00044 return value;
00045 }