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

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
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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, 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;
36  std::string tag;
37  std::string record;
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:11
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, and shouldCopy().

56 {
57 
58  std::string container;
59  std::string record;
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:11
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(), and ecalTPGAnalyzer_cfg::recordName.

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:28
ESChannelStatusMap ESChannelStatus
bool isAvailable() const
Definition: Service.h:47
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.