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.

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 }

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

Member Function Documentation

◆ bin()

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

Definition at line 45 of file L1EGammaEECalibrator.cc.

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 }

References HLT_2018_cff::distance.

Referenced by etaBin(), and ptBin().

◆ calibrationFactor()

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

Definition at line 54 of file L1EGammaEECalibrator.cc.

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 }

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

Referenced by L1EGammaEEProducer::produce().

◆ etaBin()

int L1EGammaEECalibrator::etaBin ( float  eta) const
inlineprivate

Definition at line 16 of file L1EGammaEECalibrator.h.

16 { return bin(eta_bins, std::abs(eta)); }

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

Referenced by calibrationFactor(), and L1EGammaEECalibrator().

◆ ptBin()

int L1EGammaEECalibrator::ptBin ( float  pt) const
inlineprivate

Definition at line 17 of file L1EGammaEECalibrator.h.

17 { return bin(pt_bins, pt); }

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

Referenced by calibrationFactor(), and L1EGammaEECalibrator().

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().

filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
L1EGammaEECalibrator::eta_bins
std::set< float > eta_bins
Definition: L1EGammaEECalibrator.h:20
edm::FileInPath
Definition: FileInPath.h:64
L1EGammaEECalibrator::etaBin
int etaBin(float eta) const
Definition: L1EGammaEECalibrator.h:16
PVValHelper::eta
Definition: PVValidationHelpers.h:69
L1EGammaEECalibrator::ptBin
int ptBin(float pt) const
Definition: L1EGammaEECalibrator.h:17
L1EGammaEECalibrator::bin
int bin(const std::set< float > &container, float value) const
Definition: L1EGammaEECalibrator.cc:45
l1tp2::as_vector
std::vector< float > as_vector(boost::property_tree::ptree const &pt, boost::property_tree::ptree::key_type const &key)
Definition: L1EGammaEECalibrator.cc:9
value
Definition: value.py:1
L1EGammaEECalibrator::pt_bins
std::set< float > pt_bins
Definition: L1EGammaEECalibrator.h:21
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
L1EGammaEECalibrator::calib_factors
std::vector< float > calib_factors
Definition: L1EGammaEECalibrator.h:22
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27