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>
31 
32  private:
36  std::unique_ptr<VarCalc> var_calc;
37 };
38 
39 template<class VarCalc>
43  var_calc.reset(new VarCalc());
44  eb_corr_name = conf.getParameter<std::string>("regressionKeyEB");
45  ee_corr_name = conf.getParameter<std::string>("regressionKeyEE");
46  if( conf.existsAs<std::string>("uncertaintyKeyEB") )
47  eb_err_name = conf.getParameter<std::string>("uncertaintyKeyEB");
48  if( conf.existsAs<std::string>("uncertaintyKeyEE") )
49  ee_err_name = conf.getParameter<std::string>("uncertaintyKeyEE");
50 
51 }
52 
53 template<class VarCalc>
55 update(const edm::EventSetup& es) {
56  var_calc->update(es);
57  const GBRWrapperRcd& gbrfrom_es = es.get<GBRWrapperRcd>();
58  if( !gbr_record ||
59  gbrfrom_es.cacheIdentifier() != gbr_record->cacheIdentifier() ) {
60  gbr_record = &gbrfrom_es;
63  if( eb_err_name.size() ) {
64  gbr_record->get(eb_err_name.c_str(),eb_err);
65  }
66  if( ee_err_name.size() ) {
67  gbr_record->get(ee_err_name.c_str(),ee_err);
68  }
69  }
70 }
71 
72 template<class VarCalc>
75  std::vector<float> inputs;
76  var_calc->set(sc,inputs);
77  switch( sc.seed()->seed().subdetId() ) {
79  return eb_corr->GetResponse(inputs.data());
80  break;
82  return ee_corr->GetResponse(inputs.data());
83  break;
84  }
85  return -1.0f;
86 }
87 
88 template<class VarCalc>
89 std::pair<float,float> SCRegressionCalculator<VarCalc>::
91  std::vector<float> inputs;
92  var_calc->set(sc,inputs);
93  switch( sc.seed()->seed().subdetId() ) {
95  return std::make_pair( eb_corr->GetResponse(inputs.data()),
96  eb_err->GetResponse(inputs.data()) );
97  break;
99  return std::make_pair( ee_corr->GetResponse(inputs.data()),
100  ee_err->GetResponse(inputs.data()) );
101  break;
102  }
103  return std::make_pair(-1.0f,-1.0f);
104 }
105 
106 #endif
double GetResponse(const float *vector) const
Definition: GBRForest.h:59
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
edm::ESHandle< GBRForest > eb_corr
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
float getCorrection(const reco::SuperCluster &) const
SCRegressionCalculator(const edm::ParameterSet &)
const GBRWrapperRcd * gbr_record
#define nullptr
std::pair< float, float > getCorrectionWithErrors(const reco::SuperCluster &) const
void get(HolderT &iHolder) const
std::unique_ptr< VarCalc > & varCalc()
edm::ESHandle< GBRForest > ee_corr
double f[11][100]
edm::ESHandle< GBRForest > ee_err
const T & get() const
Definition: EventSetup.h:55
void update(const edm::EventSetup &)
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
std::unique_ptr< VarCalc > var_calc
edm::ESHandle< GBRForest > eb_err