CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDbProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalDbProducer
4 // Class: HcalDbProducer
5 //
13 //
14 // Original Author: Fedor Ratnikov
15 // Created: Tue Aug 9 19:10:10 CDT 2005
16 //
17 //
18 
19 
20 // system include files
21 #include <iostream>
22 #include <fstream>
23 
26 
29 
30 
32 
33 #include "HcalDbProducer.h"
34 
36  : ESProducer(),
37  mService (new HcalDbService (fConfig)),
38  mDumpRequest (),
39  mDumpStream(0)
40 {
41  //the following line is needed to tell the framework what data is being produced
42  // comments of dependsOn:
43  // 1) There are two ways one can use 'dependsOn' the first is passing it up to three arguments.
44  // However, one can also extend the dependencies by first calling 'dependsOn() and then using '&' to add additional dependencies. So
45  // dependsOn(&FooProd::func1, &FooProd::func2, &FooProd::func3)
46  // gives the same result as
47  // dependsOn(&FooProd::func1) & (&FooProd::func2) & (&FooProd::func3)
48  // 2) Upon IOV change, all callbacks are called, in the inverse order of their specification below (tested).
63  )
64  );
65 
67  //now do what ever other initialization is needed
68 
69  mDumpRequest = fConfig.getUntrackedParameter <std::vector <std::string> > ("dump", std::vector<std::string>());
70  if (!mDumpRequest.empty()) {
71  std::string otputFile = fConfig.getUntrackedParameter <std::string> ("file", "");
72  mDumpStream = otputFile.empty () ? &std::cout : new std::ofstream (otputFile.c_str());
73  }
74 }
75 
76 
78 {
79 
80  // do anything here that needs to be done at desctruction time
81  // (e.g. close files, deallocate resources etc.)
82  if (mDumpStream != &std::cout) delete mDumpStream;
83 }
84 
85 
86 //
87 // member functions
88 //
89 
90 // ------------ method called to produce the data ------------
91 boost::shared_ptr<HcalDbService> HcalDbProducer::produce( const HcalDbRecord&)
92 {
93  return mService;
94 }
95 
98  fRecord.get (item);
99 
100  mPedestals.reset( new HcalPedestals(*item) );
101 
103  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
104  const HcalTopology* topo=&(*htopo);
105  mPedestals->setTopo(topo);
106 
107 
108  mService->setData (mPedestals.get());
109  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Pedestals")) != mDumpRequest.end()) {
110  *mDumpStream << "New HCAL Pedestals set" << std::endl;
112  }
113 }
114 
115 boost::shared_ptr<HcalChannelQuality> HcalDbProducer::produceChannelQualityWithTopo(const HcalChannelQualityRcd& fRecord)
116 {
118  fRecord.get (item);
119 
120  boost::shared_ptr<HcalChannelQuality> channelQuality( new HcalChannelQuality(*item) );
121 
123  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
124  const HcalTopology* topo=&(*htopo);
125  channelQuality->setTopo(topo);
126 
127  return channelQuality;
128 }
129 
132  fRecord.get (item);
133 
134  mPedestalWidths.reset( new HcalPedestalWidths(*item));
135 
137  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
138  const HcalTopology* topo=&(*htopo);
139  mPedestalWidths->setTopo(topo);
140 
141  mService->setData (mPedestalWidths.get());
142  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("PedestalWidths")) != mDumpRequest.end()) {
143  *mDumpStream << "New HCAL PedestalWidths set" << std::endl;
145  }
146 }
147 
148 
151  fRecord.get (item);
152 
153  mGains.reset( new HcalGains(*item) );
155  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
156  const HcalTopology* topo=&(*htopo);
157  mGains->setTopo(topo);
158 
159 
160  mService->setData (mGains.get());
161  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Gains")) != mDumpRequest.end()) {
162  *mDumpStream << "New HCAL Gains set" << std::endl;
164  }
165 }
166 
167 
170  fRecord.get (item);
171 
172  mGainWidths.reset( new HcalGainWidths(*item));
174  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
175  const HcalTopology* topo=&(*htopo);
176  mGainWidths->setTopo(topo);
177 
178 
179  mService->setData (mGainWidths.get());
180  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("GainWidths")) != mDumpRequest.end()) {
181  *mDumpStream << "New HCAL GainWidths set" << std::endl;
183  }
184 }
185 
188  fRecord.get (item);
189 
190  mQIEData.reset( new HcalQIEData(*item));
191 
192 
194  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
195  const HcalTopology* topo=&(*htopo);
196  mQIEData->setTopo(topo);
197 
198  mService->setData (mQIEData.get());
199  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("QIEData")) != mDumpRequest.end()) {
200  *mDumpStream << "New HCAL QIEData set" << std::endl;
202  }
203 }
204 
207  fRecord.get ("withTopo", item );
208 
209  mService->setData (item.product());
210  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ChannelQuality")) != mDumpRequest.end()) {
211  *mDumpStream << "New HCAL ChannelQuality set" << std::endl;
213  }
214 }
215 
218  fRecord.get (item);
219 
220  mRespCorrs.reset( new HcalRespCorrs(*item) );
221 
223  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
224  const HcalTopology* topo=&(*htopo);
225  mRespCorrs->setTopo(topo);
226 
227  mService->setData (mRespCorrs.get());
228  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("RespCorrs")) != mDumpRequest.end()) {
229  *mDumpStream << "New HCAL RespCorrs set" << std::endl;
231  }
232 }
233 
236  fRecord.get (item);
237 
238  mLUTCorrs.reset( new HcalLUTCorrs(*item) );
239 
241  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
242  const HcalTopology* topo=&(*htopo);
243  mLUTCorrs->setTopo(topo);
244 
245  mService->setData (mLUTCorrs.get());
246  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("LUTCorrs")) != mDumpRequest.end()) {
247  *mDumpStream << "New HCAL LUTCorrs set" << std::endl;
249  }
250 }
251 
254  fRecord.get (item);
255 
256  mPFCorrs.reset( new HcalPFCorrs(*item) );
257 
259  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
260  const HcalTopology* topo=&(*htopo);
261  mPFCorrs->setTopo(topo);
262 
263  mService->setData (mPFCorrs.get());
264  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("PFCorrs")) != mDumpRequest.end()) {
265  *mDumpStream << "New HCAL PFCorrs set" << std::endl;
267  }
268 }
269 
272  fRecord.get (item);
273 
274  mTimeCorrs.reset( new HcalTimeCorrs(*item) );
275 
277  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
278  const HcalTopology* topo=&(*htopo);
279  mTimeCorrs->setTopo(topo);
280 
281  mService->setData (mTimeCorrs.get());
282  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("TimeCorrs")) != mDumpRequest.end()) {
283  *mDumpStream << "New HCAL TimeCorrs set" << std::endl;
285  }
286 }
287 
290  fRecord.get (item);
291 
292  mZSThresholds.reset( new HcalZSThresholds(*item) );
293 
295  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
296  const HcalTopology* topo=&(*htopo);
297  mZSThresholds->setTopo(topo);
298 
299  mService->setData (mZSThresholds.get());
300  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ZSThresholds")) != mDumpRequest.end()) {
301  *mDumpStream << "New HCAL ZSThresholds set" << std::endl;
303  }
304 }
305 
308  fRecord.get (item);
309 
310  mL1TriggerObjects.reset( new HcalL1TriggerObjects(*item) );
311 
313  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
314  const HcalTopology* topo=&(*htopo);
315  mL1TriggerObjects->setTopo(topo);
316 
317  mService->setData (mL1TriggerObjects.get());
318  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("L1TriggerObjects")) != mDumpRequest.end()) {
319  *mDumpStream << "New HCAL L1TriggerObjects set" << std::endl;
321  }
322 }
323 
326  fRecord.get (item);
327  mService->setData (item.product ());
328  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("ElectronicsMap")) != mDumpRequest.end()) {
329  *mDumpStream << "New HCAL Electronics Map set" << std::endl;
331  }
332 }
333 
336  fRecord.get (item);
337 
338  mLutMetadata.reset( new HcalLutMetadata(*item) );
339 
341  fRecord.getRecord<IdealGeometryRecord>().get(htopo);
342  const HcalTopology* topo=&(*htopo);
343  mLutMetadata->setTopo(topo);
344 
345  mService->setData (mLutMetadata.get());
346  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("LutMetadata")) != mDumpRequest.end()) {
347  *mDumpStream << "New HCAL LUT Metadata set" << std::endl;
349  }
350 }
351 
352 
353 
std::unique_ptr< HcalPFCorrs > mPFCorrs
T getUntrackedParameter(std::string const &, T const &) const
void LUTCorrsCallback(const HcalLUTCorrsRcd &fRecord)
depends_on::OneHolder< T, TDependsOnRecord > dependsOn(void(T::*iT)(const TDependsOnRecord &))
void electronicsMapCallback(const HcalElectronicsMapRcd &fRecord)
std::unique_ptr< HcalZSThresholds > mZSThresholds
std::unique_ptr< HcalRespCorrs > mRespCorrs
std::unique_ptr< HcalGainWidths > mGainWidths
HcalDbProducer(const edm::ParameterSet &)
void pedestalsCallback(const HcalPedestalsRcd &fRecord)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::unique_ptr< HcalPedestals > mPedestals
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void gainWidthsCallback(const HcalGainWidthsRcd &fRecord)
void QIEDataCallback(const HcalQIEDataRcd &fRecord)
std::vector< std::string > mDumpRequest
void L1triggerObjectsCallback(const HcalL1TriggerObjectsRcd &fRecord)
std::unique_ptr< HcalGains > mGains
void get(HolderT &iHolder) const
void PFCorrsCallback(const HcalPFCorrsRcd &fRecord)
void channelQualityCallback(const HcalChannelQualityRcd &fRecord)
std::unique_ptr< HcalQIEData > mQIEData
boost::shared_ptr< HcalDbService > mService
std::unique_ptr< HcalTimeCorrs > mTimeCorrs
void respCorrsCallback(const HcalRespCorrsRcd &fRecord)
std::unique_ptr< HcalLUTCorrs > mLUTCorrs
std::unique_ptr< HcalPedestalWidths > mPedestalWidths
void gainsCallback(const HcalGainsRcd &fRecord)
std::unique_ptr< HcalLutMetadata > mLutMetadata
void zsThresholdsCallback(const HcalZSThresholdsRcd &fRecord)
T const * product() const
Definition: ESHandle.h:86
void timeCorrsCallback(const HcalTimeCorrsRcd &fRecord)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
boost::shared_ptr< HcalDbService > produce(const HcalDbRecord &)
std::unique_ptr< HcalL1TriggerObjects > mL1TriggerObjects
tuple cout
Definition: gather_cfg.py:121
std::ostream * mDumpStream
void pedestalWidthsCallback(const HcalPedestalWidthsRcd &fRecord)
boost::shared_ptr< HcalChannelQuality > produceChannelQualityWithTopo(const HcalChannelQualityRcd &)
void lutMetadataCallback(const HcalLutMetadataRcd &fRecord)