CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalDBCopy.cc
Go to the documentation of this file.
3 
5 
6 
9 
10 
42 
51 
62 
69 
72 
73 #include <vector>
74 
76  m_timetype(iConfig.getParameter<std::string>("timetype")),
77  m_cacheIDs(),
78  m_records()
79 {
80 
81  std::string container;
84  typedef std::vector< edm::ParameterSet > Parameters;
85  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
86  for(Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
87  container = i->getParameter<std::string>("container");
88  record = i->getParameter<std::string>("record");
89  m_cacheIDs.insert( std::make_pair(container, 0) );
90  m_records.insert( std::make_pair(container, record) );
91  }
92 
93 }
94 
95 
97 {
98 
99 }
100 
101 void EcalDBCopy::analyze( const edm::Event& evt, const edm::EventSetup& evtSetup)
102 {
103 
104  std::string container;
106  typedef std::map<std::string, std::string>::const_iterator recordIter;
107  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
108  container = (*i).first;
109  record = (*i).second;
110  if ( shouldCopy(evtSetup, container) ) {
111  copyToDB(evtSetup, container);
112  }
113  }
114 
115 }
116 
117 
118 
119 bool EcalDBCopy::shouldCopy(const edm::EventSetup& evtSetup, std::string container)
120 {
121 
122  unsigned long long cacheID = 0;
123  if (container == "EcalPedestals") {
124  cacheID = evtSetup.get<EcalPedestalsRcd>().cacheIdentifier();
125  } else if (container == "EcalADCToGeVConstant") {
126  cacheID = evtSetup.get<EcalADCToGeVConstantRcd>().cacheIdentifier();
127  } else if (container == "EcalLinearCorrections") {
128  cacheID = evtSetup.get<EcalLinearCorrectionsRcd>().cacheIdentifier();
129  } else if (container == "EcalIntercalibConstants") {
130  cacheID = evtSetup.get<EcalIntercalibConstantsRcd>().cacheIdentifier();
131  } else if (container == "EcalIntercalibConstantsMC") {
132  cacheID = evtSetup.get<EcalIntercalibConstantsMCRcd>().cacheIdentifier();
133  } else if (container == "EcalIntercalibErrors") {
134  cacheID = evtSetup.get<EcalIntercalibErrorsRcd>().cacheIdentifier();
135  } else if (container == "EcalGainRatios") {
136  cacheID = evtSetup.get<EcalGainRatiosRcd>().cacheIdentifier();
137  } else if (container == "EcalWeightXtalGroups") {
138  cacheID = evtSetup.get<EcalWeightXtalGroupsRcd>().cacheIdentifier();
139  } else if (container == "EcalTBWeights") {
140  cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
141  } else if (container == "EcalLaserAPDPNRatios") {
142  cacheID = evtSetup.get<EcalLaserAPDPNRatiosRcd>().cacheIdentifier();
143  } else if (container == "EcalLaserAPDPNRatiosRef") {
144  cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
145  } else if (container == "EcalLaserAlphas") {
146  cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
147  } else if (container == "EcalChannelStatus") {
148  cacheID = evtSetup.get<EcalChannelStatusRcd>().cacheIdentifier();
149  } else if (container == "EcalDQMTowerStatus") {
150  cacheID = evtSetup.get<EcalDQMTowerStatusRcd>().cacheIdentifier();
151  } else if (container == "EcalDQMChannelStatus") {
152  cacheID = evtSetup.get<EcalDQMChannelStatusRcd>().cacheIdentifier();
153  } else if (container == "EcalDCSTowerStatus") {
154  cacheID = evtSetup.get<EcalDCSTowerStatusRcd>().cacheIdentifier();
155  } else if (container == "EcalDAQTowerStatus") {
156  cacheID = evtSetup.get<EcalDAQTowerStatusRcd>().cacheIdentifier();
157  } else if (container == "EcalTimeCalibConstants") {
158  cacheID = evtSetup.get<EcalTimeCalibConstantsRcd>().cacheIdentifier();
159  } else if (container == "EcalClusterCrackCorrParameters") {
160  cacheID = evtSetup.get<EcalClusterCrackCorrParametersRcd>().cacheIdentifier();
161  } else if (container == "EcalClusterEnergyUncertaintyParameters") {
162  cacheID = evtSetup.get<EcalClusterEnergyUncertaintyParametersRcd>().cacheIdentifier();
163  } else if (container == "EcalClusterEnergyCorrectionParameters") {
164  cacheID = evtSetup.get<EcalClusterEnergyCorrectionParametersRcd>().cacheIdentifier();
165  } else if (container == "EcalClusterEnergyCorrectionObjectSpecificParameters") {
166  cacheID = evtSetup.get<EcalClusterEnergyCorrectionObjectSpecificParametersRcd>().cacheIdentifier();
167  } else if (container == "EcalClusterLocalContCorrParameters") {
168  cacheID = evtSetup.get<EcalClusterLocalContCorrParametersRcd>().cacheIdentifier();
169  } else if (container == "EcalTPGCrystalStatus") {
170  cacheID = evtSetup.get<EcalTPGCrystalStatusRcd>().cacheIdentifier();
171  } else if (container == "EBAlignment") {
172  cacheID = evtSetup.get<EBAlignmentRcd>().cacheIdentifier();
173  } else if (container == "EEAlignment") {
174  cacheID = evtSetup.get<EEAlignmentRcd>().cacheIdentifier();
175  } else if (container == "ESAlignment") {
176  cacheID = evtSetup.get<ESAlignmentRcd>().cacheIdentifier();
177  } else if (container == "EcalTimeOffsetConstant") {
178  cacheID = evtSetup.get<EcalTimeOffsetConstantRcd>().cacheIdentifier();
179  } else if (container == "EcalSampleMask") {
180  cacheID = evtSetup.get<EcalSampleMaskRcd>().cacheIdentifier();
181  }
182 
183  else {
184  throw cms::Exception("Unknown container");
185  }
186 
187  if (m_cacheIDs[container] == cacheID) {
188  return 0;
189  } else {
190  m_cacheIDs[container] = cacheID;
191  return 1;
192  }
193 
194 }
195 
196 
197 
198 void EcalDBCopy::copyToDB(const edm::EventSetup& evtSetup, std::string container)
199 {
201  if ( !dbOutput.isAvailable() ) {
202  throw cms::Exception("PoolDBOutputService is not available");
203  }
204 
205  std::string recordName = m_records[container];
206 
207  if (container == "EcalPedestals") {
209  evtSetup.get<EcalPedestalsRcd>().get(handle);
210  const EcalPedestals* obj = handle.product();
211  std::cout << "ped pointer is: "<< obj<< std::endl;
212  dbOutput->createNewIOV<const EcalPedestals>( new EcalPedestals(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
213 
214  } else if (container == "EcalADCToGeVConstant") {
216  evtSetup.get<EcalADCToGeVConstantRcd>().get(handle);
217  const EcalADCToGeVConstant* obj = handle.product();
218  std::cout << "adc pointer is: "<< obj<< std::endl;
219 
220  dbOutput->createNewIOV<const EcalADCToGeVConstant>( new EcalADCToGeVConstant(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
221 
222 
223  } else if (container == "EcalTimeCalibConstants") {
225  evtSetup.get<EcalTimeCalibConstantsRcd>().get(handle);
226  const EcalTimeCalibConstants* obj = handle.product();
227  std::cout << "adc pointer is: "<< obj<< std::endl;
228 
229  dbOutput->createNewIOV<const EcalTimeCalibConstants>( new EcalTimeCalibConstants(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
230 
231  } else if (container == "EcalChannelStatus") {
233  evtSetup.get<EcalChannelStatusRcd>().get(handle);
234  const EcalChannelStatus* obj = handle.product();
235  std::cout << "channel status pointer is: "<< obj<< std::endl;
236 
237  dbOutput->createNewIOV<const EcalChannelStatus>( new EcalChannelStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
238 
239  } else if (container == "EcalDQMChannelStatus") {
241  evtSetup.get<EcalDQMChannelStatusRcd>().get(handle);
242  const EcalDQMChannelStatus* obj = handle.product();
243  std::cout << "DQM channel status pointer is: "<< obj<< std::endl;
244  dbOutput->createNewIOV<const EcalDQMChannelStatus>( new EcalDQMChannelStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
245 
246  } else if (container == "EcalDQMTowerStatus") {
248  evtSetup.get<EcalDQMTowerStatusRcd>().get(handle);
249  const EcalDQMTowerStatus* obj = handle.product();
250  std::cout << "DQM Tower status pointer is: "<< obj<< std::endl;
251  dbOutput->createNewIOV<const EcalDQMTowerStatus>( new EcalDQMTowerStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
252 
253  } else if (container == "EcalDCSTowerStatus") {
255  evtSetup.get<EcalDCSTowerStatusRcd>().get(handle);
256  const EcalDCSTowerStatus* obj = handle.product();
257  std::cout << "channel status pointer is: "<< obj<< std::endl;
258 
259  dbOutput->createNewIOV<const EcalDCSTowerStatus>( new EcalDCSTowerStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
260 
261  } else if (container == "EcalDAQTowerStatus") {
263  evtSetup.get<EcalDAQTowerStatusRcd>().get(handle);
264  const EcalDAQTowerStatus* obj = handle.product();
265  std::cout << "DAQ channel status pointer is: "<< obj<< std::endl;
266 
267  dbOutput->createNewIOV<const EcalDAQTowerStatus>( new EcalDAQTowerStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
268 
269 
270  } else if (container == "EcalTPGCrystalStatus") {
272  evtSetup.get<EcalTPGCrystalStatusRcd>().get(handle);
273  const EcalTPGCrystalStatus* obj = handle.product();
274  std::cout << "TPG channel status pointer is: "<< obj<< std::endl;
275 
276  dbOutput->createNewIOV<const EcalTPGCrystalStatus>( new EcalTPGCrystalStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
277 
278 
279  } else if (container == "EcalIntercalibConstants") {
281  evtSetup.get<EcalIntercalibConstantsRcd>().get(handle);
282  const EcalIntercalibConstants* obj = handle.product();
283  std::cout << "inter pointer is: "<< obj<< std::endl;
284  dbOutput->createNewIOV<const EcalIntercalibConstants>( new EcalIntercalibConstants(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
285 
286  } else if (container == "EcalLinearCorrections") {
288  evtSetup.get<EcalLinearCorrectionsRcd>().get(handle);
289  const EcalLinearCorrections* obj = handle.product();
290  std::cout << "inter pointer is: "<< obj<< std::endl;
291  dbOutput->createNewIOV<const EcalLinearCorrections>( new EcalLinearCorrections(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
292 
293  }
294 else if (container == "EcalIntercalibConstantsMC") {
296  evtSetup.get<EcalIntercalibConstantsMCRcd>().get(handle);
297  const EcalIntercalibConstantsMC* obj = handle.product();
298  std::cout << "intercalib MC pointer is: "<< obj<< std::endl;
299  dbOutput->createNewIOV<const EcalIntercalibConstantsMC>( new EcalIntercalibConstantsMC(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
300 
301  } else if (container == "EcalIntercalibErrors") {
303  evtSetup.get<EcalIntercalibErrorsRcd>().get(handle);
304  const EcalIntercalibErrors* obj = handle.product();
305  std::cout << "inter pointer is: "<< obj<< std::endl;
306  dbOutput->createNewIOV<const EcalIntercalibErrors>( new EcalIntercalibErrors(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
307 
308  } else if (container == "EcalGainRatios") {
310  evtSetup.get<EcalGainRatiosRcd>().get(handle);
311  const EcalGainRatios* obj = handle.product();
312  std::cout << "gain pointer is: "<< obj<< std::endl;
313  dbOutput->createNewIOV<const EcalGainRatios>( new EcalGainRatios(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
314 
315  } else if (container == "EcalWeightXtalGroups") {
317  evtSetup.get<EcalWeightXtalGroupsRcd>().get(handle);
318  const EcalWeightXtalGroups* obj = handle.product();
319  std::cout << "weight pointer is: "<< obj<< std::endl;
320  dbOutput->createNewIOV<const EcalWeightXtalGroups>( new EcalWeightXtalGroups(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
321 
322  } else if (container == "EcalTBWeights") {
324  evtSetup.get<EcalTBWeightsRcd>().get(handle);
325  const EcalTBWeights* obj = handle.product();
326  std::cout << "tbweight pointer is: "<< obj<< std::endl;
327  dbOutput->createNewIOV<const EcalTBWeights>( new EcalTBWeights(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
328 
329  } else if (container == "EcalLaserAlphas") {
331  evtSetup.get<EcalLaserAlphasRcd>().get(handle);
332  const EcalLaserAlphas* obj = handle.product();
333  std::cout << "ecalLaserAlpha pointer is: "<< obj<< std::endl;
334  dbOutput->createNewIOV<const EcalLaserAlphas>( new EcalLaserAlphas(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
335 
336  } else if (container == "EcalLaserAPDPNRatios") {
338  evtSetup.get<EcalLaserAPDPNRatiosRcd>().get(handle);
339  const EcalLaserAPDPNRatios* obj = handle.product();
340  std::cout << "tbweight pointer is: "<< obj<< std::endl;
341  dbOutput->createNewIOV<const EcalLaserAPDPNRatios>( new EcalLaserAPDPNRatios(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
342 
343  } else if (container == "EcalLaserAPDPNRatiosRef") {
345  evtSetup.get<EcalLaserAPDPNRatiosRefRcd>().get(handle);
346  const EcalLaserAPDPNRatiosRef* obj = handle.product();
347  std::cout << "tbweight pointer is: "<< obj<< std::endl;
348  dbOutput->createNewIOV<const EcalLaserAPDPNRatiosRef>( new EcalLaserAPDPNRatiosRef(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
349 
350 
351  } else if (container == "EcalClusterCrackCorrParameters") {
353  evtSetup.get<EcalClusterCrackCorrParametersRcd>().get(handle);
354  const EcalClusterCrackCorrParameters* obj = handle.product();
355  std::cout << "tbweight pointer is: "<< obj<< std::endl;
357 
358 
359  } else if (container == "EcalClusterEnergyUncertaintyParameters") {
361  evtSetup.get<EcalClusterEnergyUncertaintyParametersRcd>().get(handle);
363  std::cout << "tbweight pointer is: "<< obj<< std::endl;
365 
366 
367  } else if (container == "EcalClusterEnergyCorrectionParameters") {
369  evtSetup.get<EcalClusterEnergyCorrectionParametersRcd>().get(handle);
371  std::cout << "tbweight pointer is: "<< obj<< std::endl;
373 
374  } else if (container == "EcalClusterEnergyCorrectionObjectSpecificParameters") {
378  std::cout << "tbweight pointer is: "<< obj<< std::endl;
380 
381 
382  } else if (container == "EcalClusterLocalContCorrParameters") {
384  evtSetup.get<EcalClusterLocalContCorrParametersRcd>().get(handle);
386  std::cout << "tbweight pointer is: "<< obj<< std::endl;
388 
389  } else if (container == "EBAlignment") {
391  evtSetup.get<EBAlignmentRcd>().get(handle);
392  const Alignments* obj = handle.product();
393  std::cout << "EB alignment pointer is: "<< obj<< std::endl;
394  dbOutput->createNewIOV<const Alignments>( new Alignments(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
395 
396  } else if (container == "EEAlignment") {
398  evtSetup.get<EEAlignmentRcd>().get(handle);
399  const Alignments* obj = handle.product();
400  std::cout << "EE alignment pointer is: "<< obj<< std::endl;
401  dbOutput->createNewIOV<const Alignments>( new Alignments(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
402 
403  } else if (container == "ESAlignment") {
405  evtSetup.get<ESAlignmentRcd>().get(handle);
406  const Alignments* obj = handle.product();
407  std::cout << "ES alignment pointer is: "<< obj<< std::endl;
408  dbOutput->createNewIOV<const Alignments>( new Alignments(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
409 
410  } else if (container == "EcalTimeOffsetConstant") {
412  evtSetup.get<EcalTimeOffsetConstantRcd>().get(handle);
413  const EcalTimeOffsetConstant* obj = handle.product();
414  std::cout << "TimeOffset pointer is: "<< obj<< std::endl;
415  dbOutput->createNewIOV<const EcalTimeOffsetConstant>( new EcalTimeOffsetConstant(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
416 
417  } else if (container == "EcalSampleMask") {
419  evtSetup.get<EcalSampleMaskRcd>().get(handle);
420  const EcalSampleMask* obj = handle.product();
421  std::cout << "sample mask pointer is: "<< obj<< std::endl;
422  dbOutput->createNewIOV<const EcalSampleMask>( new EcalSampleMask(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
423 
424  } else {
425  throw cms::Exception("Unknown container");
426  }
427 
428  std::cout<< "EcalDBCopy wrote " << recordName << std::endl;
429 }
EcalDAQTowerStatusMap EcalDAQTowerStatus
T getParameter(std::string const &) const
EcalIntercalibConstantMCMap EcalIntercalibConstantsMC
int i
Definition: DBlmapReader.cc:9
bool shouldCopy(const edm::EventSetup &evtSetup, std::string container)
Definition: EcalDBCopy.cc:119
EcalFunParams EcalClusterCrackCorrParameters
JetCorrectorParameters::Record record
Definition: classes.h:13
std::map< std::string, std::string > m_records
Definition: EcalDBCopy.h:31
EcalCondObjectContainer< EcalXtalGroupId > EcalWeightXtalGroups
EcalLaserAPDPNRatiosRefMap EcalLaserAPDPNRatiosRef
EcalDBCopy(const edm::ParameterSet &iConfig)
Definition: EcalDBCopy.cc:75
EcalTimeDependentCorrections EcalLinearCorrections
EcalDQMChannelStatusMap EcalDQMChannelStatus
EcalChannelStatusMap EcalChannelStatus
vector< ParameterSet > Parameters
EcalGainRatioMap EcalGainRatios
EcalLaserAlphaMap EcalLaserAlphas
EcalDCSTowerStatusMap EcalDCSTowerStatus
EcalDQMTowerStatusMap EcalDQMTowerStatus
bool isAvailable() const
Definition: Service.h:47
EcalTPGCrystalStatusMap EcalTPGCrystalStatus
tuple handle
Definition: patZpeak.py:22
EcalFunParams EcalClusterEnergyCorrectionObjectSpecificParameters
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
EcalIntercalibErrorMap EcalIntercalibErrors
EcalFunParams EcalClusterEnergyUncertaintyParameters
EcalPedestalsMap EcalPedestals
Definition: EcalPedestals.h:38
EcalTimeCalibConstantMap EcalTimeCalibConstants
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
EcalFunParams EcalClusterLocalContCorrParameters
EcalIntercalibConstantMap EcalIntercalibConstants
EcalFunParams EcalClusterEnergyCorrectionParameters
tuple cout
Definition: gather_cfg.py:121
std::map< std::string, unsigned long long > m_cacheIDs
Definition: EcalDBCopy.h:30
virtual void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup)
Definition: EcalDBCopy.cc:101
void copyToDB(const edm::EventSetup &evtSetup, std::string container)
Definition: EcalDBCopy.cc:198