CMS 3D CMS Logo

CastorHardcodeCalibrations.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // ESSource to generate default HCAL/CASTOR calibration objects
3 //
4 // Original Author: Fedor Ratnikov
5 // Adapted for CASTOR by L. Mundim
6 //
7 
8 #include <iostream>
9 #include <memory>
10 #include <map>
11 #include <string>
12 
18 
28 
32 
36 
38 
40 public:
42  ~CastorHardcodeCalibrations() override;
43 
44  void produce(){};
45 
46 protected:
48  const edm::IOVSyncValue&,
49  edm::ValidityInterval&) override;
50 
51  std::unique_ptr<CastorPedestals> producePedestals(const CastorPedestalsRcd& rcd);
52  std::unique_ptr<CastorPedestalWidths> producePedestalWidths(const CastorPedestalWidthsRcd& rcd);
53  std::unique_ptr<CastorGains> produceGains(const CastorGainsRcd& rcd);
54  std::unique_ptr<CastorGainWidths> produceGainWidths(const CastorGainWidthsRcd& rcd);
55  std::unique_ptr<CastorQIEData> produceQIEData(const CastorQIEDataRcd& rcd);
56  std::unique_ptr<CastorChannelQuality> produceChannelQuality(const CastorChannelQualityRcd& rcd);
57  std::unique_ptr<CastorElectronicsMap> produceElectronicsMap(const CastorElectronicsMapRcd& rcd);
58  std::unique_ptr<CastorRecoParams> produceRecoParams(const CastorRecoParamsRcd& rcd);
59  std::unique_ptr<CastorSaturationCorrs> produceSaturationCorrs(const CastorSaturationCorrsRcd& rcd);
60  bool h2mode_;
61 };
62 
63 // class declaration
64 //
65 
66 using namespace cms;
67 
68 namespace {
69 
70  std::vector<HcalGenericDetId> allCells(bool h2_mode) {
71  static std::vector<HcalGenericDetId> result;
72  if (result.empty()) {
73  CastorTopology castortopology;
74  HcalCastorDetId cell;
76 
77  for (int sector = 1; sector < 17; sector++) {
78  for (int module = 1; module < 3; module++) {
79  cell = HcalCastorDetId(section, true, sector, module);
80  if (castortopology.valid(cell))
81  result.push_back(cell);
82  cell = HcalCastorDetId(section, false, sector, module);
83  if (castortopology.valid(cell))
84  result.push_back(cell);
85  }
86  }
87 
89  for (int sector = 1; sector < 17; sector++) {
90  for (int module = 3; module < 15; module++) {
91  cell = HcalCastorDetId(section, true, sector, module);
92  if (castortopology.valid(cell))
93  result.push_back(cell);
94  cell = HcalCastorDetId(section, false, sector, module);
95  if (castortopology.valid(cell))
96  result.push_back(cell);
97  }
98  }
99  }
100  return result;
101  }
102 } // namespace
103 
105 
106 {
107  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::CastorHardcodeCalibrations->...";
108  //parsing record parameters
109  h2mode_ = iConfig.getUntrackedParameter<bool>("H2Mode", false);
110  std::vector<std::string> toGet = iConfig.getUntrackedParameter<std::vector<std::string> >("toGet");
111  for (std::vector<std::string>::iterator objectName = toGet.begin(); objectName != toGet.end(); ++objectName) {
112  bool all = *objectName == "all";
113  if ((*objectName == "Pedestals") || all) {
114  setWhatProduced(this, &CastorHardcodeCalibrations::producePedestals);
115  findingRecord<CastorPedestalsRcd>();
116  }
117  if ((*objectName == "PedestalWidths") || all) {
119  findingRecord<CastorPedestalWidthsRcd>();
120  }
121  if ((*objectName == "Gains") || all) {
122  setWhatProduced(this, &CastorHardcodeCalibrations::produceGains);
123  findingRecord<CastorGainsRcd>();
124  }
125  if ((*objectName == "GainWidths") || all) {
126  setWhatProduced(this, &CastorHardcodeCalibrations::produceGainWidths);
127  findingRecord<CastorGainWidthsRcd>();
128  }
129  if ((*objectName == "QIEData") || all) {
130  setWhatProduced(this, &CastorHardcodeCalibrations::produceQIEData);
131  findingRecord<CastorQIEDataRcd>();
132  }
133  if ((*objectName == "ChannelQuality") || (*objectName == "channelQuality") || all) {
135  findingRecord<CastorChannelQualityRcd>();
136  }
137  if ((*objectName == "ElectronicsMap") || (*objectName == "electronicsMap") || all) {
139  findingRecord<CastorElectronicsMapRcd>();
140  }
141  if ((*objectName == "RecoParams") || all) {
142  setWhatProduced(this, &CastorHardcodeCalibrations::produceRecoParams);
143  findingRecord<CastorRecoParamsRcd>();
144  }
145  if ((*objectName == "SaturationCorrs") || all) {
147  findingRecord<CastorSaturationCorrsRcd>();
148  }
149  }
150 }
151 
153 
154 //
155 // member functions
156 //
158  const edm::IOVSyncValue& iTime,
159  edm::ValidityInterval& oInterval) {
160  std::string record = iKey.name();
161  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::setIntervalFor-> key: " << record << " time: " << iTime.eventID()
162  << '/' << iTime.time().value();
164 }
165 
166 std::unique_ptr<CastorPedestals> CastorHardcodeCalibrations::producePedestals(const CastorPedestalsRcd&) {
167  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::producePedestals-> ...";
168  auto result = std::make_unique<CastorPedestals>(false);
169  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
170  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
172  result->addValues(item);
173  }
174  return result;
175 }
176 
177 std::unique_ptr<CastorPedestalWidths> CastorHardcodeCalibrations::producePedestalWidths(const CastorPedestalWidthsRcd&) {
178  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::producePedestalWidths-> ...";
179  auto result = std::make_unique<CastorPedestalWidths>(false);
180  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
181  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
183  result->addValues(item);
184  }
185  return result;
186 }
187 
188 std::unique_ptr<CastorGains> CastorHardcodeCalibrations::produceGains(const CastorGainsRcd&) {
189  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceGains-> ...";
190  auto result = std::make_unique<CastorGains>();
191  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
192  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
194  result->addValues(item);
195  }
196  return result;
197 }
198 
199 std::unique_ptr<CastorGainWidths> CastorHardcodeCalibrations::produceGainWidths(const CastorGainWidthsRcd&) {
200  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceGainWidths-> ...";
201  auto result = std::make_unique<CastorGainWidths>();
202  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
203  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
205  result->addValues(item);
206  }
207  return result;
208 }
209 
210 std::unique_ptr<CastorQIEData> CastorHardcodeCalibrations::produceQIEData(const CastorQIEDataRcd& rcd) {
211  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceQIEData-> ...";
212  auto result = std::make_unique<CastorQIEData>();
213  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
214  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
216  result->addCoder(coder);
217  }
218  return result;
219 }
220 
221 std::unique_ptr<CastorChannelQuality> CastorHardcodeCalibrations::produceChannelQuality(
222  const CastorChannelQualityRcd& rcd) {
223  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceChannelQuality-> ...";
224  auto result = std::make_unique<CastorChannelQuality>();
225  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
226  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
228  result->addValues(item);
229  }
230  return result;
231 }
232 
233 std::unique_ptr<CastorElectronicsMap> CastorHardcodeCalibrations::produceElectronicsMap(
234  const CastorElectronicsMapRcd& rcd) {
235  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceElectronicsMap-> ...";
236 
237  auto result = std::make_unique<CastorElectronicsMap>();
239  return result;
240 }
241 
242 std::unique_ptr<CastorRecoParams> CastorHardcodeCalibrations::produceRecoParams(const CastorRecoParamsRcd& rcd) {
243  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceRecoParams-> ...";
244  auto result = std::make_unique<CastorRecoParams>();
245  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
246  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
248  result->addValues(item);
249  }
250  return result;
251 }
252 
253 std::unique_ptr<CastorSaturationCorrs> CastorHardcodeCalibrations::produceSaturationCorrs(
254  const CastorSaturationCorrsRcd& rcd) {
255  edm::LogInfo("HCAL") << "CastorHardcodeCalibrations::produceSaturationCorrs-> ...";
256  auto result = std::make_unique<CastorSaturationCorrs>();
257  std::vector<HcalGenericDetId> cells = allCells(h2mode_);
258  for (std::vector<HcalGenericDetId>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell) {
260  result->addValues(item);
261  }
262  return result;
263 }
264 
267 
CastorPedestalWidth makePedestalWidth(HcalGenericDetId fId)
CastorQIECoder makeQIECoder(HcalGenericDetId fId)
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
std::unique_ptr< CastorQIEData > produceQIEData(const CastorQIEDataRcd &rcd)
void makeHardcodeMap(CastorElectronicsMap &emap)
std::unique_ptr< CastorRecoParams > produceRecoParams(const CastorRecoParamsRcd &rcd)
std::unique_ptr< CastorChannelQuality > produceChannelQuality(const CastorChannelQualityRcd &rcd)
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
std::unique_ptr< CastorPedestalWidths > producePedestalWidths(const CastorPedestalWidthsRcd &rcd)
CastorHardcodeCalibrations(const edm::ParameterSet &)
std::unique_ptr< CastorPedestals > producePedestals(const CastorPedestalsRcd &rcd)
std::unique_ptr< CastorSaturationCorrs > produceSaturationCorrs(const CastorSaturationCorrsRcd &rcd)
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< CastorGainWidths > produceGainWidths(const CastorGainWidthsRcd &rcd)
virtual bool valid(const HcalCastorDetId &id) const
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
CastorRecoParam makeRecoParam(HcalGenericDetId fId)
std::unique_ptr< CastorElectronicsMap > produceElectronicsMap(const CastorElectronicsMapRcd &rcd)
CastorSaturationCorr makeSaturationCorr(HcalGenericDetId fId)
Namespace of DDCMS conversion namespace.
CastorGainWidth makeGainWidth(HcalGenericDetId fId)
Log< level::Info, false > LogInfo
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
CastorPedestal makePedestal(HcalGenericDetId fId, bool fSmear=false)
TimeValue_t value() const
Definition: Timestamp.h:38
CastorGain makeGain(HcalGenericDetId fId, bool fSmear=false)
std::unique_ptr< CastorGains > produceGains(const CastorGainsRcd &rcd)
const EventID & eventID() const
Definition: IOVSyncValue.h:40
const Timestamp & time() const
Definition: IOVSyncValue.h:42
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override