CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EcalDBCopy Class Reference

#include <EcalDBCopy.h>

Inheritance diagram for EcalDBCopy:
edm::EDAnalyzer

List of all members.

Public Member Functions

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

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 EcalDBCopy.h.


Constructor & Destructor Documentation

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

Definition at line 70 of file EcalDBCopy.cc.

References edm::ParameterSet::getParameter(), i, m_cacheIDs, m_records, record, 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) );
  }
  
}
EcalDBCopy::~EcalDBCopy ( )

Definition at line 91 of file EcalDBCopy.cc.

{
  
}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 96 of file EcalDBCopy.cc.

References copyToDB(), i, m_records, record, and shouldCopy().

{

  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 EcalDBCopy::copyToDB ( const edm::EventSetup evtSetup,
std::string  container 
) [private]

Definition at line 189 of file EcalDBCopy.cc.

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

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 == "EcalPedestals") {
    edm::ESHandle<EcalPedestals> handle;
    evtSetup.get<EcalPedestalsRcd>().get(handle);
    const EcalPedestals* obj = handle.product();
    std::cout << "ped pointer is: "<< obj<< std::endl;
    dbOutput->createNewIOV<const EcalPedestals>( new EcalPedestals(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);

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

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


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

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

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

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

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

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

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

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

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

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


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

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


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

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

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

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

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

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

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

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

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


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


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


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

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


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

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

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

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

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

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

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

Definition at line 114 of file EcalDBCopy.cc.

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

Referenced by analyze().

{

  unsigned long long cacheID = 0;
  if (container == "EcalPedestals") {
    cacheID = evtSetup.get<EcalPedestalsRcd>().cacheIdentifier();
  } else if (container == "EcalADCToGeVConstant") {
    cacheID = evtSetup.get<EcalADCToGeVConstantRcd>().cacheIdentifier();
  } else if (container == "EcalIntercalibConstants") {
    cacheID = evtSetup.get<EcalIntercalibConstantsRcd>().cacheIdentifier();
  } else if (container == "EcalIntercalibConstantsMC") {
    cacheID = evtSetup.get<EcalIntercalibConstantsMCRcd>().cacheIdentifier();
  } else if (container == "EcalIntercalibErrors") {
    cacheID = evtSetup.get<EcalIntercalibErrorsRcd>().cacheIdentifier();
  } else if (container == "EcalGainRatios") {
    cacheID = evtSetup.get<EcalGainRatiosRcd>().cacheIdentifier();
  } else if (container == "EcalWeightXtalGroups") {
    cacheID = evtSetup.get<EcalWeightXtalGroupsRcd>().cacheIdentifier();
  } else if (container == "EcalTBWeights") {
    cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
  } else if (container == "EcalLaserAPDPNRatios") {
    cacheID = evtSetup.get<EcalLaserAPDPNRatiosRcd>().cacheIdentifier();
  } else if (container == "EcalLaserAPDPNRatiosRef") {
    cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
  } else if (container == "EcalLaserAlphas") {
    cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
  } else if (container == "EcalChannelStatus") {
    cacheID = evtSetup.get<EcalChannelStatusRcd>().cacheIdentifier();
  } else if (container == "EcalDQMTowerStatus") {
    cacheID = evtSetup.get<EcalDQMTowerStatusRcd>().cacheIdentifier();
  } else if (container == "EcalDQMChannelStatus") {
    cacheID = evtSetup.get<EcalDQMChannelStatusRcd>().cacheIdentifier();
  } else if (container == "EcalDCSTowerStatus") {
    cacheID = evtSetup.get<EcalDCSTowerStatusRcd>().cacheIdentifier();
  } else if (container == "EcalDAQTowerStatus") {
    cacheID = evtSetup.get<EcalDAQTowerStatusRcd>().cacheIdentifier();
  } else if (container == "EcalTimeCalibConstants") {
    cacheID = evtSetup.get<EcalTimeCalibConstantsRcd>().cacheIdentifier();
  } else if (container == "EcalClusterCrackCorrParameters") {
    cacheID = evtSetup.get<EcalClusterCrackCorrParametersRcd>().cacheIdentifier();
  } else if (container == "EcalClusterEnergyUncertaintyParameters") {
    cacheID = evtSetup.get<EcalClusterEnergyUncertaintyParametersRcd>().cacheIdentifier();
  } else if (container == "EcalClusterEnergyCorrectionParameters") {
    cacheID = evtSetup.get<EcalClusterEnergyCorrectionParametersRcd>().cacheIdentifier();
  } else if (container == "EcalClusterEnergyCorrectionObjectSpecificParameters") {
    cacheID = evtSetup.get<EcalClusterEnergyCorrectionObjectSpecificParametersRcd>().cacheIdentifier();
  } else if (container == "EcalClusterLocalContCorrParameters") {
    cacheID = evtSetup.get<EcalClusterLocalContCorrParametersRcd>().cacheIdentifier();
  } else if (container == "EcalTPGCrystalStatus") {
    cacheID = evtSetup.get<EcalTPGCrystalStatusRcd>().cacheIdentifier();
  } else if (container == "EBAlignment") {
    cacheID = evtSetup.get<EBAlignmentRcd>().cacheIdentifier();
  } else if (container == "EEAlignment") {
    cacheID = evtSetup.get<EEAlignmentRcd>().cacheIdentifier();
  } else if (container == "ESAlignment") {
    cacheID = evtSetup.get<ESAlignmentRcd>().cacheIdentifier();
  } else if (container == "EcalTimeOffsetConstant") {
    cacheID = evtSetup.get<EcalTimeOffsetConstantRcd>().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> EcalDBCopy::m_cacheIDs [private]

Definition at line 30 of file EcalDBCopy.h.

Referenced by EcalDBCopy(), and shouldCopy().

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

Definition at line 31 of file EcalDBCopy.h.

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

std::string EcalDBCopy::m_timetype [private]

Definition at line 29 of file EcalDBCopy.h.