File indexing completed on 2024-04-06 12:24:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "CondFormats/DataRecord/interface/EcalClusterEnergyUncertaintyParametersRcd.h"
0013 #include "CondFormats/EcalObjects/interface/EcalClusterEnergyUncertaintyParameters.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/Framework/interface/ConsumesCollector.h"
0016 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionBaseClass.h"
0017
0018 class EcalClusterEnergyUncertainty : public EcalClusterFunctionBaseClass {
0019 public:
0020 EcalClusterEnergyUncertainty(const edm::ParameterSet &, edm::ConsumesCollector iC) : paramsToken_(iC.esConsumes()) {}
0021
0022
0023 const EcalClusterEnergyUncertaintyParameters *getParameters() const { return params_; }
0024
0025 void checkInit() const;
0026
0027
0028 float getValue(const reco::SuperCluster &, const int mode) const override;
0029 float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const override { return 0.; };
0030
0031
0032 void init(const edm::EventSetup &es) override;
0033
0034 private:
0035 const edm::ESGetToken<EcalClusterEnergyUncertaintyParameters, EcalClusterEnergyUncertaintyParametersRcd> paramsToken_;
0036 const EcalClusterEnergyUncertaintyParameters *params_ = nullptr;
0037 };
0038
0039 void EcalClusterEnergyUncertainty::init(const edm::EventSetup &es) { params_ = &es.getData(paramsToken_); }
0040
0041 void EcalClusterEnergyUncertainty::checkInit() const {
0042 if (!params_) {
0043
0044 throw cms::Exception("EcalClusterEnergyUncertainty::checkInit()")
0045 << "Trying to access an uninitialized crack correction function.\n"
0046 "Please call `init( edm::EventSetup &)' before any use of the function.\n";
0047 }
0048 }
0049
0050 float EcalClusterEnergyUncertainty::getValue(const reco::SuperCluster &superCluster, const int mode) const {
0051 checkInit();
0052
0053
0054
0055 float en = superCluster.energy();
0056 float eta = fabs(superCluster.eta());
0057 float et = en / cosh(eta);
0058
0059
0060
0061 float brem = superCluster.etaWidth() != 0 ? superCluster.phiWidth() / superCluster.etaWidth() : 0;
0062
0063 int offset = 0;
0064
0065
0066
0067
0068 if (eta < 1.5)
0069 offset = 0;
0070 else if (eta >= 1.5)
0071 offset = 36;
0072 else {
0073
0074
0075
0076
0077
0078 return -1;
0079 }
0080 if (mode == 0)
0081 offset += 0;
0082 else if (mode == -1)
0083 offset += 12;
0084 else if (mode == 1)
0085 offset += 24;
0086 else {
0087
0088 return 0;
0089 }
0090
0091 float br0_0 = (params_->params())[offset + 0];
0092 float br0_1 = (params_->params())[offset + 1];
0093 float br0_2 = (params_->params())[offset + 2];
0094 float br0_3 = (params_->params())[offset + 3];
0095
0096 float br1_0 = (params_->params())[offset + 4];
0097 float br1_1 = (params_->params())[offset + 5];
0098 float br1_2 = (params_->params())[offset + 6];
0099 float br1_3 = (params_->params())[offset + 7];
0100
0101 float br2_0 = (params_->params())[offset + 8];
0102 float br2_1 = (params_->params())[offset + 9];
0103 float br2_2 = (params_->params())[offset + 10];
0104 float br2_3 = (params_->params())[offset + 11];
0105
0106 float p0 = (br0_0 + br0_1 * brem) + (br0_2 + br0_3 * brem) / et;
0107 float p1 = (br1_0 + br1_1 * brem) + (br1_2 + br1_3 * brem) / et;
0108 float p2 = (br2_0 + br2_1 * brem) + (br2_2 + br2_3 * brem) / et;
0109
0110
0111
0112 float uncertainty = en * (p0 + p1 * fabs(eta) + p2 * eta * eta);
0113
0114
0115 return uncertainty;
0116 }
0117
0118 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterFunctionFactory.h"
0119 DEFINE_EDM_PLUGIN(EcalClusterFunctionFactory, EcalClusterEnergyUncertainty, "EcalClusterEnergyUncertainty");