CMS 3D CMS Logo

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 
25 
26 #include "HcalDbProducer.h"
27 
29  : ESProducer(),
30  mDumpRequest (),
31  mDumpStream(nullptr)
32 {
33  setWhatProduced (this);
34 
55 
56  mDumpRequest = fConfig.getUntrackedParameter <std::vector <std::string> > ("dump", std::vector<std::string>());
57  if (!mDumpRequest.empty()) {
58  std::string otputFile = fConfig.getUntrackedParameter <std::string> ("file", "");
59  mDumpStream = otputFile.empty () ? &std::cout : new std::ofstream (otputFile.c_str());
60  }
61 }
62 
64 
65  if (mDumpStream != &std::cout) delete mDumpStream;
66 }
67 
68 // ------------ method called to produce the data ------------
69 std::shared_ptr<HcalDbService> HcalDbProducer::produce(const HcalDbRecord& record) {
70 
71  auto host = holder_.makeOrGet([]() {
72  return new HostType;
73  });
74 
75  bool pedestalWidthsChanged = false;
76  host->ifRecordChanges<HcalPedestalWidthsRcd>(record,
77  [this,h=host.get(),&pedestalWidthsChanged](auto const& rec) {
79  pedestalWidthsChanged = true;
80  });
81 
82 
83  bool pedestalsChanged = false;
84  host->ifRecordChanges<HcalPedestalsRcd>(record,
85  [this,h=host.get(),&pedestalsChanged](auto const& rec) {
86  setupEffectivePedestals(rec, *h);
87  pedestalsChanged = true;
88  });
89 
90  setupHcalDbService<HcalRecoParams, HcalRecoParamsRcd>(
91  *host, record, "withTopo", "RecoParams", "New HCAL RecoParams set");
92 
93  setupHcalDbService<HcalMCParams, HcalMCParamsRcd>(
94  *host, record, "withTopo", "MCParams", "New HCAL MCParams set");
95 
96  setupHcalDbService<HcalLutMetadata, HcalLutMetadataRcd>(
97  *host, record, "withTopo", "LutMetadata", "New HCAL LUT Metadata set");
98 
99  setupHcalDbService<HcalTPParameters, HcalTPParametersRcd>(
100  *host, record, "", "TPParameters", "New HCAL TPParameters set");
101 
102  setupHcalDbService<HcalTPChannelParameters, HcalTPChannelParametersRcd>(
103  *host, record, "withTopo", "TPChannelParameters", "New HCAL TPChannelParameters set");
104 
105  setupHcalDbService<HcalSiPMCharacteristics, HcalSiPMCharacteristicsRcd>(
106  *host, record, "", "SiPMCharacteristics", "New HCAL SiPMCharacteristics set");
107 
108  setupHcalDbService<HcalSiPMParameters, HcalSiPMParametersRcd>(
109  *host, record, "withTopo", "SiPMParameters", "New HCAL SiPMParameters set");
110 
111  setupHcalDbService<HcalFrontEndMap, HcalFrontEndMapRcd>(
112  *host, record, "", "FrontEndMap", "New HCAL FrontEnd Map set");
113 
114  setupHcalDbService<HcalElectronicsMap, HcalElectronicsMapRcd>(
115  *host, record, "", "ElectronicsMap", "New HCAL Electronics Map set");
116 
117  setupHcalDbService<HcalL1TriggerObjects, HcalL1TriggerObjectsRcd>(
118  *host, record, "withTopo", "L1TriggerObjects", "New HCAL L1TriggerObjects set");
119 
120  setupHcalDbService<HcalZSThresholds, HcalZSThresholdsRcd>(
121  *host, record, "withTopo", "ZSThresholds", "New HCAL ZSThresholds set");
122 
123  setupHcalDbService<HcalChannelQuality, HcalChannelQualityRcd>(
124  *host, record, "withTopo", "ChannelQuality", "New HCAL ChannelQuality set");
125 
126  setupHcalDbService<HcalGainWidths, HcalGainWidthsRcd>(
127  *host, record, "withTopo", "GainWidths", "New HCAL GainWidths set");
128 
129  setupHcalDbService<HcalQIETypes, HcalQIETypesRcd>(
130  *host, record, "withTopo", "QIETypes", "New HCAL QIETypes set");
131 
132  setupHcalDbService<HcalQIEData, HcalQIEDataRcd>(
133  *host, record, "withTopo", "QIEData", "New HCAL QIEData set");
134 
135  setupHcalDbService<HcalTimeCorrs, HcalTimeCorrsRcd>(
136  *host, record, "withTopo", "TimeCorrs", "New HCAL TimeCorrs set");
137 
138  setupHcalDbService<HcalPFCorrs, HcalPFCorrsRcd>(
139  *host, record, "withTopo", "PFCorrs", "New HCAL PFCorrs set");
140 
141  setupHcalDbService<HcalLUTCorrs, HcalLUTCorrsRcd>(
142  *host, record, "withTopo", "LUTCorrs", "New HCAL LUTCorrs set");
143 
144  setupHcalDbService<HcalGains, HcalGainsRcd>(
145  *host, record, "withTopo", "Gains", "New HCAL Gains set");
146 
147  setupHcalDbService<HcalRespCorrs, HcalRespCorrsRcd>(
148  *host, record, "withTopo", "RespCorrs", "New HCAL RespCorrs set");
149 
150  if (pedestalWidthsChanged) {
152  setupPedestalWidths(rec, *host);
153  }
154 
155  if (pedestalsChanged) {
156  HcalPedestalsRcd const& rec = record.getRecord<HcalPedestalsRcd>();
157  setupPedestals(rec, *host);
158  }
159 
160  return host;
161 }
162 
163 std::unique_ptr<HcalPedestals>
165  return produceWithTopology<HcalPedestals>(record);
166 }
167 
168 std::unique_ptr<HcalPedestalWidths>
170  return produceWithTopology<HcalPedestalWidths>(record);
171 }
172 
173 std::unique_ptr<HcalPedestals>
175 
177  record.get("effective", item);
178 
179  auto productWithTopology = std::make_unique<HcalPedestals>(*item);
180 
182  record.getRecord<HcalRecNumberingRecord>().get(htopo);
183  const HcalTopology* topo=&(*htopo);
184  productWithTopology->setTopo(topo);
185 
186  return productWithTopology;
187 }
188 
189 std::unique_ptr<HcalPedestalWidths>
191 
193  record.get("effective", item);
194 
195  auto productWithTopology = std::make_unique<HcalPedestalWidths>(*item);
196 
198  record. template getRecord<HcalRecNumberingRecord>().get(htopo);
199  const HcalTopology* topo=&(*htopo);
200  productWithTopology->setTopo(topo);
201 
202  return productWithTopology;
203 }
204 
205 std::unique_ptr<HcalGains>
207  return produceWithTopology<HcalGains>(record);
208 }
209 
210 std::unique_ptr<HcalGainWidths>
212  return produceWithTopology<HcalGainWidths>(record);
213 }
214 
215 std::unique_ptr<HcalQIEData>
217  return produceWithTopology<HcalQIEData>(record);
218 }
219 
220 std::unique_ptr<HcalQIETypes>
222  return produceWithTopology<HcalQIETypes>(record);
223 }
224 
225 std::unique_ptr<HcalChannelQuality>
227  return produceWithTopology<HcalChannelQuality>(record);
228 }
229 
230 std::unique_ptr<HcalZSThresholds>
232  return produceWithTopology<HcalZSThresholds>(record);
233 }
234 
235 std::unique_ptr<HcalRespCorrs>
237  return produceWithTopology<HcalRespCorrs>(record);
238 }
239 
240 std::unique_ptr<HcalL1TriggerObjects>
242  return produceWithTopology<HcalL1TriggerObjects>(record);
243 }
244 
245 std::unique_ptr<HcalTimeCorrs>
247  return produceWithTopology<HcalTimeCorrs>(record);
248 }
249 
250 std::unique_ptr<HcalLUTCorrs>
252  return produceWithTopology<HcalLUTCorrs>(record);
253 }
254 
255 std::unique_ptr<HcalPFCorrs>
257  return produceWithTopology<HcalPFCorrs>(record);
258 }
259 
260 std::unique_ptr<HcalLutMetadata>
262  return produceWithTopology<HcalLutMetadata>(record);
263 }
264 
265 std::unique_ptr<HcalSiPMParameters>
267  return produceWithTopology<HcalSiPMParameters>(record);
268 }
269 
270 std::unique_ptr<HcalTPChannelParameters>
272  return produceWithTopology<HcalTPChannelParameters>(record);
273 }
274 
275 std::unique_ptr<HcalMCParams>
277  return produceWithTopology<HcalMCParams>(record);
278 }
279 
280 std::unique_ptr<HcalRecoParams>
282  return produceWithTopology<HcalRecoParams>(record);
283 }
284 
288  record.get("withTopo", item);
289  service.setData(item.product());
290 
291  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("Pedestals")) != mDumpRequest.end()) {
292  *mDumpStream << "New HCAL Pedestals set" << std::endl;
294  }
295 }
296 
300  record.get("withTopoEff", item);
301  service.setData(item.product(), true);
302 
303  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("EffectivePedestals")) != mDumpRequest.end()) {
304  *mDumpStream << "New HCAL EffectivePedestals set" << std::endl;
306  }
307 }
308 
312  record.get("withTopo", item);
313  service.setData(item.product());
314 
315  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("PedestalWidths")) != mDumpRequest.end()) {
316  *mDumpStream << "New HCAL PedestalWidths set" << std::endl;
318  }
319 }
320 
324  record.get("withTopoEff", item);
325  service.setData(item.product(), true);
326 
327  if (std::find (mDumpRequest.begin(), mDumpRequest.end(), std::string ("EffectivePedestalWidths")) != mDumpRequest.end()) {
328  *mDumpStream << "New HCAL EffectivePedestalWidths set" << std::endl;
330  }
331 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
T getUntrackedParameter(std::string const &, T const &) const
host
Definition: query.py:115
std::unique_ptr< HcalLutMetadata > produceLUTMetadataWithTopo(const HcalLutMetadataRcd &)
void setupPedestals(const HcalPedestalsRcd &, HcalDbService &)
std::unique_ptr< HcalQIETypes > produceQIETypesWithTopo(const HcalQIETypesRcd &)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::unique_ptr< HcalTimeCorrs > produceTimeCorrsWithTopo(const HcalTimeCorrsRcd &)
JetCorrectorParameters::Record record
Definition: classes.h:7
std::unique_ptr< HcalPedestalWidths > producePedestalWidthsWithTopo(const HcalPedestalWidthsRcd &)
std::unique_ptr< HcalRespCorrs > produceRespCorrsWithTopo(const HcalRespCorrsRcd &)
#define nullptr
HcalDbProducer(const edm::ParameterSet &)
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn&#39;t an object already available, creates a new one using iFunc.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::unique_ptr< HcalSiPMParameters > produceSiPMParametersWithTopo(const HcalSiPMParametersRcd &)
std::unique_ptr< HcalTPChannelParameters > produceTPChannelParametersWithTopo(const HcalTPChannelParametersRcd &)
std::unique_ptr< HcalChannelQuality > produceChannelQualityWithTopo(const HcalChannelQualityRcd &)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
std::vector< std::string > mDumpRequest
std::unique_ptr< HcalPedestals > produceEffectivePedestalsWithTopo(const HcalPedestalsRcd &)
void setData(const HcalPedestals *fItem, bool eff=false)
Definition: HcalDbService.h:65
std::unique_ptr< HcalPFCorrs > producePFCorrsWithTopo(const HcalPFCorrsRcd &)
std::unique_ptr< HcalLUTCorrs > produceLUTCorrsWithTopo(const HcalLUTCorrsRcd &)
std::unique_ptr< HcalGains > produceGainsWithTopo(const HcalGainsRcd &)
void setupEffectivePedestalWidths(const HcalPedestalWidthsRcd &, HcalDbService &)
std::unique_ptr< HcalZSThresholds > produceZSThresholdsWithTopo(const HcalZSThresholdsRcd &)
std::unique_ptr< HcalRecoParams > produceRecoParamsWithTopo(const HcalRecoParamsRcd &)
std::unique_ptr< HcalL1TriggerObjects > produceL1triggerObjectsWithTopo(const HcalL1TriggerObjectsRcd &)
~HcalDbProducer() override
std::unique_ptr< HcalMCParams > produceMCParamsWithTopo(const HcalMCParamsRcd &)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
std::unique_ptr< HcalGainWidths > produceGainWidthsWithTopo(const HcalGainWidthsRcd &)
edm::ESProductHost< HcalDbService, HcalPedestalsRcd, HcalPedestalWidthsRcd, HcalGainsRcd, HcalGainWidthsRcd, HcalQIEDataRcd, HcalQIETypesRcd, HcalChannelQualityRcd, HcalZSThresholdsRcd, HcalRespCorrsRcd, HcalL1TriggerObjectsRcd, HcalTimeCorrsRcd, HcalLUTCorrsRcd, HcalPFCorrsRcd, HcalLutMetadataRcd, HcalSiPMParametersRcd, HcalTPChannelParametersRcd, HcalMCParamsRcd, HcalRecoParamsRcd, HcalElectronicsMapRcd, HcalFrontEndMapRcd, HcalSiPMCharacteristicsRcd, HcalTPParametersRcd > HostType
void setupPedestalWidths(const HcalPedestalWidthsRcd &, HcalDbService &)
std::ostream * mDumpStream
std::shared_ptr< HcalDbService > produce(const HcalDbRecord &)
std::unique_ptr< HcalQIEData > produceQIEDataWithTopo(const HcalQIEDataRcd &)
std::unique_ptr< HcalPedestals > producePedestalsWithTopo(const HcalPedestalsRcd &)
edm::ReusableObjectHolder< HostType > holder_
std::unique_ptr< HcalPedestalWidths > produceEffectivePedestalWidthsWithTopo(const HcalPedestalWidthsRcd &)
T const * product() const
Definition: ESHandle.h:86
void setupEffectivePedestals(const HcalPedestalsRcd &, HcalDbService &)