/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 | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
StaticCableSvc Class Reference

#include <StaticCableSvc.h>

Inheritance diagram for StaticCableSvc:
Inheritance graph
[legend]
Collaboration diagram for StaticCableSvc:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 StaticCableSvc (const std::string &name, ISvcLocator *svc)
 ~StaticCableSvc ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
const std::vector
< DayaBay::HardwareId > & 
hardwareIds (const ServiceMode &svcMode)
const std::vector
< DayaBay::PmtHardwareId > & 
pmtHardwareIds (const ServiceMode &svcMode)
const std::vector
< DayaBay::RpcHardwareId > & 
rpcHardwareIds (const ServiceMode &svcMode)
const std::vector
< DayaBay::FeeHardwareId > & 
feeHardwareIds (const ServiceMode &svcMode)
const std::vector
< DayaBay::FecHardwareId > & 
fecHardwareIds (const ServiceMode &svcMode)
const std::vector
< DayaBay::DetectorSensor > & 
sensors (const ServiceMode &svcMode)
const std::vector
< DayaBay::AdPmtSensor > & 
adPmtSensors (const ServiceMode &svcMode)
const std::vector
< DayaBay::PoolPmtSensor > & 
poolPmtSensors (const ServiceMode &svcMode)
const std::vector
< DayaBay::RpcSensor > & 
rpcSensors (const ServiceMode &svcMode)
const std::vector
< DayaBay::ElecChannelId > & 
elecChannelIds (const ServiceMode &svcMode)
const std::vector
< DayaBay::FeeChannelId > & 
feeChannelIds (const ServiceMode &svcMode)
const std::vector
< DayaBay::FecChannelId > & 
fecChannelIds (const ServiceMode &svcMode)
DayaBay::ElecChannelId elecChannelId (const DayaBay::DetectorSensor &sensId, const ServiceMode &svcMode)
DayaBay::FeeChannelId feeChannelId (const DayaBay::AdPmtSensor &sensId, const ServiceMode &svcMode)
DayaBay::FeeChannelId feeChannelId (const DayaBay::PoolPmtSensor &sensId, const ServiceMode &svcMode)
DayaBay::FecChannelId fecChannelId (const DayaBay::RpcSensor &sensId, const ServiceMode &svcMode)
DayaBay::DetectorSensor sensor (const DayaBay::ElecChannelId &elecChannel, const ServiceMode &svcMode)
DayaBay::AdPmtSensor adPmtSensor (const DayaBay::FeeChannelId &feeChannel, const ServiceMode &svcMode)
DayaBay::PoolPmtSensor poolPmtSensor (const DayaBay::FeeChannelId &feeChannel, const ServiceMode &svcMode)
DayaBay::RpcSensor rpcSensor (const DayaBay::FecChannelId &fecChannel, const ServiceMode &svcMode)
DayaBay::HardwareId hardwareId (const DayaBay::DetectorSensor &sensId, const ServiceMode &svcMode)
DayaBay::PmtHardwareId pmtHardwareId (const DayaBay::AdPmtSensor &sensId, const ServiceMode &svcMode)
DayaBay::PmtHardwareId pmtHardwareId (const DayaBay::PoolPmtSensor &sensId, const ServiceMode &svcMode)
DayaBay::RpcHardwareId rpcHardwareId (const DayaBay::RpcSensor &sensId, const ServiceMode &svcMode)
DayaBay::DetectorSensor sensor (const DayaBay::HardwareId &hardwareId, const ServiceMode &svcMode)
DayaBay::AdPmtSensor adPmtSensor (const DayaBay::PmtHardwareId &pmtId, const ServiceMode &svcMode)
DayaBay::PoolPmtSensor poolPmtSensor (const DayaBay::PmtHardwareId &pmtId, const ServiceMode &svcMode)
DayaBay::RpcSensor rpcSensor (const DayaBay::RpcHardwareId &rpcId, const ServiceMode &svcMode)
DayaBay::HardwareId hardwareId (const DayaBay::ElecChannelId &elecChannel, const ServiceMode &svcMode)
DayaBay::FeeHardwareId feeHardwareId (const DayaBay::FeeChannelId &feeChannel, const ServiceMode &svcMode)
DayaBay::FecHardwareId fecHardwareId (const DayaBay::FecChannelId &fecChannel, const ServiceMode &svcMode)
DayaBay::ElecChannelId elecChannelId (const DayaBay::HardwareId &hardwareId, const ServiceMode &svcMode)
DayaBay::FeeChannelId feeChannelId (const DayaBay::FeeHardwareId &feeHardwareId, const ServiceMode &svcMode)
DayaBay::FecChannelId fecChannelId (const DayaBay::FecHardwareId &fecHardwareId, const ServiceMode &svcMode)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

StatusCode initMap (const ServiceMode &svcMode)
 Here the real CableMap file will be loaded.

Private Attributes

IMessageSvc * msg
std::string m_feeCableFileName
std::string m_fecCableFileName
bool m_first
 First call of query?
