CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ESDBCopy Class Reference

#include <ESDBCopy.h>

Inheritance diagram for ESDBCopy:
edm::EDAnalyzer edm::EDConsumerBase

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup)
 ESDBCopy (const edm::ParameterSet &iConfig)
 ~ESDBCopy ()

Private Member Functions

void copyToDB (const edm::EventSetup &evtSetup, std::string container)
bool shouldCopy (const edm::EventSetup &evtSetup, std::string container)

Private Attributes

std::map< std::string,
unsigned long long > 
m_cacheIDs
std::map< std::string,
std::string > 
m_records
std::string m_timetype

Detailed Description

Definition at line 18 of file ESDBCopy.h.


Constructor & Destructor Documentation

ESDBCopy::ESDBCopy ( const edm::ParameterSet iConfig) [explicit]

Definition at line 29 of file ESDBCopy.cc.

References edm::ParameterSet::getParameter(), i, m_cacheIDs, m_records, record, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and copyFileAlignEB_cfg::toCopy.

                                                 :
  m_timetype(iConfig.getParameter<std::string>("timetype")),
  m_cacheIDs(),
  m_records()
{

  std::string container;
  std::string tag;
  std::string record;
  typedef std::vector< edm::ParameterSet > Parameters;
  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
  for(Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
    container = i->getParameter<std::string>("container");
    record = i->getParameter<std::string>("record");
    m_cacheIDs.insert( std::make_pair(container, 0) );
    m_records.insert( std::make_pair(container, record) );
  }
  
}
ESDBCopy::~ESDBCopy ( )

Definition at line 50 of file ESDBCopy.cc.

{
  
}

Member Function Documentation

void ESDBCopy::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 55 of file ESDBCopy.cc.

References copyToDB(), i, m_records, record, shouldCopy(), and AlCaHLTBitMon_QueryRunRegistry::string.

{

  std::string container;
  std::string record;
  typedef std::map<std::string, std::string>::const_iterator recordIter;
  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
    container = (*i).first;
    record = (*i).second;
    if ( shouldCopy(evtSetup, container) ) {
      copyToDB(evtSetup, container);
    }
  }
  
}
void ESDBCopy::copyToDB ( const edm::EventSetup evtSetup,
std::string  container 
) [private]

Definition at line 106 of file ESDBCopy.cc.

References gather_cfg::cout, Exception, edm::EventSetup::get(), patZpeak::handle, edm::Service< T >::isAvailable(), m_records, getGTfromDQMFile::obj, edm::ESHandle< T >::product(), ecalTPGAnalyzer_cfg::recordName, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

{
  edm::Service<cond::service::PoolDBOutputService> dbOutput;
  if ( !dbOutput.isAvailable() ) {
    throw cms::Exception("PoolDBOutputService is not available");
  }

  std::string recordName = m_records[container];

  if (container == "ESPedestals") {
    edm::ESHandle<ESPedestals> handle;
    evtSetup.get<ESPedestalsRcd>().get(handle);
    const ESPedestals* obj = handle.product();
    std::cout << "ped pointer is: "<< obj<< std::endl;
    dbOutput->createNewIOV<const ESPedestals>( new ESPedestals(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);

  }  else if (container == "ESADCToGeVConstant") {
    edm::ESHandle<ESADCToGeVConstant> handle;
    evtSetup.get<ESADCToGeVConstantRcd>().get(handle);
    const ESADCToGeVConstant* obj = handle.product();
    std::cout << "adc pointer is: "<< obj<< std::endl;

   dbOutput->createNewIOV<const ESADCToGeVConstant>( new ESADCToGeVConstant(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);


  }  else if (container == "ESChannelStatus") {
    edm::ESHandle<ESChannelStatus> handle;
    evtSetup.get<ESChannelStatusRcd>().get(handle);
    const ESChannelStatus* obj = handle.product();
    std::cout << "channel status pointer is: "<< obj<< std::endl;

   dbOutput->createNewIOV<const ESChannelStatus>( new ESChannelStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);


  }
else if (container == "ESIntercalibConstants") {
    edm::ESHandle<ESIntercalibConstants> handle;
    evtSetup.get<ESIntercalibConstantsRcd>().get(handle);
    const ESIntercalibConstants* obj = handle.product();
    std::cout << "inter pointer is: "<< obj<< std::endl;
   dbOutput->createNewIOV<const ESIntercalibConstants>( new ESIntercalibConstants(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);


  } else if (container == "ESWeightStripGroups") {
    edm::ESHandle<ESWeightStripGroups> handle;
    evtSetup.get<ESWeightStripGroupsRcd>().get(handle);
    const ESWeightStripGroups* obj = handle.product();
    std::cout << "weight pointer is: "<< obj<< std::endl;
   dbOutput->createNewIOV<const ESWeightStripGroups>( new ESWeightStripGroups(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);

  } else if (container == "ESTBWeights") {
    edm::ESHandle<ESTBWeights> handle;
    evtSetup.get<ESTBWeightsRcd>().get(handle);
    const ESTBWeights* obj = handle.product();
    std::cout << "tbweight pointer is: "<< obj<< std::endl;
   dbOutput->createNewIOV<const ESTBWeights>( new ESTBWeights(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);


  } else {
    throw cms::Exception("Unknown container");
  }

  std::cout<< "ESDBCopy wrote " << recordName << std::endl;
}
bool ESDBCopy::shouldCopy ( const edm::EventSetup evtSetup,
std::string  container 
) [private]

Definition at line 73 of file ESDBCopy.cc.

References Exception, edm::EventSetup::get(), and m_cacheIDs.

Referenced by analyze().

{

  unsigned long long cacheID = 0;
  if (container == "ESPedestals") {
    cacheID = evtSetup.get<ESPedestalsRcd>().cacheIdentifier();
  } else if (container == "ESADCToGeVConstant") {
    cacheID = evtSetup.get<ESADCToGeVConstantRcd>().cacheIdentifier();
  } else if (container == "ESIntercalibConstants") {
    cacheID = evtSetup.get<ESIntercalibConstantsRcd>().cacheIdentifier();
  } else if (container == "ESWeightStripGroups") {
    cacheID = evtSetup.get<ESWeightStripGroupsRcd>().cacheIdentifier();
  } else if (container == "ESTBWeights") {
    cacheID = evtSetup.get<ESTBWeightsRcd>().cacheIdentifier();
  } else if (container == "ESChannelStatus") {
    cacheID = evtSetup.get<ESChannelStatusRcd>().cacheIdentifier();
  } 

  else {
    throw cms::Exception("Unknown container");
  }
  
  if (m_cacheIDs[container] == cacheID) {
    return 0;
  } else {
    m_cacheIDs[container] = cacheID;
    return 1;
  }

}

Member Data Documentation

std::map<std::string, unsigned long long> ESDBCopy::m_cacheIDs [private]

Definition at line 30 of file ESDBCopy.h.

Referenced by ESDBCopy(), and shouldCopy().

std::map<std::string, std::string> ESDBCopy::m_records [private]

Definition at line 31 of file ESDBCopy.h.

Referenced by analyze(), copyToDB(), and ESDBCopy().

std::string ESDBCopy::m_timetype [private]

Definition at line 29 of file ESDBCopy.h.