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 
40 
49 
60 
67 
68 #include <vector>
69 
71  m_timetype(iConfig.getParameter<std::string>("timetype")),
72  m_cacheIDs(),
73  m_records()
74 {
75 
76  std::string container;
77  std::string tag;
78  std::string record;
79  typedef std::vector< edm::ParameterSet > Parameters;
80  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
81  for(Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
82  container = i->getParameter<std::string>("container");
83  record = i->getParameter<std::string>("record");
84  m_cacheIDs.insert( std::make_pair(container, 0) );
85  m_records.insert( std::make_pair(container, record) );
86  }
87 
88 }
89 
90 
92 {
93 
94 }
95 
96 void EcalDBCopy::analyze( const edm::Event& evt, const edm::EventSetup& evtSetup)
97 {
98 
99  std::string container;
100  std::string record;
101  typedef std::map<std::string, std::string>::const_iterator recordIter;
102  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
103  container = (*i).first;
104  record = (*i).second;
105  if ( shouldCopy(evtSetup, container) ) {
106  copyToDB(evtSetup, container);
107  }
108  }
109 
110 }
111 
112 
113 
114 bool EcalDBCopy::shouldCopy(const edm::EventSetup& evtSetup, std::string container)
115 {
116 
117  unsigned long long cacheID = 0;
118  if (container == "EcalPedestals") {
119  cacheID = evtSetup.get<EcalPedestalsRcd>().cacheIdentifier();
120  } else if (container == "EcalADCToGeVConstant") {
121  cacheID = evtSetup.get<EcalADCToGeVConstantRcd>().cacheIdentifier();
122  } else if (container == "EcalIntercalibConstants") {
123  cacheID = evtSetup.get<EcalIntercalibConstantsRcd>().cacheIdentifier();
124  } else if (container == "EcalIntercalibConstantsMC") {
125  cacheID = evtSetup.get<EcalIntercalibConstantsMCRcd>().cacheIdentifier();
126  } else if (container == "EcalIntercalibErrors") {
127  cacheID = evtSetup.get<EcalIntercalibErrorsRcd>().cacheIdentifier();
128  } else if (container == "EcalGainRatios") {
129  cacheID = evtSetup.get<EcalGainRatiosRcd>().cacheIdentifier();
130  } else if (container == "EcalWeightXtalGroups") {
131  cacheID = evtSetup.get<EcalWeightXtalGroupsRcd>().cacheIdentifier();
132  } else if (container == "EcalTBWeights") {
133  cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
134  } else if (container == "EcalLaserAPDPNRatios") {
135  cacheID = evtSetup.get<EcalLaserAPDPNRatiosRcd>().cacheIdentifier();
136  } else if (container == "EcalLaserAPDPNRatiosRef") {
137  cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
138  } else if (container == "EcalLaserAlphas") {
139  cacheID = evtSetup.get<EcalTBWeightsRcd>().cacheIdentifier();
140  } else if (container == "EcalChannelStatus") {
141  cacheID = evtSetup.get<EcalChannelStatusRcd>().cacheIdentifier();
142  } else if (container == "EcalDQMTowerStatus") {
143  cacheID = evtSetup.get<EcalDQMTowerStatusRcd>().cacheIdentifier();
144  } else if (container == "EcalDQMChannelStatus") {
145  cacheID = evtSetup.get<EcalDQMChannelStatusRcd>().cacheIdentifier();
146  } else if (container == "EcalDCSTowerStatus") {
147  cacheID = evtSetup.get<EcalDCSTowerStatusRcd>().cacheIdentifier();
148  } else if (container == "EcalDAQTowerStatus") {
149  cacheID = evtSetup.get<EcalDAQTowerStatusRcd>().cacheIdentifier();
150  } else if (container == "EcalTimeCalibConstants") {
151  cacheID = evtSetup.get<EcalTimeCalibConstantsRcd>().cacheIdentifier();
152  } else if (container == "EcalClusterCrackCorrParameters") {
153  cacheID = evtSetup.get<EcalClusterCrackCorrParametersRcd>().cacheIdentifier();
154  } else if (container == "EcalClusterEnergyUncertaintyParameters") {
155  cacheID = evtSetup.get<EcalClusterEnergyUncertaintyParametersRcd>().cacheIdentifier();
156  } else if (container == "EcalClusterEnergyCorrectionParameters") {
157  cacheID = evtSetup.get<EcalClusterEnergyCorrectionParametersRcd>().cacheIdentifier();
158  } else if (container == "EcalClusterEnergyCorrectionObjectSpecificParameters") {
159  cacheID = evtSetup.get<EcalClusterEnergyCorrectionObjectSpecificParametersRcd>().cacheIdentifier();
160  } else if (container == "EcalClusterLocalContCorrParameters") {
161  cacheID = evtSetup.get<EcalClusterLocalContCorrParametersRcd>().cacheIdentifier();
162  } else if (container == "EcalTPGCrystalStatus") {
163  cacheID = evtSetup.get<EcalTPGCrystalStatusRcd>().cacheIdentifier();
164  } else if (container == "EBAlignment") {
165  cacheID = evtSetup.get<EBAlignmentRcd>().cacheIdentifier();
166  } else if (container == "EEAlignment") {
167  cacheID = evtSetup.get<EEAlignmentRcd>().cacheIdentifier();
168  } else if (container == "ESAlignment") {
169  cacheID = evtSetup.get<ESAlignmentRcd>().cacheIdentifier();
170  } else if (container == "EcalTimeOffsetConstant") {
171  cacheID = evtSetup.get<EcalTimeOffsetConstantRcd>().cacheIdentifier();
172  }
173 
174  else {
175  throw cms::Exception("Unknown container");
176  }
177 
178  if (m_cacheIDs[container] == cacheID) {
179  return 0;
180  } else {
181  m_cacheIDs[container] = cacheID;
182  return 1;
183  }
184 
185 }
186 
187 
188 
189 void EcalDBCopy::copyToDB(const edm::EventSetup& evtSetup, std::string container)
190 {
192  if ( !dbOutput.isAvailable() ) {
193  throw cms::Exception("PoolDBOutputService is not available");
194  }
195 
196  std::string recordName = m_records[container];
197 
198  if (container == "EcalPedestals") {
200  evtSetup.get<EcalPedestalsRcd>().get(handle);
201  const EcalPedestals* obj = handle.product();
202  std::cout << "ped pointer is: "<< obj<< std::endl;
203  dbOutput->createNewIOV<const EcalPedestals>( new EcalPedestals(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
204 
205  } else if (container == "EcalADCToGeVConstant") {
207  evtSetup.get<EcalADCToGeVConstantRcd>().get(handle);
208  const EcalADCToGeVConstant* obj = handle.product();
209  std::cout << "adc pointer is: "<< obj<< std::endl;
210 
211  dbOutput->createNewIOV<const EcalADCToGeVConstant>( new EcalADCToGeVConstant(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
212 
213 
214  } else if (container == "EcalTimeCalibConstants") {
216  evtSetup.get<EcalTimeCalibConstantsRcd>().get(handle);
217  const EcalTimeCalibConstants* obj = handle.product();
218  std::cout << "adc pointer is: "<< obj<< std::endl;
219 
220  dbOutput->createNewIOV<const EcalTimeCalibConstants>( new EcalTimeCalibConstants(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
221 
222  } else if (container == "EcalChannelStatus") {
224  evtSetup.get<EcalChannelStatusRcd>().get(handle);
225  const EcalChannelStatus* obj = handle.product();
226  std::cout << "channel status pointer is: "<< obj<< std::endl;
227 
228  dbOutput->createNewIOV<const EcalChannelStatus>( new EcalChannelStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
229 
230  } else if (container == "EcalDQMChannelStatus") {
232  evtSetup.get<EcalDQMChannelStatusRcd>().get(handle);
233  const EcalDQMChannelStatus* obj = handle.product();
234  std::cout << "DQM channel status pointer is: "<< obj<< std::endl;
235  dbOutput->createNewIOV<const EcalDQMChannelStatus>( new EcalDQMChannelStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
236 
237  } else if (container == "EcalDQMTowerStatus") {
239  evtSetup.get<EcalDQMTowerStatusRcd>().get(handle);
240  const EcalDQMTowerStatus* obj = handle.product();
241  std::cout << "DQM Tower status pointer is: "<< obj<< std::endl;
242  dbOutput->createNewIOV<const EcalDQMTowerStatus>( new EcalDQMTowerStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
243 
244  } else if (container == "EcalDCSTowerStatus") {
246  evtSetup.get<EcalDCSTowerStatusRcd>().get(handle);
247  const EcalDCSTowerStatus* obj = handle.product();
248  std::cout << "channel status pointer is: "<< obj<< std::endl;
249 
250  dbOutput->createNewIOV<const EcalDCSTowerStatus>( new EcalDCSTowerStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
251 
252  } else if (container == "EcalDAQTowerStatus") {
254  evtSetup.get<EcalDAQTowerStatusRcd>().get(handle);
255  const EcalDAQTowerStatus* obj = handle.product();
256  std::cout << "DAQ channel status pointer is: "<< obj<< std::endl;
257 
258  dbOutput->createNewIOV<const EcalDAQTowerStatus>( new EcalDAQTowerStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
259 
260 
261  } else if (container == "EcalTPGCrystalStatus") {
263  evtSetup.get<EcalTPGCrystalStatusRcd>().get(handle);
264  const EcalTPGCrystalStatus* obj = handle.product();
265  std::cout << "TPG channel status pointer is: "<< obj<< std::endl;
266 
267  dbOutput->createNewIOV<const EcalTPGCrystalStatus>( new EcalTPGCrystalStatus(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
268 
269 
270  }
271 else if (container == "EcalIntercalibConstants") {
273  evtSetup.get<EcalIntercalibConstantsRcd>().get(handle);
274  const EcalIntercalibConstants* obj = handle.product();
275  std::cout << "inter pointer is: "<< obj<< std::endl;
276  dbOutput->createNewIOV<const EcalIntercalibConstants>( new EcalIntercalibConstants(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
277 
278  }
279 else if (container == "EcalIntercalibConstantsMC") {
281  evtSetup.get<EcalIntercalibConstantsMCRcd>().get(handle);
282  const EcalIntercalibConstantsMC* obj = handle.product();
283  std::cout << "intercalib MC pointer is: "<< obj<< std::endl;
284  dbOutput->createNewIOV<const EcalIntercalibConstantsMC>( new EcalIntercalibConstantsMC(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
285 
286  } else if (container == "EcalIntercalibErrors") {
288  evtSetup.get<EcalIntercalibErrorsRcd>().get(handle);
289  const EcalIntercalibErrors* obj = handle.product();
290  std::cout << "inter pointer is: "<< obj<< std::endl;
291  dbOutput->createNewIOV<const EcalIntercalibErrors>( new EcalIntercalibErrors(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
292 
293  } else if (container == "EcalGainRatios") {
295  evtSetup.get<EcalGainRatiosRcd>().get(handle);
296  const EcalGainRatios* obj = handle.product();
297  std::cout << "gain pointer is: "<< obj<< std::endl;
298  dbOutput->createNewIOV<const EcalGainRatios>( new EcalGainRatios(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
299 
300  } else if (container == "EcalWeightXtalGroups") {
302  evtSetup.get<EcalWeightXtalGroupsRcd>().get(handle);
303  const EcalWeightXtalGroups* obj = handle.product();
304  std::cout << "weight pointer is: "<< obj<< std::endl;
305  dbOutput->createNewIOV<const EcalWeightXtalGroups>( new EcalWeightXtalGroups(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
306 
307  } else if (container == "EcalTBWeights") {
309  evtSetup.get<EcalTBWeightsRcd>().get(handle);
310  const EcalTBWeights* obj = handle.product();
311  std::cout << "tbweight pointer is: "<< obj<< std::endl;
312  dbOutput->createNewIOV<const EcalTBWeights>( new EcalTBWeights(*obj), dbOutput->beginOfTime(),dbOutput->endOfTime(),recordName);
313 
314  } else if (container == "EcalLaserAlphas") {
316  evtSetup.get<EcalLaserAlphasRcd>().get(handle);
317  const EcalLaserAlphas* obj = handle.product();
318  std::cout << "ecalLaserAlpha pointer is: "<< obj<< std::endl;
319  dbOutput->createNewIOV<const EcalLaserAlphas>( new EcalLaserAlphas(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
320 
321  } else if (container == "EcalLaserAPDPNRatios") {
323  evtSetup.get<EcalLaserAPDPNRatiosRcd>().get(handle);
324  const EcalLaserAPDPNRatios* obj = handle.product();
325  std::cout << "tbweight pointer is: "<< obj<< std::endl;
326  dbOutput->createNewIOV<const EcalLaserAPDPNRatios>( new EcalLaserAPDPNRatios(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
327 
328  } else if (container == "EcalLaserAPDPNRatiosRef") {
330  evtSetup.get<EcalLaserAPDPNRatiosRefRcd>().get(handle);
331  const EcalLaserAPDPNRatiosRef* obj = handle.product();
332  std::cout << "tbweight pointer is: "<< obj<< std::endl;
333  dbOutput->createNewIOV<const EcalLaserAPDPNRatiosRef>( new EcalLaserAPDPNRatiosRef(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
334 
335 
336  } else if (container == "EcalClusterCrackCorrParameters") {
338  evtSetup.get<EcalClusterCrackCorrParametersRcd>().get(handle);
339  const EcalClusterCrackCorrParameters* obj = handle.product();
340  std::cout << "tbweight pointer is: "<< obj<< std::endl;
342 
343 
344  } else if (container == "EcalClusterEnergyUncertaintyParameters") {
346  evtSetup.get<EcalClusterEnergyUncertaintyParametersRcd>().get(handle);
348  std::cout << "tbweight pointer is: "<< obj<< std::endl;
350 
351 
352  } else if (container == "EcalClusterEnergyCorrectionParameters") {
354  evtSetup.get<EcalClusterEnergyCorrectionParametersRcd>().get(handle);
356  std::cout << "tbweight pointer is: "<< obj<< std::endl;
358 
359  } else if (container == "EcalClusterEnergyCorrectionObjectSpecificParameters") {
363  std::cout << "tbweight pointer is: "<< obj<< std::endl;
365 
366 
367  } else if (container == "EcalClusterLocalContCorrParameters") {
369  evtSetup.get<EcalClusterLocalContCorrParametersRcd>().get(handle);
371  std::cout << "tbweight pointer is: "<< obj<< std::endl;
373 
374  } else if (container == "EBAlignment") {
376  evtSetup.get<EBAlignmentRcd>().get(handle);
377  const Alignments* obj = handle.product();
378  std::cout << "EB alignment pointer is: "<< obj<< std::endl;
379  dbOutput->createNewIOV<const Alignments>( new Alignments(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
380 
381  } else if (container == "EEAlignment") {
383  evtSetup.get<EEAlignmentRcd>().get(handle);
384  const Alignments* obj = handle.product();
385  std::cout << "EE alignment pointer is: "<< obj<< std::endl;
386  dbOutput->createNewIOV<const Alignments>( new Alignments(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
387 
388  } else if (container == "ESAlignment") {
390  evtSetup.get<ESAlignmentRcd>().get(handle);
391  const Alignments* obj = handle.product();
392  std::cout << "ES alignment pointer is: "<< obj<< std::endl;
393  dbOutput->createNewIOV<const Alignments>( new Alignments(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
394 
395  } else if (container == "EcalTimeOffsetConstant") {
397  evtSetup.get<EcalTimeOffsetConstantRcd>().get(handle);
398  const EcalTimeOffsetConstant* obj = handle.product();
399  std::cout << "TimeOffset pointer is: "<< obj<< std::endl;
400  dbOutput->createNewIOV<const EcalTimeOffsetConstant>( new EcalTimeOffsetConstant(*obj),dbOutput->beginOfTime(), dbOutput->endOfTime(),recordName);
401 
402  } else {
403  throw cms::Exception("Unknown container");
404  }
405 
406  std::cout<< "EcalDBCopy wrote " << recordName << std::endl;
407 }
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:114
EcalFunParams EcalClusterCrackCorrParameters
JetCorrectorParameters::Record record
Definition: classes.h:11
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:70
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:96
void copyToDB(const edm::EventSetup &evtSetup, std::string container)
Definition: EcalDBCopy.cc:189