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.size()) {
58  gbr_record->get(eb_err_name.c_str(), eb_err);
59  }
60  if (ee_err_name.size()) {
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
ESHandle.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
reco::SuperCluster
Definition: SuperCluster.h:18
GBRWrapperRcd.h
SCRegressionCalculator::ee_corr
edm::ESHandle< GBRForest > ee_corr
Definition: SCRegressionCalculator.h:34
SCRegressionCalculator::eb_err_name
std::string eb_err_name
Definition: SCRegressionCalculator.h:32
SCRegressionCalculator::eb_err
edm::ESHandle< GBRForest > eb_err
Definition: SCRegressionCalculator.h:34
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
SCRegressionCalculator::varCalc
std::unique_ptr< VarCalc > & varCalc()
Definition: SCRegressionCalculator.h:26
GBRForest.h
EcalBarrel
Definition: EcalSubdetector.h:10
SCRegressionCalculator::gbr_record
const GBRWrapperRcd * gbr_record
Definition: SCRegressionCalculator.h:33
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
SCRegressionCalculator::SCRegressionCalculator
SCRegressionCalculator(const edm::ParameterSet &)
Definition: SCRegressionCalculator.h:39
edm::ESHandle< GBRForest >
SCRegressionCalculator::ee_err_name
std::string ee_err_name
Definition: SCRegressionCalculator.h:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalSubdetector.h
EcalEndcap
Definition: EcalSubdetector.h:10
SCRegressionCalculator::getCorrectionWithErrors
std::pair< float, float > getCorrectionWithErrors(const reco::SuperCluster &) const
Definition: SCRegressionCalculator.h:82
edm::ParameterSet
Definition: ParameterSet.h:47
reco::SuperCluster::seed
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
SCRegressionCalculator::ee_corr_name
std::string ee_corr_name
Definition: SCRegressionCalculator.h:32
SCRegressionCalculator::ee_err
edm::ESHandle< GBRForest > ee_err
Definition: SCRegressionCalculator.h:34
SCRegressionCalculator::eb_corr_name
std::string eb_corr_name
Definition: SCRegressionCalculator.h:32
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
edm::EventSetup
Definition: EventSetup.h:57
SCRegressionCalculator
Definition: SCRegressionCalculator.h:21
SCRegressionCalculator::eb_corr
edm::ESHandle< GBRForest > eb_corr
Definition: SCRegressionCalculator.h:34
SuperClusterFwd.h
SCRegressionCalculator::getCorrection
float getCorrection(const reco::SuperCluster &) const
Definition: SCRegressionCalculator.h:67
SuperCluster.h
GBRWrapperRcd
Definition: GBRWrapperRcd.h:24
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition: EventSetupRecordImplementation.h:74
edm::eventsetup::EventSetupRecord::cacheIdentifier
unsigned long long cacheIdentifier() const
Definition: EventSetupRecord.h:184
ParameterSet.h
SCRegressionCalculator::var_calc
std::unique_ptr< VarCalc > var_calc
Definition: SCRegressionCalculator.h:35
SCRegressionCalculator::update
void update(const edm::EventSetup &)
Definition: SCRegressionCalculator.h:50