std::vector< DayaBay::HardwareIdm_hardwareIds
std::vector
< DayaBay::PmtHardwareId
m_pmtHardwareIds
std::vector
< DayaBay::RpcHardwareId
m_rpcHardwareIds
std::vector
< DayaBay::FeeHardwareId
m_feeHardwareIds
std::vector
< DayaBay::FecHardwareId
m_fecHardwareIds
std::vector
< DayaBay::DetectorSensor
m_sensors
std::vector< DayaBay::AdPmtSensorm_adPmtSensors
std::vector
< DayaBay::PoolPmtSensor
m_poolPmtSensors
std::vector< DayaBay::RpcSensorm_rpcSensors
std::vector
< DayaBay::ElecChannelId
m_elecChannelIds
std::vector
< DayaBay::FeeChannelId
m_feeChannelIds
std::vector
< DayaBay::FecChannelId
m_fecChannelIds
std::map< DayaBay::Detector,
std::vector
< DayaBay::DetectorSensor > > 
m_sensorsBySiteDet
std::map< DayaBay::Detector,
std::vector
< DayaBay::AdPmtSensor > > 
m_adPmtSensorsBySiteDet
std::map< DayaBay::Detector,
std::vector
< DayaBay::PoolPmtSensor > > 
m_poolPmtSensorsBySiteDet
std::map< DayaBay::Detector,
std::vector
< DayaBay::RpcSensor > > 
m_rpcSensorsBySiteDet
std::map< DayaBay::Detector,
std::vector
< DayaBay::ElecChannelId > > 
m_elecChannelIdsBySiteDet
std::map< DayaBay::Detector,
std::vector
< DayaBay::FeeChannelId > > 
m_feeChannelIdsBySiteDet
std::map< DayaBay::Detector,
std::vector
< DayaBay::FecChannelId > > 
m_fecChannelIdsBySiteDet
std::map
< DayaBay::DetectorSensor,
DayaBay::ElecChannelId
m_channelBySensor
std::map
< DayaBay::ElecChannelId,
DayaBay::DetectorSensor
m_sensorByChannel
std::map
< DayaBay::DetectorSensor,
DayaBay::HardwareId
m_hardwareBySensor
std::map< DayaBay::HardwareId,
DayaBay::DetectorSensor
m_sensorByHardware
std::map
< DayaBay::ElecChannelId,
DayaBay::HardwareId
m_hardwareByChannel
std::map< DayaBay::HardwareId,
DayaBay::ElecChannelId
m_channelByHardware

Static Private Attributes

static DayaBay::Detector s_unknownSiteDet
static DayaBay::Detector s_allSiteDet

Detailed Description

Definition at line 21 of file StaticCableSvc.h.


Constructor & Destructor Documentation

StaticCableSvc::StaticCableSvc ( const std::string &  name,
ISvcLocator *  svc 
)

When specified, this is the default source. If not, it will load one depends on "Master.CableMap.txt"

Definition at line 16 of file StaticCableSvc.cc.

    : Service(name,svc)
    , m_first(true)
{
  msg = 0;
  declareProperty("FeeCableMap",m_feeCableFileName="",
                  "Filename for loading the FEE cabling map.");
  declareProperty("FecCableMap",m_fecCableFileName="",
                  "Filename for loading the FEC cabling map");
}
StaticCableSvc::~StaticCableSvc ( )

Definition at line 30 of file StaticCableSvc.cc.

{
}

Member Function Documentation

StatusCode StaticCableSvc::initialize ( ) [virtual]

Definition at line 34 of file StaticCableSvc.cc.

{
    this->Service::initialize();

    return StatusCode::SUCCESS;
}
StatusCode StaticCableSvc::finalize ( ) [virtual]

Definition at line 360 of file StaticCableSvc.cc.

{
    return this->Service::finalize();
}
StatusCode StaticCableSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
) [virtual]

Definition at line 365 of file StaticCableSvc.cc.

{
    StatusCode sc = StatusCode::FAILURE;
    if (ppvInterface) {
        *ppvInterface = 0;

        if (ICableSvc::interfaceID().versionMatch(riid)) {
            *ppvInterface = static_cast<ICableSvc*>(this);
            sc = StatusCode::SUCCESS;
            addRef();
        }
        else sc = Service::queryInterface( riid, ppvInterface );
    }
    return sc;
}
const std::vector< DayaBay::HardwareId > & StaticCableSvc::hardwareIds ( const ServiceMode svcMode) [virtual]

Implements ICableSvc.

Definition at line 382 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return m_hardwareIds;
}
const std::vector< DayaBay::PmtHardwareId > & StaticCableSvc::pmtHardwareIds ( const ServiceMode svcMode) [virtual]

Implements ICableSvc.

Definition at line 388 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return m_pmtHardwareIds;
}
const std::vector< DayaBay::RpcHardwareId > & StaticCableSvc::rpcHardwareIds ( const ServiceMode svcMode) [virtual]

Implements ICableSvc.

Definition at line 394 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return m_rpcHardwareIds;
}
const std::vector< DayaBay::FeeHardwareId > & StaticCableSvc::feeHardwareIds ( const ServiceMode svcMode) [virtual]

Implements ICableSvc.

Definition at line 400 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return m_feeHardwareIds;
}
const std::vector< DayaBay::FecHardwareId > & StaticCableSvc::fecHardwareIds ( const ServiceMode svcMode) [virtual]

