** Warning **

Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle dbname=lxr at /lxr/lib/LXR/Common.pm line 1103.

Last-Modified: Wed, 16 Aug 2022 22:26:09 GMT Content-Type: text/html; charset=utf-8 /CMSSW_12_5_X_2022-08-16-2300/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.h
Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-17 23:26:51

0001 #ifndef RecoLocalCalo_EcalRecProducers_EcalUncalibRecHitRecWorkerGlobal_hh
0002 #define RecoLocalCalo_EcalRecProducers_EcalUncalibRecHitRecWorkerGlobal_hh
0003 
0004 /** \class EcalUncalibRecHitRecGlobalAlgo                                                                                                                                           
0005  *  Template used to compute amplitude, pedestal using a weights method                                                                                                            
0006  *                           time using a ratio method                                                                                                                             
0007  *                           chi2 using express method  
0008  *
0009  *  \author R. Bruneliere - A. Zabi
0010  */
0011 
0012 #include "RecoLocalCalo/EcalRecProducers/interface/EcalUncalibRecHitWorkerBaseClass.h"
0013 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitMultiFitAlgo.h"
0014 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimeWeightsAlgo.h"
0015 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitRecChi2Algo.h"
0016 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitRatioMethodAlgo.h"
0017 #include "FWCore/Framework/interface/ESHandle.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/Utilities/interface/ESGetToken.h"
0020 #include "CondFormats/EcalObjects/interface/EcalTimeCalibConstants.h"
0021 #include "CondFormats/EcalObjects/interface/EcalTimeOffsetConstant.h"
0022 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
0023 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
0024 #include "CondFormats/EcalObjects/interface/EcalWeightXtalGroups.h"
0025 #include "CondFormats/EcalObjects/interface/EcalTBWeights.h"
0026 #include "CondFormats/EcalObjects/interface/EcalSampleMask.h"
0027 #include "CondFormats/EcalObjects/interface/EcalTimeBiasCorrections.h"
0028 #include "CondFormats/EcalObjects/interface/EcalSamplesCorrelation.h"
0029 #include "CondFormats/EcalObjects/interface/EcalPulseShapes.h"
0030 #include "CondFormats/EcalObjects/interface/EcalPulseCovariances.h"
0031 #include "RecoLocalCalo/EcalRecAlgos/interface/EigenMatrixTypes.h"
0032 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
0033 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
0034 #include "CondFormats/DataRecord/interface/EcalWeightXtalGroupsRcd.h"
0035 #include "CondFormats/DataRecord/interface/EcalTBWeightsRcd.h"
0036 #include "CondFormats/DataRecord/interface/EcalSampleMaskRcd.h"
0037 #include "CondFormats/DataRecord/interface/EcalTimeCalibConstantsRcd.h"
0038 #include "CondFormats/DataRecord/interface/EcalTimeOffsetConstantRcd.h"
0039 #include "CondFormats/DataRecord/interface/EcalTimeBiasCorrectionsRcd.h"
0040 #include "CondFormats/DataRecord/interface/EcalSamplesCorrelationRcd.h"
0041 #include "CondFormats/DataRecord/interface/EcalPulseShapesRcd.h"
0042 #include "CondFormats/DataRecord/interface/EcalPulseCovariancesRcd.h"
0043 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimingCCAlgo.h"
0044 
0045 namespace edm {
0046   class Event;
0047   class EventSetup;
0048   class ParameterSet;
0049   class ParameterSetDescription;
0050 }  // namespace edm
0051 
0052 class EcalUncalibRecHitWorkerMultiFit final : public EcalUncalibRecHitWorkerBaseClass {
0053 public:
0054   EcalUncalibRecHitWorkerMultiFit(const edm::ParameterSet&, edm::ConsumesCollector& c);
0055   EcalUncalibRecHitWorkerMultiFit(){};
0056   ~EcalUncalibRecHitWorkerMultiFit() override{};
0057 
0058 private:
0059   void set(const edm::EventSetup& es) override;
0060   void set(const edm::Event& evt) override;
0061   void run(const edm::Event& evt, const EcalDigiCollection& digis, EcalUncalibratedRecHitCollection& result) override;
0062 
0063 public:
0064   edm::ParameterSetDescription getAlgoDescription() override;
0065 
0066 private:
0067   edm::ESHandle<EcalPedestals> peds;
0068   edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> pedsToken_;
0069   edm::ESHandle<EcalGainRatios> gains;
0070   edm::ESGetToken<EcalGainRatios, EcalGainRatiosRcd> gainsToken_;
0071   edm::ESHandle<EcalSamplesCorrelation> noisecovariances;
0072   edm::ESGetToken<EcalSamplesCorrelation, EcalSamplesCorrelationRcd> noiseConvariancesToken_;
0073   edm::ESHandle<EcalPulseShapes> pulseshapes;
0074   edm::ESGetToken<EcalPulseShapes, EcalPulseShapesRcd> pulseShapesToken_;
0075   edm::ESHandle<EcalPulseCovariances> pulsecovariances;
0076   edm::ESGetToken<EcalPulseCovariances, EcalPulseCovariancesRcd> pulseConvariancesToken_;
0077 
0078   double timeCorrection(float ampli, const std::vector<float>& amplitudeBins, const std::vector<float>& shiftBins);
0079 
0080   const SampleMatrix& noisecor(bool barrel, int gain) const { return noisecors_[barrel ? 1 : 0][gain]; }
0081   const SampleMatrixGainArray& noisecor(bool barrel) const { return noisecors_[barrel ? 1 : 0]; }
0082 
0083   // multifit method
0084   std::array<SampleMatrixGainArray, 2> noisecors_;
0085   BXVector activeBX;
0086   bool ampErrorCalculation_;
0087   bool useLumiInfoRunHeader_;
0088   EcalUncalibRecHitMultiFitAlgo multiFitMethod_;
0089 
0090   int bunchSpacingManual_;
0091   edm::EDGetTokenT<unsigned int> bunchSpacing_;
0092 
0093   // determine which of the samples must actually be used by ECAL local reco
0094   edm::ESHandle<EcalSampleMask> sampleMaskHand_;
0095   edm::ESGetToken<EcalSampleMask, EcalSampleMaskRcd> sampleMaskToken_;
0096 
0097   // time algorithm to be used to set the jitter and its uncertainty
0098   enum TimeAlgo { noMethod, ratioMethod, weightsMethod, crossCorrelationMethod };
0099   TimeAlgo timealgo_ = noMethod;
0100 
0101   // time weights method
0102   edm::ESHandle<EcalWeightXtalGroups> grps;
0103   edm::ESGetToken<EcalWeightXtalGroups, EcalWeightXtalGroupsRcd> grpsToken_;
0104   edm::ESHandle<EcalTBWeights> wgts;
0105   edm::ESGetToken<EcalTBWeights, EcalTBWeightsRcd> wgtsToken_;
0106   const EcalWeightSet::EcalWeightMatrix* weights[2];
0107   EcalUncalibRecHitTimeWeightsAlgo<EBDataFrame> weightsMethod_barrel_;
0108   EcalUncalibRecHitTimeWeightsAlgo<EEDataFrame> weightsMethod_endcap_;
0109   bool doPrefitEB_;
0110   bool doPrefitEE_;
0111   double prefitMaxChiSqEB_;
0112   double prefitMaxChiSqEE_;
0113   bool dynamicPedestalsEB_;
0114   bool dynamicPedestalsEE_;
0115   bool mitigateBadSamplesEB_;
0116   bool mitigateBadSamplesEE_;
0117   bool gainSwitchUseMaxSampleEB_;
0118   bool gainSwitchUseMaxSampleEE_;
0119   bool selectiveBadSampleCriteriaEB_;
0120   bool selectiveBadSampleCriteriaEE_;
0121   double addPedestalUncertaintyEB_;
0122   double addPedestalUncertaintyEE_;
0123   bool simplifiedNoiseModelForGainSwitch_;
0124 
0125   // ratio method
0126   std::vector<double> EBtimeFitParameters_;
0127   std::vector<double> EEtimeFitParameters_;
0128   std::vector<double> EBamplitudeFitParameters_;
0129   std::vector<double> EEamplitudeFitParameters_;
0130   std::pair<double, double> EBtimeFitLimits_;
0131   std::pair<double, double> EEtimeFitLimits_;
0132 
0133   EcalUncalibRecHitRatioMethodAlgo<EBDataFrame> ratioMethod_barrel_;
0134   EcalUncalibRecHitRatioMethodAlgo<EEDataFrame> ratioMethod_endcap_;
0135 
0136   double EBtimeConstantTerm_;
0137   double EEtimeConstantTerm_;
0138   double EBtimeNconst_;
0139   double EEtimeNconst_;
0140   double outOfTimeThreshG12pEB_;
0141   double outOfTimeThreshG12mEB_;
0142   double outOfTimeThreshG61pEB_;
0143   double outOfTimeThreshG61mEB_;
0144   double outOfTimeThreshG12pEE_;
0145   double outOfTimeThreshG12mEE_;
0146   double outOfTimeThreshG61pEE_;
0147   double outOfTimeThreshG61mEE_;
0148   double amplitudeThreshEB_;
0149   double amplitudeThreshEE_;
0150   double ebSpikeThresh_;
0151 
0152   edm::ESHandle<EcalTimeBiasCorrections> timeCorrBias_;
0153   edm::ESGetToken<EcalTimeBiasCorrections, EcalTimeBiasCorrectionsRcd> timeCorrBiasToken_;
0154 
0155   edm::ESHandle<EcalTimeCalibConstants> itime;
0156   edm::ESGetToken<EcalTimeCalibConstants, EcalTimeCalibConstantsRcd> itimeToken_;
0157   edm::ESHandle<EcalTimeOffsetConstant> offtime;
0158   edm::ESGetToken<EcalTimeOffsetConstant, EcalTimeOffsetConstantRcd> offtimeToken_;
0159   std::vector<double> ebPulseShape_;
0160   std::vector<double> eePulseShape_;
0161 
0162   // chi2 thresholds for flags settings
0163   bool kPoorRecoFlagEB_;
0164   bool kPoorRecoFlagEE_;
0165   double chi2ThreshEB_;
0166   double chi2ThreshEE_;
0167 
0168   //Timing Cross Correlation Algo
0169   std::unique_ptr<EcalUncalibRecHitTimingCCAlgo> computeCC_;
0170 };
0171 
0172 #endif