/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
DybCableCache Class Reference

Cache DetectorSensors, HardwareIds and ElecChannels for a given detector. More...

#include <DybCableCache.h>

Collaboration diagram for DybCableCache:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DybCableCache ()
 ~DybCableCache ()
bool update (const ServiceMode &sm)
void SetCableMapKey (const DbiResultKey *cmapKey)
void SetHardwareIDKey (const DbiResultKey *hwidKey)

Public Attributes

std::vector
< DayaBay::DetectorSensor
sensors
std::vector< DayaBay::AdPmtSensoradPmtSensors
std::vector
< DayaBay::PoolPmtSensor
poolPmtSensors
std::vector< DayaBay::RpcSensorrpcSensors
std::vector
< DayaBay::ElecChannelId
elecChannelIds
std::vector
< DayaBay::FeeChannelId
feeChannelIds
std::vector
< DayaBay::FecChannelId
fecChannelIds
std::map
< DayaBay::DetectorSensor,
DayaBay::ElecChannelId
channelBySensor
std::map
< DayaBay::ElecChannelId,
DayaBay::DetectorSensor
sensorByChannel
std::vector< DayaBay::HardwareIdhardwareIds
std::vector
< DayaBay::PmtHardwareId
pmtHardwareIds
std::vector
< DayaBay::RpcHardwareId
rpcHardwareIds
std::vector
< DayaBay::FeeHardwareId
feeHardwareIds
std::vector
< DayaBay::FecHardwareId
fecHardwareIds
std::map
< DayaBay::DetectorSensor,
DayaBay::HardwareId
hardwareBySensor
std::map< DayaBay::HardwareId,
DayaBay::DetectorSensor
sensorByHardware
std::map
< DayaBay::ElecChannelId,
DayaBay::HardwareId
hardwareByChannel
std::map< DayaBay::HardwareId,
DayaBay::ElecChannelId
channelByHardware

Private Member Functions

void clear ()
void clear_cmap ()
void clear_hwid ()
void fill_cmap (DbiResultPtr< GCableMap > &cmapRes)
void fill_hwid (DbiResultPtr< GHardwareID > &hwidRes)

Private Attributes

const DbiResultKeym_cmapKey
const DbiResultKeym_hwidKey
ServiceMode m_lastServiceMode

Detailed Description

Cache DetectorSensors, HardwareIds and ElecChannels for a given detector.

This is used by DybCableMap to not invalidate returned references when a new detector is queried.

bv@bnl.gov Tue May 24 17:38:43 2011

Definition at line 31 of file DybCableCache.h.


Constructor & Destructor Documentation

DybCableCache::DybCableCache ( )

Definition at line 11 of file DybCableCache.cc.

    : m_cmapKey(0)
    , m_hwidKey(0)
    , m_lastServiceMode()

{
   LOGLEVEL(dbi) << "Creating DybCableCache " << std::hex << this ;

}
DybCableCache::~DybCableCache ( )

Definition at line 21 of file DybCableCache.cc.

{
    LOGLEVEL(dbi) << "Destroying DybCableCache " << std::hex << this ;
    delete m_cmapKey ;
    delete m_hwidKey ;
}

Member Function Documentation

void DybCableCache::clear ( ) [private]

Definition at line 86 of file DybCableCache.cc.

void DybCableCache::clear_cmap ( ) [private]

Definition at line 92 of file DybCableCache.cc.

{
    sensors.clear();
    adPmtSensors.clear();
    poolPmtSensors.clear();
    rpcSensors.clear();

    elecChannelIds.clear();
    feeChannelIds.clear();
    fecChannelIds.clear();

    channelBySensor.clear();
    sensorByChannel.clear();
}
void DybCableCache::clear_hwid ( ) [private]

Definition at line 107 of file DybCableCache.cc.

{
    hardwareIds.clear();
    pmtHardwareIds.clear();
    rpcHardwareIds.clear();
    feeHardwareIds.clear();
    fecHardwareIds.clear();

    hardwareBySensor.clear();
    sensorByHardware.clear();
    hardwareByChannel.clear();
    channelByHardware.clear();
}
void DybCableCache::fill_cmap ( DbiResultPtr< GCableMap > &  cmapRes) [private]

Definition at line 121 of file DybCableCache.cc.

{
    unsigned int ind, nrows = cmapRes.GetNumRows();
    for (ind = 0; ind < nrows; ++ind) {
        const GCableMap* row = cmapRes.GetRowByIndex(ind);
        DetectorSensor sens =  row->GetSensorId();
        ElecChannelId chan = row->GetChannelId();
        
        sensors.push_back(sens);
        elecChannelIds.push_back(chan);

        if (sens.isAD()) { 
            adPmtSensors.push_back(AdPmtSensor(sens.fullPackedData()));
            feeChannelIds.push_back(FeeChannelId(chan.fullPackedData()));
        }
        if (sens.isWaterShield()) { 
            poolPmtSensors.push_back(PoolPmtSensor(sens.fullPackedData())); 
            feeChannelIds.push_back(FeeChannelId(chan.fullPackedData()));
        }
        if (sens.isRPC()) { 
            rpcSensors.push_back(RpcSensor(sens.fullPackedData())); 
            fecChannelIds.push_back(FecChannelId(chan.fullPackedData()));
        }

        channelBySensor[sens] = chan;
        sensorByChannel[chan] = sens;
    }
}
void DybCableCache::fill_hwid ( DbiResultPtr< GHardwareID > &  hwidRes) [private]

