/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 Attributes
StaticSimDataSvc Class Reference

#include <StaticSimDataSvc.h>

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

List of all members.

Public Member Functions

 StaticSimDataSvc (const std::string &name, ISvcLocator *svc)
 ~StaticSimDataSvc ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
const DayaBay::PmtSimDatapmtSimData (const DayaBay::DetectorSensor &pmtId, const ServiceMode &svcMode)
const DayaBay::RpcSimDatarpcSimData (const DayaBay::RpcSensor &rpcId, const ServiceMode &svcMode)
virtual const DayaBay::FeeSimDatafeeSimData (const DayaBay::FeeChannelId &channelId, const ServiceMode &svcMode)
virtual const DayaBay::FecSimDatafecSimData (const DayaBay::FecChannelId &channelId, const ServiceMode &svcMode)
const std::vector
< DayaBay::PmtSimData > & 
pmtSimList (const DayaBay::Detector &detectorId, const ServiceMode &svcMode)
const std::vector
< DayaBay::RpcSimData > & 
rpcSimList (const DayaBay::Detector &detectorId, const ServiceMode &svcMode)
virtual const std::vector
< DayaBay::FeeSimData > & 
feeSimList (const DayaBay::Detector &detectorId, const ServiceMode &svcMode)
virtual const std::vector
< DayaBay::FecSimData > & 
fecSimList (const DayaBay::Detector &detectorId, const ServiceMode &svcMode)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Attributes

std::map< DayaBay::Detector,
std::vector
< DayaBay::PmtSimData > > 
m_pmtData
std::map< DayaBay::Detector,
std::vector
< DayaBay::RpcSimData > > 
m_rpcData
std::map< DayaBay::Detector,
std::vector
< DayaBay::FeeSimData > > 
m_feeData
std::map< DayaBay::Detector,
std::vector
< DayaBay::FecSimData > > 
m_fecData
std::map
< DayaBay::DetectorSensor,
DayaBay::PmtSimData
m_pmtDataBySensor
std::map< DayaBay::RpcSensor,
DayaBay::RpcSimData
m_rpcDataBySensor
std::map
< DayaBay::FeeChannelId,
DayaBay::FeeSimData
m_feeDataByChannel
std::map
< DayaBay::FecChannelId,
DayaBay::FecSimData
m_fecDataByChannel
std::string m_pmtDataFileName
std::string m_rpcDataFileName
std::string m_feeDataFileName
std::string m_fecDataFileName

Detailed Description

Definition at line 16 of file StaticSimDataSvc.h.


Constructor & Destructor Documentation

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

Definition at line 11 of file StaticSimDataSvc.cc.

    : Service(name,svc)
{
  std::string path = getenv ("DATASVCROOT");

  declareProperty("PmtDataFile",m_pmtDataFileName = path + "/share/pmtDataTable.txt",
                  "Optional filename for loading pmt simulation input data");
  declareProperty("RpcDataFile",m_rpcDataFileName="",
                  "Optional filename for loading rpc simulation input data");
  declareProperty("FeeDataFile",m_feeDataFileName = path + "/share/feeDataTable.txt",
                  "Optional filename for loading FEE simulation input data");
  declareProperty("FecDataFile",m_fecDataFileName="",
                  "Optional filename for loading FEC simulation input data");
}
StaticSimDataSvc::~StaticSimDataSvc ( )

Definition at line 26 of file StaticSimDataSvc.cc.

{
}

Member Function Documentation

StatusCode StaticSimDataSvc::initialize ( ) [virtual]

Definition at line 30 of file StaticSimDataSvc.cc.

