CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ESDBCopy Class Reference

#include <ESDBCopy.h>

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

Public Member Functions

virtual void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup)
 
 ESDBCopy (const edm::ParameterSet &iConfig)
 
 ~ESDBCopy ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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(), mps_fire::i, m_cacheIDs, m_records, record, AlCaHLTBitMon_QueryRunRegistry::string, and GlobalPosition_Frontier_DevDB_cff::tag.

29  :
30  m_timetype(iConfig.getParameter<std::string>("timetype")),
31  m_cacheIDs(),
32  m_records()
33 {
34 
35  std::string container;
38  typedef std::vector< edm::ParameterSet > Parameters;
39  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
40  for(Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
41  container = i->getParameter<std::string>("container");
42  record = i->getParameter<std::string>("record");
43  m_cacheIDs.insert( std::make_pair(container, 0) );
44  m_records.insert( std::make_pair(container, record) );
45  }
46 
47 }
T getParameter(std::string const &) const
std::map< std::string, unsigned long long > m_cacheIDs
Definition: ESDBCopy.h:30
JetCorrectorParameters::Record record
Definition: classes.h:7
vector< ParameterSet > Parameters
std::map< std::string, std::string > m_records
Definition: ESDBCopy.h:31
std::string m_timetype
Definition: ESDBCopy.h:29
ESDBCopy::~ESDBCopy ( )

Definition at line 50 of file ESDBCopy.cc.

51 {
52 
53 }

Member Function Documentation

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

Definition at line 55 of file ESDBCopy.cc.

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

56 {
57 
58  std::string container;
60  typedef std::map<std::string, std::string>::const_iterator recordIter;
61  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
62  container = (*i).first;
63  record = (*i).second;
64  if ( shouldCopy(evtSetup, container) ) {
65  copyToDB(evtSetup, container);
66  }
67  }
68 
69 }
void copyToDB(const edm::EventSetup &evtSetup, std::string container)
Definition: ESDBCopy.cc:106
JetCorrectorParameters::Record record
Definition: classes.h:7
bool shouldCopy(const edm::EventSetup &evtSetup, std::string container)
Definition: ESDBCopy.cc:73
std::map< std::string, std::string > m_records
Definition: ESDBCopy.h:31
void ESDBCopy::copyToDB ( const edm::EventSetup evtSetup,
std::string  container 
)
private

Definition at line 106 of file ESDBCopy.cc.

References cond::service::PoolDBOutputService::beginOfTime(), gather_cfg::cout, cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::endOfTime(), Exception, edm::EventSetup::get(), cmsBatch::handle, edm::Service< T >::isAvailable(), m_records, MuonAssociatorByHits_cfi::obj, edm::ESHandle< T >::product(), align_cfg::recordName, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

107 {
109  if ( !dbOutput.isAvailable() ) {
110  throw cms::Exception("PoolDBOutputService is not available");
111  }
112 
113  std::string recordName = m_records[container];
114 
115  if (container == "ESPedestals") {
117  evtSetup.get<ESPedestalsRcd>().get(handle);
118  const ESPedestals* obj = handle.product();
119  std::cout << "ped pointer is: "<< obj<< std::endl;
120  dbOutput->createNewIOV<const ESPedestals>( new ESPedestals(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
121 
122  } else if (container == "ESADCToGeVConstant") {
124  evtSetup.get<ESADCToGeVConstantRcd>().get(handle);
125  const ESADCToGeVConstant* obj = handle.product();
126  std::cout << "adc pointer is: "<< obj<< std::endl;
127 
128  dbOutput->createNewIOV<const ESADCToGeVConstant>( new ESADCToGeVConstant(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
129 
130 
131  } else if (container == "ESChannelStatus") {
133  evtSetup.get<ESChannelStatusRcd>().get(handle);
134  const ESChannelStatus* obj = handle.product();
135  std::cout << "channel status pointer is: "<< obj<< std::endl;
136 
137  dbOutput->createNewIOV<const ESChannelStatus>( new ESChannelStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
138 
139 
140  }
141 else if (container == "ESIntercalibConstants") {
143  evtSetup.get<ESIntercalibConstantsRcd>().get(handle);
144  const ESIntercalibConstants* obj = handle.product();
145  std::cout << "inter pointer is: "<< obj<< std::endl;
146  dbOutput->createNewIOV<const ESIntercalibConstants>( new ESIntercalibConstants(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
147 
148 
149  } else if (container == "ESWeightStripGroups") {
151  evtSetup.get<ESWeightStripGroupsRcd>().get(handle);
152  const ESWeightStripGroups* obj = handle.product();
153  std::cout << "weight pointer is: "<< obj<< std::endl;
154  dbOutput->createNewIOV<const ESWeightStripGroups>( new ESWeightStripGroups(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
155 
156  } else if (container == "ESTBWeights") {
158  evtSetup.get<ESTBWeightsRcd>().get(handle);
159  const ESTBWeights* obj = handle.product();
160  std::cout << "tbweight pointer is: "<< obj<< std::endl;
161  dbOutput->createNewIOV<const ESTBWeights>( new ESTBWeights(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
162 
163 
164  } else {
165  throw cms::Exception("Unknown container");
166  }
167 
168  std::cout<< "ESDBCopy wrote " << recordName << std::endl;
169 }
ESPedestalsMap ESPedestals
Definition: ESPedestals.h:32
ESChannelStatusMap ESChannelStatus
bool isAvailable() const
Definition: Service.h:46
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
std::map< std::string, std::string > m_records
Definition: ESDBCopy.h:31
ESIntercalibConstantMap ESIntercalibConstants
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
ESCondObjectContainer< ESStripGroupId > ESWeightStripGroups
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().

74 {
75 
76  unsigned long long cacheID = 0;
77  if (container == "ESPedestals") {
78  cacheID = evtSetup.get<ESPedestalsRcd>().cacheIdentifier();
79  } else if (container == "ESADCToGeVConstant") {
80  cacheID = evtSetup.get<ESADCToGeVConstantRcd>().cacheIdentifier();
81  } else if (container == "ESIntercalibConstants") {
82  cacheID = evtSetup.get<ESIntercalibConstantsRcd>().cacheIdentifier();
83  } else if (container == "ESWeightStripGroups") {
84  cacheID = evtSetup.get<ESWeightStripGroupsRcd>().cacheIdentifier();
85  } else if (container == "ESTBWeights") {
86  cacheID = evtSetup.get<ESTBWeightsRcd>().cacheIdentifier();
87  } else if (container == "ESChannelStatus") {
88  cacheID = evtSetup.get<ESChannelStatusRcd>().cacheIdentifier();
89  }
90 
91  else {
92  throw cms::Exception("Unknown container");
93  }
94 
95  if (m_cacheIDs[container] == cacheID) {
96  return 0;
97  } else {
98  m_cacheIDs[container] = cacheID;
99  return 1;
100  }
101 
102 }
std::map< std::string, unsigned long long > m_cacheIDs
Definition: ESDBCopy.h:30
const T & get() const
Definition: EventSetup.h:56

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.