Definition at line 150 of file DybCableCache.cc.

{
    unsigned int ind, nrows = hwidRes.GetNumRows();
    for (ind = 0; ind < nrows; ++ind) {
        const GHardwareID* row = hwidRes.GetRowByIndex(ind);
        Detector det = row->GetChanOrSens();
        HardwareId hwid = row->GetHardwareId();

        hardwareIds.push_back(hwid);
        
        // sensors

        if (hwid.type() == Hardware::kPmt8inch || hwid.type() == Hardware::kPmt2inch) {
            pmtHardwareIds.push_back(PmtHardwareId(hwid.id(),hwid.type()));
            DetectorSensor sens(det.fullPackedData());
            hardwareBySensor[sens] = hwid;
            sensorByHardware[hwid] = sens;
        }
        if (hwid.type() == Hardware::kRpc) {
            rpcHardwareIds.push_back(RpcHardwareId(hwid.fullPackedData()));
            DetectorSensor sens(det.fullPackedData());
            hardwareBySensor[sens] = hwid;
            sensorByHardware[hwid] = sens;
        }

        // channels 

        if (hwid.type() == Hardware::kFee) {
            feeHardwareIds.push_back(FeeHardwareId(hwid.fullPackedData()));
            ElecChannelId chan(det.fullPackedData());
            hardwareByChannel[chan] = hwid;
            channelByHardware[hwid] = chan;
        }
        if (hwid.type() == Hardware::kFec) {
            fecHardwareIds.push_back(FecHardwareId(hwid.fullPackedData()));
            ElecChannelId chan(det.fullPackedData());
            hardwareByChannel[chan] = hwid;
            channelByHardware[hwid] = chan;
        }
    }

}
bool DybCableCache::update ( const ServiceMode sm)

Definition at line 43 of file DybCableCache.cc.

{
    if(sm.context() == m_lastServiceMode.context() 
       && sm.task() == m_lastServiceMode.task())
    {
        return false;
    }
    m_lastServiceMode = sm;
 

    LOGLEVEL(dbi) << "DybCableCache::update DbiResultPtr call svcMode changed: " 
                  << sm << " " << std::hex << this  ;
    DbiResultPtr<GCableMap>   cmapRes("CableMap",  sm.context(),sm.context().GetDetId(),sm.task());
    DbiResultPtr<GHardwareID> hwidRes("HardwareID",sm.context(),sm.context().GetDetId(),sm.task());

    const DbiResultKey* cmapKey= cmapRes.GetKey(); 
    const DbiResultKey* hwidKey= hwidRes.GetKey(); 

    bool updated = false;

    if ( ! m_cmapKey || ! cmapKey->IsEqualTo(m_cmapKey) ) {
        LOGLEVEL(dbi) << "DybCableCache::update clearing CableMap cache for new query keys " 
                      << std::hex << this ;
        // keys are copied, with ownership of copies being taken, see #1198
        SetCableMapKey(cmapKey);
        clear_cmap();
        fill_cmap(cmapRes);
        updated = true;
    }

    if ( ! m_hwidKey || ! hwidKey->IsEqualTo(m_hwidKey) ) {
        LOGLEVEL(dbi) << "DybCableCache::update clearing HardwareID cache for new query keys " 
                      << std::hex << this ;
        // keys are copied, with ownership of copies being taken, see #1198
        SetHardwareIDKey(hwidKey);
        clear_hwid();
        fill_hwid(hwidRes);
        updated = true;
    }

    return updated;
}
void DybCableCache::SetCableMapKey ( const DbiResultKey cmapKey)

Definition at line 28 of file DybCableCache.cc.

{
    assert(cmapKey != NULL);
    delete m_cmapKey ;
    m_cmapKey = new DbiResultKey( cmapKey );
}
void DybCableCache::SetHardwareIDKey ( const DbiResultKey hwidKey)

Definition at line 35 of file DybCableCache.cc.

{
    assert(hwidKey != NULL);
    delete m_hwidKey ;
    m_hwidKey = new DbiResultKey( hwidKey );
}

Member Data Documentation

Definition at line 34 of file DybCableCache.h.

Definition at line 36 of file DybCableCache.h.

Definition at line 38 of file DybCableCache.h.

Definition at line 63 of file DybCableCache.h.

Definition at line 64 of file DybCableCache.h.

Definition at line 65 of file DybCableCache.h.

Definition at line 66 of file DybCableCache.h.

Definition at line 68 of file DybCableCache.h.

Definition at line 69 of file DybCableCache.h.

Definition at line 70 of file DybCableCache.h.

Definition at line 72 of file DybCableCache.h.

Definition at line 73 of file DybCableCache.h.

Definition at line 76 of file DybCableCache.h.

Definition at line 77 of file DybCableCache.h.

Definition at line 78 of file DybCableCache.h.

Definition at line 79 of file DybCableCache.h.

Definition at line 80 of file DybCableCache.h.

Definition at line 82 of file DybCableCache.h.

Definition at line 83 of file DybCableCache.h.

Definition at line 85 of file DybCableCache.h.

Definition at line 86 of file DybCableCache.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:00:00 for DybMetaDataSvc by doxygen 1.7.4