CMS 3D CMS Logo

EcalClusterEnergyUncertainty.cc
Go to the documentation of this file.
1 
16 
18 public:
20 
21  // get/set explicit methods for parameters
23  // check initialization
24  void checkInit() const;
25 
26  // compute the correction
27  float getValue(const reco::SuperCluster &, const int mode) const override;
28  float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const override { return 0.; };
29 
30  // set parameters
31  void init(const edm::EventSetup &es) override;
32 
33 private:
36 };
37 
40  params_ = esParams_.product();
41 }
42 
44  if (!params_) {
45  // non-initialized function parameters: throw exception
46  throw cms::Exception("EcalClusterEnergyUncertainty::checkInit()")
47  << "Trying to access an uninitialized crack correction function.\n"
48  "Please call `init( edm::EventSetup &)' before any use of the function.\n";
49  }
50 }
51 
52 float EcalClusterEnergyUncertainty::getValue(const reco::SuperCluster &superCluster, const int mode) const {
53  checkInit();
54  // mode = -1 returns negative energy uncertainty
55  // = +1 returns positive energy uncertainty
56  // = 0 (default) returns overall energy uncertainty
57  float en = superCluster.energy();
58  float eta = fabs(superCluster.eta());
59  float et = en / cosh(eta);
60  //fixing divide by zero issue for brem varible, this is the case for single crystal superclusters
61  //as these "superclusters" are likely noise or spikes so setting value to 0 as the uncertainties
62  //will be incorrect regardless so doesnt matter what it is
63  float brem = superCluster.etaWidth() != 0 ? superCluster.phiWidth() / superCluster.etaWidth() : 0;
64 
65  int offset = 0;
66 
67  //if ( superCluster.algoID() == reco::CaloCluster::hybrid ) offset = 0;
68  //else if ( superCluster.algoID() == reco::CaloCluster::multi5x5 ) offset = 36;
69  // TEMPORARY FIX!!
70  if (eta < 1.5)
71  offset = 0;
72  else if (eta >= 1.5)
73  offset = 36;
74  else {
75  // not supported now
76  //std::cout << "Not supported value " << superCluster.algoID() << std::endl;
77  //std::cout << "eta = " << superCluster.eta() << std::endl;
78  //std::cout << "phi = " << superCluster.phi() << std::endl;
79  //std::cout << "En = " << superCluster.energy() << std::endl;
80  return -1;
81  }
82  if (mode == 0)
83  offset += 0; // total effective uncertainty
84  else if (mode == -1)
85  offset += 12; // negative energy uncertainty
86  else if (mode == 1)
87  offset += 24; // positive energy uncertainty
88  else {
89  // wrong input
90  return 0;
91  }
92 
93  float br0_0 = (params_->params())[offset + 0];
94  float br0_1 = (params_->params())[offset + 1];
95  float br0_2 = (params_->params())[offset + 2];
96  float br0_3 = (params_->params())[offset + 3];
97 
98  float br1_0 = (params_->params())[offset + 4];
99  float br1_1 = (params_->params())[offset + 5];
100  float br1_2 = (params_->params())[offset + 6];
101  float br1_3 = (params_->params())[offset + 7];
102 
103  float br2_0 = (params_->params())[offset + 8];
104  float br2_1 = (params_->params())[offset + 9];
105  float br2_2 = (params_->params())[offset + 10];
106  float br2_3 = (params_->params())[offset + 11];
107 
108  float p0 = (br0_0 + br0_1 * brem) + (br0_2 + br0_3 * brem) / et;
109  float p1 = (br1_0 + br1_1 * brem) + (br1_2 + br1_3 * brem) / et;
110  float p2 = (br2_0 + br2_1 * brem) + (br2_2 + br2_3 * brem) / et;
111  //std::cout << "====================================================" << std::endl;
112  //std::cout << "et = " << et << "\t eta = " << eta << std::endl;
113  //std::cout << "p0 = " << p0 << "\t p1 = " << p1 << "\t p2 = " << p2 << std::endl;
114  float uncertainty = en * (p0 + p1 * fabs(eta) + p2 * eta * eta);
115  //std::cout << uncertainty << std::endl;
116  //std::cout << std::endl;
117  return uncertainty;
118 }
119 
EcalClusterEnergyUncertainty::getValue
float getValue(const reco::SuperCluster &, const int mode) const override
Definition: EcalClusterEnergyUncertainty.cc:52
reco::SuperCluster
Definition: SuperCluster.h:18
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
EcalFunParams
Definition: EcalFunctionParameters.h:11
edm::SortedCollection< EcalRecHit >
EcalClusterFunctionBaseClass.h
EcalClusterEnergyUncertainty::esParams_
edm::ESHandle< EcalClusterEnergyUncertaintyParameters > esParams_
Definition: EcalClusterEnergyUncertainty.cc:34
EcalClusterEnergyUncertainty
Definition: EcalClusterEnergyUncertainty.cc:17
EcalClusterEnergyUncertainty::checkInit
void checkInit() const
Definition: EcalClusterEnergyUncertainty.cc:43
EcalClusterEnergyUncertainty::EcalClusterEnergyUncertainty
EcalClusterEnergyUncertainty(const edm::ParameterSet &)
Definition: EcalClusterEnergyUncertainty.cc:19
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
reco::SuperCluster::phiWidth
double phiWidth() const
obtain phi and eta width of the Super Cluster
Definition: SuperCluster.h:66
PVValHelper::eta
Definition: PVValidationHelpers.h:69
reco::CaloCluster
Definition: CaloCluster.h:31
edm::ESHandle
Definition: DTSurvey.h:22
p2
double p2[4]
Definition: TauolaWrapper.h:90
EcalClusterEnergyUncertaintyParameters.h
EcalClusterFunctionFactory.h
EcalClusterEnergyUncertaintyParametersRcd
Definition: EcalClusterEnergyUncertaintyParametersRcd.h:5
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
EcalClusterFunctionFactory
EcalClusterEnergyUncertaintyParametersRcd.h
edm::ParameterSet
Definition: ParameterSet.h:47
reco::CaloCluster::eta
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
EcalClusterEnergyUncertainty::getParameters
const EcalClusterEnergyUncertaintyParameters * getParameters() const
Definition: EcalClusterEnergyUncertainty.cc:22
EcalClusterEnergyUncertainty::params_
const EcalClusterEnergyUncertaintyParameters * params_
Definition: EcalClusterEnergyUncertainty.cc:35
p1
double p1[4]
Definition: TauolaWrapper.h:89
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
EcalFunParams::params
EcalFunctionParameters & params()
Definition: EcalFunctionParameters.h:13
EcalClusterEnergyUncertainty::getValue
float getValue(const reco::BasicCluster &, const EcalRecHitCollection &) const override
Definition: EcalClusterEnergyUncertainty.cc:28
Exception
Definition: hltDiff.cc:246
EventSetup.h
reco::SuperCluster::etaWidth
double etaWidth() const
Definition: SuperCluster.h:67
EcalClusterEnergyUncertainty::init
void init(const edm::EventSetup &es) override
Definition: EcalClusterEnergyUncertainty.cc:38
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149
EcalClusterFunctionBaseClass
Definition: EcalClusterFunctionBaseClass.h:26