#include <BDSwicMaskAccessor.h>
Public Member Functions | |
| BDSwicMaskAccessor () | |
| ~BDSwicMaskAccessor () | |
| void | AddDevice (const char *device_name) |
| bool | SetSpillTime (VldContext vc) |
| const std::vector< double > & | GetMask (const char *device_name) const |
Private Types | |
| typedef std::map< std::string, Device > | SwicMap |
Private Member Functions | |
| void | Reset () |
Private Attributes | |
| SwicMap | fSwicMap |
| DbiResultPtr< BeamMonSwicMask > * | fMaskResPtr |
| DbiResultPtr< BeamMonSwicRel > * | fRelResPtr |
| const DbiResultKey * | fMaskResKey |
| const DbiResultKey * | fRelResKey |
Created on: Mon Apr 25 12:08:17 2005
Definition at line 37 of file BDSwicMaskAccessor.h.
|
|
Definition at line 63 of file BDSwicMaskAccessor.h. |
|
|
Definition at line 19 of file BDSwicMaskAccessor.cxx. 00020 : fMaskResPtr(new DbiResultPtr<BeamMonSwicMask>) 00021 , fRelResPtr(new DbiResultPtr<BeamMonSwicRel>) 00022 , fMaskResKey(0), fRelResKey(0) 00023 { 00024 }
|
|
|
Definition at line 25 of file BDSwicMaskAccessor.cxx. References fMaskResKey, fMaskResPtr, fRelResKey, and fRelResPtr. 00026 {
00027 if (fMaskResPtr) delete fMaskResPtr;
00028 if (fRelResPtr) delete fRelResPtr;
00029 fMaskResPtr = 0;
00030 fRelResPtr = 0;
00031 fMaskResKey = fRelResKey = 0;
00032 }
|
|
|
Definition at line 34 of file BDSwicMaskAccessor.cxx. References fSwicMap, BDSwicMaskAccessor::Device::mask, BDSwicMaskAccessor::Device::prod, and BDSwicMaskAccessor::Device::rel. Referenced by BDSwicCalibrator::AddDevice(). 00035 {
00036 if (fSwicMap.find(device_name) != fSwicMap.end()) return;
00037
00038 Device dev;
00039 dev.mask = vector<double>(96,1);
00040 dev.rel = vector<double>(96,1);
00041 dev.prod = vector<double>(96,1);
00042 fSwicMap[device_name] = dev;
00043 }
|
|
|
Get the current masks for given device. Return empty vector if device name is unknown. Definition at line 114 of file BDSwicMaskAccessor.cxx. References fSwicMap. Referenced by BDSwicCalibrator::CalibrateOne(). 00115 {
00116 static vector<double> looser;
00117
00118 SwicMap::const_iterator it = fSwicMap.find(device_name);
00119 if (it == fSwicMap.end()) return looser;
00120
00121 return it->second.prod;
00122 }
|
|
|
Definition at line 46 of file BDSwicMaskAccessor.cxx. References done(), fSwicMap, BDSwicMaskAccessor::Device::mask, BDSwicMaskAccessor::Device::prod, and BDSwicMaskAccessor::Device::rel. Referenced by SetSpillTime(). 00047 {
00048 SwicMap::iterator it, done = fSwicMap.end();
00049 for (it=fSwicMap.begin(); it != done; ++it) {
00050 it->second.mask = vector<double>(96,1);
00051 it->second.rel = vector<double>(96,1);
00052 it->second.prod = vector<double>(96,1);
00053 }
00054 }
|
|
|
Update masks. Should be called once per spill. Return true if an update was needed. Definition at line 57 of file BDSwicMaskAccessor.cxx. References done(), fMaskResKey, fMaskResPtr, fRelResKey, fRelResPtr, fSwicMap, BeamMonSwicRel::GetChannelsAsDoubles(), BeamMonSwicRel::GetDeviceName(), BeamMonSwicMask::GetDeviceName(), DbiResultPtr< T >::GetKey(), BeamMonSwicMask::GetMask(), BeamMonSwicMask::GetOffset(), DbiResultPtr< T >::GetRow(), DbiResultKey::IsEqualTo(), MSG, DbiResultPtr< T >::NewQuery(), and Reset(). Referenced by BDSwicCalibrator::Calibrate(). 00058 {
00059
00060 bool tf1 = true; // db hit?
00061 int nrows1 = fMaskResPtr->NewQuery(vc,0,true);
00062 const DbiResultKey* result_key1 = fMaskResPtr->GetKey();
00063 if (fMaskResKey && result_key1->IsEqualTo(fMaskResKey)) tf1=false;
00064
00065 bool tf2 = true; // db hit?
00066 int nrows2 = fRelResPtr->NewQuery(vc,0,true);
00067 const DbiResultKey* result_key2 = fRelResPtr->GetKey();
00068 if (fRelResKey && result_key2->IsEqualTo(fRelResKey)) tf2=false;
00069
00070 if (!tf1 && !tf2) return false;
00071
00072
00073 fMaskResKey = result_key1;
00074 fRelResKey = result_key2;
00075
00076 this->Reset();
00077
00078 if (tf1) {
00079 for (int row=0; row<nrows1; ++row) {
00080 const BeamMonSwicMask* mask = fMaskResPtr->GetRow(row);
00081 string name = mask->GetDeviceName();
00082 SwicMap::iterator it = fSwicMap.find(name);
00083 if (it == fSwicMap.end()) {
00084 MSG("BD",Msg::kDebug) << "No Device for "
00085 << name << ", continuing\n";
00086 continue;
00087 }
00088 int ind = mask->GetOffset();
00089 it->second.mask[ind] = mask->GetMask();
00090 }
00091 }
00092 if (tf2) {
00093 for (int row=0; row<nrows2; ++row) {
00094 const BeamMonSwicRel* rel = fRelResPtr->GetRow(row);
00095 string name = rel->GetDeviceName();
00096 SwicMap::iterator it = fSwicMap.find(name);
00097 if (it == fSwicMap.end()) {
00098 MSG("BD",Msg::kDebug) << "No Device for "
00099 << name << ", continuing\n";
00100 continue;
00101 }
00102 it->second.rel = rel->GetChannelsAsDoubles();
00103 }
00104 }
00105
00106 SwicMap::iterator it, done = fSwicMap.end();
00107 for (it=fSwicMap.begin(); it != done; ++it)
00108 for (int ind=0; ind<96; ++ind)
00109 it->second.prod[ind] = it->second.mask[ind]*it->second.rel[ind];
00110
00111 return true;
00112 }
|
|
|
Definition at line 68 of file BDSwicMaskAccessor.h. Referenced by SetSpillTime(), and ~BDSwicMaskAccessor(). |
|
|
Definition at line 66 of file BDSwicMaskAccessor.h. Referenced by SetSpillTime(), and ~BDSwicMaskAccessor(). |
|
|
Definition at line 68 of file BDSwicMaskAccessor.h. Referenced by SetSpillTime(), and ~BDSwicMaskAccessor(). |
|
|
Definition at line 67 of file BDSwicMaskAccessor.h. Referenced by SetSpillTime(), and ~BDSwicMaskAccessor(). |
|
|
Definition at line 64 of file BDSwicMaskAccessor.h. Referenced by AddDevice(), GetMask(), Reset(), and SetSpillTime(). |
1.3.9.1