Implements ICableSvc.

Definition at line 406 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return m_fecHardwareIds;
}
const std::vector< DayaBay::DetectorSensor > & StaticCableSvc::sensors ( const ServiceMode svcMode) [virtual]

Implements ICableSvc.

Definition at line 412 of file StaticCableSvc.cc.

{
  MsgStream log(msgSvc(), "StaticCableSvc");

  if( m_first ) initMap(svcMode);
  DayaBay::Detector siteDetId(svcMode.context().GetSite(),
                              svcMode.context().GetDetId());
  std::map<DayaBay::Detector,std::vector<DayaBay::DetectorSensor> >::iterator iter;
  iter = m_sensorsBySiteDet.find(siteDetId);
  if( iter != m_sensorsBySiteDet.end() ){
    // Found site / det

      const std::vector<DayaBay::DetectorSensor>& detSensors = iter->second;
      for (size_t idet = 0; idet < detSensors.size(); ++idet) {
          DayaBay::DetectorSensor detSens = detSensors[idet];
          if (detSens.isAD() ) {
              DayaBay::AdPmtSensor pmtid(detSens.fullPackedData());
              if (pmtid.bogus()) {
                  log << MSG::WARNING << "bogus AD PMT id: " << pmtid << endreq;
              }
          }
          else if ( detSens.detectorId() != DetectorId::kRPC ) {
              DayaBay::PoolPmtSensor pmtid(detSens.fullPackedData());
              if (pmtid.bogus()) {
                  log << MSG::WARNING << "bogus Pool PMT id: " << pmtid << endreq;
              }
          }
      }

    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "sensors(): No sensors for site / detector ID: " << siteDetId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return m_sensorsBySiteDet[s_unknownSiteDet];
}
const std::vector< DayaBay::AdPmtSensor > & StaticCableSvc::adPmtSensors ( const ServiceMode svcMode) [virtual]

Note that this query is not based on time stamp. So you'd better assign a CableMap

Implements ICableSvc.

Definition at line 449 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  DayaBay::Detector siteDetId(svcMode.context().GetSite(),
                              svcMode.context().GetDetId());
  std::map<DayaBay::Detector,std::vector<DayaBay::AdPmtSensor> >::iterator iter;
  iter = m_adPmtSensorsBySiteDet.find(siteDetId);
  if( iter != m_adPmtSensorsBySiteDet.end() ){
    // Found site / det
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "adPmtSensors(): No sensors for site / detector ID: " << siteDetId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return m_adPmtSensorsBySiteDet[s_unknownSiteDet];
}
const std::vector< DayaBay::PoolPmtSensor > & StaticCableSvc::poolPmtSensors ( const ServiceMode svcMode) [virtual]

Note that this query is not based on time stamp. So you'd better assign a CableMap

Implements ICableSvc.

Definition at line 467 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  DayaBay::Detector siteDetId(svcMode.context().GetSite(),
                              svcMode.context().GetDetId());
  std::map<DayaBay::Detector,std::vector<DayaBay::PoolPmtSensor> >::iterator iter;
  iter = m_poolPmtSensorsBySiteDet.find(siteDetId);
  if( iter != m_poolPmtSensorsBySiteDet.end() ){
    // Found site / det
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "poolPmtSensors(): No sensors for site / detector ID: "<< siteDetId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return m_poolPmtSensorsBySiteDet[s_unknownSiteDet];
}
const std::vector< DayaBay::RpcSensor > & StaticCableSvc::rpcSensors ( const ServiceMode svcMode) [virtual]

Implements ICableSvc.

Definition at line 485 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  DayaBay::Detector siteDetId(svcMode.context().GetSite(),
                              svcMode.context().GetDetId());
  std::map<DayaBay::Detector,std::vector<DayaBay::RpcSensor> >::iterator iter;
  iter = m_rpcSensorsBySiteDet.find(siteDetId);
  if( iter != m_rpcSensorsBySiteDet.end() ){
    // Found site / det
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "rpcSensors(): No sensors for site / detector ID: "<< siteDetId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return m_rpcSensorsBySiteDet[s_unknownSiteDet];
}
const std::vector< DayaBay::ElecChannelId > & StaticCableSvc::elecChannelIds ( const ServiceMode svcMode) [virtual]

Implements ICableSvc.

Definition at line 502 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  DayaBay::Detector siteDetId(svcMode.context().GetSite(),
                              svcMode.context().GetDetId());
  std::map<DayaBay::Detector,std::vector<DayaBay::ElecChannelId> >::iterator iter;
  iter = m_elecChannelIdsBySiteDet.find(siteDetId);
  if( iter != m_elecChannelIdsBySiteDet.end() ){
    // Found site / det
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "elecChannelIds(): No sensors for site / detector ID: "<< siteDetId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return m_elecChannelIdsBySiteDet[s_unknownSiteDet];
}
const std::vector< DayaBay::FeeChannelId > & StaticCableSvc::feeChannelIds ( const ServiceMode svcMode) [virtual]

Implements ICableSvc.

Definition at line 519 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  DayaBay::Detector siteDetId(svcMode.context().GetSite(),
                              svcMode.context().GetDetId());
  std::map<DayaBay::Detector,std::vector<DayaBay::FeeChannelId> >::iterator iter;
  iter = m_feeChannelIdsBySiteDet.find(siteDetId);
  if( iter != m_feeChannelIdsBySiteDet.end() ){
    // Found site / det
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "feeChannelIds(): No sensors for site / detector ID: " << siteDetId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return m_feeChannelIdsBySiteDet[s_unknownSiteDet];
}
const std::vector< DayaBay::FecChannelId > & StaticCableSvc::fecChannelIds ( const ServiceMode svcMode) [virtual]

Implements ICableSvc.

Definition at line 536 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  DayaBay::Detector siteDetId(svcMode.context().GetSite(),
                              svcMode.context().GetDetId());
  std::map<DayaBay::Detector,std::vector<DayaBay::FecChannelId> >::iterator iter;
  iter = m_fecChannelIdsBySiteDet.find(siteDetId);
  if( iter != m_fecChannelIdsBySiteDet.end() ){
    // Found site / det
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "fecChannelIds(): No sensors for site / detector ID: " << siteDetId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return m_fecChannelIdsBySiteDet[s_unknownSiteDet];
}
DayaBay::ElecChannelId StaticCableSvc::elecChannelId ( const DayaBay::DetectorSensor sensId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 553 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  std::map<DayaBay::DetectorSensor,DayaBay::ElecChannelId>::iterator iter;
  iter = m_channelBySensor.find(sensId);
  if( iter != m_channelBySensor.end() ){
    // Found channel
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "elecChannelId(): No electronics channel for sensor ID: " << sensId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return DayaBay::ElecChannelId(0);
}
DayaBay::FeeChannelId StaticCableSvc::feeChannelId ( const DayaBay::AdPmtSensor sensId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 570 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::FeeChannelId(elecChannelId(sensId,svcMode).fullPackedData());
}
DayaBay::FeeChannelId StaticCableSvc::feeChannelId ( const DayaBay::PoolPmtSensor sensId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 578 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::FeeChannelId(elecChannelId(sensId,svcMode).fullPackedData());
}
DayaBay::FecChannelId StaticCableSvc::fecChannelId ( const DayaBay::RpcSensor sensId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 586 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);

  // check if this is whole panel
  if (sensId.layer() == 0 && sensId.strip() == 0) {
    DayaBay::RpcSensor helper(sensId.panelRow(),sensId.panelColumn(),
        1, 1, sensId.site(), sensId.detectorId());
    return DayaBay::FecChannelId(elecChannelId(helper, svcMode).fullPackedData()).boardId();
  }
  return DayaBay::FecChannelId(elecChannelId(sensId,svcMode).fullPackedData());
}
DayaBay::DetectorSensor StaticCableSvc::sensor ( const DayaBay::ElecChannelId elecChannel,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 601 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  std::map<DayaBay::ElecChannelId,DayaBay::DetectorSensor>::iterator iter;
  iter = m_sensorByChannel.find(elecChannel);
  if( iter != m_sensorByChannel.end() ){
    // Found sensor
    return iter->second;
  }
  static unsigned int errorCount=0;
  static const unsigned int maxErrors=100;
  if(errorCount<maxErrors){
    std::ostringstream msgStr;
    msgStr << "elecChannelId(): No sensor ID for electronics channel: "
           << elecChannel;
    msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
    errorCount++;
    if(errorCount==maxErrors){
      msg->reportMessage("StaticCableSvc",MSG::WARNING,
                         "elecChannelId(): No more errors will reported");
    }
  }
  return DayaBay::DetectorSensor(0);
}
DayaBay::AdPmtSensor StaticCableSvc::adPmtSensor ( const DayaBay::FeeChannelId feeChannel,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 628 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::AdPmtSensor(sensor(feeChannel,svcMode).fullPackedData());
}
DayaBay::PoolPmtSensor StaticCableSvc::poolPmtSensor ( const DayaBay::FeeChannelId feeChannel,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 636 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::PoolPmtSensor(sensor(feeChannel,svcMode).fullPackedData());
}
DayaBay::RpcSensor StaticCableSvc::rpcSensor ( const DayaBay::FecChannelId fecChannel,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 644 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  // check if we are dealing with full board Id
  if (fecChannel.connector() == 0) {
    DayaBay::ElecChannelId helper(fecChannel.board(), 1, fecChannel.site(), fecChannel.detectorId());
    return DayaBay::RpcSensor(sensor(helper,svcMode).fullPackedData()).panel();
  }

  return DayaBay::RpcSensor(sensor(fecChannel,svcMode).fullPackedData());
}
DayaBay::HardwareId StaticCableSvc::hardwareId ( const DayaBay::DetectorSensor sensId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 658 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  std::map<DayaBay::DetectorSensor,DayaBay::HardwareId>::iterator iter;
  iter = m_hardwareBySensor.find(sensId);
  if( iter != m_hardwareBySensor.end() ){
    // Found hardware
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "hardwareId(): No hardware ID for sensor ID: " << sensId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return DayaBay::HardwareId(0);
}
DayaBay::PmtHardwareId StaticCableSvc::pmtHardwareId ( const DayaBay::AdPmtSensor sensId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 675 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::PmtHardwareId(hardwareId(sensId,svcMode).fullPackedData());
}
DayaBay::PmtHardwareId StaticCableSvc::pmtHardwareId ( const DayaBay::PoolPmtSensor sensId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 683 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::PmtHardwareId(hardwareId(sensId,svcMode).fullPackedData());
}
DayaBay::RpcHardwareId StaticCableSvc::rpcHardwareId ( const DayaBay::RpcSensor sensId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 691 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::RpcHardwareId(hardwareId(sensId,svcMode).fullPackedData());
}
DayaBay::DetectorSensor StaticCableSvc::sensor ( const DayaBay::HardwareId hardwareId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 699 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  std::map<DayaBay::HardwareId,DayaBay::DetectorSensor>::iterator iter;
  iter = m_sensorByHardware.find(hardwareId);
  if( iter != m_sensorByHardware.end() ){
    // Found sensor
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "sensor(): No sensor for hardware ID: " << hardwareId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return DayaBay::DetectorSensor(0);
}
DayaBay::AdPmtSensor StaticCableSvc::adPmtSensor ( const DayaBay::PmtHardwareId pmtId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 716 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::AdPmtSensor(sensor(pmtId,svcMode).fullPackedData());
}
DayaBay::PoolPmtSensor StaticCableSvc::poolPmtSensor ( const DayaBay::PmtHardwareId pmtId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 724 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::PoolPmtSensor(sensor(pmtId,svcMode).fullPackedData());
}
DayaBay::RpcSensor StaticCableSvc::rpcSensor ( const DayaBay::RpcHardwareId rpcId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 732 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::RpcSensor(sensor(rpcId, svcMode).fullPackedData());
}
DayaBay::HardwareId StaticCableSvc::hardwareId ( const DayaBay::ElecChannelId elecChannel,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 740 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  std::map<DayaBay::ElecChannelId,DayaBay::HardwareId>::iterator iter;
  iter = m_hardwareByChannel.find(elecChannel);
  if( iter != m_hardwareByChannel.end() ){
    // Found hardware
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "hardwareId(): No hardware ID for electronics channel: "
         << elecChannel;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return DayaBay::HardwareId(0);
}
DayaBay::FeeHardwareId StaticCableSvc::feeHardwareId ( const DayaBay::FeeChannelId feeChannel,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 758 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::FeeHardwareId(hardwareId(feeChannel,svcMode).fullPackedData());
}
DayaBay::FecHardwareId StaticCableSvc::fecHardwareId ( const DayaBay::FecChannelId fecChannel,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 766 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::FecHardwareId(hardwareId(fecChannel,svcMode).fullPackedData());
}
DayaBay::ElecChannelId StaticCableSvc::elecChannelId ( const DayaBay::HardwareId hardwareId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 774 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  std::map<DayaBay::HardwareId,DayaBay::ElecChannelId>::iterator iter;
  iter = m_channelByHardware.find(hardwareId);
  if( iter != m_channelByHardware.end() ){
    // Found channel
    return iter->second;
  }
  std::ostringstream msgStr;
  msgStr << "elecChannelId(): No electronics channel for hardware ID: "
         << hardwareId;
  msg->reportMessage("StaticCableSvc",MSG::WARNING,msgStr.str());
  return DayaBay::ElecChannelId(0);
}
DayaBay::FeeChannelId StaticCableSvc::feeChannelId ( const DayaBay::FeeHardwareId feeHardwareId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 792 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::FeeChannelId(elecChannelId(feeHardwareId,svcMode).fullPackedData());
}
DayaBay::FecChannelId StaticCableSvc::fecChannelId ( const DayaBay::FecHardwareId fecHardwareId,
const ServiceMode svcMode 
) [virtual]

Implements ICableSvc.

Definition at line 800 of file StaticCableSvc.cc.

{
  if( m_first ) initMap(svcMode);
  return DayaBay::FecChannelId(elecChannelId(fecHardwareId,svcMode).fullPackedData());
}
StatusCode StaticCableSvc::initMap ( const ServiceMode svcMode) [private]

Here the real CableMap file will be loaded.

Master CableMap file. In case no FeeCableMap file specified, it will try to find one from there.

Master CableMap file. In case no FeeCableMap file specified, it will try to find one from there.

Definition at line 42 of file StaticCableSvc.cc.

{
    // Prepare the message service for reporting
    msg = msgSvc();
    if( !msg ){
      return StatusCode::FAILURE;
    }
    MsgStream log(msgSvc(), "StaticCableSvc");

    if(m_feeCableFileName=="")  {
      msg->reportMessage("StaticCableSvc",MSG::INFO,
                         "No FeeCableMap file specified. Loading one based on Master.CableMap.txt");

      std::string MasterCableMapFile = "Master.CableMap.txt";
      std::string Path = getenv ("DATASVCROOT");
      std::ifstream m_masterCableMap( (Path+"/share/"+MasterCableMapFile).c_str() );

      if( !m_masterCableMap.is_open() ){
        msg->reportMessage("StaticCableSvc",MSG::ERROR,"Fail to open Master.CableMap.txt");
        exit(1);
        return StatusCode::FAILURE;
      }

      int StartRun,EndRun;
      int Sites;
      int SimFlag, StartTimeSec, StartTimeNanoSec, EndTimeSec, EndTimeNanoSec;
      std::string MapFile;

      std::string line;

      while( std::getline( m_masterCableMap, line ) ){
        std::stringstream streamLine(line);
        if( streamLine.peek() == '#' ){
          continue;
        }
        streamLine >>StartRun >>EndRun >>Sites
          >>SimFlag >>StartTimeSec>> StartTimeNanoSec >>EndTimeSec >>EndTimeNanoSec
          >>MapFile;

        ContextRange CRange( Sites, SimFlag,
                             TimeStamp( StartTimeSec, StartTimeNanoSec ),
                             TimeStamp( EndTimeSec, EndTimeNanoSec ) );

        const Context &cont = svcMode.context();

        /*
        std::cout<< "Searching: "<<cont.GetSite()<<" "<<cont.GetSimFlag()<<std::endl;
        std::cout<< cont.GetTimeStamp().AsString()<<std::endl;
        std::cout<<"Start: "<<TimeStamp( StartTimeSec, StartTimeNanoSec ).AsString()<<std::endl;
        std::cout<<"End:   "<<TimeStamp( EndTimeSec, EndTimeNanoSec ).AsString()<<std::endl;
        */

        if( CRange.IsCompatible( cont ) && MapFile.find("fee") != MapFile.npos ) {
          m_feeCableFileName = Path + "/share/" + MapFile;
        }

      }

    } //if(m_feeCableFileName=="")

    if(m_fecCableFileName=="")  {
        log << MSG::INFO
            << "No FecCableMap file specified. Loading one based on Master.CableMap.txt"
            << endreq;

        std::string MasterCableMapFile = "Master.CableMap.txt";
        std::string Path = getenv ("DATASVCROOT");
        std::ifstream m_masterCableMap( (Path+"/share/"+MasterCableMapFile).c_str() );

        if( !m_masterCableMap.is_open() ){
            log << MSG::ERROR << "Fail to open Master.CableMap.txt"
                << endreq;
            exit(1);
            return StatusCode::FAILURE;
        }

        int StartRun,EndRun;
        int Sites;
        int SimFlag, StartTimeSec, StartTimeNanoSec, EndTimeSec, EndTimeNanoSec;
        std::string MapFile;

        std::string line;

        while( std::getline( m_masterCableMap, line ) ){
            std::stringstream streamLine(line);
            if( streamLine.peek() == '#' ){
              continue;
            }
            streamLine >>StartRun >>EndRun >>Sites
            >>SimFlag >>StartTimeSec>> StartTimeNanoSec >>EndTimeSec >>EndTimeNanoSec
            >>MapFile;

            ContextRange CRange( Sites, SimFlag,
                     TimeStamp( StartTimeSec, StartTimeNanoSec ),
                     TimeStamp( EndTimeSec, EndTimeNanoSec ) );

            const Context &cont = svcMode.context();

            if( CRange.IsCompatible( cont ) && MapFile.find("fec") != MapFile.npos ) {
                m_fecCableFileName = Path + "/share/" + MapFile;
            }
        }
    }

    if(m_feeCableFileName!=""){

      msg->reportMessage("StaticCableSvc",MSG::INFO,("FeeCableMap: "+m_feeCableFileName).c_str());

      std::ifstream input( m_feeCableFileName.c_str() );
      if( !input.is_open() ){
        std::ostringstream msgStr;
        msgStr << "Failed to open input file: " << m_feeCableFileName;
        msg->reportMessage("StaticCableSvc",MSG::ERROR,msgStr.str());
    exit(1);
        return StatusCode::FAILURE;
      }
      int site, detectorId, feeBoard, feeBoardSerial, feeConnector;
      int adPmtRing, adPmtColumn, poolPmtWallNumber, poolPmtWallSpot;
      int poolPmtInwardFacing, pmtHardwareType, pmtSerialNumber;
      std::string line;
      while( std::getline(input,line) ){
        std::stringstream streamLine(line);
        if( streamLine.peek() == '#' ){
          continue;
        }
        streamLine >> site >> detectorId >> feeBoard >> feeBoardSerial
                   >> feeConnector >> adPmtRing >> adPmtColumn
                   >> poolPmtWallNumber >> poolPmtWallSpot
                   >> poolPmtInwardFacing >> pmtHardwareType
                   >> pmtSerialNumber;
        DayaBay::FeeChannelId feeChannel(feeBoard, feeConnector,
                                         (Site::Site_t)site,
                                         (DetectorId::DetectorId_t)detectorId);
        DayaBay::FeeHardwareId feeHardware(feeBoardSerial, feeConnector);
        DayaBay::PmtHardwareId pmtHardware(pmtSerialNumber,
                                           (DayaBay::Hardware::Hardware_t)pmtHardwareType);
        // Make map by site / detector
        DayaBay::Detector siteId((Site::Site_t)site, DetectorId::kAll);
        DayaBay::Detector detector((Site::Site_t)site,
                                   (DetectorId::DetectorId_t)detectorId);
        m_elecChannelIdsBySiteDet[s_allSiteDet].push_back(feeChannel);
        m_elecChannelIdsBySiteDet[siteId].push_back(feeChannel);
        m_elecChannelIdsBySiteDet[detector].push_back(feeChannel);
        m_feeChannelIdsBySiteDet[s_allSiteDet].push_back(feeChannel);
        m_feeChannelIdsBySiteDet[siteId].push_back(feeChannel);
        m_feeChannelIdsBySiteDet[detector].push_back(feeChannel);
        // Make hardware connections
        m_channelByHardware[feeHardware] = feeChannel;
        m_hardwareByChannel[feeChannel] = feeHardware;

        // Make PMT connections
        int sensorId = 0;
        if( detector.isAD() ) {
          // AD PMT
          DayaBay::AdPmtSensor pmtId(adPmtRing, adPmtColumn,
                                     (Site::Site_t)site,
                                     (DetectorId::DetectorId_t)detectorId);
          sensorId = pmtId.fullPackedData();
        }else if( detector.isWaterShield() ) {
          // Pool PMT
          DayaBay::PoolPmtSensor pmtId(poolPmtWallNumber, poolPmtWallSpot,
                                       poolPmtInwardFacing,
                                       (Site::Site_t)site,
                                       (DetectorId::DetectorId_t)detectorId);
          sensorId = pmtId.fullPackedData();
        }
        if( sensorId == 0 ){
          // Unconnected FEE channel
          log <<"Unconnected FEE channel: S"<<site<<" D:"<<detectorId<<" B:"<<feeBoard<<" C:"<<feeConnector<<endreq;
          continue;
        }
        DayaBay::DetectorSensor sensor(sensorId);

        m_sensorsBySiteDet[s_allSiteDet].push_back(sensor);
        m_sensorsBySiteDet[siteId].push_back(sensor);
        m_sensorsBySiteDet[detector].push_back(sensor);
        m_channelBySensor[sensor] = feeChannel;
        m_sensorByChannel[feeChannel] = sensor;
        m_hardwareBySensor[sensor] = pmtHardware;
        m_sensorByHardware[pmtHardware] = sensor;
        if(sensor.detectorId() == DetectorId::kIWS
           || sensor.detectorId() == DetectorId::kOWS){
          DayaBay::PoolPmtSensor poolPmt(sensorId);
          if (poolPmt.bogus()) {
              log << "Warning: got bogus Pool PMT ID: " << poolPmt
                  << " while parsing line:\"" << line << "\""
                  << endreq;
          }
          m_poolPmtSensorsBySiteDet[s_allSiteDet].push_back(poolPmt);
          m_poolPmtSensorsBySiteDet[siteId].push_back(poolPmt);
          m_poolPmtSensorsBySiteDet[detector].push_back(poolPmt);
        }else{
          DayaBay::AdPmtSensor adPmt(sensorId);
          if (adPmt.bogus()) {
              log << "Warning: got bogus AD PMT ID: " << adPmt
                  << " while parsing line:\"" << line << "\""
                  << endreq;
          }
          m_adPmtSensorsBySiteDet[s_allSiteDet].push_back(adPmt);
          m_adPmtSensorsBySiteDet[siteId].push_back(adPmt);
          m_adPmtSensorsBySiteDet[detector].push_back(adPmt);
        }
      }
    } else { // if(m_feeCableFileName!="")
      log << MSG::ERROR << "No compatible Fee cable map found" << endreq;
    }

// retrieve data from the FEC cable map file
    if(m_fecCableFileName!=""){
        log<<MSG::INFO<<("FecCableMap: "+m_fecCableFileName).c_str()<<endreq;

        std::ifstream input( m_fecCableFileName.c_str() );
        if( !input.is_open() ){
            log << MSG::ERROR
                << ("Failed to open input file: " + m_fecCableFileName).c_str()
                << endreq;
            exit(1);
            return StatusCode::FAILURE;
        }

        int channelId, elecHwId, sensorId, detectorHwId;
        int romBoard, romBoardSerial, rtmBoard, rtmBoardSerial, rotBox, rotBoxSerial;
        int fecBoard, fecBoardSerial, fecConnector;
        int detectorId, site;
        int rpcRow, rpcColumn, rpcLayer, rpcStrip;
        int rpcModuleSerial;

        std::string line;
        while( std::getline(input,line) ){
            std::stringstream streamLine(line);
            if( streamLine.peek() == '#' ){
                continue;
            }

            streamLine >> site >> detectorId >> romBoard >> romBoardSerial
                >> rtmBoard >> rtmBoardSerial >> rotBox >> rotBoxSerial
                >> fecBoard >> fecBoardSerial >> fecConnector
                >> rpcRow >> rpcColumn >> rpcLayer >> rpcStrip
                >> rpcModuleSerial;

            // data correct check
            if ( streamLine.fail() ) {
            log << MSG::ERROR
                   << "The data format in the input file '"
                  << m_fecCableFileName.c_str() << "' does not seem"
                  << " to conform the one expected for RPC cable map."
                  << endreq;
                exit(1);
                return StatusCode::FAILURE;
            }
            if ( detectorId != DetectorId::kRPC ) {
                log << MSG::ERROR
                    << ("Incorrect data in the input file: "+ m_fecCableFileName).c_str()
                    << "Expected RPC data. Detector Id gotten is not DetectorId::kRPC : "
                    << detectorId << endreq;
                    exit(1);
                return StatusCode::FAILURE;
            }

            DayaBay::FecChannelId fecChannelId(fecBoard, fecConnector,
                (Site::Site_t) site, (DetectorId::DetectorId_t) detectorId);
            DayaBay::FecHardwareId fecHardwareId(fecBoardSerial, fecConnector);
            DayaBay::RpcHardwareId rpcHardwareId(rpcModuleSerial, rpcLayer, rpcStrip);
            // Make map by site / detector
            DayaBay::Detector siteId(fecChannelId.site(), DetectorId::kAll);
            DayaBay::Detector detector(fecChannelId.site(), DetectorId::kRPC);

            m_elecChannelIdsBySiteDet[s_allSiteDet].push_back(fecChannelId);
            m_elecChannelIdsBySiteDet[siteId].push_back(fecChannelId);
            m_elecChannelIdsBySiteDet[detector].push_back(fecChannelId);
            m_fecChannelIdsBySiteDet[s_allSiteDet].push_back(fecChannelId);
            m_fecChannelIdsBySiteDet[siteId].push_back(fecChannelId);
            m_fecChannelIdsBySiteDet[detector].push_back(fecChannelId);
            // Make hardware connections
            m_channelByHardware[fecHardwareId] = fecChannelId;
            m_hardwareByChannel[fecChannelId] = fecHardwareId;

            // Make RPC sensor connections
            int sensorId = 0;

            DayaBay::RpcSensor rpcSensor(rpcRow, rpcColumn, rpcLayer, rpcStrip,
                (Site::Site_t)site,
                DetectorId::kRPC);
            sensorId = rpcSensor.fullPackedData();

            if( sensorId == 0 ){
                // Unconnected FEC channel
                // note to myself: Can this ever happen?
                continue;
            }

            DayaBay::DetectorSensor sensor(sensorId);

            m_sensorsBySiteDet[s_allSiteDet].push_back(sensor);
            m_sensorsBySiteDet[siteId].push_back(sensor);
            m_sensorsBySiteDet[detector].push_back(sensor);
            m_channelBySensor[sensor] = fecChannelId;
            m_sensorByChannel[fecChannelId] = sensor;
            m_hardwareBySensor[sensor] = rpcHardwareId;
            m_sensorByHardware[rpcHardwareId] = sensor;

            m_rpcSensorsBySiteDet[s_allSiteDet].push_back(rpcSensor);
            m_rpcSensorsBySiteDet[siteId].push_back(rpcSensor);
            m_rpcSensorsBySiteDet[detector].push_back(rpcSensor);
        } // while
    } else {// if(m_fecCableFileName!="")
        log << MSG::ERROR << "No compatible Fec cable map found" << endreq;
    }

    m_first = false;

    return StatusCode::SUCCESS;
}
static const InterfaceID& ICableSvc::interfaceID ( ) [inline, static, inherited]

Definition at line 28 of file ICableSvc.h.

                                         {
    return IID_ICableSvc;
  }

Member Data Documentation

IMessageSvc* StaticCableSvc::msg [private]

Definition at line 159 of file StaticCableSvc.h.

Initial value:

Definition at line 162 of file StaticCableSvc.h.

Initial value:

Definition at line 163 of file StaticCableSvc.h.

std::string StaticCableSvc::m_feeCableFileName [private]

Definition at line 166 of file StaticCableSvc.h.

std::string StaticCableSvc::m_fecCableFileName [private]

Definition at line 169 of file StaticCableSvc.h.

bool StaticCableSvc::m_first [private]

First call of query?

Definition at line 172 of file StaticCableSvc.h.

Definition at line 178 of file StaticCableSvc.h.

Definition at line 179 of file StaticCableSvc.h.

Definition at line 180 of file StaticCableSvc.h.

Definition at line 181 of file StaticCableSvc.h.

Definition at line 182 of file StaticCableSvc.h.

Definition at line 185 of file StaticCableSvc.h.

Definition at line 186 of file StaticCableSvc.h.

Definition at line 187 of file StaticCableSvc.h.

Definition at line 188 of file StaticCableSvc.h.

Definition at line 191 of file StaticCableSvc.h.

Definition at line 192 of file StaticCableSvc.h.

Definition at line 193 of file StaticCableSvc.h.

Definition at line 196 of file StaticCableSvc.h.

Definition at line 197 of file StaticCableSvc.h.

Definition at line 198 of file StaticCableSvc.h.

Definition at line 199 of file StaticCableSvc.h.

Definition at line 202 of file StaticCableSvc.h.

Definition at line 203 of file StaticCableSvc.h.

Definition at line 204 of file StaticCableSvc.h.

Definition at line 207 of file StaticCableSvc.h.

Definition at line 208 of file StaticCableSvc.h.

Definition at line 211 of file StaticCableSvc.h.

Definition at line 212 of file StaticCableSvc.h.

Definition at line 215 of file StaticCableSvc.h.

Definition at line 216 of file StaticCableSvc.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 09:59:23 for DataSvc by doxygen 1.7.4