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
 
const std::vector< std::string > & getParametersName () 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 nParameters () 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< std::string > m_parameters_name
 
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  if ((tokens.size() > n_bins + n_variables + 3) && (std::atoi(tokens[n_bins + n_variables + 3].c_str()))) {
176  size_t n_parameters = std::stoul(tokens[n_bins + n_variables + 3]);
177 
178  if (tokens.size() < (1 + n_bins + 1 + n_variables + 1 + 1 + n_parameters)) {
179  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
180  }
181 
182  for (size_t i = 0; i < n_parameters; i++) {
183  m_formula_str += tokens[n_bins + n_variables + 4 + i] + " ";
184  }
185  }
186  }
187 
188  init();
189  }
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 198 of file JetResolutionObject.h.

References init.

198  {
199  return m_formula.get();
200  }
std::shared_ptr< reco::FormulaEvaluator > m_formula
std::string JME::JetResolutionObject::Definition::getFormulaString ( ) const
inline

Definition at line 193 of file JetResolutionObject.h.

193  {
194  return m_formula_str;
195  }
const std::vector<std::string>& JME::JetResolutionObject::Definition::getParametersName ( ) const
inline

Definition at line 189 of file JetResolutionObject.h.

189 { return m_parameters_name; }
std::vector< std::string > m_parameters_name
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 191 of file JetResolutionObject.cc.

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

191  {
192  if (!m_formula_str.empty()) {
193  if (m_formula_str.find(' ') == std::string::npos)
194 #ifndef STANDALONE
195  m_formula = std::make_shared<reco::FormulaEvaluator>(m_formula_str);
196 #else
197  m_formula = std::make_shared<TFormula>("jet_resolution_formula", m_formula_str.c_str());
198 #endif
199  else
200  m_parameters_name = getTokens(m_formula_str);
201  }
202  for (const auto& bin: m_bins_name) {
203  const auto& b = JetParameters::binning_to_string.right.find(bin);
204  if (b == JetParameters::binning_to_string.right.cend()) {
205  throwException(edm::errors::UnimplementedFeature, "Bin name not supported: '" + bin + "'");
206  }
207  m_bins.push_back(b->second);
208  }
209 
210  for (const auto& v: m_variables_name) {
211  const auto& var = JetParameters::binning_to_string.right.find(v);
212  if (var == JetParameters::binning_to_string.right.cend()) {
213  throwException(edm::errors::UnimplementedFeature, "Variable name not supported: '" + v + "'");
214  }
215  m_variables.push_back(var->second);
216  }
217  }
std::vector< std::string > m_parameters_name
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::nParameters ( ) const
inline

Definition at line 191 of file JetResolutionObject.h.

191 { return m_parameters_name.size(); }
std::vector< std::string > m_parameters_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 222 of file JetResolutionObject.h.

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

Definition at line 222 of file JetResolutionObject.h.

Member Data Documentation

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

Definition at line 218 of file JetResolutionObject.h.

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

Definition at line 209 of file JetResolutionObject.h.

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

Definition at line 214 of file JetResolutionObject.h.

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

Definition at line 211 of file JetResolutionObject.h.

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

Definition at line 220 of file JetResolutionObject.h.

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

Definition at line 219 of file JetResolutionObject.h.

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

Definition at line 210 of file JetResolutionObject.h.