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 
75 
76 #include <vector>
77 
79  m_timetype(iConfig.getParameter<std::string>("timetype")),
80  m_cacheIDs(),
81  m_records()
82 {
83 
84  std::string container;
87  typedef std::vector< edm::ParameterSet > Parameters;
88  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
89  for(Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
90  container = i->getParameter<std::string>("container");
91  record = i->getParameter<std::string>("record");
92  m_cacheIDs.insert( std::make_pair(container, 0) );
93  m_records.insert( std::make_pair(container, record) );
94  }
95 
96 }
97 
98 
100 {
101 
102 }
103 
104 void EcalDBCopy::analyze( const edm::Event& evt, const edm::EventSetup& evtSetup)
105 {
106 
107  std::string container;
109  typedef std::map<std::string, std::string>::const_iterator recordIter;
110  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
111  container = (*i).first;
112  record = (*i).second;
113  if ( shouldCopy(evtSetup, container) ) {
114  copyToDB(evtSetup, container);
115  }
116  }
117 
118 }
119 
120 
121 
122 bool EcalDBCopy::shouldCopy(const edm::EventSetup& evtSetup, std::string container)
123 {
124 
125  unsigned long long cacheID = 0;
126  if (container == "EcalPedestals") {
127  cacheID = evtSetup.get<EcalPedestalsRcd>().cacheIdentifier();
128  } else if (container == "EcalADCToGeVConstant") {
129  cacheID = evtSetup.get<EcalADCToGeVConstantRcd>().cacheIdentifier();
130  } else if (container == "EcalLinearCorrections") {
131  cacheID = evtSetup.get<EcalLinearCorrectionsRcd>().cacheIdentifier();
132  } else if (container == "EcalIntercalibConstants") {
133  cacheID = evtSetup.get<EcalIntercalibConstantsRcd>().cacheIdentifier();
134  } else if (container == "EcalIntercalibConstantsMC") {
135  cacheID = evtSetup.get<EcalIntercalibConstantsMCRcd>().cacheIdentifier();
136  } else if (container == "EcalIntercalibErrors") {
137  cacheID = evtSetup.get<EcalIntercalibErrorsRcd>().cacheIdentifier();
138  } else if (container == "EcalGainRatios") {
139  cacheID = evtSetup.get<EcalGainRatiosRcd>().cacheIdentifier();
140  } else if (container == "EcalWeightXtalGroups") {
141  cacheID = evtSetup.get<EcalWeightXtalGroupsRcd>().cacheIdentifier();
142  } else if (container == "EcalTBWeights") {
143  cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
144  } else if (container == "EcalLaserAPDPNRatios") {
145  cacheID = evtSetup.get<EcalLaserAPDPNRatiosRcd>().cacheIdentifier();
146  } else if (container == "EcalLaserAPDPNRatiosRef") {
147  cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
148  } else if (container == "EcalLaserAlphas") {
149  cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
150  } else if (container == "EcalChannelStatus") {
151  cacheID = evtSetup.get<EcalChannelStatusRcd>().cacheIdentifier();
152  } else if (container == "EcalDQMTowerStatus") {
153  cacheID = evtSetup.get<EcalDQMTowerStatusRcd>().cacheIdentifier();
154  } else if (container == "EcalDQMChannelStatus") {
155  cacheID = evtSetup.get<EcalDQMChannelStatusRcd>().cacheIdentifier();
156  } else if (container == "EcalDCSTowerStatus") {
157  cacheID = evtSetup.get<EcalDCSTowerStatusRcd>().cacheIdentifier();
158  } else if (container == "EcalDAQTowerStatus") {
159  cacheID = evtSetup.get<EcalDAQTowerStatusRcd>().cacheIdentifier();
160  } else if (container == "EcalTimeCalibConstants") {
161  cacheID = evtSetup.get<EcalTimeCalibConstantsRcd>().cacheIdentifier();
162  } else if (container == "EcalClusterCrackCorrParameters") {
163  cacheID = evtSetup.get<EcalClusterCrackCorrParametersRcd>().cacheIdentifier();
164  } else if (container == "EcalClusterEnergyUncertaintyParameters") {
165  cacheID = evtSetup.get<EcalClusterEnergyUncertaintyParametersRcd>().cacheIdentifier();
166  } else if (container == "EcalClusterEnergyCorrectionParameters") {
167  cacheID = evtSetup.get<EcalClusterEnergyCorrectionParametersRcd>().cacheIdentifier();
168  } else if (container == "EcalClusterEnergyCorrectionObjectSpecificParameters") {
169  cacheID = evtSetup.get<EcalClusterEnergyCorrectionObjectSpecificParametersRcd>().cacheIdentifier();
170  } else if (container == "EcalClusterLocalContCorrParameters") {
171  cacheID = evtSetup.get<EcalClusterLocalContCorrParametersRcd>().cacheIdentifier();
172  } else if (container == "EcalTPGCrystalStatus") {
173  cacheID = evtSetup.get<EcalTPGCrystalStatusRcd>().cacheIdentifier();
174  } else if (container == "EBAlignment") {
175  cacheID = evtSetup.get<EBAlignmentRcd>().cacheIdentifier();
176  } else if (container == "EEAlignment") {
177  cacheID = evtSetup.get<EEAlignmentRcd>().cacheIdentifier();
178  } else if (container == "ESAlignment") {
179  cacheID = evtSetup.get<ESAlignmentRcd>().cacheIdentifier();
180  } else if (container == "EcalTimeOffsetConstant") {
181  cacheID = evtSetup.get<EcalTimeOffsetConstantRcd>().cacheIdentifier();
182  } else if (container == "EcalSampleMask") {
183  cacheID = evtSetup.get<EcalSampleMaskRcd>().cacheIdentifier();
184  } else if (container == "EcalTimeBiasCorrections") {
185  cacheID = evtSetup.get<EcalTimeBiasCorrectionsRcd>().cacheIdentifier();
186  }
187 
188  else {
189  throw cms::Exception("Unknown container");
190  }
191 
192  if (m_cacheIDs[container] == cacheID) {
193  return 0;
194  } else {
195  m_cacheIDs[container] = cacheID;
196  return 1;
197  }
198 
199 }
200 
201 
202 
203 void EcalDBCopy::copyToDB(const edm::EventSetup& evtSetup, std::string container)
204 {
206  if ( !dbOutput.isAvailable() ) {
207  throw cms::Exception("PoolDBOutputService is not available");
208  }
209 
210  std::string recordName = m_records[container];
211 
212  if (container == "EcalPedestals") {
214  evtSetup.get<EcalPedestalsRcd>().get(handle);
215  const EcalPedestals* obj = handle.product();
216  std::cout << "ped pointer is: "<< obj<< std::endl;
217  dbOutput->createNewIOV<const EcalPedestals>( new EcalPedestals(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
218 
219  } else if (container == "EcalADCToGeVConstant") {
221  evtSetup.get<EcalADCToGeVConstantRcd>().get(handle);
222  const EcalADCToGeVConstant* obj = handle.product();
223  std::cout << "adc pointer is: "<< obj<< std::endl;
224 
225  dbOutput->createNewIOV<const EcalADCToGeVConstant>( new EcalADCToGeVConstant(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
226 
227 
228  } else if (container == "EcalTimeCalibConstants") {
230  evtSetup.get<EcalTimeCalibConstantsRcd>().get(handle);
231  const EcalTimeCalibConstants* obj = handle.product();
232  std::cout << "adc pointer is: "<< obj<< std::endl;
233 
234  dbOutput->createNewIOV<const EcalTimeCalibConstants>( new EcalTimeCalibConstants(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
235 
236  } else if (container == "EcalChannelStatus") {
238  evtSetup.get<EcalChannelStatusRcd>().get(handle);
239  const EcalChannelStatus* obj = handle.product();
240  std::cout << "channel status pointer is: "<< obj<< std::endl;
241 
242  dbOutput->createNewIOV<const EcalChannelStatus>( new EcalChannelStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
243 
244  } else if (container == "EcalDQMChannelStatus") {
246  evtSetup.get<EcalDQMChannelStatusRcd>().get(handle);
247  const EcalDQMChannelStatus* obj = handle.product();
248  std::cout << "DQM channel status pointer is: "<< obj<< std::endl;
249  dbOutput->createNewIOV<const EcalDQMChannelStatus>( new EcalDQMChannelStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
250 
251  } else if (container == "EcalDQMTowerStatus") {
253  evtSetup.get<EcalDQMTowerStatusRcd>().get(handle);
254  const EcalDQMTowerStatus* obj = handle.product();
255  std::cout << "DQM Tower status pointer is: "<< obj<< std::endl;
256  dbOutput->createNewIOV<const EcalDQMTowerStatus>( new EcalDQMTowerStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
257 
258  } else if (container == "EcalDCSTowerStatus") {
260  evtSetup.get<EcalDCSTowerStatusRcd>().get(handle);
261  const EcalDCSTowerStatus* obj = handle.product();
262  std::cout << "channel status pointer is: "<< obj<< std::endl;
263 
264  dbOutput->createNewIOV<const EcalDCSTowerStatus>( new EcalDCSTowerStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
265 
266  } else if (container == "EcalDAQTowerStatus") {
268  evtSetup.get<EcalDAQTowerStatusRcd>().get(handle);
269  const EcalDAQTowerStatus* obj = handle.product();
270  std::cout << "DAQ channel status pointer is: "<< obj<< std::endl;
271 
272  dbOutput->createNewIOV<const EcalDAQTowerStatus>( new EcalDAQTowerStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
273 
274 
275  } else if (container == "EcalTPGCrystalStatus") {
277  evtSetup.get<EcalTPGCrystalStatusRcd>().get(handle);
278  const EcalTPGCrystalStatus* obj = handle.product();
279  std::cout << "TPG channel status pointer is: "<< obj<< std::endl;
280 
281  dbOutput->createNewIOV<const EcalTPGCrystalStatus>( new EcalTPGCrystalStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
282 
283 
284  } else if (container == "EcalIntercalibConstants") {
286  evtSetup.get<EcalIntercalibConstantsRcd>().get(handle);
287  const EcalIntercalibConstants* obj = handle.product();
288  std::cout << "inter pointer is: "<< obj<< std::endl;
289  dbOutput->createNewIOV<const EcalIntercalibConstants>( new EcalIntercalibConstants(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
290 
291  } else if (container == "EcalLinearCorrections") {
293  evtSetup.get<EcalLinearCorrectionsRcd>().get(handle);
294  const EcalLinearCorrections* obj = handle.product();
295  std::cout << "inter pointer is: "<< obj<< std::endl;
296  dbOutput->createNewIOV<const EcalLinearCorrections>( new EcalLinearCorrections(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
297 
298  }
299 else if (container == "EcalIntercalibConstantsMC") {
301  evtSetup.get<EcalIntercalibConstantsMCRcd>().get(handle);
302  const EcalIntercalibConstantsMC* obj = handle.product();
303  std::cout << "intercalib MC pointer is: "<< obj<< std::endl;
304  dbOutput->createNewIOV<const EcalIntercalibConstantsMC>( new EcalIntercalibConstantsMC(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
305 
306  } else if (container == "EcalIntercalibErrors") {
308  evtSetup.get<EcalIntercalibErrorsRcd>().get(handle);
309  const EcalIntercalibErrors* obj = handle.product();
310  std::cout << "inter pointer is: "<< obj<< std::endl;
311  dbOutput->createNewIOV<const EcalIntercalibErrors>( new EcalIntercalibErrors(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
312 
313  } else if (container == "EcalGainRatios") {
315  evtSetup.get<EcalGainRatiosRcd>().get(handle);
316  const EcalGainRatios* obj = handle.product();
317  std::cout << "gain pointer is: "<< obj<< std::endl;
318  dbOutput->createNewIOV<const EcalGainRatios>( new EcalGainRatios(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
319 
320  } else if (container == "EcalWeightXtalGroups") {
322  evtSetup.get<EcalWeightXtalGroupsRcd>().get(handle);
323  const EcalWeightXtalGroups* obj = handle.product();
324  std::cout << "weight pointer is: "<< obj<< std::endl;
325  dbOutput->createNewIOV<const EcalWeightXtalGroups>( new EcalWeightXtalGroups(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
326 
327  } else if (container == "EcalTBWeights") {
329  evtSetup.get<EcalTBWeightsRcd>().get(handle);
330  const EcalTBWeights* obj = handle.product();
331  std::cout << "tbweight pointer is: "<< obj<< std::endl;
332  dbOutput->createNewIOV<const EcalTBWeights>( new EcalTBWeights(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
333 
334  } else if (container == "EcalLaserAlphas") {
336  evtSetup.get<EcalLaserAlphasRcd>().get(handle);
337  const EcalLaserAlphas* obj = handle.product();
338  std::cout << "ecalLaserAlpha pointer is: "<< obj<< std::endl;
339  dbOutput->createNewIOV<const EcalLaserAlphas>( new EcalLaserAlphas(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
340 
341  } else if (container == "EcalLaserAPDPNRatios") {
343  evtSetup.get<EcalLaserAPDPNRatiosRcd>().get(handle);
344  const EcalLaserAPDPNRatios* obj = handle.product();
345  std::cout << "tbweight pointer is: "<< obj<< std::endl;
346  dbOutput->createNewIOV<const EcalLaserAPDPNRatios>( new EcalLaserAPDPNRatios(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
347 
348  } else if (container == "EcalLaserAPDPNRatiosRef") {
350  evtSetup.get<EcalLaserAPDPNRatiosRefRcd>().get(handle);
351  const EcalLaserAPDPNRatiosRef* obj = handle.product();
352  std::cout << "tbweight pointer is: "<< obj<< std::endl;
353  dbOutput->createNewIOV<const EcalLaserAPDPNRatiosRef>( new EcalLaserAPDPNRatiosRef(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
354 
355 
356  } else if (container == "EcalClusterCrackCorrParameters") {
358  evtSetup.get<EcalClusterCrackCorrParametersRcd>().get(handle);
359  const EcalClusterCrackCorrParameters* obj = handle.product();
360  std::cout << "tbweight pointer is: "<< obj<< std::endl;
362 
363 
364  } else if (container == "EcalClusterEnergyUncertaintyParameters") {
366  evtSetup.get<EcalClusterEnergyUncertaintyParametersRcd>().get(handle);
368  std::cout << "tbweight pointer is: "<< obj<< std::endl;
370 
371 
372  } else if (container == "EcalClusterEnergyCorrectionParameters") {
374  evtSetup.get<EcalClusterEnergyCorrectionParametersRcd>().get(handle);
376  std::cout << "tbweight pointer is: "<< obj<< std::endl;
378 
379  } else if (container == "EcalClusterEnergyCorrectionObjectSpecificParameters") {
383  std::cout << "tbweight pointer is: "<< obj<< std::endl;
385 
386 
387  } else if (container == "EcalClusterLocalContCorrParameters") {
389  evtSetup.get<EcalClusterLocalContCorrParametersRcd>().get(handle);
391  std::cout << "tbweight pointer is: "<< obj<< std::endl;
393 
394  } else if (container == "EBAlignment") {
396  evtSetup.get<EBAlignmentRcd>().get(handle);
397  const Alignments* obj = handle.product();
398  std::cout << "EB alignment pointer is: "<< obj<< std::endl;
399  dbOutput->createNewIOV<const Alignments>( new Alignments(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
400 
401  } else if (container == "EEAlignment") {
403  evtSetup.get<EEAlignmentRcd>().get(handle);
404  const Alignments* obj = handle.product();
405  std::cout << "EE alignment pointer is: "<< obj<< std::endl;
406  dbOutput->createNewIOV<const Alignments>( new Alignments(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
407 
408  } else if (container == "ESAlignment") {
410  evtSetup.get<ESAlignmentRcd>().get(handle);
411  const Alignments* obj = handle.product();
412  std::cout << "ES alignment pointer is: "<< obj<< std::endl;
413  dbOutput->createNewIOV<const Alignments>( new Alignments(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
414 
415  } else if (container == "EcalTimeOffsetConstant") {
417  evtSetup.get<EcalTimeOffsetConstantRcd>().get(handle);
418  const EcalTimeOffsetConstant* obj = handle.product();
419  std::cout << "TimeOffset pointer is: "<< obj<< std::endl;
420  dbOutput->createNewIOV<const EcalTimeOffsetConstant>( new EcalTimeOffsetConstant(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
421 
422  } else if (container == "EcalSampleMask") {
424  evtSetup.get<EcalSampleMaskRcd>().get(handle);
425  const EcalSampleMask* obj = handle.product();
426  std::cout << "sample mask pointer is: "<< obj<< std::endl;
427  dbOutput->createNewIOV<const EcalSampleMask>( new EcalSampleMask(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
428 
429  } else if (container == "EcalTimeBiasCorrections") {
431  evtSetup.get<EcalTimeBiasCorrectionsRcd>().get(handle);
432  const EcalTimeBiasCorrections* obj = handle.product();
433  std::cout << "TimeBiasCorrections pointer is: "<< obj<< std::endl;
435  bias_ = new EcalTimeBiasCorrections();
436  std::vector<float> vect = obj->EBTimeCorrAmplitudeBins;
437  copy(vect.begin(), vect.end(), back_inserter(bias_->EBTimeCorrAmplitudeBins));
438  vect = obj->EBTimeCorrShiftBins;
439  copy(vect.begin(), vect.end(), back_inserter(bias_->EBTimeCorrShiftBins));
440  vect = obj->EETimeCorrAmplitudeBins;
441  copy(vect.begin(), vect.end(), back_inserter(bias_->EETimeCorrAmplitudeBins));
442  vect = obj->EETimeCorrShiftBins;
443  copy(vect.begin(), vect.end(), back_inserter(bias_->EETimeCorrShiftBins));
444  dbOutput->writeOne(bias_, dbOutput->beginOfTime(), "EcalTimeBiasCorrectionsRcd");
445 } else {
446  throw cms::Exception("Unknown container");
447  }
448 
449  std::cout<< "EcalDBCopy wrote " << recordName << std::endl;
450 }
EcalDAQTowerStatusMap EcalDAQTowerStatus
T getParameter(std::string const &) const
EcalIntercalibConstantMCMap EcalIntercalibConstantsMC
int i
Definition: DBlmapReader.cc:9
std::vector< float > EBTimeCorrShiftBins
bool shouldCopy(const edm::EventSetup &evtSetup, std::string container)
Definition: EcalDBCopy.cc:122
EcalFunParams EcalClusterCrackCorrParameters
JetCorrectorParameters::Record record
Definition: classes.h:7
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:78
EcalTimeDependentCorrections EcalLinearCorrections
std::vector< float > EBTimeCorrAmplitudeBins
std::vector< float > EETimeCorrShiftBins
EcalDQMChannelStatusMap EcalDQMChannelStatus
EcalChannelStatusMap EcalChannelStatus
vector< ParameterSet > Parameters
EcalGainRatioMap EcalGainRatios
EcalLaserAlphaMap EcalLaserAlphas
std::vector< float > EETimeCorrAmplitudeBins
EcalDCSTowerStatusMap EcalDCSTowerStatus
EcalDQMTowerStatusMap EcalDQMTowerStatus
bool isAvailable() const
Definition: Service.h:46
EcalTPGCrystalStatusMap EcalTPGCrystalStatus
tuple handle
Definition: patZpeak.py:22
EcalFunParams EcalClusterEnergyCorrectionObjectSpecificParameters
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
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:53
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:104
void copyToDB(const edm::EventSetup &evtSetup, std::string container)
Definition: EcalDBCopy.cc:203