CMS 3D CMS Logo

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