CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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

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
int i
Definition: DBlmapReader.cc:9
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

Implements edm::EDAnalyzer.

Definition at line 55 of file ESDBCopy.cc.

References copyToDB(), 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 }
int i
Definition: DBlmapReader.cc:9
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(), edm::hlt::Exception, edm::EventSetup::get(), patZpeak::handle, edm::Service< T >::isAvailable(), m_records, getGTfromDQMFile::obj, edm::ESHandle< class >::product(), ecalTPGAnalyzer_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
tuple handle
Definition: patZpeak.py:22
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:55
T const * product() const
Definition: ESHandle.h:62
tuple cout
Definition: gather_cfg.py:121
ESCondObjectContainer< ESStripGroupId > ESWeightStripGroups
bool ESDBCopy::shouldCopy ( const edm::EventSetup evtSetup,
std::string  container 
)
private

Definition at line 73 of file ESDBCopy.cc.

References edm::hlt::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:55

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.