CMS 3D CMS Logo

EcalMultifitConditionsHostESProducer.cc
Go to the documentation of this file.
3 
4 #include <algorithm>
5 #include <cassert>
24 
28 
31 
39 
42  public:
44  auto cc = setWhatProduced(this);
45  pedestalsToken_ = cc.consumes();
46  gainRatiosToken_ = cc.consumes();
47  pulseShapesToken_ = cc.consumes();
48  pulseCovariancesToken_ = cc.consumes();
49  samplesCorrelationToken_ = cc.consumes();
50  timeBiasCorrectionsToken_ = cc.consumes();
51  timeCalibConstantsToken_ = cc.consumes();
52  sampleMaskToken_ = cc.consumes();
53  timeOffsetConstantToken_ = cc.consumes();
54  }
55 
56  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
58  descriptions.addWithDefaultLabel(desc);
59  }
60 
61  std::unique_ptr<EcalMultifitConditionsHost> produce(EcalMultifitConditionsRcd const& iRecord) {
62  auto const& pedestalsData = iRecord.get(pedestalsToken_);
63  auto const& gainRatiosData = iRecord.get(gainRatiosToken_);
64  auto const& pulseShapesData = iRecord.get(pulseShapesToken_);
65  auto const& pulseCovariancesData = iRecord.get(pulseCovariancesToken_);
66  auto const& samplesCorrelationData = iRecord.get(samplesCorrelationToken_);
67  auto const& timeBiasCorrectionsData = iRecord.get(timeBiasCorrectionsToken_);
68  auto const& timeCalibConstantsData = iRecord.get(timeCalibConstantsToken_);
69  auto const& sampleMaskData = iRecord.get(sampleMaskToken_);
70  auto const& timeOffsetConstantData = iRecord.get(timeOffsetConstantToken_);
71 
72  size_t numberOfXtals = pedestalsData.size();
73 
74  auto product = std::make_unique<EcalMultifitConditionsHost>(numberOfXtals, cms::alpakatools::host());
75  auto view = product->view();
76 
77  // Filling pedestals
78  const auto barrelSize = pedestalsData.barrelItems().size();
79  const auto endcapSize = pedestalsData.endcapItems().size();
80 
81  auto const& pedestalsEB = pedestalsData.barrelItems();
82  auto const& pedestalsEE = pedestalsData.endcapItems();
83  auto const& gainRatiosEB = gainRatiosData.barrelItems();
84  auto const& gainRatiosEE = gainRatiosData.endcapItems();
85  auto const& pulseShapesEB = pulseShapesData.barrelItems();
86  auto const& pulseShapesEE = pulseShapesData.endcapItems();
87  auto const& pulseCovariancesEB = pulseCovariancesData.barrelItems();
88  auto const& pulseCovariancesEE = pulseCovariancesData.endcapItems();
89  auto const& timeCalibConstantsEB = timeCalibConstantsData.barrelItems();
90  auto const& timeCalibConstantsEE = timeCalibConstantsData.endcapItems();
91 
92  for (unsigned int i = 0; i < barrelSize; i++) {
93  auto vi = view[i];
94 
95  vi.pedestals_mean_x12() = pedestalsEB[i].mean_x12;
96  vi.pedestals_rms_x12() = pedestalsEB[i].rms_x12;
97  vi.pedestals_mean_x6() = pedestalsEB[i].mean_x6;
98  vi.pedestals_rms_x6() = pedestalsEB[i].rms_x6;
99  vi.pedestals_mean_x1() = pedestalsEB[i].mean_x1;
100  vi.pedestals_rms_x1() = pedestalsEB[i].rms_x1;
101 
102  vi.gain12Over6() = gainRatiosEB[i].gain12Over6();
103  vi.gain6Over1() = gainRatiosEB[i].gain6Over1();
104 
105  vi.timeCalibConstants() = timeCalibConstantsEB[i];
106 
107  std::memcpy(vi.pulseShapes().data(), pulseShapesEB[i].pdfval, sizeof(float) * EcalPulseShape::TEMPLATESAMPLES);
108  for (unsigned int j = 0; j < EcalPulseShape::TEMPLATESAMPLES; j++) {
109  for (unsigned int k = 0; k < EcalPulseShape::TEMPLATESAMPLES; k++) {
110  vi.pulseCovariance()(j, k) = pulseCovariancesEB[i].val(j, k);
111  }
112  }
113  } // end Barrel loop
114  for (unsigned int i = 0; i < endcapSize; i++) {
115  auto vi = view[barrelSize + i];
116 
117  vi.pedestals_mean_x12() = pedestalsEE[i].mean_x12;
118  vi.pedestals_rms_x12() = pedestalsEE[i].rms_x12;
119  vi.pedestals_mean_x6() = pedestalsEE[i].mean_x6;
120  vi.pedestals_rms_x6() = pedestalsEE[i].rms_x6;
121  vi.pedestals_mean_x1() = pedestalsEE[i].mean_x1;
122  vi.pedestals_rms_x1() = pedestalsEE[i].rms_x1;
123 
124  vi.gain12Over6() = gainRatiosEE[i].gain12Over6();
125  vi.gain6Over1() = gainRatiosEE[i].gain6Over1();
126 
127  vi.timeCalibConstants() = timeCalibConstantsEE[i];
128 
129  std::memcpy(vi.pulseShapes().data(), pulseShapesEE[i].pdfval, sizeof(float) * EcalPulseShape::TEMPLATESAMPLES);
130 
131  for (unsigned int j = 0; j < EcalPulseShape::TEMPLATESAMPLES; j++) {
132  for (unsigned int k = 0; k < EcalPulseShape::TEMPLATESAMPLES; k++) {
133  vi.pulseCovariance()(j, k) = pulseCovariancesEE[i].val(j, k);
134  }
135  }
136  } // end Endcap loop
137 
138  // === Scalar data (not by xtal)
139  //TimeBiasCorrection
140  // Assert that there are not more parameters than the EcalMultiFitConditionsSoA expects
141  assert(timeBiasCorrectionsData.EBTimeCorrAmplitudeBins.size() <= kMaxTimeBiasCorrectionBinsEB);
142  assert(timeBiasCorrectionsData.EBTimeCorrShiftBins.size() <= kMaxTimeBiasCorrectionBinsEB);
143  std::memcpy(view.timeBiasCorrections_amplitude_EB().data(),
144  timeBiasCorrectionsData.EBTimeCorrAmplitudeBins.data(),
146  std::memcpy(view.timeBiasCorrections_shift_EB().data(),
147  timeBiasCorrectionsData.EBTimeCorrShiftBins.data(),
149 
150  // Assert that there are not more parameters than the EcalMultiFitConditionsSoA expects
151  assert(timeBiasCorrectionsData.EETimeCorrAmplitudeBins.size() <= kMaxTimeBiasCorrectionBinsEE);
152  assert(timeBiasCorrectionsData.EETimeCorrShiftBins.size() <= kMaxTimeBiasCorrectionBinsEE);
153  std::memcpy(view.timeBiasCorrections_amplitude_EE().data(),
154  timeBiasCorrectionsData.EETimeCorrAmplitudeBins.data(),
156  std::memcpy(view.timeBiasCorrections_shift_EE().data(),
157  timeBiasCorrectionsData.EETimeCorrShiftBins.data(),
159 
160  view.timeBiasCorrectionSizeEB() =
161  std::min(timeBiasCorrectionsData.EBTimeCorrAmplitudeBins.size(), kMaxTimeBiasCorrectionBinsEB);
162  view.timeBiasCorrectionSizeEE() =
163  std::min(timeBiasCorrectionsData.EETimeCorrAmplitudeBins.size(), kMaxTimeBiasCorrectionBinsEE);
164 
165  // SampleCorrelation
166  std::memcpy(view.sampleCorrelation_EB_G12().data(),
167  samplesCorrelationData.EBG12SamplesCorrelation.data(),
168  sizeof(double) * ecalPh1::sampleSize);
169  std::memcpy(view.sampleCorrelation_EB_G6().data(),
170  samplesCorrelationData.EBG6SamplesCorrelation.data(),
171  sizeof(double) * ecalPh1::sampleSize);
172  std::memcpy(view.sampleCorrelation_EB_G1().data(),
173  samplesCorrelationData.EBG1SamplesCorrelation.data(),
174  sizeof(double) * ecalPh1::sampleSize);
175 
176  std::memcpy(view.sampleCorrelation_EE_G12().data(),
177  samplesCorrelationData.EEG12SamplesCorrelation.data(),
178  sizeof(double) * ecalPh1::sampleSize);
179  std::memcpy(view.sampleCorrelation_EE_G6().data(),
180  samplesCorrelationData.EBG6SamplesCorrelation.data(),
181  sizeof(double) * ecalPh1::sampleSize);
182  std::memcpy(view.sampleCorrelation_EE_G1().data(),
183  samplesCorrelationData.EEG1SamplesCorrelation.data(),
184  sizeof(double) * ecalPh1::sampleSize);
185 
186  // Sample masks
187  view.sampleMask_EB() = sampleMaskData.getEcalSampleMaskRecordEB();
188  view.sampleMask_EE() = sampleMaskData.getEcalSampleMaskRecordEE();
189 
190  // Time offsets
191  view.timeOffset_EB() = timeOffsetConstantData.getEBValue();
192  view.timeOffset_EE() = timeOffsetConstantData.getEEValue();
193 
194  // number of barrel items as offset for hashed ID access to EE items of columns
195  view.offsetEE() = barrelSize;
196 
197  return product;
198  }
199 
200  private:
210  };
211 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
212 
213 DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(EcalMultifitConditionsHostESProducer);
edm::ESGetToken< EcalSamplesCorrelation, EcalSamplesCorrelationRcd > samplesCorrelationToken_
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
static const int TEMPLATESAMPLES
constexpr size_t kMaxTimeBiasCorrectionBinsEB
assert(be >=bs)
edm::ESGetToken< EcalTimeBiasCorrections, EcalTimeBiasCorrectionsRcd > timeBiasCorrectionsToken_
std::unique_ptr< EcalMultifitConditionsHost > produce(EcalMultifitConditionsRcd const &iRecord)
edm::ESGetToken< EcalTimeCalibConstants, EcalTimeCalibConstantsRcd > timeCalibConstantsToken_
constexpr size_t kMaxTimeBiasCorrectionBinsEE
edm::ESGetToken< EcalPulseCovariances, EcalPulseCovariancesRcd > pulseCovariancesToken_
alpaka::DevCpu const & host()
Definition: host.h:14
edm::ESGetToken< EcalTimeOffsetConstant, EcalTimeOffsetConstantRcd > timeOffsetConstantToken_
static constexpr unsigned int sampleSize
Definition: EcalConstants.h:53
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(type)
Definition: ModuleFactory.h:17
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const