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