Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-02 03:46:04

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/EcalUncalibRecHitWorkerRunOneDigiBase.h"
0013 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitRecWeightsAlgo.h"
0014 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitRecChi2Algo.h"
0015 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitRatioMethodAlgo.h"
0016 #include "FWCore/Framework/interface/ESHandle.h"
0017 #include "FWCore/Utilities/interface/ESGetToken.h"
0018 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
0019 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
0020 #include "CondFormats/DataRecord/interface/EcalWeightXtalGroupsRcd.h"
0021 #include "CondFormats/DataRecord/interface/EcalTBWeightsRcd.h"
0022 #include "CondFormats/DataRecord/interface/EcalSampleMaskRcd.h"
0023 #include "CondFormats/DataRecord/interface/EcalTimeCalibConstantsRcd.h"
0024 #include "CondFormats/DataRecord/interface/EcalTimeOffsetConstantRcd.h"
0025 #include "CondFormats/DataRecord/interface/EcalTimeBiasCorrectionsRcd.h"
0026 #include "CondFormats/EcalObjects/interface/EcalTimeCalibConstants.h"
0027 #include "CondFormats/EcalObjects/interface/EcalTimeOffsetConstant.h"
0028 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
0029 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
0030 #include "CondFormats/EcalObjects/interface/EcalWeightXtalGroups.h"
0031 #include "CondFormats/EcalObjects/interface/EcalTBWeights.h"
0032 #include "CondFormats/EcalObjects/interface/EcalSampleMask.h"
0033 #include "CondFormats/EcalObjects/interface/EcalTimeBiasCorrections.h"
0034 #include "SimCalorimetry/EcalSimAlgos/interface/EBShape.h"
0035 #include "SimCalorimetry/EcalSimAlgos/interface/EEShape.h"
0036 
0037 namespace edm {
0038   class Event;
0039   class EventSetup;
0040   class ParameterSet;
0041   class ParameterSetDescription;
0042 }  // namespace edm
0043 
0044 class EcalUncalibRecHitWorkerGlobal : public EcalUncalibRecHitWorkerRunOneDigiBase {
0045 public:
0046   EcalUncalibRecHitWorkerGlobal(const edm::ParameterSet&, edm::ConsumesCollector& c);
0047   EcalUncalibRecHitWorkerGlobal() = default;  // for EcalUncalibRecHitFillDescriptionWorkerFactory
0048   ~EcalUncalibRecHitWorkerGlobal() override{};
0049 
0050   void set(const edm::EventSetup& es) override;
0051   bool run(const edm::Event& evt,
0052            const EcalDigiCollection::const_iterator& digi,
0053            EcalUncalibratedRecHitCollection& result) override;
0054 
0055   edm::ParameterSetDescription getAlgoDescription() override;
0056 
0057 protected:
0058   double pedVec[3];
0059   double pedRMSVec[3];
0060   double gainRatios[3];
0061 
0062   edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> tokenPeds_;
0063   edm::ESGetToken<EcalGainRatios, EcalGainRatiosRcd> tokenGains_;
0064   edm::ESHandle<EcalPedestals> peds_;
0065   edm::ESHandle<EcalGainRatios> gains_;
0066 
0067   template <class C>
0068   int isSaturated(const C& digi);
0069 
0070   double timeCorrection(float ampli, const std::vector<float>& amplitudeBins, const std::vector<float>& shiftBins);
0071 
0072   // weights method
0073   edm::ESGetToken<EcalWeightXtalGroups, EcalWeightXtalGroupsRcd> tokenGrps_;
0074   edm::ESGetToken<EcalTBWeights, EcalTBWeightsRcd> tokenWgts_;
0075   edm::ESHandle<EcalWeightXtalGroups> grps_;
0076   edm::ESHandle<EcalTBWeights> wgts_;
0077   const EcalWeightSet::EcalWeightMatrix* weights[2];
0078   const EcalWeightSet::EcalChi2WeightMatrix* chi2mat[2];
0079   EcalUncalibRecHitRecWeightsAlgo<EBDataFrame> weightsMethod_barrel_;
0080   EcalUncalibRecHitRecWeightsAlgo<EEDataFrame> weightsMethod_endcap_;
0081   EEShape testbeamEEShape;  // used in the chi2
0082   EBShape testbeamEBShape;  // can be replaced by simple shape arrays of float in the future
0083 
0084   // determie which of the samples must actually be used by ECAL local reco
0085   edm::ESGetToken<EcalSampleMask, EcalSampleMaskRcd> tokenSampleMask_;
0086   edm::ESHandle<EcalSampleMask> sampleMaskHand_;
0087 
0088   // ratio method
0089   std::vector<double> EBtimeFitParameters_;
0090   std::vector<double> EEtimeFitParameters_;
0091   std::vector<double> EBamplitudeFitParameters_;
0092   std::vector<double> EEamplitudeFitParameters_;
0093   std::pair<double, double> EBtimeFitLimits_;
0094   std::pair<double, double> EEtimeFitLimits_;
0095 
0096   EcalUncalibRecHitRatioMethodAlgo<EBDataFrame> ratioMethod_barrel_;
0097   EcalUncalibRecHitRatioMethodAlgo<EEDataFrame> ratioMethod_endcap_;
0098 
0099   double EBtimeConstantTerm_;
0100   double EBtimeNconst_;
0101   double EEtimeConstantTerm_;
0102   double EEtimeNconst_;
0103   double outOfTimeThreshG12pEB_;
0104   double outOfTimeThreshG12mEB_;
0105   double outOfTimeThreshG61pEB_;
0106   double outOfTimeThreshG61mEB_;
0107   double outOfTimeThreshG12pEE_;
0108   double outOfTimeThreshG12mEE_;
0109   double outOfTimeThreshG61pEE_;
0110   double outOfTimeThreshG61mEE_;
0111   double amplitudeThreshEB_;
0112   double amplitudeThreshEE_;
0113   double ebSpikeThresh_;
0114 
0115   edm::ESGetToken<EcalTimeBiasCorrections, EcalTimeBiasCorrectionsRcd> tokenTimeCorrBias_;
0116   edm::ESHandle<EcalTimeBiasCorrections> timeCorrBias_;
0117 
0118   edm::ESGetToken<EcalTimeCalibConstants, EcalTimeCalibConstantsRcd> tokenItime_;
0119   edm::ESGetToken<EcalTimeOffsetConstant, EcalTimeOffsetConstantRcd> tokenOfftime_;
0120   edm::ESHandle<EcalTimeCalibConstants> itime_;
0121   edm::ESHandle<EcalTimeOffsetConstant> offtime_;
0122   std::vector<double> ebPulseShape_;
0123   std::vector<double> eePulseShape_;
0124 
0125   // chi2 method
0126   bool kPoorRecoFlagEB_;
0127   bool kPoorRecoFlagEE_;
0128   double chi2ThreshEB_;
0129   double chi2ThreshEE_;
0130   std::vector<double> EBchi2Parameters_;
0131   std::vector<double> EEchi2Parameters_;
0132 };
0133 
0134 #endif