CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
JME::JetResolutionObject::Definition Class Reference

#include <JetResolutionObject.h>

Public Member Functions

 Definition ()
 
 Definition (const std::string &definition)
 
std::string getBinName (size_t bin) const
 
const std::vector< Binning > & getBins () const
 
const std::vector< std::string > & getBinsName () const
 
const reco::FormulaEvaluatorgetFormula () const
 
std::string getFormulaString () const
 
std::string getVariableName (size_t variable) const
 
const std::vector< Binning > & getVariables () const
 
const std::vector< std::string > & getVariablesName () const
 
void init ()
 
size_t nBins () const
 
size_t nVariables () const
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

std::vector< Binningm_bins
 
std::vector< std::string > m_bins_name
 
std::shared_ptr< reco::FormulaEvaluatorm_formula
 
std::string m_formula_str
 
std::vector< Binningm_variables
 
std::vector< std::string > m_variables_name
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Definition at line 148 of file JetResolutionObject.h.

Constructor & Destructor Documentation

JME::JetResolutionObject::Definition::Definition ( )
inline

Definition at line 151 of file JetResolutionObject.h.

References AlCaHLTBitMon_QueryRunRegistry::string.

151  {
152  // Empty
153  }
JME::JetResolutionObject::Definition::Definition ( const std::string &  definition)

Definition at line 138 of file JetResolutionObject.cc.

References edm::errors::ConfigFileReadError, mps_fire::i, init, AlCaHLTBitMon_QueryRunRegistry::string, JME::throwException(), and create_public_lumi_plots::transform.

138  {
139 
140  std::vector<std::string> tokens = getTokens(definition);
141 
142  // We need at least 3 tokens
143  if (tokens.size() < 3) {
144  throwException(edm::errors::ConfigFileReadError, "Definition line needs at least three tokens. Please check file format.");
145  }
146 
147  size_t n_bins = std::stoul(tokens[0]);
148 
149  if (tokens.size() < (n_bins + 2)) {
150  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
151  }
152 
153  for (size_t i = 0; i < n_bins; i++) {
154  m_bins_name.push_back(tokens[i + 1]);
155  }
156 
157  size_t n_variables = std::stoul(tokens[n_bins + 1]);
158 
159  if (tokens.size() < (1 + n_bins + 1 + n_variables + 1)) {
160  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
161  }
162 
163  for (size_t i = 0; i < n_variables; i++) {
164  m_variables_name.push_back(tokens[n_bins + 2 + i]);
165  }
166 
167  m_formula_str = tokens[n_bins + n_variables + 2];
168 
169  std::string formula_str_lower = m_formula_str;
170  std::transform(formula_str_lower.begin(), formula_str_lower.end(), formula_str_lower.begin(), ::tolower);
171 
172  if (formula_str_lower == "none")
173  m_formula_str = "";
174 
175  init();
176  }
std::vector< std::string > m_variables_name
std::vector< std::string > m_bins_name
void throwException(uint32_t code, const std::string &message)

Member Function Documentation

std::string JME::JetResolutionObject::Definition::getBinName ( size_t  bin) const
inline

Definition at line 165 of file JetResolutionObject.h.

References stringResolutionProvider_cfi::bin.

165  {
166  return m_bins_name[bin];
167  }
std::vector< std::string > m_bins_name
bin
set the eta bin as selection string.
const std::vector<Binning>& JME::JetResolutionObject::Definition::getBins ( ) const
inline

Definition at line 161 of file JetResolutionObject.h.

Referenced by JetResolutionDemo::analyze().

161  {
162  return m_bins;
163  }
const std::vector<std::string>& JME::JetResolutionObject::Definition::getBinsName ( ) const
inline

Definition at line 157 of file JetResolutionObject.h.

157  {
158  return m_bins_name;
159  }
std::vector< std::string > m_bins_name
const reco::FormulaEvaluator* JME::JetResolutionObject::Definition::getFormula ( ) const
inline

Definition at line 194 of file JetResolutionObject.h.

References init.

194  {
195  return m_formula.get();
196  }
std::shared_ptr< reco::FormulaEvaluator > m_formula
std::string JME::JetResolutionObject::Definition::getFormulaString ( ) const
inline

