CMS 3D CMS Logo

ESDBCopy.cc
Go to the documentation of this file.
3 
5 
8 
22 
23 #include <vector>
24 
26  : m_timetype(iConfig.getParameter<std::string>("timetype")), m_cacheIDs(), m_records() {
27  std::string container;
30  typedef std::vector<edm::ParameterSet> Parameters;
31  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
32  for (Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
33  container = i->getParameter<std::string>("container");
34  record = i->getParameter<std::string>("record");
35  m_cacheIDs.insert(std::make_pair(container, 0));
36  m_records.insert(std::make_pair(container, record));
37  }
38 }
39 
41 
42 void ESDBCopy::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
43  std::string container;
45  typedef std::map<std::string, std::string>::const_iterator recordIter;
46  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
47  container = (*i).first;
48  record = (*i).second;
49  if (shouldCopy(evtSetup, container)) {
50  copyToDB(evtSetup, container);
51  }
52  }
53 }
54 
55 bool ESDBCopy::shouldCopy(const edm::EventSetup& evtSetup, std::string container) {
56  unsigned long long cacheID = 0;
57  if (container == "ESPedestals") {
58  cacheID = evtSetup.get<ESPedestalsRcd>().cacheIdentifier();
59  } else if (container == "ESADCToGeVConstant") {
60  cacheID = evtSetup.get<ESADCToGeVConstantRcd>().cacheIdentifier();
61  } else if (container == "ESIntercalibConstants") {
62  cacheID = evtSetup.get<ESIntercalibConstantsRcd>().cacheIdentifier();
63  } else if (container == "ESWeightStripGroups") {
64  cacheID = evtSetup.get<ESWeightStripGroupsRcd>().cacheIdentifier();
65  } else if (container == "ESTBWeights") {
66  cacheID = evtSetup.get<ESTBWeightsRcd>().cacheIdentifier();
67  } else if (container == "ESChannelStatus") {
68  cacheID = evtSetup.get<ESChannelStatusRcd>().cacheIdentifier();
69  }
70 
71  else {
72  throw cms::Exception("Unknown container");
73  }
74 
75  if (m_cacheIDs[container] == cacheID) {
76  return false;
77  } else {
78  m_cacheIDs[container] = cacheID;
79  return true;
80  }
81 }
82 
83 void ESDBCopy::copyToDB(const edm::EventSetup& evtSetup, std::string container) {
85  if (!dbOutput.isAvailable()) {
86  throw cms::Exception("PoolDBOutputService is not available");
87  }
88 
89  std::string recordName = m_records[container];
90 
91  if (container == "ESPedestals") {
93  evtSetup.get<ESPedestalsRcd>().get(handle);
94  const ESPedestals* obj = handle.product();
95  std::cout << "ped pointer is: " << obj << std::endl;
96  dbOutput->createNewIOV<const ESPedestals>(
97  new ESPedestals(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
98 
99  } else if (container == "ESADCToGeVConstant") {
101  evtSetup.get<ESADCToGeVConstantRcd>().get(handle);
102  const ESADCToGeVConstant* obj = handle.product();
103  std::cout << "adc pointer is: " << obj << std::endl;
104 
105  dbOutput->createNewIOV<const ESADCToGeVConstant>(
106  new ESADCToGeVConstant(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
107 
108  } else if (container == "ESChannelStatus") {
110  evtSetup.get<ESChannelStatusRcd>().get(handle);
111  const ESChannelStatus* obj = handle.product();
112  std::cout << "channel status pointer is: " << obj << std::endl;
113 
114  dbOutput->createNewIOV<const ESChannelStatus>(
115  new ESChannelStatus(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
116 
117  } else if (container == "ESIntercalibConstants") {
119  evtSetup.get<ESIntercalibConstantsRcd>().get(handle);
120  const ESIntercalibConstants* obj = handle.product();
121  std::cout << "inter pointer is: " << obj << std::endl;
122  dbOutput->createNewIOV<const ESIntercalibConstants>(
123  new ESIntercalibConstants(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
124 
125  } else if (container == "ESWeightStripGroups") {
127  evtSetup.get<ESWeightStripGroupsRcd>().get(handle);
128  const ESWeightStripGroups* obj = handle.product();
129  std::cout << "weight pointer is: " << obj << std::endl;
130  dbOutput->createNewIOV<const ESWeightStripGroups>(
131  new ESWeightStripGroups(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
132 
133  } else if (container == "ESTBWeights") {
135  evtSetup.get<ESTBWeightsRcd>().get(handle);
136  const ESTBWeights* obj = handle.product();
137  std::cout << "tbweight pointer is: " << obj << std::endl;
138  dbOutput->createNewIOV<const ESTBWeights>(
139  new ESTBWeights(*obj), dbOutput->beginOfTime(), dbOutput->endOfTime(), recordName);
140 
141  } else {
142  throw cms::Exception("Unknown container");
143  }
144 
145  std::cout << "ESDBCopy wrote " << recordName << std::endl;
146 }
ESPedestalsRcd
Definition: ESPedestalsRcd.h:5
ESDBCopy::~ESDBCopy
~ESDBCopy() override
Definition: ESDBCopy.cc:40
mps_fire.i
i
Definition: mps_fire.py:428
ESDBCopy.h
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
ESHandle.h
ESDBCopy::m_records
std::map< std::string, std::string > m_records
Definition: ESDBCopy.h:31
ESIntercalibConstants.h
ESChannelStatusRcd
Definition: ESChannelStatusRcd.h:5
patZpeak.handle
handle
Definition: patZpeak.py:23
align_cfg.recordName
recordName
Definition: align_cfg.py:66
ESADCToGeVConstantRcd.h
ESADCToGeVConstantRcd
Definition: ESADCToGeVConstantRcd.h:5
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ESWeightStripGroups.h
ESTBWeightsRcd
Definition: ESTBWeightsRcd.h:5
ESADCToGeVConstant
Definition: ESADCToGeVConstant.h:7
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
ESDBCopy::ESDBCopy
ESDBCopy(const edm::ParameterSet &iConfig)
Definition: ESDBCopy.cc:25
ESChannelStatus
ESChannelStatusMap ESChannelStatus
Definition: ESChannelStatus.h:7
ESWeightStripGroups
ESCondObjectContainer< ESStripGroupId > ESWeightStripGroups
Definition: ESWeightStripGroups.h:12
ESChannelStatusRcd.h
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
ESWeightStripGroupsRcd.h
ESPedestals.h
PoolDBOutputService.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
cond::service::PoolDBOutputService::createNewIOV
void createNewIOV(const T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t, const std::string &recordName)
Definition: PoolDBOutputService.h:116
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
Service.h
edm::ESHandle
Definition: DTSurvey.h:22
ESDBCopy::shouldCopy
bool shouldCopy(const edm::EventSetup &evtSetup, std::string container)
Definition: ESDBCopy.cc:55
ESTBWeights
Definition: ESTBWeights.h:10
ESIntercalibConstantsRcd
Definition: ESIntercalibConstantsRcd.h:5
ESDBCopy::analyze
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
Definition: ESDBCopy.cc:42
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ESIntercalibConstantsRcd.h
edm::ParameterSet
Definition: ParameterSet.h:47
ESADCToGeVConstant.h
ESChannelStatus.h
edm::Service< cond::service::PoolDBOutputService >
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
ESCondObjectContainer< ESPedestal >
cond::service::PoolDBOutputService::endOfTime
cond::Time_t endOfTime() const
Definition: PoolDBOutputService.cc:213
ESWeightStripGroupsRcd
Definition: ESWeightStripGroupsRcd.h:5
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:246
ESPedestals
ESPedestalsMap ESPedestals
Definition: ESPedestals.h:29
ESTBWeights.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterSet.h
ESIntercalibConstants
ESIntercalibConstantMap ESIntercalibConstants
Definition: ESIntercalibConstants.h:7
edm::Event
Definition: Event.h:73
ESDBCopy::m_cacheIDs
std::map< std::string, unsigned long long > m_cacheIDs
Definition: ESDBCopy.h:30
Parameters
vector< ParameterSet > Parameters
Definition: HLTMuonPlotter.cc:25
ESDBCopy::copyToDB
void copyToDB(const edm::EventSetup &evtSetup, std::string container)
Definition: ESDBCopy.cc:83
ESTBWeightsRcd.h
ESPedestalsRcd.h