CMS 3D CMS Logo

EcalUncalibRecHitWorkerMultiFit.cc
Go to the documentation of this file.
1 
48 
50 public:
53 
54 private:
55  void set(const edm::EventSetup& es) override;
56  void set(const edm::Event& evt) override;
57  void run(const edm::Event& evt, const EcalDigiCollection& digis, EcalUncalibratedRecHitCollection& result) override;
58 
59 public:
61 
62 private:
73 
74  double timeCorrection(float ampli, const std::vector<float>& amplitudeBins, const std::vector<float>& shiftBins);
75 
76  const SampleMatrix& noisecor(bool barrel, int gain) const { return noisecors_[barrel ? 1 : 0][gain]; }
77  const SampleMatrixGainArray& noisecor(bool barrel) const { return noisecors_[barrel ? 1 : 0]; }
78 
79  // multifit method
80  std::array<SampleMatrixGainArray, 2> noisecors_;
85 
88 
89  // determine which of the samples must actually be used by ECAL local reco
92 
93  // time algorithm to be used to set the jitter and its uncertainty
96 
97  // time weights method
120 
121  // ratio method
122  std::vector<double> EBtimeFitParameters_;
123  std::vector<double> EEtimeFitParameters_;
124  std::vector<double> EBamplitudeFitParameters_;
125  std::vector<double> EEamplitudeFitParameters_;
126  std::pair<double, double> EBtimeFitLimits_;
127  std::pair<double, double> EEtimeFitLimits_;
128 
131 
147 
150 
155  std::vector<double> ebPulseShape_;
156  std::vector<double> eePulseShape_;
157 
158  // chi2 thresholds for flags settings
163 
164  //Timing Cross Correlation Algo
165  std::unique_ptr<EcalUncalibRecHitTimingCCAlgo> computeCC_;
166 };
167 
170  // get the BX for the pulses to be activated
171  std::vector<int32_t> activeBXs = ps.getParameter<std::vector<int32_t>>("activeBXs");
172  activeBX.resize(activeBXs.size());
173  for (unsigned int ibx = 0; ibx < activeBXs.size(); ++ibx) {
174  activeBX.coeffRef(ibx) = activeBXs[ibx];
175  }
176 
177  // uncertainty calculation (CPU intensive)
178  ampErrorCalculation_ = ps.getParameter<bool>("ampErrorCalculation");
179  useLumiInfoRunHeader_ = ps.getParameter<bool>("useLumiInfoRunHeader");
180 
181  if (useLumiInfoRunHeader_) {
182  bunchSpacing_ = c.consumes<unsigned int>(edm::InputTag("bunchSpacingProducer"));
184  } else {
185  bunchSpacingManual_ = ps.getParameter<int>("bunchSpacing");
186  }
187 
188  doPrefitEB_ = ps.getParameter<bool>("doPrefitEB");
189  doPrefitEE_ = ps.getParameter<bool>("doPrefitEE");
190 
191  prefitMaxChiSqEB_ = ps.getParameter<double>("prefitMaxChiSqEB");
192  prefitMaxChiSqEE_ = ps.getParameter<double>("prefitMaxChiSqEE");
193 
194  dynamicPedestalsEB_ = ps.getParameter<bool>("dynamicPedestalsEB");
195  dynamicPedestalsEE_ = ps.getParameter<bool>("dynamicPedestalsEE");
196  mitigateBadSamplesEB_ = ps.getParameter<bool>("mitigateBadSamplesEB");
197  mitigateBadSamplesEE_ = ps.getParameter<bool>("mitigateBadSamplesEE");
198  gainSwitchUseMaxSampleEB_ = ps.getParameter<bool>("gainSwitchUseMaxSampleEB");
199  gainSwitchUseMaxSampleEE_ = ps.getParameter<bool>("gainSwitchUseMaxSampleEE");
200  selectiveBadSampleCriteriaEB_ = ps.getParameter<bool>("selectiveBadSampleCriteriaEB");
201  selectiveBadSampleCriteriaEE_ = ps.getParameter<bool>("selectiveBadSampleCriteriaEE");
202  addPedestalUncertaintyEB_ = ps.getParameter<double>("addPedestalUncertaintyEB");
203  addPedestalUncertaintyEE_ = ps.getParameter<double>("addPedestalUncertaintyEE");
204  simplifiedNoiseModelForGainSwitch_ = ps.getParameter<bool>("simplifiedNoiseModelForGainSwitch");
205  pedsToken_ = c.esConsumes<EcalPedestals, EcalPedestalsRcd>();
212  wgtsToken_ = c.esConsumes<EcalTBWeights, EcalTBWeightsRcd>();
216 
217  // algorithm to be used for timing
218  auto const& timeAlgoName = ps.getParameter<std::string>("timealgo");
219  if (timeAlgoName == "RatioMethod")
221  else if (timeAlgoName == "WeightsMethod")
223  else if (timeAlgoName == "crossCorrelationMethod") {
225  double startTime = ps.getParameter<double>("crossCorrelationStartTime");
226  double stopTime = ps.getParameter<double>("crossCorrelationStopTime");
227  double targetTimePrecision = ps.getParameter<double>("crossCorrelationTargetTimePrecision");
228  computeCC_ = std::make_unique<EcalUncalibRecHitTimingCCAlgo>(startTime, stopTime, targetTimePrecision);
229  } else if (timeAlgoName != "None")
230  edm::LogError("EcalUncalibRecHitError") << "No time estimation algorithm defined";
231 
232  // ratio method parameters
233  EBtimeFitParameters_ = ps.getParameter<std::vector<double>>("EBtimeFitParameters");
234  EEtimeFitParameters_ = ps.getParameter<std::vector<double>>("EEtimeFitParameters");
235  EBamplitudeFitParameters_ = ps.getParameter<std::vector<double>>("EBamplitudeFitParameters");
236  EEamplitudeFitParameters_ = ps.getParameter<std::vector<double>>("EEamplitudeFitParameters");
237  EBtimeFitLimits_.first = ps.getParameter<double>("EBtimeFitLimits_Lower");
238  EBtimeFitLimits_.second = ps.getParameter<double>("EBtimeFitLimits_Upper");
239  EEtimeFitLimits_.first = ps.getParameter<double>("EEtimeFitLimits_Lower");
240  EEtimeFitLimits_.second = ps.getParameter<double>("EEtimeFitLimits_Upper");
241  EBtimeConstantTerm_ = ps.getParameter<double>("EBtimeConstantTerm");
242  EEtimeConstantTerm_ = ps.getParameter<double>("EEtimeConstantTerm");
243  EBtimeNconst_ = ps.getParameter<double>("EBtimeNconst");
244  EEtimeNconst_ = ps.getParameter<double>("EEtimeNconst");
245  outOfTimeThreshG12pEB_ = ps.getParameter<double>("outOfTimeThresholdGain12pEB");
246  outOfTimeThreshG12mEB_ = ps.getParameter<double>("outOfTimeThresholdGain12mEB");
247  outOfTimeThreshG61pEB_ = ps.getParameter<double>("outOfTimeThresholdGain61pEB");
248  outOfTimeThreshG61mEB_ = ps.getParameter<double>("outOfTimeThresholdGain61mEB");
249  outOfTimeThreshG12pEE_ = ps.getParameter<double>("outOfTimeThresholdGain12pEE");
250  outOfTimeThreshG12mEE_ = ps.getParameter<double>("outOfTimeThresholdGain12mEE");
251  outOfTimeThreshG61pEE_ = ps.getParameter<double>("outOfTimeThresholdGain61pEE");
252  outOfTimeThreshG61mEE_ = ps.getParameter<double>("outOfTimeThresholdGain61mEE");
253  amplitudeThreshEB_ = ps.getParameter<double>("amplitudeThresholdEB");
254  amplitudeThreshEE_ = ps.getParameter<double>("amplitudeThresholdEE");
255 }
256 
258  // common setup
260  peds = es.getHandle(pedsToken_);
261 
262  // for the multifit method
268 
269  // weights parameters for the time
270  grps = es.getHandle(grpsToken_);
271  wgts = es.getHandle(wgtsToken_);
272 
273  // which of the samples need be used
275 
276  // for the ratio method
279 
280  // for the time correction methods
282 
283  int nnoise = SampleVector::RowsAtCompileTime;
284  SampleMatrix& noisecorEBg12 = noisecors_[1][0];
285  SampleMatrix& noisecorEBg6 = noisecors_[1][1];
286  SampleMatrix& noisecorEBg1 = noisecors_[1][2];
287  SampleMatrix& noisecorEEg12 = noisecors_[0][0];
288  SampleMatrix& noisecorEEg6 = noisecors_[0][1];
289  SampleMatrix& noisecorEEg1 = noisecors_[0][2];
290 
291  for (int i = 0; i < nnoise; ++i) {
292  for (int j = 0; j < nnoise; ++j) {
293  int vidx = std::abs(j - i);
294  noisecorEBg12(i, j) = noisecovariances->EBG12SamplesCorrelation[vidx];
295  noisecorEEg12(i, j) = noisecovariances->EEG12SamplesCorrelation[vidx];
296  noisecorEBg6(i, j) = noisecovariances->EBG6SamplesCorrelation[vidx];
297  noisecorEEg6(i, j) = noisecovariances->EEG6SamplesCorrelation[vidx];
298  noisecorEBg1(i, j) = noisecovariances->EBG1SamplesCorrelation[vidx];
299  noisecorEEg1(i, j) = noisecovariances->EEG1SamplesCorrelation[vidx];
300  }
301  }
302 }
303 
305  unsigned int bunchspacing = 450;
306 
307  if (useLumiInfoRunHeader_) {
308  edm::Handle<unsigned int> bunchSpacingH;
309  evt.getByToken(bunchSpacing_, bunchSpacingH);
310  bunchspacing = *bunchSpacingH;
311  } else {
312  bunchspacing = bunchSpacingManual_;
313  }
314 
316  if (bunchspacing == 25) {
317  activeBX.resize(10);
318  activeBX << -5, -4, -3, -2, -1, 0, 1, 2, 3, 4;
319  } else {
320  //50ns configuration otherwise (also for no pileup)
321  activeBX.resize(5);
322  activeBX << -4, -2, 0, 2, 4;
323  }
324  }
325 }
326 
337  const std::vector<float>& amplitudeBins,
338  const std::vector<float>& shiftBins) {
339  // computed initially in ns. Than turned in the BX's, as
340  // EcalUncalibratedRecHit need be.
341  double theCorrection = 0;
342 
343  // sanity check for arrays
344  if (amplitudeBins.empty()) {
345  edm::LogError("EcalRecHitError") << "timeCorrAmplitudeBins is empty, forcing no time bias corrections.";
346 
347  return 0;
348  }
349 
350  if (amplitudeBins.size() != shiftBins.size()) {
351  edm::LogError("EcalRecHitError") << "Size of timeCorrAmplitudeBins different from "
352  "timeCorrShiftBins. Forcing no time bias corrections. ";
353 
354  return 0;
355  }
356 
357  // FIXME? what about a binary search?
358  int myBin = -1;
359  for (int bin = 0; bin < (int)amplitudeBins.size(); bin++) {
360  if (ampli > amplitudeBins[bin]) {
361  myBin = bin;
362  } else {
363  break;
364  }
365  }
366 
367  if (myBin == -1) {
368  theCorrection = shiftBins[0];
369  } else if (myBin == ((int)(amplitudeBins.size() - 1))) {
370  theCorrection = shiftBins[myBin];
371  } else {
372  // interpolate linearly between two assingned points
373  theCorrection = (shiftBins[myBin + 1] - shiftBins[myBin]);
374  theCorrection *= (((double)ampli) - amplitudeBins[myBin]) / (amplitudeBins[myBin + 1] - amplitudeBins[myBin]);
375  theCorrection += shiftBins[myBin];
376  }
377 
378  // convert ns into clocks
379  constexpr double inv25 = 1. / 25.;
380  return theCorrection * inv25;
381 }
382 
384  const EcalDigiCollection& digis,
386  if (digis.empty())
387  return;
388 
389  // assume all digis come from the same subdetector (either barrel or endcap)
390  DetId detid(digis.begin()->id());
391  bool barrel = (detid.subdetId() == EcalBarrel);
392 
394  if (barrel) {
402  } else {
410  }
411 
412  FullSampleVector fullpulse(FullSampleVector::Zero());
413  FullSampleMatrix fullpulsecov(FullSampleMatrix::Zero());
414 
415  result.reserve(result.size() + digis.size());
416  for (auto itdg = digis.begin(); itdg != digis.end(); ++itdg) {
417  DetId detid(itdg->id());
418 
419  const EcalSampleMask* sampleMask_ = sampleMaskHand_.product();
420 
421  // intelligence for recHit computation
422  float offsetTime = 0;
423 
424  const EcalPedestals::Item* aped = nullptr;
425  const EcalMGPAGainRatio* aGain = nullptr;
426  const EcalXtalGroupId* gid = nullptr;
427  const EcalPulseShapes::Item* aPulse = nullptr;
428  const EcalPulseCovariances::Item* aPulseCov = nullptr;
429 
430  if (barrel) {
431  unsigned int hashedIndex = EBDetId(detid).hashedIndex();
432  aped = &peds->barrel(hashedIndex);
433  aGain = &gains->barrel(hashedIndex);
434  gid = &grps->barrel(hashedIndex);
435  aPulse = &pulseshapes->barrel(hashedIndex);
436  aPulseCov = &pulsecovariances->barrel(hashedIndex);
437  offsetTime = offtime->getEBValue();
438  } else {
439  unsigned int hashedIndex = EEDetId(detid).hashedIndex();
440  aped = &peds->endcap(hashedIndex);
441  aGain = &gains->endcap(hashedIndex);
442  gid = &grps->endcap(hashedIndex);
443  aPulse = &pulseshapes->endcap(hashedIndex);
444  aPulseCov = &pulsecovariances->endcap(hashedIndex);
445  offsetTime = offtime->getEEValue();
446  }
447 
448  double pedVec[3] = {aped->mean_x12, aped->mean_x6, aped->mean_x1};
449  double pedRMSVec[3] = {aped->rms_x12, aped->rms_x6, aped->rms_x1};
450  double gainRatios[3] = {1., aGain->gain12Over6(), aGain->gain6Over1() * aGain->gain12Over6()};
451 
452  for (int i = 0; i < EcalPulseShape::TEMPLATESAMPLES; ++i)
453  fullpulse(i + 7) = aPulse->pdfval[i];
454 
455  for (int i = 0; i < EcalPulseShape::TEMPLATESAMPLES; i++)
456  for (int j = 0; j < EcalPulseShape::TEMPLATESAMPLES; j++)
457  fullpulsecov(i + 7, j + 7) = aPulseCov->covval[i][j];
458 
459  // compute the right bin of the pulse shape using time calibration constants
461  EcalTimeCalibConstant itimeconst = 0;
462  if (it != itime->end()) {
463  itimeconst = (*it);
464  } else {
465  edm::LogError("EcalRecHitError") << "No time intercalib const found for xtal " << detid.rawId()
466  << "! something wrong with EcalTimeCalibConstants in your DB? ";
467  }
468 
469  int lastSampleBeforeSaturation = -2;
470  for (unsigned int iSample = 0; iSample < EcalDataFrame::MAXSAMPLES; iSample++) {
471  if (((EcalDataFrame)(*itdg)).sample(iSample).gainId() == 0) {
472  lastSampleBeforeSaturation = iSample - 1;
473  break;
474  }
475  }
476 
477  // === amplitude computation ===
478 
479  if (lastSampleBeforeSaturation == 4) { // saturation on the expected max sample
480  result.emplace_back((*itdg).id(), 4095 * 12, 0, 0, 0);
481  auto& uncalibRecHit = result.back();
482  uncalibRecHit.setFlagBit(EcalUncalibratedRecHit::kSaturated);
483  // do not propagate the default chi2 = -1 value to the calib rechit (mapped to 64), set it to 0 when saturation
484  uncalibRecHit.setChi2(0);
485  } else if (lastSampleBeforeSaturation >=
486  -1) { // saturation on other samples: cannot extrapolate from the fourth one
487  int gainId = ((EcalDataFrame)(*itdg)).sample(5).gainId();
488  if (gainId == 0)
489  gainId = 3;
490  auto pedestal = pedVec[gainId - 1];
491  auto gainratio = gainRatios[gainId - 1];
492  double amplitude = ((double)(((EcalDataFrame)(*itdg)).sample(5).adc()) - pedestal) * gainratio;
493  result.emplace_back((*itdg).id(), amplitude, 0, 0, 0);
494  auto& uncalibRecHit = result.back();
495  uncalibRecHit.setFlagBit(EcalUncalibratedRecHit::kSaturated);
496  // do not propagate the default chi2 = -1 value to the calib rechit (mapped to 64), set it to 0 when saturation
497  uncalibRecHit.setChi2(0);
498  } else {
499  // multifit
500  const SampleMatrixGainArray& noisecors = noisecor(barrel);
501 
502  result.push_back(multiFitMethod_.makeRecHit(*itdg, aped, aGain, noisecors, fullpulse, fullpulsecov, activeBX));
503  auto& uncalibRecHit = result.back();
504 
505  // === time computation ===
506  if (timealgo_ == ratioMethod) {
507  // ratio method
508  constexpr float clockToNsConstant = 25.;
509  constexpr float invClockToNs = 1. / clockToNsConstant;
510  if (not barrel) {
511  ratioMethod_endcap_.init(*itdg, *sampleMask_, pedVec, pedRMSVec, gainRatios);
516  double theTimeCorrectionEE = timeCorrection(
518 
519  uncalibRecHit.setJitter(crh.timeMax - 5 + theTimeCorrectionEE);
520  uncalibRecHit.setJitterError(
521  std::sqrt(std::pow(crh.timeError, 2) + std::pow(EEtimeConstantTerm_ * invClockToNs, 2)));
522 
523  // consider flagging as kOutOfTime only if above noise
524  if (uncalibRecHit.amplitude() > pedRMSVec[0] * amplitudeThreshEE_) {
525  float outOfTimeThreshP = outOfTimeThreshG12pEE_;
526  float outOfTimeThreshM = outOfTimeThreshG12mEE_;
527  // determine if gain has switched away from gainId==1 (x12 gain)
528  // and determine cuts (number of 'sigmas') to ose for kOutOfTime
529  // >3k ADC is necessasry condition for gain switch to occur
530  if (uncalibRecHit.amplitude() > 3000.) {
531  for (int iSample = 0; iSample < EEDataFrame::MAXSAMPLES; iSample++) {
532  int GainId = ((EcalDataFrame)(*itdg)).sample(iSample).gainId();
533  if (GainId != 1) {
534  outOfTimeThreshP = outOfTimeThreshG61pEE_;
535  outOfTimeThreshM = outOfTimeThreshG61mEE_;
536  break;
537  }
538  }
539  }
540  float correctedTime = (crh.timeMax - 5) * clockToNsConstant + itimeconst + offsetTime;
541  float cterm = EEtimeConstantTerm_;
542  float sigmaped = pedRMSVec[0]; // approx for lower gains
543  float nterm = EEtimeNconst_ * sigmaped / uncalibRecHit.amplitude();
544  float sigmat = std::sqrt(nterm * nterm + cterm * cterm);
545  if ((correctedTime > sigmat * outOfTimeThreshP) || (correctedTime < -sigmat * outOfTimeThreshM)) {
546  uncalibRecHit.setFlagBit(EcalUncalibratedRecHit::kOutOfTime);
547  }
548  }
549 
550  } else {
551  ratioMethod_barrel_.init(*itdg, *sampleMask_, pedVec, pedRMSVec, gainRatios);
557 
558  double theTimeCorrectionEB = timeCorrection(
560 
561  uncalibRecHit.setJitter(crh.timeMax - 5 + theTimeCorrectionEB);
562  uncalibRecHit.setJitterError(std::hypot(crh.timeError, EBtimeConstantTerm_ / clockToNsConstant));
563 
564  // consider flagging as kOutOfTime only if above noise
565  if (uncalibRecHit.amplitude() > pedRMSVec[0] * amplitudeThreshEB_) {
566  float outOfTimeThreshP = outOfTimeThreshG12pEB_;
567  float outOfTimeThreshM = outOfTimeThreshG12mEB_;
568  // determine if gain has switched away from gainId==1 (x12 gain)
569  // and determine cuts (number of 'sigmas') to ose for kOutOfTime
570  // >3k ADC is necessasry condition for gain switch to occur
571  if (uncalibRecHit.amplitude() > 3000.) {
572  for (int iSample = 0; iSample < EBDataFrame::MAXSAMPLES; iSample++) {
573  int GainId = ((EcalDataFrame)(*itdg)).sample(iSample).gainId();
574  if (GainId != 1) {
575  outOfTimeThreshP = outOfTimeThreshG61pEB_;
576  outOfTimeThreshM = outOfTimeThreshG61mEB_;
577  break;
578  }
579  }
580  }
581  float correctedTime = (crh.timeMax - 5) * clockToNsConstant + itimeconst + offsetTime;
582  float cterm = EBtimeConstantTerm_;
583  float sigmaped = pedRMSVec[0]; // approx for lower gains
584  float nterm = EBtimeNconst_ * sigmaped / uncalibRecHit.amplitude();
585  float sigmat = std::sqrt(nterm * nterm + cterm * cterm);
586  if ((correctedTime > sigmat * outOfTimeThreshP) || (correctedTime < -sigmat * outOfTimeThreshM)) {
587  uncalibRecHit.setFlagBit(EcalUncalibratedRecHit::kOutOfTime);
588  }
589  }
590  }
591  } else if (timealgo_ == weightsMethod) {
592  // weights method on the PU subtracted pulse shape
593  std::vector<double> amplitudes;
594  for (unsigned int ibx = 0; ibx < activeBX.size(); ++ibx)
595  amplitudes.push_back(uncalibRecHit.outOfTimeAmplitude(ibx));
596 
597  EcalTBWeights::EcalTDCId tdcid(1);
598  EcalTBWeights::EcalTBWeightMap const& wgtsMap = wgts->getMap();
599  EcalTBWeights::EcalTBWeightMap::const_iterator wit;
600  wit = wgtsMap.find(std::make_pair(*gid, tdcid));
601  if (wit == wgtsMap.end()) {
602  edm::LogError("EcalUncalibRecHitError")
603  << "No weights found for EcalGroupId: " << gid->id() << " and EcalTDCId: " << tdcid
604  << "\n skipping digi with id: " << detid.rawId();
605  result.pop_back();
606  continue;
607  }
608  const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet
609 
612 
613  weights[0] = &mat1;
614  weights[1] = &mat2;
615 
616  double timerh;
617  if (detid.subdetId() == EcalEndcap) {
618  timerh = weightsMethod_endcap_.time(*itdg, amplitudes, aped, aGain, fullpulse, weights);
619  } else {
620  timerh = weightsMethod_barrel_.time(*itdg, amplitudes, aped, aGain, fullpulse, weights);
621  }
622  uncalibRecHit.setJitter(timerh);
623  uncalibRecHit.setJitterError(0.); // not computed with weights
624 
625  } else if (timealgo_ == crossCorrelationMethod) {
626  std::vector<double> amplitudes(activeBX.size());
627  for (unsigned int ibx = 0; ibx < activeBX.size(); ++ibx)
628  amplitudes[ibx] = uncalibRecHit.outOfTimeAmplitude(ibx);
629 
630  float jitterError = 0.;
631  float jitter = computeCC_->computeTimeCC(*itdg, amplitudes, aped, aGain, fullpulse, uncalibRecHit, jitterError);
632 
633  uncalibRecHit.setJitter(jitter);
634  uncalibRecHit.setJitterError(jitterError);
635 
636  } else { // no time method;
637  uncalibRecHit.setJitter(0.);
638  uncalibRecHit.setJitterError(0.);
639  }
640  }
641 
642  // set flags if gain switch has occurred
643  auto& uncalibRecHit = result.back();
644  if (((EcalDataFrame)(*itdg)).hasSwitchToGain6())
645  uncalibRecHit.setFlagBit(EcalUncalibratedRecHit::kHasSwitchToGain6);
646  if (((EcalDataFrame)(*itdg)).hasSwitchToGain1())
647  uncalibRecHit.setFlagBit(EcalUncalibratedRecHit::kHasSwitchToGain1);
648  }
649 }
650 
653  psd.addNode(edm::ParameterDescription<std::vector<int>>("activeBXs", {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4}, true) and
654  edm::ParameterDescription<bool>("ampErrorCalculation", true, true) and
655  edm::ParameterDescription<bool>("useLumiInfoRunHeader", true, true) and
656  edm::ParameterDescription<int>("bunchSpacing", 0, true) and
657  edm::ParameterDescription<bool>("doPrefitEB", false, true) and
658  edm::ParameterDescription<bool>("doPrefitEE", false, true) and
659  edm::ParameterDescription<double>("prefitMaxChiSqEB", 25., true) and
660  edm::ParameterDescription<double>("prefitMaxChiSqEE", 10., true) and
661  edm::ParameterDescription<bool>("dynamicPedestalsEB", false, true) and
662  edm::ParameterDescription<bool>("dynamicPedestalsEE", false, true) and
663  edm::ParameterDescription<bool>("mitigateBadSamplesEB", false, true) and
664  edm::ParameterDescription<bool>("mitigateBadSamplesEE", false, true) and
665  edm::ParameterDescription<bool>("gainSwitchUseMaxSampleEB", false, true) and
666  edm::ParameterDescription<bool>("gainSwitchUseMaxSampleEE", false, true) and
667  edm::ParameterDescription<bool>("selectiveBadSampleCriteriaEB", false, true) and
668  edm::ParameterDescription<bool>("selectiveBadSampleCriteriaEE", false, true) and
669  edm::ParameterDescription<double>("addPedestalUncertaintyEB", 0., true) and
670  edm::ParameterDescription<double>("addPedestalUncertaintyEE", 0., true) and
671  edm::ParameterDescription<bool>("simplifiedNoiseModelForGainSwitch", true, true) and
672  edm::ParameterDescription<std::string>("timealgo", "RatioMethod", true) and
673  edm::ParameterDescription<std::vector<double>>("EBtimeFitParameters",
674  {-2.015452e+00,
675  3.130702e+00,
676  -1.234730e+01,
677  4.188921e+01,
678  -8.283944e+01,
679  9.101147e+01,
680  -5.035761e+01,
681  1.105621e+01},
682  true) and
683  edm::ParameterDescription<std::vector<double>>("EEtimeFitParameters",
684  {-2.390548e+00,
685  3.553628e+00,
686  -1.762341e+01,
687  6.767538e+01,
688  -1.332130e+02,
689  1.407432e+02,
690  -7.541106e+01,
691  1.620277e+01},
692  true) and
693  edm::ParameterDescription<std::vector<double>>("EBamplitudeFitParameters", {1.138, 1.652}, true) and
694  edm::ParameterDescription<std::vector<double>>("EEamplitudeFitParameters", {1.890, 1.400}, true) and
695  edm::ParameterDescription<double>("EBtimeFitLimits_Lower", 0.2, true) and
696  edm::ParameterDescription<double>("EBtimeFitLimits_Upper", 1.4, true) and
697  edm::ParameterDescription<double>("EEtimeFitLimits_Lower", 0.2, true) and
698  edm::ParameterDescription<double>("EEtimeFitLimits_Upper", 1.4, true) and
699  edm::ParameterDescription<double>("EBtimeConstantTerm", .6, true) and
700  edm::ParameterDescription<double>("EEtimeConstantTerm", 1.0, true) and
701  edm::ParameterDescription<double>("EBtimeNconst", 28.5, true) and
702  edm::ParameterDescription<double>("EEtimeNconst", 31.8, true) and
703  edm::ParameterDescription<double>("outOfTimeThresholdGain12pEB", 5, true) and
704  edm::ParameterDescription<double>("outOfTimeThresholdGain12mEB", 5, true) and
705  edm::ParameterDescription<double>("outOfTimeThresholdGain61pEB", 5, true) and
706  edm::ParameterDescription<double>("outOfTimeThresholdGain61mEB", 5, true) and
707  edm::ParameterDescription<double>("outOfTimeThresholdGain12pEE", 1000, true) and
708  edm::ParameterDescription<double>("outOfTimeThresholdGain12mEE", 1000, true) and
709  edm::ParameterDescription<double>("outOfTimeThresholdGain61pEE", 1000, true) and
710  edm::ParameterDescription<double>("outOfTimeThresholdGain61mEE", 1000, true) and
711  edm::ParameterDescription<double>("amplitudeThresholdEB", 10, true) and
712  edm::ParameterDescription<double>("amplitudeThresholdEE", 10, true) and
713  edm::ParameterDescription<double>("crossCorrelationStartTime", -25.0, true) and
714  edm::ParameterDescription<double>("crossCorrelationStopTime", 25.0, true) and
715  edm::ParameterDescription<double>("crossCorrelationTargetTimePrecision", 0.01, true));
716 
717  return psd;
718 }
719 
726  "EcalUncalibRecHitWorkerMultiFit");
edm::ESGetToken< EcalPulseCovariances, EcalPulseCovariancesRcd > pulseConvariancesToken_
edm::ParameterSetDescription getAlgoDescription() override
std::array< SampleMatrixGainArray, 2 > noisecors_
EcalPulseShapesMap EcalPulseShapes
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void computeAmplitude(std::vector< double > &amplitudeFitParameters)
std::vector< float > EBTimeCorrShiftBins
EcalUncalibRecHitMultiFitAlgo multiFitMethod_
const EcalTBWeightMap & getMap() const
Definition: EcalTBWeights.h:28
std::array< SampleMatrix, NGains > SampleMatrixGainArray
EcalUncalibRecHitTimeWeightsAlgo< EEDataFrame > weightsMethod_endcap_
edm::ESGetToken< EcalPulseShapes, EcalPulseShapesRcd > pulseShapesToken_
Eigen::Matrix< double, FullSampleVectorSize, FullSampleVectorSize > FullSampleMatrix
double time(const C &dataFrame, const std::vector< double > &amplitudes, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const FullSampleVector &fullpulse, const EcalWeightSet::EcalWeightMatrix **weights)
Compute time.
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
std::vector< double > EBG12SamplesCorrelation
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
Definition: EcalTBWeights.h:18
void computeTime(std::vector< double > &timeFitParameters, std::pair< double, double > &timeFitLimits, std::vector< double > &amplitudeFitParameters)
edm::ESGetToken< EcalGainRatios, EcalGainRatiosRcd > gainsToken_
EcalCondObjectContainer< EcalXtalGroupId > EcalWeightXtalGroups
static const int TEMPLATESAMPLES
edm::ESHandle< EcalWeightXtalGroups > grps
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:19
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
Log< level::Error, false > LogError
edm::ESGetToken< EcalSamplesCorrelation, EcalSamplesCorrelationRcd > noiseConvariancesToken_
edm::EDGetTokenT< unsigned int > bunchSpacing_
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
std::vector< double > EBG6SamplesCorrelation
const SampleMatrixGainArray & noisecor(bool barrel) const
unsigned size(int bx) const
std::vector< float > EBTimeCorrAmplitudeBins
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedsToken_
std::vector< float > EETimeCorrShiftBins
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:36
edm::ESGetToken< EcalTBWeights, EcalTBWeightsRcd > wgtsToken_
string startTime
T const * product() const
Definition: ESHandle.h:86
EcalGainRatioMap EcalGainRatios
EcalUncalibRecHitRatioMethodAlgo< EEDataFrame > ratioMethod_endcap_
std::vector< float > EETimeCorrAmplitudeBins
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle< EcalPulseShapes > pulseshapes
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EcalPulseCovariancesMap EcalPulseCovariances
edm::ESHandle< EcalTimeCalibConstants > itime
double timeCorrection(float ampli, const std::vector< float > &amplitudeBins, const std::vector< float > &shiftBins)
unsigned int id() const
std::unique_ptr< EcalUncalibRecHitTimingCCAlgo > computeCC_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:27
const SampleMatrix & noisecor(bool barrel, int gain) const
EcalUncalibratedRecHit makeRecHit(const EcalDataFrame &dataFrame, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const SampleMatrixGainArray &noisecors, const FullSampleVector &fullpulse, const FullSampleMatrix &fullpulsecov, const BXVector &activeBX)
compute rechits
const_iterator end() const
edm::ESHandle< EcalTimeBiasCorrections > timeCorrBias_
float gain12Over6() const
Definition: DetId.h:17
EcalPedestalsMap EcalPedestals
Definition: EcalPedestals.h:50
edm::ESGetToken< EcalTimeOffsetConstant, EcalTimeOffsetConstantRcd > offtimeToken_
void set(const edm::EventSetup &es) override
edm::ESHandle< EcalPulseCovariances > pulsecovariances
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:26
EcalTimeCalibConstantMap EcalTimeCalibConstants
std::vector< double > EBG1SamplesCorrelation
const_iterator begin() const
The iterator returned can not safely be used across threads.
std::vector< Item >::const_iterator const_iterator
void resize(int bx, unsigned size)
edm::ESGetToken< EcalTimeBiasCorrections, EcalTimeBiasCorrectionsRcd > timeCorrBiasToken_
float gain6Over1() const
Eigen::Matrix< double, SampleVectorSize, SampleVectorSize > SampleMatrix
EcalUncalibRecHitTimeWeightsAlgo< EBDataFrame > weightsMethod_barrel_
edm::ESHandle< EcalTimeOffsetConstant > offtime
std::vector< double > EEG1SamplesCorrelation
float EcalTimeCalibConstant
edm::ESGetToken< EcalSampleMask, EcalSampleMaskRcd > sampleMaskToken_
edm::ESGetToken< EcalTimeCalibConstants, EcalTimeCalibConstantsRcd > itimeToken_
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
#define DEFINE_EDM_PLUGIN(factory, type, name)
void run(const edm::Event &evt, const EcalDigiCollection &digis, EcalUncalibratedRecHitCollection &result) override
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
edm::ESHandle< EcalSampleMask > sampleMaskHand_
const EcalWeightSet::EcalWeightMatrix * weights[2]
std::vector< double > EEG12SamplesCorrelation
edm::ESHandle< EcalSamplesCorrelation > noisecovariances
void init(const C &dataFrame, const EcalSampleMask &sampleMask, const double *pedestals, const double *pedestalRMSes, const double *gainRatios)
int hashedIndex() const
Definition: EEDetId.h:183
std::vector< double > EEG6SamplesCorrelation
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
edm::ESGetToken< EcalWeightXtalGroups, EcalWeightXtalGroupsRcd > grpsToken_