CMS 3D CMS Logo

SCRegressionCalculator.h
Go to the documentation of this file.
1 #ifndef __SCREGRESSIONCALCULATOR_H__
2 #define __SCREGRESSIONCALCULATOR_H__
3 
7 
10 
12 
14 
16 
17 #include <vector>
18 #include <memory>
19 
20 template <class VarCalc>
22 public:
24  void update(const edm::EventSetup&);
25 
26  std::unique_ptr<VarCalc>& varCalc() { return var_calc; }
27 
28  float getCorrection(const reco::SuperCluster&) const;
29  std::pair<float, float> getCorrectionWithErrors(const reco::SuperCluster&) const;
30 
31 private:
35  std::unique_ptr<VarCalc> var_calc;
36 };
37 
38 template <class VarCalc>
40  var_calc.reset(new VarCalc());
41  eb_corr_name = conf.getParameter<std::string>("regressionKeyEB");
42  ee_corr_name = conf.getParameter<std::string>("regressionKeyEE");
43  if (conf.existsAs<std::string>("uncertaintyKeyEB"))
44  eb_err_name = conf.getParameter<std::string>("uncertaintyKeyEB");
45  if (conf.existsAs<std::string>("uncertaintyKeyEE"))
46  ee_err_name = conf.getParameter<std::string>("uncertaintyKeyEE");
47 }
48 
49 template <class VarCalc>
51  var_calc->update(es);
52  const GBRWrapperRcd& gbrfrom_es = es.get<GBRWrapperRcd>();
53  if (!gbr_record || gbrfrom_es.cacheIdentifier() != gbr_record->cacheIdentifier()) {
54  gbr_record = &gbrfrom_es;
55  gbr_record->get(eb_corr_name.c_str(), eb_corr);
56  gbr_record->get(ee_corr_name.c_str(), ee_corr);
57  if (!eb_err_name.empty()) {
58  gbr_record->get(eb_err_name.c_str(), eb_err);
59  }
60  if (!ee_err_name.empty()) {
61  gbr_record->get(ee_err_name.c_str(), ee_err);
62  }
63  }
64 }
65 
66 template <class VarCalc>
68  std::vector<float> inputs;
69  var_calc->set(sc, inputs);
70  switch (sc.seed()->seed().subdetId()) {
72  return eb_corr->GetResponse(inputs.data());
73  break;
75  return ee_corr->GetResponse(inputs.data());
76  break;
77  }
78  return -1.0f;
79 }
80 
81 template <class VarCalc>
83  std::vector<float> inputs;
84  var_calc->set(sc, inputs);
85  switch (sc.seed()->seed().subdetId()) {
87  return std::make_pair(eb_corr->GetResponse(inputs.data()), eb_err->GetResponse(inputs.data()));
88  break;
90  return std::make_pair(ee_corr->GetResponse(inputs.data()), ee_err->GetResponse(inputs.data()));
91  break;
92  }
93  return std::make_pair(-1.0f, -1.0f);
94 }
95 
96 #endif
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESHandle< GBRForest > eb_corr
SCRegressionCalculator(const edm::ParameterSet &)
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
const GBRWrapperRcd * gbr_record
unsigned long long cacheIdentifier() const
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
std::unique_ptr< VarCalc > & varCalc()
edm::ESHandle< GBRForest > ee_corr
T get() const
Definition: EventSetup.h:82
double f[11][100]
float getCorrection(const reco::SuperCluster &) const
edm::ESHandle< GBRForest > ee_err
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
void update(const edm::EventSetup &)
std::pair< float, float > getCorrectionWithErrors(const reco::SuperCluster &) const
std::unique_ptr< VarCalc > var_calc
edm::ESHandle< GBRForest > eb_err