BDSwicMaskAccessor Class Reference
[BeamDataUtil]

Access any SWIC channel weights (masks). More...

#include <BDSwicMaskAccessor.h>

List of all members.

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 DbiResultKeyfMaskResKey
const DbiResultKeyfRelResKey

Classes

struct  Device


Detailed Description

Access any SWIC channel weights (masks).

Author:
(last to touch it)
Author
minoscvs
Version:
Revision
1.4
Date:
Date
2005/05/05 21:11:12
Contact: bv@bnl.gov

Created on: Mon Apr 25 12:08:17 2005

Id
BDSwicMaskAccessor.h,v 1.4 2005/05/05 21:11:12 minoscvs Exp

Definition at line 37 of file BDSwicMaskAccessor.h.


Member Typedef Documentation

typedef std::map<std::string,Device> BDSwicMaskAccessor::SwicMap [private]

Definition at line 63 of file BDSwicMaskAccessor.h.


Constructor & Destructor Documentation

BDSwicMaskAccessor::BDSwicMaskAccessor (  ) 

Definition at line 19 of file BDSwicMaskAccessor.cxx.

BDSwicMaskAccessor::~BDSwicMaskAccessor (  ) 

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 }


Member Function Documentation

void BDSwicMaskAccessor::AddDevice ( const char *  device_name  ) 

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 }

const vector< double > & BDSwicMaskAccessor::GetMask ( const char *  device_name  )  const

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 }

void BDSwicMaskAccessor::Reset (  )  [private]

Definition at line 46 of file BDSwicMaskAccessor.cxx.

References done(), and fSwicMap.

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 }

bool BDSwicMaskAccessor::SetSpillTime ( VldContext  vc  ) 

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::GetDeviceName(), BeamMonSwicMask::GetDeviceName(), DbiResultPtr< T >::GetKey(), DbiResultPtr< T >::GetRow(), DbiResultKey::IsEqualTo(), Msg::kDebug, 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 }


Member Data Documentation

const DbiResultKey* BDSwicMaskAccessor::fMaskResKey [private]

Definition at line 68 of file BDSwicMaskAccessor.h.

Referenced by SetSpillTime(), and ~BDSwicMaskAccessor().

DbiResultPtr<BeamMonSwicMask>* BDSwicMaskAccessor::fMaskResPtr [private]

Definition at line 66 of file BDSwicMaskAccessor.h.

Referenced by SetSpillTime(), and ~BDSwicMaskAccessor().

const DbiResultKey * BDSwicMaskAccessor::fRelResKey [private]

Definition at line 68 of file BDSwicMaskAccessor.h.

Referenced by SetSpillTime(), and ~BDSwicMaskAccessor().

DbiResultPtr<BeamMonSwicRel>* BDSwicMaskAccessor::fRelResPtr [private]

Definition at line 67 of file BDSwicMaskAccessor.h.

Referenced by SetSpillTime(), and ~BDSwicMaskAccessor().

SwicMap BDSwicMaskAccessor::fSwicMap [private]

Definition at line 64 of file BDSwicMaskAccessor.h.

Referenced by AddDevice(), GetMask(), Reset(), and SetSpillTime().


The documentation for this class was generated from the following files:
Generated on Thu Jul 10 22:52:25 2014 for loon by  doxygen 1.4.7