CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1EGammaEECalibrator Class Reference

#include <L1EGammaEECalibrator.h>

Public Member Functions

float calibrationFactor (const float &pt, const float &eta) const
 
 L1EGammaEECalibrator (const edm::ParameterSet &)
 

Private Member Functions

int bin (const std::set< float > &container, float value) const
 
int etaBin (float eta) const
 
int ptBin (float pt) const
 

Private Attributes

std::vector< float > calib_factors
 
std::set< float > eta_bins
 
std::set< float > pt_bins
 

Detailed Description

Definition at line 9 of file L1EGammaEECalibrator.h.

Constructor & Destructor Documentation

◆ L1EGammaEECalibrator()

L1EGammaEECalibrator::L1EGammaEECalibrator ( const edm::ParameterSet pset)
explicit

Definition at line 18 of file L1EGammaEECalibrator.cc.

References l1tp2::as_vector(), calib_factors, filterCSVwithJSON::copy, eta_bins, etaBin(), edm::FileInPath::fullPath(), muonDTDigis_cfi::pset, pt_bins, and ptBin().

18  {
19  //read the JSON file and populate the eta - pt bins and the value container
20  boost::property_tree::ptree calibration_map;
21  read_json(pset.getParameter<edm::FileInPath>("calibrationFile").fullPath(), calibration_map);
22 
23  auto eta_l = l1tp2::as_vector(calibration_map, "eta_l");
24  std::copy(eta_l.begin(), eta_l.end(), std::inserter(eta_bins, eta_bins.end()));
25  auto eta_h = l1tp2::as_vector(calibration_map, "eta_h");
26  eta_bins.insert(eta_h.back());
27 
28  auto pt_l = l1tp2::as_vector(calibration_map, "pt_l");
29  std::copy(pt_l.begin(), pt_l.end(), std::inserter(pt_bins, pt_bins.end()));
30  auto pt_h = l1tp2::as_vector(calibration_map, "pt_h");
31  pt_bins.insert(pt_h.back());
32 
33  auto calib_data = l1tp2::as_vector(calibration_map, "calib");
34  auto n_bins_eta = eta_bins.size();
35  auto n_bins_pt = pt_bins.size();
36  calib_factors.reserve(n_bins_eta * n_bins_pt);
37  for (auto calib_f = calib_data.begin(); calib_f != calib_data.end(); ++calib_f) {
38  auto index = calib_f - calib_data.begin();
39  int eta_bin = etaBin(eta_l[index]);
40  int pt_bin = ptBin(pt_l[index]);
41  calib_factors[(eta_bin * n_bins_pt) + pt_bin] = *calib_f;
42  }
43 }
int etaBin(float eta) const
std::set< float > pt_bins
std::string fullPath() const
Definition: FileInPath.cc:161
int ptBin(float pt) const
std::set< float > eta_bins
std::vector< float > as_vector(boost::property_tree::ptree const &pt, boost::property_tree::ptree::key_type const &key)
std::vector< float > calib_factors

Member Function Documentation

◆ bin()

int L1EGammaEECalibrator::bin ( const std::set< float > &  container,
float  value 
) const
private

Definition at line 45 of file L1EGammaEECalibrator.cc.

References HLT_2022v12_cff::distance.

Referenced by etaBin(), and ptBin().

45  {
46  auto bin_l = container.upper_bound(value);
47  if (bin_l == container.end()) {
48  // value not mapped to any bin
49  return -1;
50  }
51  return std::distance(container.begin(), bin_l) - 1;
52 }
Definition: value.py:1

◆ calibrationFactor()

float L1EGammaEECalibrator::calibrationFactor ( const float &  pt,
const float &  eta 
) const

Definition at line 54 of file L1EGammaEECalibrator.cc.

References calib_factors, PVValHelper::eta, etaBin(), DiDispStaMuonMonitor_cfi::pt, pt_bins, and ptBin().

Referenced by L1EGammaEEProducer::produce().

54  {
55  int bin_eta = etaBin(eta);
56  int bin_pt = ptBin(pt);
57  if (bin_eta == -1 || bin_pt == -1)
58  return 1.;
59  auto n_bins_pt = pt_bins.size();
60  return calib_factors[(bin_eta * n_bins_pt) + bin_pt];
61 }
int etaBin(float eta) const
std::set< float > pt_bins
int ptBin(float pt) const
std::vector< float > calib_factors

◆ etaBin()

int L1EGammaEECalibrator::etaBin ( float  eta) const
inlineprivate

Definition at line 16 of file L1EGammaEECalibrator.h.

References funct::abs(), bin(), PVValHelper::eta, and eta_bins.

Referenced by calibrationFactor(), and L1EGammaEECalibrator().

16 { return bin(eta_bins, std::abs(eta)); }
std::set< float > eta_bins
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int bin(const std::set< float > &container, float value) const

◆ ptBin()

int L1EGammaEECalibrator::ptBin ( float  pt) const
inlineprivate

Definition at line 17 of file L1EGammaEECalibrator.h.

References bin(), DiDispStaMuonMonitor_cfi::pt, and pt_bins.

Referenced by calibrationFactor(), and L1EGammaEECalibrator().

17 { return bin(pt_bins, pt); }
std::set< float > pt_bins
int bin(const std::set< float > &container, float value) const

Member Data Documentation

◆ calib_factors

std::vector<float> L1EGammaEECalibrator::calib_factors
private

Definition at line 22 of file L1EGammaEECalibrator.h.

Referenced by calibrationFactor(), and L1EGammaEECalibrator().

◆ eta_bins

std::set<float> L1EGammaEECalibrator::eta_bins
private

Definition at line 20 of file L1EGammaEECalibrator.h.

Referenced by etaBin(), and L1EGammaEECalibrator().

◆ pt_bins

std::set<float> L1EGammaEECalibrator::pt_bins
private

Definition at line 21 of file L1EGammaEECalibrator.h.

Referenced by calibrationFactor(), L1EGammaEECalibrator(), and ptBin().