Definition at line 189 of file JetResolutionObject.h.

189  {
190  return m_formula_str;
191  }
std::string JME::JetResolutionObject::Definition::getVariableName ( size_t  variable) const
inline

Definition at line 181 of file JetResolutionObject.h.

References taus_updatedMVAIds_cff::variable.

181  {
182  return m_variables_name[variable];
183  }
std::vector< std::string > m_variables_name
const std::vector<Binning>& JME::JetResolutionObject::Definition::getVariables ( ) const
inline

Definition at line 177 of file JetResolutionObject.h.

177  {
178  return m_variables;
179  }
const std::vector<std::string>& JME::JetResolutionObject::Definition::getVariablesName ( ) const
inline

Definition at line 173 of file JetResolutionObject.h.

173  {
174  return m_variables_name;
175  }
std::vector< std::string > m_variables_name
void JME::JetResolutionObject::Definition::init ( void  )

Definition at line 178 of file JetResolutionObject.cc.

References b, stringResolutionProvider_cfi::bin, JME::throwException(), edm::errors::UnimplementedFeature, findQualityFiles::v, and JetChargeProducer_cfi::var.

178  {
179  if (!m_formula_str.empty())
180 #ifndef STANDALONE
181  m_formula = std::make_shared<reco::FormulaEvaluator>(m_formula_str);
182 #else
183  m_formula = std::make_shared<TFormula>("jet_resolution_formula", m_formula_str.c_str());
184 #endif
185  for (const auto& bin: m_bins_name) {
186  const auto& b = JetParameters::binning_to_string.right.find(bin);
187  if (b == JetParameters::binning_to_string.right.cend()) {
188  throwException(edm::errors::UnimplementedFeature, "Bin name not supported: '" + bin + "'");
189  }
190  m_bins.push_back(b->second);
191  }
192 
193  for (const auto& v: m_variables_name) {
194  const auto& var = JetParameters::binning_to_string.right.find(v);
195  if (var == JetParameters::binning_to_string.right.cend()) {
196  throwException(edm::errors::UnimplementedFeature, "Variable name not supported: '" + v + "'");
197  }
198  m_variables.push_back(var->second);
199  }
200  }
std::shared_ptr< reco::FormulaEvaluator > m_formula
std::vector< std::string > m_variables_name
std::vector< std::string > m_bins_name
right_type right
bin
set the eta bin as selection string.
double b
Definition: hdecay.h:120
void throwException(uint32_t code, const std::string &message)
static const bimap< Binning, std::string > binning_to_string
size_t JME::JetResolutionObject::Definition::nBins ( ) const
inline

Definition at line 169 of file JetResolutionObject.h.

Referenced by JME::JetResolutionObject::Record::Record().

169  {
170  return m_bins_name.size();
171  }
std::vector< std::string > m_bins_name
size_t JME::JetResolutionObject::Definition::nVariables ( ) const
inline

Definition at line 185 of file JetResolutionObject.h.

Referenced by JME::JetResolutionObject::Record::Record().

185  {
186  return m_variables.size();
187  }
template<class Archive >
void JME::JetResolutionObject::Definition::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 217 of file JetResolutionObject.h.

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 217 of file JetResolutionObject.h.

Member Data Documentation

std::vector<Binning> JME::JetResolutionObject::Definition::m_bins
private

Definition at line 214 of file JetResolutionObject.h.

std::vector<std::string> JME::JetResolutionObject::Definition::m_bins_name
private

Definition at line 205 of file JetResolutionObject.h.

std::shared_ptr<reco::FormulaEvaluator> JME::JetResolutionObject::Definition::m_formula
private

Definition at line 210 of file JetResolutionObject.h.

std::string JME::JetResolutionObject::Definition::m_formula_str
private

Definition at line 207 of file JetResolutionObject.h.

std::vector<Binning> JME::JetResolutionObject::Definition::m_variables
private

Definition at line 215 of file JetResolutionObject.h.

std::vector<std::string> JME::JetResolutionObject::Definition::m_variables_name
private

Definition at line 206 of file JetResolutionObject.h.