{
  this->Service::initialize();
  
  IMessageSvc* msg = msgSvc();
  if( !msg ){    
    return StatusCode::FAILURE;
  }

  if(m_pmtDataFileName!=""){
    std::ifstream input( m_pmtDataFileName.c_str() );
    if( !input.is_open() ){
      std::ostringstream msgStr;
      msgStr << "Failed to open input file: " << m_pmtDataFileName;
      msg->reportMessage("StaticSimDataSvc",MSG::ERROR,msgStr.str());
      return StatusCode::FAILURE;
    }
    else {
      std::ostringstream msgStr;
      msgStr << "Opened input file: " << m_pmtDataFileName;
      msg->reportMessage("StaticSimDataSvc",MSG::INFO,msgStr.str());
    }
    int sensorId;
    std::string description;
    double gain, sigmaGain, timeOffset, timeSpread, efficiency;
    double prePulseProb, afterPulseProb, darkRate;
    std::string line;
    while( std::getline(input,line) ){
      std::ostringstream msgStr;
      msgStr << "Got line: " << line;
      msg->reportMessage("StaticSimDataSvc",MSG::VERBOSE,msgStr.str());
      msgStr.str("");
      std::stringstream streamLine(line);
      if( streamLine.peek() == '#' ){
        continue;
      }
      streamLine >> sensorId >> description
                 >> gain >> sigmaGain >> timeOffset >> timeSpread 
                 >> efficiency >> prePulseProb >> afterPulseProb 
                 >> darkRate;
      msgStr << "Adding PMT: " << description;
      msg->reportMessage("StaticSimDataSvc",MSG::VERBOSE,msgStr.str());
    
      DayaBay::DetectorSensor pmtId(sensorId); 
      DayaBay::Detector detector( pmtId.site(), pmtId.detectorId() );
      DayaBay::PmtSimData pmt;
      pmt.m_pmtId = pmtId;
      pmt.m_gain = gain;
      pmt.m_sigmaGain = sigmaGain;
      pmt.m_timeOffset = timeOffset * Units::ns;
      pmt.m_timeSpread = timeSpread * Units::ns;
      pmt.m_efficiency = efficiency;
      pmt.m_prePulseProb = prePulseProb;
      pmt.m_afterPulseProb = afterPulseProb;
      pmt.m_darkRate = darkRate * Units::hertz;
      std::vector<DayaBay::PmtSimData>& pmtList = m_pmtData[detector];
      pmtList.push_back(pmt);
      // Add lookup by sensor ID
      m_pmtDataBySensor[pmtId] = pmtList[pmtList.size()-1];
    }
  }

  if(m_feeDataFileName!=""){
    std::ifstream input( m_feeDataFileName.c_str() );
    if( !input.is_open() ){
      std::ostringstream msgStr;
      msgStr << "Failed to open input file: " << m_feeDataFileName;
      msg->reportMessage("StaticSimDataSvc",MSG::ERROR,msgStr.str());
      return StatusCode::FAILURE;
    }
    else {
      std::ostringstream msgStr;
      msgStr << "Opening input file: " << m_feeDataFileName;
      msg->reportMessage("StaticSimDataSvc",MSG::INFO,msgStr.str());
    }
    int channelId;
    std::string description;
    double channelThreshold, adcRangeHigh, adcRangeLow; 
    double adcBaselineHigh, adcBaselineLow;
    std::string line;
    while( std::getline(input,line) ){
      std::ostringstream msgStr;
      msgStr << "Got line: " << line;
      msg->reportMessage("StaticSimDataSvc",MSG::VERBOSE,msgStr.str());
      msgStr.str("");
      std::stringstream streamLine(line);
      if( streamLine.peek() == '#' ){
        continue;
      }
      streamLine >> channelId >> description
                 >> channelThreshold >> adcRangeHigh >> adcRangeLow 
                 >> adcBaselineHigh >> adcBaselineLow;

      msgStr << "Adding FEE Channel: " << description;
      msg->reportMessage("StaticSimDataSvc",MSG::VERBOSE,msgStr.str());
    
      DayaBay::FeeChannelId feeChannelId(channelId); 
      DayaBay::Detector detector(feeChannelId.site(),feeChannelId.detectorId());
      DayaBay::FeeSimData fee;
      fee.m_channelId = feeChannelId;
      fee.m_channelThreshold = channelThreshold * Units::volt;
      fee.m_adcRangeHigh = adcRangeHigh * Units::volt;
      fee.m_adcRangeLow = adcRangeLow * Units::volt;
      fee.m_adcBaselineHigh = adcBaselineHigh;
      fee.m_adcBaselineLow = adcBaselineLow;
      std::vector<DayaBay::FeeSimData>& feeList = m_feeData[detector];
      feeList.push_back(fee);
      // Add lookup by channel ID
      m_feeDataByChannel[feeChannelId] = feeList[feeList.size()-1];
    }
  }

  if(m_rpcDataFileName!=""){
    // FIXME: Add RPC data file
    std::ostringstream msgStr;
    msgStr << "RPC simulation data file not yet implemented!";
    msg->reportMessage("StaticSimDataSvc",MSG::ERROR,msgStr.str());
    return StatusCode::FAILURE;
  }

  if(m_fecDataFileName!=""){
    // FIXME: Add FEC data file
    std::ostringstream msgStr;
    msgStr << "FEC simulation data file not yet implemented!";
    msg->reportMessage("StaticSimDataSvc",MSG::ERROR,msgStr.str());
    return StatusCode::FAILURE;
  }

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

Definition at line 161 of file StaticSimDataSvc.cc.

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

Definition at line 166 of file StaticSimDataSvc.cc.

{
  StatusCode sc = StatusCode::FAILURE;
  if (ppvInterface) {
    *ppvInterface = 0;
    
    if (ISimDataSvc::interfaceID().versionMatch(riid)) {
      *ppvInterface = static_cast<ISimDataSvc*>(this);
      sc = StatusCode::SUCCESS;
      addRef();
    }
    else sc = Service::queryInterface( riid, ppvInterface );    
  }
  return sc;
}
const DayaBay::PmtSimData * StaticSimDataSvc::pmtSimData ( const DayaBay::DetectorSensor pmtId,
const ServiceMode svcMode 
) [virtual]

Implements ISimDataSvc.

Definition at line 183 of file StaticSimDataSvc.cc.

{
  std::map<DayaBay::DetectorSensor, DayaBay::PmtSimData>::iterator result = 
    m_pmtDataBySensor.find(pmtId); 
  if(result != m_pmtDataBySensor.end()){
    return &(result->second);
  }
  return 0;
}
const DayaBay::RpcSimData * StaticSimDataSvc::rpcSimData ( const DayaBay::RpcSensor rpcId,
const ServiceMode svcMode 
) [virtual]

Implements ISimDataSvc.

Definition at line 195 of file StaticSimDataSvc.cc.

{
  std::map<DayaBay::RpcSensor, DayaBay::RpcSimData>::iterator result = 
    m_rpcDataBySensor.find(rpcId); 
  if(result != m_rpcDataBySensor.end()){
    return &(result->second);
  }
  return 0;
}
const DayaBay::FeeSimData * StaticSimDataSvc::feeSimData ( const DayaBay::FeeChannelId channelId,
const ServiceMode svcMode 
) [virtual]

Implements ISimDataSvc.

Definition at line 207 of file StaticSimDataSvc.cc.

{
  std::map<DayaBay::FeeChannelId, DayaBay::FeeSimData>::iterator result = 
    m_feeDataByChannel.find(channelId); 
  if(result != m_feeDataByChannel.end()){
    return &(result->second);
  }
  // FIXME: Temporarily return a default FEE channel until cabling settles down
  DayaBay::FeeChannelId tmpId(1,1,Site::kDayaBay,DetectorId::kAD1);
  result = m_feeDataByChannel.find(tmpId); 
  if(result != m_feeDataByChannel.end()){
    return &(result->second);
  }
  return 0;
}
const DayaBay::FecSimData * StaticSimDataSvc::fecSimData ( const DayaBay::FecChannelId channelId,
const ServiceMode svcMode 
) [virtual]

Implements ISimDataSvc.

Definition at line 225 of file StaticSimDataSvc.cc.

{
  std::map<DayaBay::FecChannelId, DayaBay::FecSimData>::iterator result = 
    m_fecDataByChannel.find(channelId); 
  if(result != m_fecDataByChannel.end()){
    return &(result->second);
  }
  return 0;
}
const std::vector< DayaBay::PmtSimData > & StaticSimDataSvc::pmtSimList ( const DayaBay::Detector detectorId,
const ServiceMode svcMode 
) [virtual]

Implements ISimDataSvc.

Definition at line 237 of file StaticSimDataSvc.cc.

{
  return m_pmtData[detectorId];
}
const std::vector< DayaBay::RpcSimData > & StaticSimDataSvc::rpcSimList ( const DayaBay::Detector detectorId,
const ServiceMode svcMode 
) [virtual]

Implements ISimDataSvc.

Definition at line 244 of file StaticSimDataSvc.cc.

{
  return m_rpcData[detectorId];
}
const std::vector< DayaBay::FeeSimData > & StaticSimDataSvc::feeSimList ( const DayaBay::Detector detectorId,
const ServiceMode svcMode 
) [virtual]

Implements ISimDataSvc.

Definition at line 251 of file StaticSimDataSvc.cc.

{
  return m_feeData[detectorId];
}
const std::vector< DayaBay::FecSimData > & StaticSimDataSvc::fecSimList ( const DayaBay::Detector detectorId,
const ServiceMode svcMode 
) [virtual]

Implements ISimDataSvc.

Definition at line 258 of file StaticSimDataSvc.cc.

{
  return m_fecData[detectorId];
}
static const InterfaceID& ISimDataSvc::interfaceID ( ) [inline, static, inherited]

Definition at line 93 of file ISimDataSvc.h.

                                         {
    return IID_ISimDataSvc;
  }

Member Data Documentation

Definition at line 69 of file StaticSimDataSvc.h.

Definition at line 70 of file StaticSimDataSvc.h.

Definition at line 71 of file StaticSimDataSvc.h.

Definition at line 72 of file StaticSimDataSvc.h.

Definition at line 75 of file StaticSimDataSvc.h.

Definition at line 76 of file StaticSimDataSvc.h.

Definition at line 78 of file StaticSimDataSvc.h.

Definition at line 79 of file StaticSimDataSvc.h.

std::string StaticSimDataSvc::m_pmtDataFileName [private]

Definition at line 82 of file StaticSimDataSvc.h.

std::string StaticSimDataSvc::m_rpcDataFileName [private]

Definition at line 84 of file StaticSimDataSvc.h.

std::string StaticSimDataSvc::m_feeDataFileName [private]

Definition at line 86 of file StaticSimDataSvc.h.

std::string StaticSimDataSvc::m_fecDataFileName [private]

Definition at line 88 of file StaticSimDataSvc.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